freecwmp
[Top] [All Lists]

[PATCH 26/27] update common script and freecwmp.sh for set parameter att

To: freecwmp@linux-mips.org
Subject: [PATCH 26/27] update common script and freecwmp.sh for set parameter attributes in order to have the communication with the core via ubus Contributed by Inteno Broadband Technology AB
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Thu, 6 Dec 2012 16:54:51 +0100
Cc: freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>, Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
In-reply-to: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
Sender: freecwmp-bounce@linux-mips.org
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/config/freecwmp          |    6 ++++++
 ext/openwrt/scripts/freecwmp.sh      |   29 +++++++++++++++++++++++++++--
 ext/openwrt/scripts/functions/common |    3 +++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 1f72c27..68a455d 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -32,29 +32,35 @@ config scripts
        list get_name_function get_device_info_name
        list get_notification_function get_device_info_notification
        list set_value_function set_device_info
+       list set_notification_function set_device_info_notification
        list get_value_function get_device_info_generic
        list get_name_function get_device_info_generic_name
        list get_notification_function get_device_info_generic_notification
        list set_value_function set_device_info_generic
+       list set_notification_function set_device_info_generic_notification
        list location /usr/share/freecwmp/functions/lan_device
        list get_value_function get_lan_device
        list get_name_function get_lan_device_name
        list get_notification_function get_lan_device_notification
        list set_value_function set_lan_device
+       list set_notification_function set_lan_device_notification
        list location /usr/share/freecwmp/functions/management_server
        list get_value_function get_management_server
        list get_name_function get_management_server_name
        list get_notification_function get_management_server_notification
        list set_value_function set_management_server
+       list set_notification_function set_management_server_notification
        list get_value_function get_management_server_generic
        list get_name_function get_management_server_generic_name
        list get_notification_function 
get_management_server_generic_notification
        list set_value_function set_management_server_generic
+       list set_notification_function 
set_management_server_generic_notification
        list location /usr/share/freecwmp/functions/wan_device
        list get_value_function get_wan_device
        list get_name_function get_wan_device_name
        list get_notification_function get_wan_device_notification
        list set_value_function set_wan_device
+       list set_notification_function set_wan_device_notification
        list location /usr/share/freecwmp/functions/misc
        list get_value_function get_misc
        list location /usr/share/freecwmp/functions/device_users
diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index 54c0924..f448c73 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -124,6 +124,7 @@ handle_scripts() {
        config_get get_name_functions "$section" "get_name_function"
        config_get get_notification_functions "$section" 
"get_notification_function"
        config_get set_value_functions "$section" "set_value_function"
+       config_get set_notification_functions "$section" 
"set_notification_function"
 }
 
 config_load freecwmp
@@ -276,8 +277,30 @@ if [ "$action" = "get_notification" -o "$action" = 
"get_all" ]; then
 fi
 
 if [ "$action" = "set_notification" ]; then
-       freecwmp_set_parameter_notification "$__arg1" "$__arg2"
-       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+       no_fault="0"
+       freecwmp_check_fault "$__arg1"
+       fault_code="$?"
+       if [ "$fault_code" = "0" ]; then
+               if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" 
= "" \) ]; then
+                       __arg1="InternetGatewayDevice."
+               fi
+               for function_name in $set_notification_functions
+               do
+                       $function_name "$__arg1" "$__arg2"
+                       fault_code="$?"
+                       if [ "$fault_code" = "0" ]; then
+                               no_fault="1"
+                       fi
+                       if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; 
then
+                               break
+                       fi
+               done
+               if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+       fi
+       if [ "$fault_code" != "0" ]; then
+               let fault_code=$fault_code+9000
+               freecwmp_set_parameter_fault "$__arg1" "$fault_code"
+       fi
 fi
 
 if [ "$action" = "get_tags" -o "$action" = "get_all" ]; then
@@ -331,6 +354,7 @@ if [ \( "$action" = "apply_notification" \) -o \( "$action" 
= "apply_value" \) ]
                # applying
                /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
                if [ "$action" = "apply_value" ]; then ubus call tr069 
set_parameter_values_status '{"status": "0"}'; fi
+               if [ "$action" = "apply_notification" ]; then ubus call tr069 
set_parameter_attributes '{"success": "0", "fault_code":""}' 2> /dev/null; fi
        else
                let n=$__fault_count-1
                for i in `seq 0 $n`
@@ -338,6 +362,7 @@ if [ \( "$action" = "apply_notification" \) -o \( "$action" 
= "apply_value" \) ]
                        local parm=`/sbin/uci -P /var/state get 
freecwmp.@fault[$i].parameter 2> /dev/null`
                        local fault_code=`/sbin/uci -P /var/state get 
freecwmp.@fault[$i].fault_code 2> /dev/null`
                        ubus_freecwmp_fault_output "$parm" "$fault_code"
+                       if [ "$action" = "apply_notification" ]; then break; fi
                done
                rm -rf /var/state/freecwmp 2> /dev/null
                /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert freecwmp
diff --git a/ext/openwrt/scripts/functions/common 
b/ext/openwrt/scripts/functions/common
index f701eb9..a4117d0 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -64,6 +64,9 @@ case "$action" in
        apply_value)
        ubus call tr069 set_parameter_values_fault '{"parameter": 
"'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null
        ;;
+       apply_notification)
+       ubus call tr069 set_parameter_attributes '{"success": "", 
"fault_code":"'$fault_code'"}' 2> /dev/null
+       ;;
 esac
 }
 freecwmp_value_output() {
-- 
1.7.4.1


<Prev in Thread] Current Thread [Next in Thread>