Wifi and Services code review
This commit is contained in:
Mohamed Kallel 2013-10-14 10:55:09 +01:00
parent 4aa69bf3bc
commit 8dceb7fb7f
7 changed files with 42 additions and 38 deletions

View file

@ -6,7 +6,7 @@ config 'cwmp' 'acs'
option 'periodic_inform_interval' '1800'
option 'periodic_inform_time' '0'
option 'ParameterKey' ''
option 'dhcp_discovery' '1'
option 'dhcp_discovery' 'enable'
option 'dhcp_url_path' 'provisioning.iup.url'
config 'cwmp' 'cpe'

View file

@ -17,7 +17,7 @@ check_url_format() {
SCHEMA_LIST="http"
for schema in $SCHEMA_LIST; do
dest=`echo $1|sed 's/$schema:\/\///g'|cut -f1 -d \/|cut -f1 -d:`
dest=`echo $1 | sed 's/$schema:\/\///g' | cut -f1 -d \/ | cut -f1 -d:`
if [ "_$dest" != "_" ]; then
return 0
fi
@ -108,7 +108,7 @@ boot() {
}
start_cwmpd() {
run=$(ps aux|grep /usr/sbin/cwmpd|grep -v grep|grep -v rc.common)
run=$(ps | grep /usr/sbin/cwmpd | grep -v grep | grep -v rc.common)
if [ "$run" = "" ];then
stop_freecwmp_cache
echo "Check if the whole cache is built. Wait if the whole cache is not built yet..."
@ -163,7 +163,7 @@ get_process_childs() {
pidof_cwmp() {
local pids=""
pids="`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v \" Z \"|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
pids="`ps | grep /usr/sbin/cwmpd | sed 's/^ \+//g' | sed 's/ \+/:/g' | grep -v \" Z \" | grep -v grep | cut -f1 -d: | tr '\n' ' '`"
pids=${pids% }
pids=${pids# }
echo "$pids"
@ -171,7 +171,7 @@ pidof_cwmp() {
pidof_freecwmp() {
local pids=""
pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
pids="`ps | grep /usr/sbin/freecwmp | sed 's/^ \+//g' | sed 's/ \+/:/g' | grep -v grep | cut -f1 -d: | tr '\n' ' '`"
pids=${pids% }
pids=${pids# }
echo "$pids"

View file

@ -573,7 +573,7 @@ handle_action() {
json_get_var param parameter
json_get_var type type
val=`eval "$exec_get_cmd"`
freecwmp_output "$param" "$val" "" "$type"
freecwmp_output "$param" "$val" "" "" "$type"
done
fi

View file

@ -649,7 +649,7 @@ get_param_value_generic() {
json_get_var param parameter
json_get_var type type
val=`eval "$exec_get_cmd"`
freecwmp_output "$param" "$val" "" "$type"
freecwmp_output "$param" "$val" "" "" "$type"
done
fi

View file

@ -58,8 +58,8 @@ set_wlan_max_bit_rate() {
get_wlan_channel() {
local num="$1"
local val=`$UCI_GET wireless.@wifi-iface[$num].channel`
if [ "$val" = "auto" ];then
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
@ -73,7 +73,7 @@ set_wlan_channel() {
local num="$1"
local val="$2"
delay_service reload "network" "1"
$UCI_SET wireless.@wifi-iface[$num].channel="$val"
$UCI_SET wireless.wl0.channel="$val"
}
set_wlan_ssid() {
@ -91,11 +91,11 @@ get_wlan_beacon_type() {
val="None"
elif [ "$encryption" = "wep-shared" -o "$encryption" = "wep-open" ]; then
val="Basic"
elif [ "$encryption" = "psk" -o "$encryption" = "wpa" ]; then
elif [ "`echo $encryption|grep ^psk$`" != "" -o "`echo $encryption|grep ^psk+`" != "" -o "$encryption" = "wpa" ]; then
val="WPA"
elif [ "$encryption" = "psk2" -o "$encryption" = "wpa2" ]; then
elif [ "`echo $encryption|grep ^psk2$`" != "" -o "`echo $encryption|grep ^psk2+`" != "" -o "$encryption" = "wpa2" ]; then
val="11i"
elif [ "$encryption" = "pskmixedpsk2" -o "$encryption" = "wpamixedwpa2" ]; then
elif [ "`echo $encryption|grep ^pskmixedpsk2$`" != "" -o "`echo $encryption|grep ^pskmixedpsk2+`" != "" -o "$encryption" = "wpamixedwpa2" ]; then
val="WPAand11i"
fi
echo "$val"
@ -148,8 +148,8 @@ set_wlan_beacon_type() {
get_wlan_mac_control_enable() {
local num="$1"
local val=`$UCI_GET wireless.@wifi-device[$num].macfilter 2> /dev/null`
if [ "$val" = "2" ]; then
local val=`$UCI_GET wireless.@wifi-iface[$num].macfilter 2> /dev/null`
if [ "$val" != "0" ]; then
val="1"
else
val="0"
@ -166,7 +166,7 @@ set_wlan_mac_control_enable() {
val="0"
fi
delay_service reload "network" "1"
$UCI_SET wireless.@wifi-device[$num].macfilter="$val"
$UCI_SET wireless.@wifi-iface[$num].macfilter="$val"
}
get_wlan_standard() {
@ -272,7 +272,7 @@ set_wlan_basic_encryption_modes() {
get_wlan_basic_authentication_mode() {
local num="$1"
local encryption==`$UCI_GET wireless.@wifi-iface[$num].encryption`
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
local val=""
if [ "$encryption" = "wep-shared" ]; then
val="SharedAuthentication"
@ -346,7 +346,7 @@ get_wlan_wpa_authentication_mode() {
local num="$1"
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
local val=""
if [ "$encryption" = "psk" -o "$encryption" = "pskmixedpsk2+tkip" ]; then
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"
@ -419,7 +419,7 @@ get_wlan_ieee_11i_authentication_mode() {
local num="$1"
local encryption=`$UCI_GET wireless.@wifi-iface[$num].encryption`
local val=""
if [ "$encryption" = "psk2" -o "$encryption" = "pskmixedpsk2+tkip" ]; then
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"
@ -535,7 +535,8 @@ get_wlan_total_associations() {
set_wlan_wep_key() {
local num="$1"
local val="$2"
local key_index="$2"
local val="$3"
$UCI_DELETE wireless.@wifi-iface[$num].gtk_rekey
$UCI_DELETE wireless.@wifi-iface[$num].wps_pbc
$UCI_DELETE wireless.@wifi-iface[$num].key
@ -550,18 +551,17 @@ set_wlan_wep_key() {
set_wlan_pre_shared_key() {
local num="$1"
local val="$3"
local val="$2"
reset_wlan $num
delay_service reload "network" "1"
$UCI_SET wireless.@wifi-iface[$num].key=$val
$UCI_SET wireless.@wifi-iface[$num].gtk_rekey="3600"
#$UCI_SET wireless.@wifi-iface[$num].encryption="$val"
$UCI_SET wireless.@wifi-iface[$num].encryption="psk"
}
set_wlan_pre_shared_key_key_passphrase() {
local num="$1"
local param="$2"
local val="$3"
local val="$2"
delay_service reload "network" "1"
}
@ -606,15 +606,15 @@ get_landevice_wlanconfiguration_generic() {
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.2." "0"
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.3." "0"
get_object_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.4." "0"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.1.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.2.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.3.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.WEPKey.4.WEPKey" "1" "" "set_wlan_wep_key $uci_num \$val" "" "" "" "" "" "1"
get_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 1 \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.KeyPassphrase" "1" "" "set_wlan_pre_shared_key_key_passphrase $uci_num 1 \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.LANDevice.$lan_num.WLANConfiguration.$wlan_num.PreSharedKey.1.AssociatedDeviceMACAddress" "1" "" "set_wlan_pre_shared_key_associated_device_MACAddress $uci_num 1 \$val"
get_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_pre_shared_key_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_cache_InternetGatewayDevice_LANDevice() {

View file

@ -93,8 +93,8 @@ set_voice_profile_reset() {
}
set_voice_profile_signaling_protocol() {
local num="$1"
local val="$2"
local num="$1"
local val="$2"
}
get_voice_profile_max_sessions() {
@ -302,9 +302,9 @@ get_line_enable() {
}
set_line_enable() {
local num="$1"
local line_name="$2"
local val="$3"
local num="$1"
local line_name="$2"
local val="$3"
if [ "$val" = "Enabled" ]; then
val="1"
else
@ -487,7 +487,7 @@ get_services_voice_service_generic() {
local sip_id="$2"
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num." "1"
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Enable" "1" "get_voice_profile_enable $sip_id" "set_voice_profile_enable $sip_id \$val" "" "xsd:boolean"
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Enable" "1" "get_voice_profile_enable $sip_id" "set_voice_profile_enable $sip_id \$val"
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Reset" "1" "echo 0" "set_voice_profile_reset $sip_id \$val" "" "xsd:boolean"
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Name" "0" "$UCI_GET voice_client.sip$sip_id.name"
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SignalingProtocol" "1" "echo SIP" "set_voice_profile_signaling_protocol $sip_id \$val"
@ -550,13 +550,13 @@ get_cache_InternetGatewayDevice_Services() {
let profile_num=$sip_id+1
get_services_voice_service_generic "$profile_num" "$sip_id"
# Line
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line." "1"
for line_name in `$UCI_SHOW voice_client|grep sip_account|grep sip$sip_id$|awk -F'.' '{print$2}'`;do
line_id=`echo $line_name|sed 's/brcm//g'`
if [ $line_id -gt $max_line ];then
continue
fi
line_num=`$UCI_GET voice_client.$line_name.instances|cut -d : -f$profile_num`
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line." "1"
get_services_voice_service_line_generic "$profile_num" "$sip_id" "$line_num"
done
done
@ -800,3 +800,4 @@ delete_object_InternetGatewayDevice_Services() {
get_dynamic_InternetGatewayDevice_Services() {
return $FAULT_CPE_NO_FAULT
}

View file

@ -158,6 +158,9 @@ get_wan_device_wan_dsl_interface_config_status() {
"Disabled")
val="Disabled"
;;
*)
val="NoSignal"
;;
esac
echo $val
}