mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-02-05 15:00:11 +01:00
700 lines
No EOL
25 KiB
Bash
700 lines
No EOL
25 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
|
|
|
get_lan_device_interface() {
|
|
local i=0
|
|
for lan in `ubus list|sed -n 's/network\.interface\.//p'|grep -v loopback`;do
|
|
if [ "`$UCI_GET network.$lan.is_lan`" = "1" ];then
|
|
let i=$i+1
|
|
echo "$lan:$i"
|
|
fi
|
|
done
|
|
}
|
|
|
|
get_wlan_enable() {
|
|
local num="$1"
|
|
val=`$UCI_GET wireless.@wifi-device[$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-device[$num].disabled="$val"
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_wlan_status() {
|
|
local num="$1"
|
|
val=`$UCI_GET wireless.@wifi-device[$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_command "wifi" "5"
|
|
$UCI_SET wireless.wl0.hwmode="auto"
|
|
}
|
|
|
|
get_wlan_channel() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].channel`
|
|
if [ "$val" = "auto" ];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_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-iface[$num].channel="$val"
|
|
}
|
|
|
|
set_wlan_ssid() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_command "wifi" "5"
|
|
$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 [ "$encryption" = "psk" -o "$encryption" = "wpa" ]; then
|
|
val="WPA"
|
|
elif [ "$encryption" = "psk2" -o "$encryption" = "wpa2" ]; then
|
|
val="11i"
|
|
elif [ "$encryption" = "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"
|
|
reset_wlan "$num"
|
|
if [ "$val" = "None" ]; then
|
|
val="none"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "Basic" ]; then
|
|
val="wep-open"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=$val
|
|
elif [ "$val" = "WPA" ]; then
|
|
val="psk"
|
|
$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].encryption=$val
|
|
elif [ "$val" = "11i" ]; then
|
|
val="psk2"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
$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].encryption=$val
|
|
elif [ "$val" = "WPAand11i" ]; then
|
|
val="pskmixedpsk2"
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc="1"
|
|
$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].encryption=$val
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_wlan_mac_control_enable() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-device[$num].macfilter 2> /dev/null`
|
|
if [ "$val" = "2" ]; 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_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-device[$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_command "wifi" "5"
|
|
$UCI_SET wireless.wl0.hwmode="$val"
|
|
}
|
|
|
|
get_wlan_wep_key_index() {
|
|
local num="$1"
|
|
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"
|
|
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].radius_server
|
|
UCI_DELETE wireless.@wifi-iface[$num].radius_port
|
|
UCI_DELETE wireless.@wifi-iface[$num].radius_secret
|
|
delay_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="$val"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wep-shared"
|
|
}
|
|
|
|
set_wlan_key_passphrase() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption=wep-shared
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
i=1
|
|
for key in `/usr/sbin/wepkeygen 64 $val`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
}
|
|
|
|
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"
|
|
reset_wlan "$num"
|
|
if [ "$val" = "WEPEncryption" ]; then
|
|
val="wep-open"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "None" ]; then
|
|
val="none"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
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"
|
|
reset_wlan "$num"
|
|
if [ "$val" = "SharedAuthentication" ]; then
|
|
val="wep-shared"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
i=1
|
|
for key in `/usr/sbin/wepkeygen 64 Inteno`;do
|
|
$UCI_SET wireless.@wifi-iface[$num].key$i="$key"
|
|
let i++
|
|
done
|
|
elif [ "$val" = "None" ]; then
|
|
val="none"
|
|
$UCI_SET wireless.@wifi-iface[$num].key="1"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
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
|
|
reset_wlan "$num"
|
|
if [ "$val" = "TKIPEncryption" ]; then
|
|
val="psk+tkip"
|
|
$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].encryption="$val"
|
|
elif [ "$val" = "AESEncryption" ]; then
|
|
val="psk+ccmp"
|
|
$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].encryption="$val"
|
|
elif [ "$val" = "TKIPandAESEncryption" ]; then
|
|
val="psk+tkip+ccmp"
|
|
$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].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_wlan_wpa_authentication_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "$encryption" = "psk" -o "$encryption" = "pskmixedpsk2+tkip" ]; 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"
|
|
reset_wlan "$num"
|
|
if [ "$val" = "PSKAuthentication" ]; then
|
|
val="psk"
|
|
$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].encryption="$val"
|
|
elif [ "$val" = "EAPAuthentication" ]; then
|
|
val="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=""
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_wlan_ieee_11i_encryption_modes() {
|
|
local num="$1"
|
|
local val=""
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
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"
|
|
#TKIPEncryption, AESEncryption, TKIPandAESEncryption
|
|
reset_wlan "$num"
|
|
if [ "$val" = "TKIPEncryption" ]; then
|
|
val="psk2+tkip"
|
|
$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"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "AESEncryption" ]; then
|
|
val="psk2+ccmp"
|
|
$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"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "TKIPandAESEncryption" ]; then
|
|
val="psk2+tkip+ccmp"
|
|
$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"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_wlan_ieee_11i_authentication_mode() {
|
|
local num="$1"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
local val=""
|
|
if [ "$encryption" = "psk2" -o "$encryption" = "pskmixedpsk2+tkip" ]; 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"
|
|
reset_wlan "$num"
|
|
if [ "$val" = "PSKAuthentication" ]; then
|
|
val="psk2"
|
|
$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"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
elif [ "$val" = "EAPAuthentication" ]; then
|
|
val="wpa2"
|
|
$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=""
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
fi
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
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_command "wifi" "5"
|
|
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_command "wifi" "5"
|
|
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"
|
|
delay_command "wifi" "5"
|
|
if [ "$val" = "None" ];then
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="psk"
|
|
elif [ "$val" = "RadiusClient" ];then
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wpa"
|
|
fi
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
set_wlan_wep_key() {
|
|
local num="$1"
|
|
local val="$2"
|
|
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].radius_server
|
|
UCI_DELETE wireless.@wifi-iface[$num].radius_port
|
|
UCI_DELETE wireless.@wifi-iface[$num].radius_secret
|
|
delay_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-iface[$num].key$key_index=$val
|
|
$UCI_SET wireless.@wifi-iface[$num].key="$key_index"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="wep-shared"
|
|
}
|
|
|
|
set_wlan_pre_shared_key() {
|
|
local num="$1"
|
|
local val="$2"
|
|
reset_wlan $num
|
|
delay_command "wifi" "5"
|
|
$UCI_SET wireless.@wifi-iface[$num].key=$val
|
|
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
|
|
$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
|
|
}
|
|
|
|
set_wlan_pre_shared_key_key_passphrase() {
|
|
local num="$1"
|
|
local param="$2"
|
|
local val="$3"
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
set_wlan_pre_shared_key_associated_device_MACAddress() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_command "wifi" "5"
|
|
}
|
|
|
|
get_landevice_wlanconfiguration_generic() {
|
|
lan_num=$1
|
|
wlan_num=$2
|
|
uci_num=$3
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice." "0" "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num." "0" "0"
|
|
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" "1" "" "set_wlan_status $uci_num \$val" "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_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 \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.2.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.3.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.4.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$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 1 \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.KeyPassphrase" "1" "" "set_wlan_pre_shared_key_key_passphrase $uci_num 1 \$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 1 \$val"
|
|
}
|
|
|
|
get_cache_InternetGatewayDevice_LANDevice() {
|
|
for lan in `get_lan_device_interface`;do
|
|
lan_num=`echo $lan|cut -f2 -d:`
|
|
lan_dev=`echo $lan|cut -f1 -d:`
|
|
wlan_num=0
|
|
for uci_num in `$UCI_SHOW wireless|grep $lan_dev|sed -n 's/wireless\.@wifi-iface//p'|sed -n 's/\.network=\w\+ *\w*//p'|sed -n 's/\]//p'|sed -n 's/\[//p'`;do
|
|
let "wlan_num++"
|
|
get_landevice_wlanconfiguration_generic $lan_num $wlan_num $uci_num
|
|
done
|
|
done
|
|
}
|
|
|
|
get_dynamic_InternetGatewayDevice_LANDevice() {
|
|
local param="$1"
|
|
local assoclist="" num="" lan_num="" wlan_num=0 i=0
|
|
local mac_lower="" ip="" is_authenticated=""
|
|
|
|
if [ "$param" = "" ]; then param="InternetGatewayDevice."; fi
|
|
|
|
case "$param" 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 lan in `get_lan_device_interface`;do
|
|
lan_num=`echo $lan|cut -f2 -d:`
|
|
lan_dev=`echo $lan|cut -f1 -d:`
|
|
wlan_num=0
|
|
for num in `$UCI_SHOW wireless|grep $lan_dev|sed -n 's/wireless\.@wifi-iface//p'|sed -n 's/\.network=\w\+ *\w*//p'|sed -n 's/\]//p'|sed -n 's/\[//p'`;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 "InternetGatewayDevice.LANDevice.$lan_num.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 "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AssociatedDevice.$i." "" "0" "" "" "" "" "0"
|
|
freecwmp_cache_output "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceMACAddress" "$mac" "0" "0" "" "" "" "0"
|
|
freecwmp_cache_output "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceIPAddress" "$ip" "0" "0" "" "" "" "0"
|
|
freecwmp_cache_output "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AssociatedDevice.$i.AssociatedDeviceAuthenticationState" "$is_authenticated" "0" "0" "xsd:boolean" "" "" "0"
|
|
done
|
|
done
|
|
done
|
|
esac
|
|
}
|
|
|
|
add_object_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|
|
|
|
delete_object_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
} |