mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-02-03 13:59:43 +01:00
937 lines
34 KiB
Bash
937 lines
34 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
|
# Copyright (C) 2013-2014 Inteno Broadband Technology AB
|
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
|
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
|
|
|
get_lan_device_interface() {
|
|
local i=0
|
|
local ret=""
|
|
for lan in `ubus list|sed -n 's/network\.interface\.//p'|grep -v loopback`;do
|
|
if [ "`$UCI_GET network.$lan.is_lan`" = "1" ];then
|
|
local dev
|
|
local jsmsg=`ifstatus $lan`
|
|
json_init
|
|
json_load "$jsmsg"
|
|
json_get_var dev device
|
|
dev=${dev/br-/}
|
|
local tmp=${ret#*:$dev;}
|
|
if [ "$tmp" = "$ret" ]; then
|
|
let i++
|
|
ret="$ret $i:$dev;1:$lan"
|
|
else
|
|
tmp=${tmp%%:*}
|
|
json_select "ipv4-address"
|
|
local type index="1"
|
|
while json_get_type type $index && [ "$type" != "" ]; do
|
|
let tmp++
|
|
let index++
|
|
ret=${ret/:$dev;/:$dev;$tmp:$lan,}
|
|
done
|
|
fi
|
|
fi
|
|
done
|
|
echo $ret
|
|
}
|
|
|
|
get_wlan_enable() {
|
|
local num="$1"
|
|
val=`$UCI_GET wireless.@wifi-iface[$num].disabled 2> /dev/null`
|
|
let val^=1
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
let val^=1
|
|
$UCI_SET wireless.@wifi-iface[$num].disabled="$val"
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_status() {
|
|
local num="$1"
|
|
val=`$UCI_GET wireless.@wifi-iface[$num].disabled 2> /dev/null`
|
|
if [ "$val" = "1" ]; then
|
|
val="Disabled"
|
|
else
|
|
val="Up"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
get_wlan_bssid() {
|
|
local num="$1"
|
|
if [ "$num" = "0" ];then
|
|
val=`/usr/sbin/wlctl -i wl$num bssid`
|
|
else
|
|
val=`/usr/sbin/wlctl -i wl0.$num bssid`
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_max_bit_rate() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.wl0.hwmode="auto"
|
|
}
|
|
|
|
get_wlan_channel() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.wl0.channel`
|
|
if [ "$val" = "auto" -o "$val" = "" ];then
|
|
if [ "$num" = "0" ];then
|
|
val=`/usr/sbin/wlctl -i wl$num channel|grep "target channel"|awk -F ' ' '{print$3}'`
|
|
else
|
|
val=`/usr/sbin/wlctl -i wl0.$num channel|grep "target channel"|awk -F ' ' '{print$3}'`
|
|
fi
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
set_wlan_channel() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.wl0.channel="$val"
|
|
}
|
|
|
|
set_wlan_ssid() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.@wifi-iface[$num].ssid="$val"
|
|
}
|
|
|
|
get_wlan_beacon_type() {
|
|
local num="$1"
|
|
local val=""
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$encryption" = "none" ]; then
|
|
val="None"
|
|
elif [ "$encryption" = "wep-shared" -o "$encryption" = "wep-open" ]; then
|
|
val="Basic"
|
|
elif [ "`echo $encryption|grep ^psk$`" != "" -o "`echo $encryption|grep ^psk+`" != "" -o "$encryption" = "wpa" ]; then
|
|
val="WPA"
|
|
elif [ "`echo $encryption|grep ^psk2$`" != "" -o "`echo $encryption|grep ^psk2+`" != "" -o "$encryption" = "wpa2" ]; then
|
|
val="11i"
|
|
elif [ "`echo $encryption|grep ^pskmixedpsk2$`" != "" -o "`echo $encryption|grep ^pskmixedpsk2+`" != "" -o "$encryption" = "wpamixedwpa2" ]; then
|
|
val="WPAand11i"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
reset_wlan() {
|
|
local num="$1"
|
|
$UCI_DELETE wireless.@wifi-iface[$num].gtk_rekey
|
|
$UCI_DELETE wireless.@wifi-iface[$num].wps_pbc
|
|
$UCI_DELETE wireless.@wifi-iface[$num].key
|
|
$UCI_DELETE wireless.@wifi-iface[$num].key1
|
|
$UCI_DELETE wireless.@wifi-iface[$num].key2
|
|
$UCI_DELETE wireless.@wifi-iface[$num].key3
|
|
$UCI_DELETE wireless.@wifi-iface[$num].key4
|
|
$UCI_DELETE wireless.@wifi-iface[$num].radius_server
|
|
$UCI_DELETE wireless.@wifi-iface[$num].radius_port
|
|
$UCI_DELETE wireless.@wifi-iface[$num].radius_secret
|
|
}
|
|
|
|
set_wlan_beacon_type() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "None" ]; then
|
|
val="none"
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "Basic" ]; then
|
|
val="wep-open"
|
|
if [ $encryption != "wep-shared" -a $encryption != "wep-open" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
local i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`; do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "WPA" ]; then
|
|
val="psk"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "11i" ]; then
|
|
val="psk2"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "WPAand11i" ]; then
|
|
val="pskmixedpsk2"
|
|
if [ "`echo $encryption |grep psk`" = "" ]; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_mac_control_enable() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].macfilter 2> /dev/null`
|
|
if [ "$val" != "0" ]; then
|
|
val="1"
|
|
else
|
|
val="0"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_mac_control_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
if [ "$val" = "1" ]; then
|
|
val="2"
|
|
else
|
|
val="0"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.@wifi-iface[$num].macfilter="$val"
|
|
}
|
|
|
|
get_wlan_standard() {
|
|
local num="$1"
|
|
val=`$UCI_GET wireless.wl0.hwmode`
|
|
if [ "$val" = "11b" ]; then
|
|
val="b"
|
|
elif [ "$val" = "11bg" ]; then
|
|
val="g"
|
|
elif [ "$val" = "11g" -o "$val" = "11gst" -o "$val" = "11lrs" ]; then
|
|
val="g-only"
|
|
elif [ "$val" = "11n" -o "$val" = "auto" ]; then
|
|
val="n"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_standard() {
|
|
local num="$1"
|
|
local val="$2"
|
|
if [ "$val" = "b" ]; then
|
|
val="11b"
|
|
elif [ "$val" = "g" ]; then
|
|
val="11bg"
|
|
elif [ "$val" = "g-only" ]; then
|
|
val="11g"
|
|
elif [ "$val" = "n" ]; then
|
|
val="auto"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.wl0.hwmode="$val"
|
|
}
|
|
|
|
get_wlan_wep_key_index() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$encryption" = "wep-shared" ]; then
|
|
val=`$UCI_GET wireless.@wifi-iface[$num].key`
|
|
else
|
|
val=""
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_wep_key_index() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
delay_service reload "network" "1"
|
|
if [ $encryption != "wep-shared" -a $encryption != "wep-open" ] ; then
|
|
reset_wlan $nums
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wep-open"
|
|
local i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].key="$val"
|
|
}
|
|
|
|
set_wlan_key_passphrase() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
delay_service reload "network" "1"
|
|
if [ $encryption == "wep-shared" -o $encryption == "wep-open" ] ; then
|
|
for key in `/usr/sbin/wepkeygen 64 $val`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
elif [ $encryption == "none" ];then
|
|
echo "error"
|
|
else
|
|
set_wlan_pre_shared_key $num $val
|
|
fi
|
|
}
|
|
|
|
get_wlan_wep_encryption_level() {
|
|
local num="$1"
|
|
val="40-bit, 104-bit"
|
|
echo "$val"
|
|
}
|
|
|
|
get_wlan_basic_encryption_modes() {
|
|
local num="$1"
|
|
local encryption==`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "$encryption" = "wep-open" -o "$encryption" = "wep-shared" ]; then
|
|
val="WEPEncryption"
|
|
else
|
|
val="None"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_basic_encryption_modes() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "WEPEncryption" ]; then
|
|
val="wep-open"
|
|
if [ $encryption != "wep-shared" -a $encryption != "wep-open" ] ; then
|
|
reset_wlan $nums
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
local i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "None" ]; then
|
|
val="none"
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_basic_authentication_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "$encryption" = "wep-shared" ]; then
|
|
val="SharedAuthentication"
|
|
else
|
|
val="None"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_basic_authentication_mode() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "SharedAuthentication" ]; then
|
|
val="wep-open"
|
|
if [ $encryption != "wep-shared" -a $encryption != "wep-open" ] ; then
|
|
reset_wlan $nums
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
local i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "None" ]; then
|
|
val="none"
|
|
reset_wlan $nums
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_wpa_encryption_modes() {
|
|
local num="$1"
|
|
local val=""
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$encryption" = "psk+tkip" -o "$encryption" = "pskmixedpsk2+tkip" ];then
|
|
val="TKIPEncryption"
|
|
elif [ "$encryption" = "psk+ccmp" -o "$encryption" = "pskmixedpsk2+ccmp" ];then
|
|
val="AESEncryption"
|
|
elif [ "$encryption" = "psk+tkip+ccmp" -o "$encryption" = "pskmixedpsk2+tkip+ccmp" ];then
|
|
val="TKIPandAESEncryption"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_wpa_encryption_modes() {
|
|
local num="$1"
|
|
local val="$2"
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
if [ "$val" = "TKIPEncryption" ]; then
|
|
val="psk+tkip"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "AESEncryption" ]; then
|
|
val="psk+ccmp"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "TKIPandAESEncryption" ]; then
|
|
val="psk+tkip+ccmp"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_wpa_authentication_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "`echo $encryption|grep ^psk$`" != "" -o "`echo $encryption|grep ^psk+`" != "" -o "`echo $encryption|grep ^pskmixedpsk2`" != "" ]; then
|
|
val="PSKAuthentication"
|
|
elif [ "$encryption" = "wpa" -o "$encryption" = "wpamixedwpa2" ];then
|
|
val="EAPAuthentication"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_wpa_authentication_mode() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "PSKAuthentication" ]; then
|
|
val="psk"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "EAPAuthentication" ]; then
|
|
val="wpa"
|
|
if [ $encryption != "wpa" -a $encryption != "wpa2" -a $encryption != "wpamixedwpa2" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_server=""
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_port="1812"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_secret=""
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_ieee_11i_encryption_modes() {
|
|
local num="$1"
|
|
local val=""
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$encryption" = "psk2+tkip" -o "$encryption" = "pskmixedpsk2+tkip" ];then
|
|
val="TKIPEncryption"
|
|
elif [ "$encryption" = "psk2+ccmp" -o "$encryption" = "pskmixedpsk2+ccmp" ];then
|
|
val="AESEncryption"
|
|
elif [ "$encryption" = "psk2+tkip+ccmp" -o "$encryption" = "pskmixedpsk2+tkip+ccmp" ];then
|
|
val="TKIPandAESEncryption"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_ieee_11i_encryption_modes() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
if [ "$val" = "TKIPEncryption" ]; then
|
|
val="psk2+tkip"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "AESEncryption" ]; then
|
|
val="psk2+ccmp"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "TKIPandAESEncryption" ]; then
|
|
val="psk2+tkip+ccmp"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_ieee_11i_authentication_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "`echo $encryption|grep ^psk2$`" != "" -o "`echo $encryption|grep ^psk2+`" != "" -o "`echo $encryption|grep ^pskmixedpsk2`" != "" ]; then
|
|
val="PSKAuthentication"
|
|
elif [ "$encryption" = "wpa2" -o "$encryption" = "wpamixedwpa2" ];then
|
|
val="EAPAuthentication"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_ieee_11i_authentication_mode() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "PSKAuthentication" ]; then
|
|
val="psk2"
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="`cat /proc/nvram/WpaKey`"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "EAPAuthentication" ]; then
|
|
val="wpa2"
|
|
if [ $encryption != "wpa" -a $encryption != "wpa2" -a $encryption != "wpamixedwpa2" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_server=""
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_port="1812"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_secret=""
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_radio_enabled() {
|
|
local num="$1"
|
|
local val=""
|
|
if [ "$num" = "0" ];then
|
|
radio=`/usr/sbin/wlctl -i wl$num radio`
|
|
else
|
|
radio=`/usr/sbin/wlctl -i wl0.$num radio`
|
|
fi
|
|
val=`echo $(($radio))`
|
|
if [ "$val" = "0" ];then
|
|
val=1
|
|
elif [ "$val" = "1" ];then
|
|
val=0
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_radio_enabled() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
if [ "$val" = "0" ];then
|
|
val="off"
|
|
elif [ "$val" = "1" ];then
|
|
val="on"
|
|
fi
|
|
if [ "$num" = "0" ];then
|
|
/usr/sbin/wlctl -i wl$num radio $val
|
|
else
|
|
/usr/sbin/wlctl -i wl0.$num radio $val
|
|
fi
|
|
}
|
|
|
|
get_wlan_device_operation_mode() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].mode`
|
|
if [ "$val" = "ap" ];then
|
|
val="InfrastructureAccessPoint"
|
|
else
|
|
val=""
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_device_operation_mode() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
if [ "$val" = "InfrastructureAccessPoint" ];then
|
|
$UCI_SET wireless.@wifi-iface[$num].mode="ap"
|
|
fi
|
|
}
|
|
|
|
get_wlan_authentication_service_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "$encryption" = "wpa" -o "$encryption" = "wpa2" -o "$encryption" = "wpamixedwpa2" ]; then
|
|
val="RadiusClient"
|
|
else
|
|
val="None"
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_authentication_service_mode() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "$val" = "None" ];then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="none"
|
|
elif [ "$val" = "RadiusClient" ];then
|
|
if [ "$encryption" != "wpa" -a "$encryption" != "wpa2" -a "$encryption" != "wpamixedwpa2" ]; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wpa"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_server=""
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_port="1812"
|
|
$UCI_SET wireless.@wifi-iface[$num].radius_secret=""
|
|
fi
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_total_associations() {
|
|
local num="$1"
|
|
if [ "$num" = "0" ];then
|
|
val=`/usr/sbin/wlctl -i wl$num assoclist | grep -c 'assoclist'`
|
|
else
|
|
val=`/usr/sbin/wlctl -i wl0.$num assoclist | grep -c 'assoclist'`
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
get_wlan_channel_in_use() {
|
|
local val=`$UCI_GET wireless.wl0.channel`
|
|
[ "$val" = "auto" ] && val="any"
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_channel_in_use() {
|
|
local val="$1"
|
|
[ "$val" = "any" ] && val="auto"
|
|
$UCI_SET wireless.wl0.channel=$val
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_devstatus_statistics() {
|
|
local num="$1"
|
|
local counter="$2"
|
|
local wdevstatus val
|
|
if [ "$num" = "0" ];then
|
|
wdevstatus=`devstatus wl0`
|
|
else
|
|
wdevstatus=`devstatus wl0.$num`
|
|
fi
|
|
json_init
|
|
json_load "$wdevstatus"
|
|
json_select "statistics"
|
|
json_get_var val $counter
|
|
json_select ".."
|
|
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_wep_key() {
|
|
local num="$1"
|
|
local key_index="$2"
|
|
local val="$3"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ $encryption != "wep-shared" -a $encryption != "wep-open" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wep-open"
|
|
local i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].key$key_index=$val
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
set_wlan_pre_shared_key() {
|
|
local num="$1"
|
|
local val="$2"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "`echo $encryption |grep psk`" = "" ] ; then
|
|
reset_wlan "$num"
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="psk"
|
|
fi
|
|
$UCI_SET wireless.@wifi-iface[$num].key=$val
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
set_wlan_pre_shared_key_associated_device_MACAddress() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_lan_dns() {
|
|
local lan_name=$1
|
|
local val="" dns
|
|
json_load "$(ifstatus $lan_name)"
|
|
json_select "dns-server"
|
|
local index="1"
|
|
while json_get_type dns $index && [ "$dns" = string ]; do
|
|
json_get_var dns "$((index++))"
|
|
val="$dns,$val"
|
|
done
|
|
json_select ".."
|
|
val=${val%,}
|
|
if [ "$val" = "" ]; then val=`$UCI_GET network.$lan_name.dns`; val=${val// /,}; fi
|
|
echo $val
|
|
}
|
|
|
|
set_lan_dns() {
|
|
local lan_name=$1
|
|
local val="$2"
|
|
val=${val//,/ }
|
|
$UCI_SET network.$lan_name.dns="$val"
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_server_configurable() {
|
|
local lan_name=$1
|
|
if [ "`$UCI_GET dhcp.$lan_name`" = "" ];then echo 0; else echo 1; fi
|
|
}
|
|
|
|
set_lan_dhcp_server_configurable() {
|
|
local lan_name=$1
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
if [ "`$UCI_GET dhcp.$lan_name`" = "" ];then
|
|
$UCI_SET dhcp.$lan_name=dhcp
|
|
$UCI_SET dhcp.$lan_name.interface=$lan_name
|
|
$UCI_SET dhcp.$lan_name.start=100
|
|
$UCI_SET dhcp.$lan_name.limit=150
|
|
$UCI_SET dhcp.$lan_name.leasetime=12h
|
|
fi
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
$UCI_SET dhcp.$lan_name=
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_server_enable() {
|
|
local lan_name=$1
|
|
if [ "`$UCI_GET dhcp.$lan_name`" = "" ]; then
|
|
echo 0
|
|
else
|
|
if [ "`$UCI_GET dhcp.$lan_name.ignore`" = "" ]; then echo 1; else echo 0; fi
|
|
fi
|
|
}
|
|
|
|
set_lan_dhcp_server_enable() {
|
|
local lan_name=$1
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
$UCI_SET dhcp.$lan_name.ignore=
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
$UCI_SET dhcp.$lan_name.ignore=1
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
get_landevice_wlanconfiguration_generic() {
|
|
lan_num=$1
|
|
wlan_num=$2
|
|
uci_num=$3
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration." "0" "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num." "0" "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.Enable" "1" "get_wlan_enable $uci_num" "set_wlan_enable $uci_num \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.Status" "0" "" "" "get_wlan_status $uci_num"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.BSSID" "0" "get_wlan_bssid $uci_num"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.MaxBitRate" "1" "$UCI_GET wireless.wl0.hwmode" "set_wlan_max_bit_rate $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.Channel" "1" "get_wlan_channel $uci_num" "set_wlan_channel $uci_num \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.SSID" "1" "$UCI_GET wireless.@wifi-iface[$num].ssid" "set_wlan_ssid $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.BeaconType" "1" "get_wlan_beacon_type $uci_num" "set_wlan_beacon_type $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.MACAddressControlEnabled" "1" "get_wlan_mac_control_enable $uci_num" "set_wlan_mac_control_enable $uci_num \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.Standard" "1" "get_wlan_standard $uci_num" "set_wlan_standard $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKeyIndex" "1" "get_wlan_wep_key_index $uci_num" "set_wlan_wep_key_index $uci_num \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.KeyPassphrase" "1" "" "set_wlan_key_passphrase $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPEncryptionLevel" "0" "get_wlan_wep_encryption_level $uci_num"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.BasicEncryptionModes" "1" "get_wlan_basic_encryption_modes $uci_num" "set_wlan_basic_encryption_modes $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.BasicAuthenticationMode" "1" "get_wlan_basic_authentication_mode $uci_num" "set_wlan_basic_authentication_mode $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WPAEncryptionModes" "1" "get_wlan_wpa_encryption_modes $uci_num" "set_wlan_wpa_encryption_modes $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WPAAuthenticationMode" "1" "get_wlan_wpa_authentication_mode $uci_num" "set_wlan_wpa_authentication_mode $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.IEEE11iEncryptionModes" "1" "get_wlan_ieee_11i_encryption_modes $uci_num" "set_wlan_ieee_11i_encryption_modes $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.IEEE11iAuthenticationMode" "1" "get_wlan_ieee_11i_authentication_mode $uci_num" "set_wlan_ieee_11i_authentication_mode $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.RadioEnabled" "1" "" "set_wlan_radio_enabled $uci_num \$val" "get_wlan_radio_enabled $uci_num" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.DeviceOperationMode" "1" "get_wlan_device_operation_mode $uci_num" "set_wlan_device_operation_mode $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AuthenticationServiceMode" "1" "get_wlan_authentication_service_mode $uci_num" "set_wlan_authentication_service_mode $uci_num \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalAssociations" "0" "" "" "get_wlan_total_associations $uci_num" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.ChannelsInUse" "1" "get_wlan_channel_in_use" "set_wlan_channel_in_use \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalBytesSent" "0" "" "" "get_wlan_devstatus_statistics $uci_num tx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalBytesReceived" "0" "" "" "get_wlan_devstatus_statistics $uci_num rx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalPacketsSent" "0" "" "" "get_wlan_devstatus_statistics $uci_num tx_packets" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalPacketsReceived" "0" "" "" "get_wlan_devstatus_statistics $uci_num rx_packets" "xsd:unsignedInt"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.1." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.2." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.3." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.4." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.1.WEPKey" "1" "" "set_wlan_wep_key $uci_num 1 \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.2.WEPKey" "1" "" "set_wlan_wep_key $uci_num 2 \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.3.WEPKey" "1" "" "set_wlan_wep_key $uci_num 3 \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.4.WEPKey" "1" "" "set_wlan_wep_key $uci_num 4 \$val" "" "" "" "" "" "1"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.PreSharedKey" "1" "" "set_wlan_pre_shared_key $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.KeyPassphrase" "1" "" "set_wlan_key_passphrase $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.AssociatedDeviceMACAddress" "1" "" "set_wlan_pre_shared_key_associated_device_MACAddress $uci_num \$val"
|
|
}
|
|
|
|
get_landevice_lanhostconfigmanagement_generic() {
|
|
local idev=$1
|
|
local ndev=$2
|
|
local ilan=$3
|
|
local nlan=$4
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan." "0" "" "linker_interface:$nlan"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan.Enable" "1" "" "set_interface_enable_ubus $nlan \$val" "get_interface_enable_ubus $nlan" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan.X_BROADCOM_COM_FirewallEnabled" "1" "get_interface_firewall_enabled $nlan" "set_interface_firewall_enabled $nlan \$val"
|
|
}
|
|
|
|
get_cache_InternetGatewayDevice_LANDevice() {
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice." "0" "0"
|
|
for interface in `get_lan_device_interface`;do
|
|
local tmp=${interface%%;*}
|
|
local idev=${tmp%%:*}
|
|
local ndev=${tmp#*:}
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev." "0" "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DNSServers" "1" "" "set_lan_dns $ndev \$val" "get_lan_dns $ndev"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPServerConfigurable" "1" "get_lan_dhcp_server_configurable $ndev" "set_lan_dhcp_server_configurable $ndev \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPServerEnable" "1" "get_lan_dhcp_server_enable $ndev" "set_lan_dhcp_server_enable $ndev \$val" "" "xsd:boolean"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface." "0"
|
|
|
|
tmp=${interface#*;}
|
|
tmp=${tmp/,/ }
|
|
for lan in $tmp; do
|
|
ilan=${lan%%:*}
|
|
nlan=${lan#*:}
|
|
get_landevice_lanhostconfigmanagement_generic $idev $ndev $ilan $nlan
|
|
done
|
|
|
|
local iwlan=0
|
|
for iuci in `$UCI_SHOW wireless|grep "wireless\.@wifi-iface\[[0-9]\+\]\.network=.*$ndev$" | cut -f2 -d'[' | cut -f1 -d']'`;do
|
|
let iwlan++
|
|
get_landevice_wlanconfiguration_generic $idev $iwlan $iuci
|
|
done
|
|
done
|
|
}
|
|
|
|
get_dynamic_InternetGatewayDevice_LANDevice() {
|
|
local assoclist="" num="" lan_num="" wlan_num=0 i=0
|
|
local mac_lower="" ip="" is_authenticated=""
|
|
|
|
case "$1" in
|
|
""|\
|
|
InternetGatewayDevice.|\
|
|
InternetGatewayDevice.LANDevice.|\
|
|
InternetGatewayDevice.LANDevice.[1-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.[1-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.[1-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.[1-9]*.AssociatedDeviceMACAddress|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.[1-9]*.AssociatedDeviceIPAddress|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.AssociatedDevice.[1-9]*.AssociatedDeviceAuthenticationState)
|
|
for interface in `get_lan_device_interface`;do
|
|
local tmp=${interface%%;*}
|
|
local idev=${tmp%%:*}
|
|
local ndev=${tmp#*:}
|
|
wlan_num=0
|
|
for num in `$UCI_SHOW wireless|grep "wireless\.@wifi-iface\[[0-9]\+\]\.network=.*$ndev$" | cut -f2 -d'[' | cut -f1 -d']'`;do
|
|
let "wlan_num++"
|
|
if [ "$num" = "0" ];then
|
|
assoclist=`/usr/sbin/wlctl -i wl$num assoclist|awk -F' ' '{print $2}'`
|
|
else
|
|
assoclist=`/usr/sbin/wlctl -i wl0.$num assoclist|awk -F' ' '{print $2}'`
|
|
fi
|
|
i=0
|
|
freecwmp_cache_output_obj "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration.$wlan_num.AssociatedDevice." "0" "0"
|
|
for mac in $assoclist;do
|
|
let i++
|
|
ip=""
|
|
is_authenticated=""
|
|
if [ "$action" = "get_value" ]; then
|
|
mac_lower=`echo $mac|tr '[A-F]' '[a-f]'`
|
|
ip=`cat /proc/net/arp|grep "$mac_lower"|awk -F' ' '{print $1}'`
|
|
if [ "$num" = "0" ];then
|
|
is_authenticated=`/usr/sbin/wlctl -i wl$num authe_sta_list|grep $mac`
|
|
else
|
|
is_authenticated=`/usr/sbin/wlctl -i wl0.$num authe_sta_list|grep $mac`
|
|
fi
|
|
if [ "$is_authenticated" = "" ];then
|
|
is_authenticated="0"
|
|
else
|
|
is_authenticated="1"
|
|
fi
|
|
fi
|
|
freecwmp_cache_output_obj "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration.$wlan_num.AssociatedDevice.$i." "0" "0"
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceMACAddress" "$mac" "0" "0" "" "" "" "0"
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceIPAddress" "$ip" "0" "0" "" "" "" "0"
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceAuthenticationState" "$is_authenticated" "0" "0" "xsd:boolean" "" "" "0"
|
|
done
|
|
done
|
|
done
|
|
esac
|
|
}
|
|
|
|
get_dynamic_linker_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
add_object_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|
|
|
|
delete_object_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|