fix some bugs in:

This commit is contained in:
zribiahmed 2013-05-22 17:17:40 +00:00
parent 0aa8bfe94a
commit 82e8527fb8
5 changed files with 4899 additions and 1470 deletions

View file

@ -123,6 +123,7 @@ ifeq ($(CONFIG_CWMP_SCRIPTS_FULL),y)
$(CP) $(PKG_BUILD_DIR)/scripts/functions $(1)/usr/share/freecwmp
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/freecwmp.sh $(1)/usr/sbin/freecwmp
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/wepkeygen $(1)/usr/sbin/wepkeygen
endif
endef

View file

@ -431,7 +431,7 @@ fi
if [ "$action" = "set_tag" ]; then
freecwmp_set_parameter_tag "$__arg1" "$__arg2"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q commit
fi
if [ "$action" = "download" ]; then
@ -524,7 +524,7 @@ if [ "$action" = "apply_notification" -o "$action" = "apply_value" ]; then
let __fault_count=$__fault_count/3
if [ "$__fault_count" = "0" ]; then
# applying
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q commit
if [ "$action" = "apply_notification" ]; then
freecwmp_output "" "" "" "" "" "" "" "0"
elif [ "$action" = "apply_value" ]; then
@ -535,13 +535,13 @@ if [ "$action" = "apply_notification" -o "$action" = "apply_value" ]; then
let n=$__fault_count-1
for i in `seq 0 $n`
do
local parm=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get cwmp.@fault[$i].parameter 2> /dev/null`
local fault_code=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get cwmp.@fault[$i].fault_code 2> /dev/null`
local parm=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get cwmp.@fault[$i].parameter 2> /dev/null`
local fault_code=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get cwmp.@fault[$i].fault_code 2> /dev/null`
freecwmp_fault_output "$parm" "$fault_code"
if [ "$action" = "apply_notification" ]; then break; fi
done
rm -rf /var/state/cwmp 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert cwmp
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q revert cwmp
fi
fi

View file

@ -6,13 +6,13 @@
uci_remove_list_element() {
local option="$1"
local value="$2"
local list="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get $option)"
local list="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get $option)"
local elem
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} delete $option
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q delete $option
for elem in $list; do
if [ "$elem" != "$value" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list $option=$elem
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list $option=$elem
fi
done
}
@ -272,7 +272,7 @@ freecwmp_config_cwmp() {
fi
elif [ "set" = "$2" ]; then
if [ "value" = "$3" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.$1.value=$5 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set cwmp.$1.value=$5 2> /dev/null
fi
elif [ "check" = "$2" ]; then
if [ "parameter" = "$3" ]; then
@ -340,9 +340,9 @@ freecwmp_set_parameter_value() {
local _val="$2"
config_foreach freecwmp_config_cwmp "cwmp" "check" "parameter" "$_parm" "_section"
if [ ! "$_section" = "" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.$_section.value=$_val 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set cwmp.$_section.value=$_val 2> /dev/null
else
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} batch << EOF 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q batch << EOF 2>&1 >/dev/null
add cwmp cwmp
set cwmp.@cwmp[-1].parameter="$_parm"
set cwmp.@cwmp[-1].value="$_val"
@ -388,20 +388,20 @@ freecwmp_notify() {
freecwmp_set_parameter_notification() {
local _parm="$1"
local _val="$2"
local tmp=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.@notifications[0] 2>/dev/null`
local tmp=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get cwmp.@notifications[0] 2>/dev/null`
if [ "$tmp" = "" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add cwmp notifications 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add cwmp notifications 2>&1 >/dev/null
else
uci_remove_list_element "cwmp.@notifications[0].passive" "$_parm" 2>/dev/null
uci_remove_list_element "cwmp.@notifications[0].active" "$_parm" 2>/dev/null
uci_remove_list_element "cwmp.@notifications[0].disabled" "$_parm" 2>/dev/null
fi
if [ "$_val" -eq "1" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list cwmp.@notifications[0].passive="$_parm" 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].passive="$_parm" 2>&1 >/dev/null
elif [ "$_val" -eq "2" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list cwmp.@notifications[0].active="$_parm" 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].active="$_parm" 2>&1 >/dev/null
elif [ "$_val" -eq "0" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list cwmp.@notifications[0].disabled="$_parm" 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].disabled="$_parm" 2>&1 >/dev/null
fi
}
@ -417,9 +417,9 @@ freecwmp_set_parameter_tag() {
local _tag="$2"
config_foreach freecwmp_config_cwmp "cwmp" "check" "parameter" "$_parm" "_section"
if [ ! "$_section" = "" ]; then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list cwmp.$_section.tag=$_tag 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.$_section.tag=$_tag 2> /dev/null
else
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} batch << EOF 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q batch << EOF 2>&1 >/dev/null
add cwmp cwmp
set cwmp.@cwmp[-1].parameter="$_parm"
add_list cwmp.@cwmp[-1].tag="$_tag"
@ -471,7 +471,7 @@ return $FAULT_CPE_NO_FAULT
freecwmp_set_parameter_fault() {
local _parm="$1"
local _fault="$2"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state batch << EOF 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state batch << EOF 2>&1 >/dev/null
add cwmp fault
set cwmp.@fault[-1].parameter="$_parm"
set cwmp.@fault[-1].fault_code="$_fault"
@ -486,7 +486,7 @@ freecwmp_add_lan_device_ip_interface() {
else
indice=$_instance
fi
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} batch << EOF 2>&1 >/dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q batch << EOF 2>&1 >/dev/null
add cwmp object
set cwmp.@object[-1].parameter="$_parm"
set cwmp.@object[-1].instance="$_instance"
@ -494,10 +494,10 @@ freecwmp_add_lan_device_ip_interface() {
EOF
if [ "$indice" != "" ]; then
let i=$indice-1
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.lan$indice=interface 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.lan$indice.ifname=eth$i 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.lan$indice.type=bridge 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.lan$indice.proto=dhcp 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set network.lan$indice=interface 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set network.lan$indice.ifname=eth$i 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set network.lan$indice.type=bridge 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set network.lan$indice.proto=dhcp 2> /dev/null
fi
}
@ -597,9 +597,9 @@ freecwmp_apply_vendor_configuration()
{
local fault_code="9000"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import < /tmp/vendor_configuration_file.cfg
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q import < /tmp/vendor_configuration_file.cfg
if [ "$?" = "0" ];then
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q commit
if [ "$?" != "0" ];then
let fault_code=$fault_code+$FAULT_CPE_INTERNAL_ERROR
freecwmp_fault_output "" "$fault_code"

File diff suppressed because it is too large Load diff

View file

@ -673,7 +673,7 @@ local type="xsd:unsignedInt"
local permissions=""
case "$action" in
get_value)
val=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Default context : sip$num"`
val=""
let num=$num+1
freecwmp_output "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$num.SIP.Organization" "$val" "$permissions"
;;
@ -790,7 +790,7 @@ local type="xsd:unsignedInt"
local permissions=""
case "$action" in
get_value)
val=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Default context : sip$num"`
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get voice_client.SIP.registertimeout`
let num=$num+1
freecwmp_output "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$num.SIP.ReInviteExpires" "$val" "$permissions"
;;
@ -812,6 +812,7 @@ local num="$1"
local val="$2"
case $action in
set_value)
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set voice_client.SIP.registertimeout="$val"
;;
set_notification)
let num=$num+1
@ -1166,8 +1167,8 @@ local type="xsd:string"
local permissions=""
case "$action" in
get_value)
val1="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state -q get asterisk.sip$num.sip_registry_registered"
val2="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state -q get asterisk.sip$num.sip_registry_request_sent"
val1="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get asterisk.sip$num.sip_registry_registered"
val2="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get asterisk.sip$num.sip_registry_request_sent"
if [ "$val1" = "yes" ];then
val="Up"
else
@ -1466,7 +1467,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -1513,7 +1514,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -1554,7 +1555,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -1704,6 +1705,7 @@ case "$1" in
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-$max_num].SIP.Organization)
return $FAULT_CPE_INVALID_PARAMETER_NAME
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.Organization" "rc" "num"
if [ $rc -eq 0 ] && [ $num -gt 0 ] && [ $num -le $max_num ]; then
let profile_num=$num-1
@ -2130,7 +2132,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2177,7 +2179,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2218,7 +2220,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2368,6 +2370,7 @@ case "$1" in
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-$max_num].SIP.Organization)
return $FAULT_CPE_INVALID_PARAMETER_NAME
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.Organization" "rc" "num"
if [ $rc -eq 0 ] && [ $num -gt 0 ] && [ $num -le $max_num ]; then
let profile_num=$num-1
@ -2798,7 +2801,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2853,7 +2856,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2907,7 +2910,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -2959,7 +2962,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -3012,7 +3015,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -3059,7 +3062,7 @@ case "$1" in
get_sip_user_agent_transport $profile_num
get_sip_outbound_proxy $profile_num
get_sip_outbound_proxy_port $profile_num
get_sip_organization $profile_num
# get_sip_organization $profile_num
get_sip_registration_period $profile_num
# get_sip_invite_expires $profile_num
get_sip_re_invite_expires $profile_num
@ -3261,6 +3264,7 @@ case "$1" in
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-$max_num].SIP.Organization)
return $FAULT_CPE_INVALID_PARAMETER_NAME
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.Organization" "rc" "num"
if [ $rc -eq 0 ] && [ $num -gt 0 ] && [ $num -le $max_num ]; then
let profile_num=$num-1
@ -3751,6 +3755,7 @@ case "$1" in
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-$max_num].SIP.Organization)
return $FAULT_CPE_INVALID_PARAMETER_NAME
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.Organization" "rc" "num"
if [ $rc -eq 0 ] && [ $num -gt 0 ] && [ $num -le $max_num ]; then
let profile_num=$num-1
@ -4239,6 +4244,7 @@ case "$1" in
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-$max_num].SIP.Organization)
return $FAULT_CPE_INVALID_PARAMETER_NAME
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.Organization" "rc" "num"
if [ $rc -eq 0 ] && [ $num -gt 0 ] && [ $num -le $max_num ]; then
let profile_num=$num-1