freecwmp
[Top] [All Lists]

ubus data model patch [15/27]

To: freecwmp@linux-mips.org
Subject: ubus data model patch [15/27]
From: KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
Date: Thu, 06 Dec 2012 14:53:28 +0100
Cc: freecwmp@lukaperkov.net
Original-recipient: rfc822;freecwmp@linux-mips.org
Sender: freecwmp-bounce@linux-mips.org
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
Hi Luka

  ubus data model patch [15/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [15/27] ---------------------------------
>From 61c6b8784a75db9f14f9f22e835e708a3a56e93c Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:25:54 +0100
Subject: [PATCH 15/27] add the common function and adapt the script freecwmp.sh in order to support get parameter names
   Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/config/freecwmp          |    6 ++++
ext/openwrt/scripts/freecwmp.sh | 47 ++++++++++++++++++++++++++++++++++
 ext/openwrt/scripts/functions/common |    4 +++
 3 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index ba6fbda..3b2b4c3 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -29,19 +29,25 @@ config scripts
     # freecwmp specific functions
     list location /usr/share/freecwmp/functions/device_info
     list get_value_function get_device_info
+    list get_name_function get_device_info_name
     list set_value_function set_device_info
     list get_value_function get_device_info_generic
+    list get_name_function get_device_info_generic_name
     list set_value_function set_device_info_generic
     list location /usr/share/freecwmp/functions/lan_device
     list get_value_function get_lan_device
+    list get_name_function get_lan_device_name
     list set_value_function set_lan_device
     list location /usr/share/freecwmp/functions/management_server
     list get_value_function get_management_server
+    list get_name_function get_management_server_name
     list set_value_function set_management_server
     list get_value_function get_management_server_generic
+    list get_name_function get_management_server_generic_name
     list set_value_function set_management_server_generic
     list location /usr/share/freecwmp/functions/wan_device
     list get_value_function get_wan_device
+    list get_name_function get_wan_device_name
     list set_value_function set_wan_device
     list location /usr/share/freecwmp/functions/misc
     list get_value_function get_misc
diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index f2bebc8..c5a0d53 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -68,6 +68,10 @@ case "$1" in
         elif [ "$2" = "value" ]; then
             __arg1="$3"
             action="get_value"
+        elif [ "$2" = "name" ]; then
+            __arg1="$3"
+            __arg2=`echo $4| tr '[A-Z]' '[a-z]'`
+            action="get_name"
         elif [ "$2" = "all" ]; then
             __arg1="$3"
             action="get_all"
@@ -107,6 +111,7 @@ handle_scripts() {
     config_get prefix "$section" "prefix"
     config_list_foreach "$section" 'location' load_script
     config_get get_value_functions "$section" "get_value_function"
+    config_get get_name_functions "$section" "get_name_function"
     config_get set_value_functions "$section" "set_value_function"
 }

@@ -163,6 +168,48 @@ if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
     fi
 fi

+if [ "$action" = "get_name" -o "$action" = "get_all" ]; then
+    no_fault="0"
+    freecwmp_check_fault "$__arg1"
+    fault_code="$?"
+    if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg2" != "0" \) -a \( "$__arg2" != "1" \) -a \( "$__arg2" != "true" \) -a \( "$__arg2" != "false" \) ]; then
+            fault_code="$FAULT_CPE_INVALID_ARGUMENTS"
+        else
+            if [ "$__arg2" = "true" ]; then
+                __arg2="1"
+            elif [ "$__arg2" = "false" ]; then
+                __arg2="0"
+            fi
+        fi
+        if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" = "" \) ]; then
+                ubus_freecwmp_output "InternetGatewayDevice." "0"
+                if [ \( "$__arg1" = "" \) -a \( "$__arg2" = "1" \) ]; then
+                    exit 0
+                fi
+                __arg1="InternetGatewayDevice."
+            fi
+            for function_name in $get_name_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
+    fi
+    if [ "$fault_code" != "0" ]; then
+        let fault_code=$fault_code+9000
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    fi
+fi
+
 if [ "$action" = "set_value" ]; then
     for function_name in $set_value_functions
     do
diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
index 082e067..abba220 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -48,6 +48,10 @@ case "$action" in
     get_value)
ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", "value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 2> /dev/null
     ;;
+    get_name)
+ ubus call tr069 get_parameter_names '{"parameter": "'$parameter'", "writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
+    ;;
+
 esac
 }
 freecwmp_value_output() {
--
1.7.4.1



<Prev in Thread] Current Thread [Next in Thread>
  • ubus data model patch [15/27], KALLEL Mohamed <=