mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-01-28 01:27:16 +01:00
1980 lines
70 KiB
Bash
1980 lines
70 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
|
# Copyright (C) 2013-2015 Inteno Broadband Technology AB
|
|
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
|
# Author Feten Besbes <feten.besbes@pivasoftware.com>
|
|
# Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
|
|
|
prefix_list="$prefix_list InternetGatewayDevice.LANDevice."
|
|
|
|
get_lan_device_interface() {
|
|
local i=0
|
|
local ret=""
|
|
local fislan=0
|
|
local lan wnet
|
|
for lan in `ubus list|sed -n 's/network\.interface\.//p'|grep -v loopback`;do
|
|
fislan=0
|
|
wnet=`$UCI_SHOW wireless |grep "wireless\.@wifi-iface\[[0-9]\+\]\.network=$lan"`
|
|
[ "$wnet" != "" ] && fislan=1
|
|
local ifname=`$UCI_GET network.$lan.ifname`
|
|
[ "${ifname//eth[1-9]/}" != "$ifname" ] && fislan=1
|
|
local ftype=`$UCI_GET network.$lan.type`
|
|
if [ "$fislan" = "1" -a "$ftype" != "alias" ];then
|
|
dev=$lan
|
|
elif [ "$ftype" = "alias" ]; then
|
|
dev=`$UCI_GET network.$lan.ifname`
|
|
dev=${dev/br-/}
|
|
else
|
|
continue
|
|
fi
|
|
local tmp=${ret/:$dev./}
|
|
if [ "$tmp" = "$ret" ]; then
|
|
let i++
|
|
ret="$ret $i:$dev.0;"
|
|
fi
|
|
tmp=${ret#*:$dev.}
|
|
tmp=${tmp%% *}
|
|
local flan=${tmp%%,}
|
|
[ "$flan" = "$tmp" -o "$ftype" != "alias" ] && flan="" || flan="${flan#*;},"
|
|
local inst=${tmp%%;*}
|
|
[ "$inst" = "$tmp" -o "$inst" = "" ] && inst=1 || let inst++
|
|
ret=${ret/:$dev.$((inst-1));$flan/:$dev.$inst;$flan$inst:$lan,}
|
|
done
|
|
ret=${ret//, / }; ret=${ret%,}
|
|
ret=${ret//.[0-9]/}; ret=${ret//.[0-9]/}
|
|
echo $ret
|
|
}
|
|
|
|
update_instance_landevice_wlanconfiguration() {
|
|
local idev="$1"
|
|
local wiface="$2"
|
|
|
|
local inst=`$UCI_GET wireless.$wiface.instance`
|
|
if [ "$inst" != "" ]; then
|
|
echo ${inst#*.}
|
|
else
|
|
local inst=`$UCI_SHOW wireless |sed -n "s/wireless\.@wifi-iface\[[0-9]\+\]\.instance=$idev\.//p" | sort -rn | head -n1`
|
|
inst=${inst:-0}
|
|
$UCI_SET wireless.$wiface.instance="$idev.$((++inst))"
|
|
$UCI_COMMIT
|
|
echo $inst
|
|
fi
|
|
}
|
|
|
|
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 wunit="$1"
|
|
local wlctl_num="$2"
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
val=`/usr/sbin/wlctl -i $wunit bssid`
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_max_bit_rate() {
|
|
local wunit="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.$wunit.hwmode="auto"
|
|
}
|
|
|
|
get_wlan_channel() {
|
|
local wunit=$1
|
|
local val=`$UCI_GET wireless.$wunit.channel`
|
|
if [ "$val" = "auto" -o "$val" = "" ];then
|
|
val=`/usr/sbin/wlctl -i $wunit channel|grep "target channel"|awk -F ' ' '{print$3}'`
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
set_wlan_channel() {
|
|
local wunit="$1"
|
|
local val="$2"
|
|
delay_service reload "network" "1"
|
|
$UCI_SET wireless.$wunit.channel="$val"
|
|
}
|
|
|
|
get_wlan_auto_channel_enable() {
|
|
local wunit=$1
|
|
local val=`$UCI_GET wireless.$wunit.channel`
|
|
if [ "$val" = "auto" -o "$val" = "" ];then
|
|
echo 1
|
|
else
|
|
echo 0
|
|
fi
|
|
}
|
|
|
|
set_wlan_auto_channel_enable() {
|
|
local wunit="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
val="auto"
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
val=`/usr/sbin/wlctl -i $wunit channel|grep "target channel"|awk -F ' ' '{print$3}'`
|
|
fi
|
|
$UCI_SET wireless.$wunit.channel="$val"
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
|
|
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 ^mixed-psk$`" != "" -o "`echo $encryption|grep ^mixed-psk+`" != "" -o "$encryption" = "mixed-wpa" ]; 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="mixed-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"
|
|
$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 wunit="$1"
|
|
val=`$UCI_GET wireless.$wunit.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 wunit="$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.$wunit.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" = "mixed-psk+tkip" ];then
|
|
val="TKIPEncryption"
|
|
elif [ "$encryption" = "psk+ccmp" -o "$encryption" = "mixed-psk+ccmp" ];then
|
|
val="AESEncryption"
|
|
elif [ "$encryption" = "psk+tkip+ccmp" -o "$encryption" = "mixed-psk+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 ^mixed-psk`" != "" ]; then
|
|
val="PSKAuthentication"
|
|
elif [ "$encryption" = "wpa" -o "$encryption" = "mixed-wpa" ];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 != "mixed-wpa" ] ; 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" = "mixed-psk+tkip" ];then
|
|
val="TKIPEncryption"
|
|
elif [ "$encryption" = "psk2+ccmp" -o "$encryption" = "mixed-psk+ccmp" ];then
|
|
val="AESEncryption"
|
|
elif [ "$encryption" = "psk2+tkip+ccmp" -o "$encryption" = "mixed-psk+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 ^mixed-psk`" != "" ]; then
|
|
val="PSKAuthentication"
|
|
elif [ "$encryption" = "wpa2" -o "$encryption" = "mixed-wpa" ];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 != "mixed-wpa" ] ; 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 wunit="$1"
|
|
local wlctl_num="$2"
|
|
local val=""
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
radio=`/usr/sbin/wlctl -i $wunit radio`
|
|
val=`echo $(($radio))`
|
|
if [ "$val" = "0" ];then
|
|
val=1
|
|
elif [ "$val" = "1" ];then
|
|
val=0
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_wlan_radio_enabled() {
|
|
local wunit="$1"
|
|
local wlctl_num="$2"
|
|
local val="$3"
|
|
delay_service reload "network" "1"
|
|
if [ "$val" = "0" ];then
|
|
val="off"
|
|
elif [ "$val" = "1" ];then
|
|
val="on"
|
|
fi
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
/usr/sbin/wlctl -i $wunit radio $val
|
|
|
|
}
|
|
|
|
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" = "mixed-wpa" ]; 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" != "mixed-wpa" ]; 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 wunit="$1"
|
|
local wlctl_num="$2"
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
val=`/usr/sbin/wlctl -i $wunit assoclist | grep -c 'assoclist'`
|
|
echo "$val"
|
|
}
|
|
|
|
get_wlan_devstatus_statistics() {
|
|
local wunit="$1"
|
|
local wlctl_num="$2"
|
|
local counter="$3"
|
|
local wdevstatus val
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
wdevstatus=`devstatus $wunit`
|
|
json_init
|
|
json_load "$wdevstatus"
|
|
json_select "statistics"
|
|
json_get_var val $counter
|
|
json_select ".."
|
|
|
|
echo "$val"
|
|
}
|
|
|
|
get_wlan_ssid_advertisement_enable() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].hidden`
|
|
[ "$val" = "1" ] && echo 0 || echo 1
|
|
}
|
|
|
|
set_wlan_ssid_advertisement_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
$UCI_SET wireless.@wifi-iface[$num].hidden=
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
$UCI_SET wireless.@wifi-iface[$num].hidden=1
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_wps_enable() {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].wps_pbc`
|
|
[ "$val" = "1" ] && echo 1 || echo 0
|
|
}
|
|
|
|
set_wlan_wps_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc=1
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
$UCI_SET wireless.@wifi-iface[$num].wps_pbc=
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
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
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($lan_name\|@dhcp\[[0-9]\+\]\).interface=$lan_name"`
|
|
if [ "$dface" = "" ];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]'`
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($lan_name\|@dhcp\[[0-9]\+\]\).interface=$lan_name" | cut -f2 -d'.'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
if [ "$dface" = "" ];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
|
|
local list=`$UCI_SHOW -X dhcp |grep "dhcp\..*\.interface=$lan_name" | cut -f2 -d'.'`
|
|
for dface in $list;do
|
|
[ "`$UCI_GET dhcp.$dface`" = "dhcp" ] && break
|
|
done
|
|
$UCI_DELETE dhcp.$dface
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_server_enable() {
|
|
local lan_name=$1
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($lan_name\|@dhcp\[[0-9]\+\]\).interface=$lan_name" | cut -f2 -d'.'`
|
|
if [ "$dface" = "" ]; then
|
|
echo 0
|
|
else
|
|
if [ "`$UCI_GET dhcp.$dface.ignore`" = "" ]; then echo 1; else echo 0; fi
|
|
fi
|
|
}
|
|
|
|
set_lan_dhcp_server_enable() {
|
|
local lan_name=$1
|
|
local val="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($lan_name\|@dhcp\[[0-9]\+\]\).interface=$lan_name" | cut -f2 -d'.'`
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
$UCI_SET dhcp.$dface.ignore=
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
$UCI_SET dhcp.$dface.ignore=1
|
|
else
|
|
return
|
|
fi
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
DHCPSTATICADDRESS_DISABLED_CHADDR="00:00:00:00:00:01"
|
|
get_dhcpstaticaddress_enable() {
|
|
local slease="$1"
|
|
local chaddr=`$UCI_GET dhcp.$slease.mac`
|
|
if [ "$chaddr" = "$DHCPSTATICADDRESS_DISABLED_CHADDR" ]; then
|
|
echo 0
|
|
else
|
|
echo 1
|
|
fi
|
|
}
|
|
|
|
set_dhcpstaticaddress_enable() {
|
|
local slease="$1"
|
|
local val="$2"
|
|
local orig_chaddr chaddr=`$UCI_GET dhcp.$slease.mac`
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
if [ "$chaddr" = "$DHCPSTATICADDRESS_DISABLED_CHADDR" ]; then
|
|
orig_chaddr=`$UCI_GET dhcp.$slease.mac_orig`
|
|
$UCI_SET dhcp.$slease.mac=$orig_chaddr
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
else
|
|
return
|
|
fi
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
if [ "$chaddr" = "$DHCPSTATICADDRESS_DISABLED_CHADDR" ]; then
|
|
return
|
|
else
|
|
orig_chaddr=`$UCI_GET dhcp.$slease.mac`
|
|
$UCI_SET dhcp.$slease.mac_orig=$orig_chaddr
|
|
$UCI_SET dhcp.$slease.mac=$DHCPSTATICADDRESS_DISABLED_CHADDR
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
get_dhcpstaticaddress_chaddr() {
|
|
local slease="$1"
|
|
local chaddr=`$UCI_GET dhcp.$slease.mac`
|
|
if [ "$chaddr" = "$DHCPSTATICADDRESS_DISABLED_CHADDR" ]; then
|
|
chaddr=`$UCI_GET dhcp.$slease.mac_orig`
|
|
fi
|
|
echo $chaddr
|
|
}
|
|
|
|
set_dhcpstaticaddress_chaddr() {
|
|
local slease="$1"
|
|
local val="$2"
|
|
local chaddr=`$UCI_GET dhcp.$slease.mac`
|
|
if [ "$chaddr" = "$DHCPSTATICADDRESS_DISABLED_CHADDR" ]; then
|
|
$UCI_SET dhcp.$slease.mac_orig=$val
|
|
else
|
|
$UCI_SET dhcp.$slease.mac=$val
|
|
fi
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_dhcpstaticaddress_yiaddr() {
|
|
local slease="$1"
|
|
local ip=`$UCI_GET dhcp.$slease.ip`
|
|
echo $ip
|
|
}
|
|
|
|
set_dhcpstaticaddress_yiaddr() {
|
|
local slease="$1"
|
|
local val="$2"
|
|
$UCI_SET dhcp.$slease.ip="$val"
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
update_instance_landevice_dhcpstaticaddress() {
|
|
local idev="$1"
|
|
local slease="$2"
|
|
|
|
local inst=`$UCI_GET dhcp.$slease.instance`
|
|
if [ "$inst" != "" ]; then
|
|
echo ${inst#*.}
|
|
else
|
|
local inst=`$UCI_SHOW dhcp |sed -n "s/dhcp\.@host\[[0-9]\+\]\.instance=$idev\.//p" | sort -rn | head -n1`
|
|
inst=${inst:-0}
|
|
$UCI_SET dhcp.$slease.instance="$idev.$((++inst))"
|
|
$UCI_COMMIT
|
|
echo $inst
|
|
fi
|
|
}
|
|
|
|
get_lan_dhcp_interval_address() {
|
|
local opt="$1"
|
|
local nlan="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local start=`$UCI_GET dhcp.$dface.start`
|
|
local limit=`$UCI_GET dhcp.$dface.limit`
|
|
[ "$start" = "" -o "$limit" = "" ] && return
|
|
local ipaddr=`$UCI_GET network.$nlan.ipaddr`
|
|
if [ "$ipaddr" = "" ]; then
|
|
json_load "$(ifstatus $nlan)"
|
|
json_select "ipv4-address"
|
|
json_select 1
|
|
json_get_var ipaddr address
|
|
fi
|
|
[ "$ipaddr" = "" ] && return
|
|
local mask=`$UCI_GET network.$nlan.netmask`
|
|
if [ "$mask" = "" ]; then
|
|
json_load "$(ifstatus $nlan)"
|
|
json_select "ipv4-address"
|
|
json_select 1
|
|
json_get_var mask mask
|
|
mask=`cidr2netmask $mask`
|
|
fi
|
|
[ "$mask" = "" ] && return
|
|
ipcalc.sh $ipaddr $mask $start $limit | sed -n "s/$opt=//p"
|
|
}
|
|
|
|
set_lan_dhcp_address_start() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local ipaddr=`$UCI_GET network.$nlan.ipaddr`
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
if [ "$ipaddr" = "" ]; then
|
|
json_load "$(ifstatus $nlan)"
|
|
json_select "ipv4-address"
|
|
json_select 1
|
|
json_get_var ipaddr address
|
|
fi
|
|
[ "$ipaddr" = "" ] && return
|
|
local mask=`$UCI_GET network.$nlan.netmask`
|
|
if [ "$mask" = "" ]; then
|
|
json_load "$(ifstatus $nlan)"
|
|
json_select "ipv4-address"
|
|
json_select 1
|
|
json_get_var mask mask
|
|
mask=`cidr2netmask $mask`
|
|
fi
|
|
[ "$mask" = "" ] && return
|
|
local naddr=`ip_to_int $val`
|
|
mask=`ip_to_int $mask`
|
|
ipaddr=`ip_to_int $ipaddr`
|
|
val=$((naddr-(mask&ipaddr)))
|
|
[ $val -lt 0 ] && val=0
|
|
`$UCI_SET dhcp.$dface.start=$val`
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
set_lan_dhcp_address_end() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local start=`get_lan_dhcp_interval_address START $nlan`
|
|
[ "$start" = "" ] && return
|
|
start=`ip_to_int $start`
|
|
val=`ip_to_int $val`
|
|
|
|
val=$((val-start))
|
|
[ $val -lt 0 ] && val=0
|
|
`$UCI_SET dhcp.$dface.limit=$val`
|
|
delay_service reload "network" "1"
|
|
delay_service reload "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_reserved_addresses() {
|
|
local nlan="$1"
|
|
local min=`get_lan_dhcp_interval_address START $nlan`
|
|
local max=`get_lan_dhcp_interval_address END $nlan`
|
|
min=`ip_to_int $min`
|
|
max=`ip_to_int $max`
|
|
|
|
local reserveds=""
|
|
local ip ips=`$UCI_SHOW dhcp | sed -n 's/dhcp\.@host\[[0-9]\+\].ip=//p'`
|
|
for ip in $ips; do
|
|
local nip=""
|
|
nip=`ip_to_int $ip`
|
|
if [ $nip -ge $min -a $nip -le $max ]; then
|
|
reserveds="$reserveds,$ip"
|
|
fi
|
|
done
|
|
echo ${reserveds#,}
|
|
}
|
|
|
|
set_lan_dhcp_reserved_addresses() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local min=`get_lan_dhcp_interval_address START $nlan`
|
|
local max=`get_lan_dhcp_interval_address END $nlan`
|
|
min=`ip_to_int $min`
|
|
max=`ip_to_int $max`
|
|
|
|
local ip
|
|
for ip in ${val//,/ }; do
|
|
local exist=`$UCI_SHOW dhcp | sed -n 's/dhcp\.@host\[[0-9]\+\].ip=//p' | grep $ip`
|
|
[ "$exist" != "" ] && continue
|
|
local nip=""
|
|
nip=`ip_to_int $ip`
|
|
[ $nip -lt $min -o $nip -gt $max ] && continue
|
|
local slease=`$UCI_ADD dhcp host`
|
|
$UCI_SET dhcp.$slease.mac="$DHCPSTATICADDRESS_DISABLED_CHADDR"
|
|
$UCI_SET dhcp.$slease.interface="$nlan"
|
|
$UCI_SET dhcp.$slease.ip="$ip"
|
|
done
|
|
local host hosts=`$UCI_SHOW dhcp | grep "dhcp\.@host\[[0-9]\+\].ip="`
|
|
for host in $hosts; do
|
|
ip=${host#*=}
|
|
local nip=""
|
|
nip=`ip_to_int $ip`
|
|
if [ $nip -ge $min -a $nip -le $max ]; then
|
|
if [ "${val//$ip/}" = "$val" ]; then
|
|
$UCI_DELETE ${host%=*}
|
|
fi
|
|
fi
|
|
done
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_subnetmask() {
|
|
local nlan="$1"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local mask=`$UCI_GET dhcp.$dface.netmask`
|
|
if [ "$mask" = "" ]; then
|
|
mask=`$UCI_GET network.$nlan.netmask`
|
|
fi
|
|
if [ "$mask" = "" ]; then
|
|
json_load "$(ifstatus $nlan)"
|
|
json_select "ipv4-address"
|
|
json_select 1
|
|
json_get_var mask mask
|
|
mask=`cidr2netmask $mask`
|
|
fi
|
|
echo $mask
|
|
}
|
|
|
|
set_lan_dhcp_subnetmask() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
$UCI_SET dhcp.$dface.netmask=$val
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_iprouters() {
|
|
local nlan="$1"
|
|
local gw=`$UCI_GET network.$nlan.gateway`
|
|
if [ "$gw" = "" ]; then
|
|
gw=`$UCI_GET network.$nlan.ipaddr`
|
|
fi
|
|
echo $gw
|
|
}
|
|
|
|
set_lan_dhcp_iprouters() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
$UCI_SET network.$nlan.gateway=$val
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_leasetime() {
|
|
local nlan="$1"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local ltime=`$UCI_GET dhcp.$dface.leasetime`
|
|
if [ "$ltime" = "" ]; then
|
|
echo -1
|
|
return
|
|
fi
|
|
mtime=60
|
|
ntime=${ltime%m}
|
|
if [ "$ntime" = "$ltime" ]; then
|
|
mtime=3600
|
|
ntime=${ltime%h}
|
|
[ "$ntime" = "$ltime" ] && return
|
|
fi
|
|
echo $((ntime*mtime))
|
|
}
|
|
|
|
set_lan_dhcp_leasetime() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
val=$((val/60))
|
|
$UCI_SET dhcp.$dface.leasetime="$val"m
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_dhcp_domainname() {
|
|
local nlan="$1"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local dop dhcp_options=`$UCI_GET dhcp.$dface.dhcp_option`
|
|
for dop in $dhcp_options; do
|
|
local dn=${dop/15,/}
|
|
[ "$dn" = "$dop" ] && continue
|
|
echo $dn
|
|
break
|
|
done
|
|
}
|
|
|
|
set_lan_dhcp_domainname() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
local dface=`$UCI_SHOW dhcp | grep "dhcp\.\($nlan\|@dhcp\[[0-9]\+\]\).interface=$nlan" | cut -f2 -d'.'`
|
|
local dop dhcp_options=`$UCI_GET dhcp.$dface.dhcp_option`
|
|
for dop in $dhcp_options; do
|
|
local dn=${dop/15,/}
|
|
[ "$dn" = "$dop" ] && continue
|
|
$UCI_DEL_LIST dhcp.$dface.dhcp_option=$dop
|
|
done
|
|
$UCI_ADD_LIST dhcp.$dface.dhcp_option="15,$val"
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
}
|
|
|
|
get_lan_ethernet_interfaces() {
|
|
local ndev="$1"
|
|
local ifaces=""
|
|
jmsg=`devstatus br-$ndev 2>/dev/null`
|
|
[ "$jmsg" = "" ] && { echo $ndev; return; }
|
|
json_load "$jmsg"
|
|
json_select "bridge-members"
|
|
local index="1"
|
|
while json_get_type bridge $index && [ "$bridge" = string ]; do
|
|
json_get_var bridge "$((index++))"
|
|
[ "${bridge/eth/}" = "$bridge" ] && continue
|
|
ifaces="$ifaces $bridge"
|
|
done
|
|
json_select ".."
|
|
echo "$ifaces"
|
|
}
|
|
|
|
get_lan_eth_iface_cfg_enable() {
|
|
local eth="$1"
|
|
local val
|
|
jmsg=`devstatus $eth`
|
|
json_load "$jmsg"
|
|
json_get_var val link
|
|
echo $val
|
|
}
|
|
|
|
set_lan_eth_iface_cfg_enable() {
|
|
local eth="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
ethctl $eth phy-power up >/dev/null
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
ethctl $eth phy-power down
|
|
fi
|
|
}
|
|
|
|
get_lan_eth_iface_cfg_status() {
|
|
local eth="$1"
|
|
local val
|
|
val=`get_lan_eth_iface_cfg_enable $eth`
|
|
[ "$val" = "true" -o "$val" = "1" ] && echo Up || echo Disabled
|
|
}
|
|
|
|
get_lan_eth_iface_cfg_maxbitrate() {
|
|
local eth="$1"
|
|
local val=`$UCI_GET ports.@ethports[0].$eth`
|
|
[ "$val" = "auto" ] && { echo "Auto"; return; }
|
|
echo ${val%[FHfh][Dd]*}
|
|
}
|
|
|
|
set_lan_eth_iface_cfg_maxbitrate() {
|
|
local eth="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
[ "$val" = "auto" ] && { $UCI_SET ports.@ethports[0].$eth="auto" ; return ; }
|
|
local duplex=`$UCI_GET ports.@ethports[0].$eth`
|
|
[ "$duplex" = "auto" ] && duplex="FD" || duplex=${duplex##*[0-9]}
|
|
$UCI_SET ports.@ethports[0].$eth="$val$duplex"
|
|
delay_service reload "network" "1"
|
|
delay_service restart "port_management" "1"
|
|
}
|
|
|
|
get_lan_eth_iface_cfg_duplexmode() {
|
|
local eth="$1"
|
|
local val=`$UCI_GET ports.@ethports[0].$eth`
|
|
[ "$val" = "auto" ] && { echo "Auto"; return; }
|
|
val=${val##*[0-9]}
|
|
val=`echo $val|tr '[a-z]' '[A-Z]'`
|
|
[ "$val" = "HD" ] && echo "Half"
|
|
[ "$val" = "FD" ] && echo "Full"
|
|
}
|
|
|
|
set_lan_eth_iface_cfg_duplexmode() {
|
|
local eth="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
[ "$val" = "auto" ] && { $UCI_SET ports.@ethports[0].$eth="auto" ; return ; }
|
|
local rate=`$UCI_GET ports.@ethports[0].$eth`
|
|
[ "$rate" = "auto" ] && rate="100" || rate=${rate%[FHfh][Dd]*}
|
|
if [ "$val" = "full" ]; then
|
|
val="FD"
|
|
elif [ "$val" = "half" ]; then
|
|
val="HD"
|
|
else
|
|
return
|
|
fi
|
|
$UCI_SET ports.@ethports[0].$eth="$rate$val"
|
|
delay_service reload "network" "1"
|
|
delay_service restart "port_management" "1"
|
|
}
|
|
|
|
get_lan_eth_iface_cfg_stats() {
|
|
local eth="$1"
|
|
local counter="$2"
|
|
local devstatus="" val=""
|
|
devstatus=`devstatus $eth`
|
|
json_load "$devstatus"
|
|
json_select "statistics"
|
|
json_get_var val $counter
|
|
json_select ".."
|
|
echo "$val"
|
|
}
|
|
|
|
get_lan_host_nbr_entries() {
|
|
local flan="$1"
|
|
ubus call router clients | grep -c "\"network\": \"$flan\""
|
|
}
|
|
|
|
get_interface_ipaddress() {
|
|
local nlan="$1"
|
|
local val=""
|
|
if [ "`$UCI_GET network.$nlan.proto`" = "static" ]; then
|
|
val=`$UCI_GET network.$nlan.ipaddr`
|
|
else
|
|
local jsmsg=`ifstatus $nlan`
|
|
json_init
|
|
json_load "$jsmsg"
|
|
json_select "ipv4-address"
|
|
local type
|
|
json_get_type type 1
|
|
[ "$type" = "" ] && return
|
|
json_select 1
|
|
json_get_var val address
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_interface_ipaddress() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
[ "$val" = "" ] && return
|
|
$UCI_SET network.$nlan.ipaddr=$val
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_interface_subnetmask() {
|
|
local nlan="$1"
|
|
local val=""
|
|
if [ "`$UCI_GET network.$nlan.proto`" = "static" ]; then
|
|
val=`$UCI_GET network.$nlan.netmask`
|
|
else
|
|
local jsmsg=`ifstatus $nlan`
|
|
json_init
|
|
json_load "$jsmsg"
|
|
json_select "ipv4-address"
|
|
local type
|
|
json_get_type type 1
|
|
[ "$type" = "" ] && return
|
|
json_select 1
|
|
json_get_var val mask
|
|
val=`cidr2netmask $val`
|
|
fi
|
|
echo "$val"
|
|
}
|
|
|
|
set_interface_subnetmask() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
[ "$val" = "" ] && return
|
|
$UCI_SET network.$nlan.netmask=$val
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_interface_addressingtype() {
|
|
local nlan="$1"
|
|
local val="`$UCI_GET network.$nlan.proto`"
|
|
case "$val" in
|
|
static) echo "Static";;
|
|
dhcp) echo "DHCP";;
|
|
esac
|
|
}
|
|
|
|
set_interface_addressingtype() {
|
|
local nlan="$1"
|
|
local val="$2"
|
|
case "$val" in
|
|
Static) $UCI_SET network.$nlan.proto=static;;
|
|
DHCP) $UCI_SET network.$nlan.proto=dhcp;;
|
|
*) return;;
|
|
esac
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_x_inteno_se_channelmode () {
|
|
local wunit="$1"
|
|
local val=`$UCI_GET wireless.$wunit.channel`
|
|
if [ "$val" = "auto" -o "$val" = "" ];then
|
|
echo "Auto"
|
|
else
|
|
echo "Manual"
|
|
fi
|
|
}
|
|
|
|
set_x_inteno_se_channelmode () {
|
|
local wunit="$1"
|
|
local val="$2"
|
|
if [ "$val" = "Auto" ]; then
|
|
$UCI_SET wireless.$wunit.channel="auto"
|
|
elif [ "$val" = "Manual" ]; then
|
|
local channel=`/usr/sbin/wlctl -i $wunit channel |grep "target channel" |awk -F ' ' '{print$3}'`
|
|
$UCI_SET wireless.$wunit.channel="$channel"
|
|
fi
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_x_inteno_se_supported_standard () {
|
|
local wunit="$1"
|
|
local val=`wlctl -i $wunit status |awk '$1=="Chanspec:" {print$2}'`
|
|
case $val in
|
|
"5GHz") echo "a, n, ac";;
|
|
*) echo "b, g, n, gst, lrs";;
|
|
esac
|
|
}
|
|
|
|
get_x_inteno_se_operating_channel_bandwidth () {
|
|
local wunit="$1"
|
|
local val=`$UCI_GET wireless.$wunit.bandwidth`
|
|
[ "$val" = "" ] && val=`wlctl -i $wunit status |awk '$1=="Chanspec:" {print$5}'`
|
|
echo "${val//[^0-9]/}""MHz"
|
|
}
|
|
|
|
set_x_inteno_se_operating_channel_bandwidth () {
|
|
local wunit="$1"
|
|
local val="$2"
|
|
|
|
val=` printf %u ${val//[^0-9]/} 2>/dev/null`
|
|
[ "$val" = "0" -o "$val" = "" ] && return
|
|
$UCI_SET wireless.$wunit.bandwidth=$val
|
|
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_x_inteno_se_maxssid () {
|
|
local num="$1"
|
|
local val=`$UCI_GET wireless.@wifi-iface[$num].bss_max`
|
|
echo "$val"
|
|
}
|
|
|
|
set_x_inteno_se_maxssid () {
|
|
local num="$1"
|
|
local val="$2"
|
|
|
|
$UCI_SET wireless.@wifi-iface[$num].bss_max=$val
|
|
|
|
delay_service reload "network" "1"
|
|
}
|
|
|
|
get_wlan_psk_assoc_MACAddress() {
|
|
local assoc_list adma
|
|
local wunit="$1"
|
|
local wlctl_num="$2"
|
|
local num="$3"
|
|
local pki="$4"
|
|
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
|
|
if [ "${encryption//psk/}" != "$encryption" ]; then
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit="$wunit.$wlctl_num"
|
|
fi
|
|
assoc_list=`/usr/sbin/wlctl -i $wunit assoclist|awk -F' ' '{print $2}'`
|
|
adma=`echo $assoc_list | awk -F' ' '{print $'"$pki"'}'`
|
|
echo "$adma"
|
|
fi
|
|
}
|
|
|
|
get_interface_type() {
|
|
local mac="$1"
|
|
local ndev="$2"
|
|
local wunit wunit_l iuci assoc_mac int_type="Ethernet"
|
|
|
|
for wunit in `$UCI_SHOW wireless|grep "wireless\.wl[0-9]\+=wifi-device" | awk -F '[.=]' '{print $2}'`; do
|
|
local wlctl_num=0
|
|
for iuci in `$UCI_SHOW wireless|grep "wireless\.@wifi-iface\[[0-9]\+\]\.device=$wunit"| awk -F '[][]' '{print $2}'`; do
|
|
[ "`$UCI_GET wireless.@wifi-iface[$iuci].network`" != "$ndev" ] && continue
|
|
wunit_l="$wunit"
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit_l="$wunit.$wlctl_num"
|
|
fi
|
|
assoclist=`/usr/sbin/wlctl -i $wunit_l assoclist|awk -F' ' '{print $2}'`
|
|
assoclist=`echo $assoclist|tr '[A-Z]' '[a-z]'`
|
|
for assoc_mac in $assoclist;do
|
|
if [ "$assoc_mac" = "$mac" ]; then
|
|
int_type="802.11"
|
|
break 3
|
|
fi
|
|
done
|
|
let "wlctl_num++"
|
|
done
|
|
done
|
|
echo "$int_type"
|
|
}
|
|
|
|
get_landevice_wlanconfiguration_generic() {
|
|
local pki=0
|
|
local lan_num=$1
|
|
local wlan_num=$2
|
|
local uci_num=$3
|
|
local wunit=$4
|
|
local wlctl_num=$5
|
|
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 $wunit $wlctl_num"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.MaxBitRate" "1" "$UCI_GET wireless.$wunit.hwmode" "set_wlan_max_bit_rate $wunit \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.Channel" "1" "get_wlan_channel $wunit" "set_wlan_channel $wunit \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.AutoChannelEnable" "1" "get_wlan_auto_channel_enable $wunit" "set_wlan_auto_channel_enable $wunit \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.SSID" "1" "$UCI_GET wireless.@wifi-iface[$uci_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 $wunit" "set_wlan_standard $wunit \$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 $wunit $wlctl_num \$val" "get_wlan_radio_enabled $wunit $wlctl_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 $wunit $wlctl_num" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.ChannelsInUse" "1" "get_wlan_channel $wunit" "set_wlan_channel $wunit \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalBytesSent" "0" "" "" "get_wlan_devstatus_statistics $wunit $wlctl_num tx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalBytesReceived" "0" "" "" "get_wlan_devstatus_statistics $wunit $wlctl_num rx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalPacketsSent" "0" "" "" "get_wlan_devstatus_statistics $wunit $wlctl_num tx_packets" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.TotalPacketsReceived" "0" "" "" "get_wlan_devstatus_statistics $wunit $wlctl_num rx_packets" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.SSIDAdvertisementEnabled" "1" "get_wlan_ssid_advertisement_enable $uci_num" "set_wlan_ssid_advertisement_enable $uci_num \$val" "" "xsd:boolean"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WPS." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WPS.Enable" "1" "get_wlan_wps_enable $uci_num" "set_wlan_wps_enable $uci_num \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.X_INTENO_SE_ChannelMode" "1" "get_x_inteno_se_channelmode $wunit" "set_x_inteno_se_channelmode $wunit \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.X_INTENO_SE_SupportedStandards" "0" "get_x_inteno_se_supported_standard $wunit"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.X_INTENO_SE_OperatingChannelBandwidth" "1" "get_x_inteno_se_operating_channel_bandwidth $wunit" "set_x_inteno_se_operating_channel_bandwidth $wunit \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.X_INTENO_SE_MaxSSID" "1" "get_x_inteno_se_maxssid $uci_num" "set_x_inteno_se_maxssid $uci_num \$val"
|
|
|
|
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"
|
|
while [ "$((pki++))" != "10" ];do
|
|
get_landevice_wlanconfiguration_presharedkey "$lan_num" "$wlan_num" "$pki" "$wunit" "$wlctl_num" "$uci_num"
|
|
done
|
|
|
|
}
|
|
|
|
get_landevice_wlanconfiguration_presharedkey() {
|
|
local lan_num=$1
|
|
local wlan_num=$2
|
|
local pki=$3
|
|
local wunit=$4
|
|
local wlctl_num=$5
|
|
local uci_num=$6
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.$pki." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.$pki.PreSharedKey" "1" "" "set_wlan_pre_shared_key $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.$pki.KeyPassphrase" "1" "" "set_wlan_key_passphrase $uci_num \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.$pki.AssociatedDeviceMACAddress" "0" "" "" "get_wlan_psk_assoc_MACAddress $wunit $wlctl_num $uci_num $pki"
|
|
}
|
|
get_landevice_lanhostconfigmanagement_ipinterface() {
|
|
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_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan.IPInterfaceIPAddress" "1" "get_interface_ipaddress $nlan" "set_interface_ipaddress $nlan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan.IPInterfaceSubnetMask" "1" "get_interface_subnetmask $nlan" "set_interface_subnetmask $nlan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface.$ilan.IPInterfaceAddressingType" "1" "get_interface_addressingtype $nlan" "set_interface_addressingtype $nlan \$val"
|
|
}
|
|
|
|
get_landevice_lanhostconfigmanagement_dhcpstaticaddress() {
|
|
local idev=$1
|
|
local idhcp=$2
|
|
local ndhcp=$3
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPStaticAddress.$idhcp." "1"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPStaticAddress.$idhcp.Enable" "1" "get_dhcpstaticaddress_enable $ndhcp" "set_dhcpstaticaddress_enable $ndhcp \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPStaticAddress.$idhcp.Chaddr" "1" "get_dhcpstaticaddress_chaddr $ndhcp" "set_dhcpstaticaddress_chaddr $ndhcp \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPStaticAddress.$idhcp.Yiaddr" "1" "$UCI_GET dhcp.$ndhcp.ip" "set_dhcpstaticaddress_yiaddr $ndhcp \$val"
|
|
}
|
|
|
|
get_landevice_ethernet_interface_config() {
|
|
local idev=$1
|
|
local ieth=$2
|
|
local eth=$3
|
|
local flan=$4
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Enable" "1" "" "set_lan_eth_iface_cfg_enable $eth \$val" "get_lan_eth_iface_cfg_enable $eth" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Status" "0" "" "" "get_lan_eth_iface_cfg_status $eth"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.MaxBitRate" "1" "get_lan_eth_iface_cfg_maxbitrate $eth" "set_lan_eth_iface_cfg_maxbitrate $eth \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.DuplexMode" "1" "get_lan_eth_iface_cfg_duplexmode $eth" "set_lan_eth_iface_cfg_duplexmode $eth \$val"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Stats." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Stats.BytesSent" "0" "" "" "get_lan_eth_iface_cfg_stats $eth tx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Stats.BytesReceived" "0" "" "" "get_lan_eth_iface_cfg_stats $eth rx_bytes" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Stats.PacketsSent" "0" "" "" "get_lan_eth_iface_cfg_stats $eth tx_packets" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig.$ieth.Stats.PacketsReceived" "0" "" "" "get_lan_eth_iface_cfg_stats $eth rx_packets" "xsd:unsignedInt"
|
|
}
|
|
|
|
get_cache_InternetGatewayDevice_LANDevice() {
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice." "0" "0"
|
|
for interface in `get_lan_device_interface`;do
|
|
local lan_iface=${interface%%;*}
|
|
local idev=${lan_iface%%:*}
|
|
local ndev=${lan_iface#*:}
|
|
lan_iface=${interface#*;}
|
|
lan_iface=${lan_iface/,/ }
|
|
local flan=${lan_iface%% *}
|
|
flan=${flan#*:}
|
|
|
|
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 $flan \$val" "get_lan_dns $flan"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPServerConfigurable" "1" "get_lan_dhcp_server_configurable $flan" "set_lan_dhcp_server_configurable $flan \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPServerEnable" "1" "get_lan_dhcp_server_enable $flan" "set_lan_dhcp_server_enable $flan \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.MinAddress" "1" "get_lan_dhcp_interval_address START $flan" "set_lan_dhcp_address_start $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.MaxAddress" "1" "get_lan_dhcp_interval_address END $flan" "set_lan_dhcp_address_end $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.ReservedAddresses" "1" "get_lan_dhcp_reserved_addresses $flan" "set_lan_dhcp_reserved_addresses $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.SubnetMask" "1" "get_lan_dhcp_subnetmask $flan" "set_lan_dhcp_subnetmask $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPRouters" "1" "get_lan_dhcp_iprouters $flan" "set_lan_dhcp_iprouters $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPLeaseTime" "1" "get_lan_dhcp_leasetime $flan" "set_lan_dhcp_leasetime $flan \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DomainName" "1" "get_lan_dhcp_domainname $flan" "set_lan_dhcp_domainname $flan \$val"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.Hosts." "0" "0"
|
|
get_param_cache_generic "InternetGatewayDevice.LANDevice.$idev.Hosts.HostNumberOfEntries" "0" "" "" "get_lan_host_nbr_entries $flan" "xsd:unsignedInt"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.Hosts.Host." "0" "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.IPInterface." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANHostConfigManagement.DHCPStaticAddress." "1"
|
|
|
|
for lan in $lan_iface; do
|
|
ilan=${lan%%:*}
|
|
nlan=${lan#*:}
|
|
get_landevice_lanhostconfigmanagement_ipinterface "$idev" "$ndev" "$ilan" "$nlan"
|
|
local slease sleases=`$UCI_SHOW dhcp|grep "dhcp\.@host\[[0-9]\+\].interface=.*$nlan" | cut -f2 -d'.'`
|
|
for slease in $sleases; do
|
|
local idhcp=`update_instance_landevice_dhcpstaticaddress "$idev" "$slease"`
|
|
get_landevice_lanhostconfigmanagement_dhcpstaticaddress "$idev" "$idhcp" "$slease"
|
|
done
|
|
done
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.WLANConfiguration." "0" "0"
|
|
local wunit iuci
|
|
for wunit in `$UCI_SHOW wireless|grep "wireless\.wl[0-9]\+=wifi-device" | awk -F '[.=]' '{print $2}'`; do
|
|
local wlctl_num=0
|
|
for iuci in `$UCI_SHOW wireless |grep "wireless\.@wifi-iface\[[0-9]\+\]\.device=$wunit"| awk -F '[][]' '{print $2}'`; do
|
|
[ "`$UCI_GET wireless.@wifi-iface[$iuci].network`" != "$ndev" ] && continue
|
|
local iwlan=`update_instance_landevice_wlanconfiguration "$idev" "@wifi-iface[$iuci]"`
|
|
get_landevice_wlanconfiguration_generic "$idev" "$iwlan" "$iuci" "$wunit" "$((wlctl_num++))"
|
|
done
|
|
done
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.LANDevice.$idev.LANEthernetInterfaceConfig." "0"
|
|
local eth eths=`get_lan_ethernet_interfaces $ndev`
|
|
local ieth=0
|
|
for eth in $eths; do
|
|
get_landevice_ethernet_interface_config $idev $((++ieth)) $eth $flan
|
|
done
|
|
done
|
|
}
|
|
|
|
get_dynamic_InternetGatewayDevice_LANDevice() {
|
|
local assoclist="" num="" lan_num="" wlan_num=0 i=0
|
|
local mac_lower="" ip="" is_authenticated="" mac="" Int_type=""
|
|
|
|
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
|
|
local wunit wunit_l iuci
|
|
for wunit in `$UCI_SHOW wireless|grep "wireless\.wl[0-9]\+=wifi-device" | awk -F '[.=]' '{print $2}'`; do
|
|
local wlctl_num=0
|
|
for iuci in `$UCI_SHOW wireless|grep "wireless\.@wifi-iface\[[0-9]\+\]\.device=$wunit"| awk -F '[][]' '{print $2}'`; do
|
|
[ "`$UCI_GET wireless.@wifi-iface[$iuci].network`" != "$ndev" ] && continue
|
|
let "wlan_num++"
|
|
wunit_l="$wunit"
|
|
if [ "$wlctl_num" != "0" ];then
|
|
wunit_l="$wunit.$wlctl_num"
|
|
fi
|
|
assoclist=`/usr/sbin/wlctl -i $wunit_l assoclist|awk -F' ' '{print $2}'`
|
|
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}'`
|
|
is_authenticated=`/usr/sbin/wlctl -i $wunit_l authe_sta_list|grep $mac`
|
|
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
|
|
let "wlctl_num++"
|
|
done
|
|
done
|
|
done
|
|
esac
|
|
case "$1" in
|
|
""|\
|
|
InternetGatewayDevice.|\
|
|
InternetGatewayDevice.LANDevice.|\
|
|
InternetGatewayDevice.LANDevice.[1-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9][0-9][0-9].|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.IPAddress|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.MACAddress|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.HostName|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.Active|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.LeaseTimeRemaining|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.AddressSource|\
|
|
InternetGatewayDevice.LANDevice.[1-9]*.Hosts.Host.[1-9]*.InterfaceType )
|
|
clients=`ubus call router clients`
|
|
json_load "$clients"
|
|
for interface in `get_lan_device_interface`;do
|
|
local lan_iface=${interface%%;*}
|
|
local idev=${lan_iface%%:*}
|
|
local ndev=${lan_iface#*:}
|
|
lan_iface=${interface#*;}
|
|
lan_iface=${lan_iface/,/ }
|
|
local flan=${lan_iface%% *}
|
|
flan=${flan#*:}
|
|
local idx=1
|
|
local num=0
|
|
local val check
|
|
local exist=1
|
|
while [ true ]; do
|
|
let num++
|
|
json_select "client-$num" > /dev/null
|
|
check="$?"
|
|
[ "$check" != 0 ] && break
|
|
json_get_var val network
|
|
[ "$val" != "$flan" ] && { json_select ".." > /dev/null; continue; }
|
|
freecwmp_cache_output_obj "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx." "0" "0"
|
|
json_get_var val ipaddr
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.IPAddress" "$val" "0" "0" "" "" "" "0"
|
|
json_get_var val hostname
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.HostName" "$val" "0" "0" "" "" "" "0"
|
|
json_get_var val connected
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.Active" "$val" "0" "0" "xsd:boolean" "" "" "0"
|
|
json_get_var mac macaddr
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.MACAddress" "$mac" "0" "0" "" "" "" "0"
|
|
Int_type=`get_interface_type $mac $ndev`
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.InterfaceType" "$Int_type" "0" "0" "" "" "" "0"
|
|
json_get_var dhcp dhcp
|
|
if [ $dhcp -eq 1 ]; then
|
|
dhcp="DHCP"
|
|
leasetime=`awk -F ' ' ' $2=="'$mac'" {print$1}' /var/dhcp.leases`
|
|
time=$(date +%s)
|
|
rem_lease=$(( $leasetime - $time ))
|
|
[ $rem_lease -lt 0 ] && rem_lease=-1
|
|
else
|
|
dhcp="Static"
|
|
rem_lease=0
|
|
fi
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.AddressSource" "$dhcp" "0" "0" "" "" "" "0"
|
|
freecwmp_cache_output_param "InternetGatewayDevice.LANDevice.$idev.Hosts.Host.$idx.LeaseTimeRemaining" "$rem_lease" "0" "0" "" "" "" "0"
|
|
let idx++
|
|
json_select ".." > /dev/null
|
|
done
|
|
done
|
|
esac
|
|
}
|
|
|
|
get_dynamic_linker_InternetGatewayDevice_LANDevice() {
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
add_landevice_dhcpstaticaddress() {
|
|
local inst="$1"
|
|
local filename="$2"
|
|
local interface tmp ndev nlan found=""
|
|
for interface in `get_lan_device_interface`; do
|
|
tmp=${interface%%;*}
|
|
idev=${tmp%%:*}
|
|
ndev=${tmp#*:}
|
|
[ "$idev" != "$inst" ] && continue
|
|
found=1
|
|
tmp=${interface#*;}
|
|
tmp=${tmp%%,*}
|
|
nlan=${tmp#*:}
|
|
break
|
|
done
|
|
if [ "$found" != "1" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
nlan=${nlan:-$ndev}
|
|
|
|
local slease=`$UCI_ADD dhcp host`
|
|
$UCI_SET dhcp.$slease.mac="$DHCPSTATICADDRESS_DISABLED_CHADDR"
|
|
$UCI_SET dhcp.$slease.interface="$nlan"
|
|
local idhcp=`update_instance_landevice_dhcpstaticaddress "$idev" "$slease"`
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
get_landevice_lanhostconfigmanagement_dhcpstaticaddress "$idev" "$idhcp" "$slease" >> $cache_path/$filename
|
|
freecwmp_output "" "" "" "" "" "" "1" "$idhcp"
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
delete_landevice_dhcpstaticaddress() {
|
|
local instances="$2"
|
|
local filename="$3"
|
|
instances=${instances// /.}
|
|
local slease=`$UCI_SHOW dhcp | grep "dhcp\.@host\[[0-9]\+\]\.instance=$instances" | cut -f2 -d'.' | head -n1`
|
|
[ "$slease" = "" ] && return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
$UCI_DELETE dhcp.$slease
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1/d" $cache_path/$filename
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
delete_landevice_dhcpstaticaddress_all() {
|
|
local instances="$2"
|
|
local filename="$3"
|
|
local interface tmp found=""
|
|
for interface in `get_lan_device_interface`; do
|
|
tmp=${interface%%;*}
|
|
idev=${tmp%%:*}
|
|
[ "$idev" != "$instances" ] && continue
|
|
found=1
|
|
break
|
|
done
|
|
if [ "$found" != "1" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
local uci_num uci_nums=`$UCI_SHOW dhcp | grep "dhcp\.@host\[[0-9]\+\]\.instance=$instances\." | awk -F '[][]' '{print $2}' | sort -rn`
|
|
for uci_num in $uci_nums; do
|
|
$UCI_DELETE dhcp.@host[$uci_num]
|
|
done
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
delay_service restart "dnsmasq" "1"
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1[0-9]\+\./d" $cache_path/$filename
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
add_landevice_wlanconfiguration() {
|
|
local inst="$1"
|
|
local filename="$2"
|
|
local interface tmp ndev nlan found=""
|
|
for interface in `get_lan_device_interface`; do
|
|
tmp=${interface%%;*}
|
|
idev=${tmp%%:*}
|
|
ndev=${tmp#*:}
|
|
[ "$idev" != "$inst" ] && continue
|
|
found=1
|
|
tmp=${interface#*;}
|
|
tmp=${tmp%%,*}
|
|
nlan=${tmp#*:}
|
|
break
|
|
done
|
|
if [ "$found" != "1" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
nlan=${nlan:-$ndev}
|
|
|
|
local wiface=`$UCI_ADD wireless wifi-iface`
|
|
local instance=`update_instance_landevice_wlanconfiguration "$idev" "$wiface"`
|
|
$UCI_SET wireless.$wiface.device=wl0
|
|
$UCI_SET wireless.$wiface.encryption=none
|
|
$UCI_SET wireless.$wiface.macfilter=0
|
|
$UCI_SET wireless.$wiface.mode=ap
|
|
$UCI_SET wireless.$wiface.network=$nlan
|
|
$UCI_SET wireless.$wiface.ssid=Inteno_"$nlan"_"$instance"
|
|
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
local iwiface=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\]\.instance=$idev.$instance" | awk -F'[][]' '{print $2}' | head -n1`
|
|
get_landevice_wlanconfiguration_generic "$idev" "$instance" "$iwiface" >> $cache_path/$filename
|
|
freecwmp_output "" "" "" "" "" "" "1" "$instance"
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
delete_landevice_wlanconfiguration() {
|
|
local instances="$2"
|
|
local filename="$3"
|
|
instances=${instances// /.}
|
|
local wiface=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\]\.instance=$instances" | cut -f2 -d'.' | head -n1`
|
|
[ "$wiface" = "" ] && return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
$UCI_DELETE wireless.$wiface
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1/d" $cache_path/$filename
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
delete_landevice_wlanconfiguration_all() {
|
|
local instances="$2"
|
|
local filename="$3"
|
|
local interface tmp found=""
|
|
for interface in `get_lan_device_interface`; do
|
|
tmp=${interface%%;*}
|
|
idev=${tmp%%:*}
|
|
[ "$idev" != "$instances" ] && continue
|
|
found=1
|
|
break
|
|
done
|
|
if [ "$found" != "1" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
|
|
local wiface wifaces=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\]\.instance=$instances\." | awk -F '[][]' '{print $2}' | sort -rn`
|
|
for wiface in $wifaces; do
|
|
$UCI_DELETE wireless.@wifi-iface[$wiface]
|
|
done
|
|
$UCI_COMMIT
|
|
delay_service reload "network" "1"
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1[0-9]\+\./d" $cache_path/$filename
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
add_object_InternetGatewayDevice_LANDevice() {
|
|
local filename="$2"
|
|
local fault_code idev
|
|
case $1 in
|
|
InternetGatewayDevice.LANDevice.[1-9]*.LANHostConfigManagement.DHCPStaticAddress.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.DHCPStaticAddress." "rc" "idev"
|
|
if [ "$rc" != "0" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
add_landevice_dhcpstaticaddress "$idev" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.WLANConfiguration." "rc" "idev"
|
|
if [ "$rc" != "0" ]; then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME;
|
|
fi
|
|
add_landevice_wlanconfiguration "$idev" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
esac
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|
|
|
|
delete_object_InternetGatewayDevice_LANDevice() {
|
|
local filename="$2"
|
|
local fault_code instances
|
|
case $1 in
|
|
InternetGatewayDevice.LANDevice.[1-9]*.LANHostConfigManagement.DHCPStaticAddress.[1-9]*.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.DHCPStaticAddress.{i}." "rc" "instances"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
delete_landevice_dhcpstaticaddress "$1" "$instances" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
InternetGatewayDevice.LANDevice.[1-9]*.LANHostConfigManagement.DHCPStaticAddress.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.DHCPStaticAddress." "rc" "instances"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
delete_landevice_dhcpstaticaddress_all "$1" "$instances" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.[1-9]*.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.WLANConfiguration.{i}." "rc" "instances"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
delete_landevice_wlanconfiguration "$1" "$instances" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
InternetGatewayDevice.LANDevice.[1-9]*.WLANConfiguration.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.LANDevice.{i}.WLANConfiguration." "rc" "instances"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
delete_landevice_wlanconfiguration_all "$1" "$instances" "$filename"
|
|
fault_code="$?"
|
|
return $fault_code
|
|
;;
|
|
esac
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|