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