freecwmp
[Top] [All Lists]

[PATCH v2 09/10] Use ubus for set parameter values

To: freecwmp@linux-mips.org
Subject: [PATCH v2 09/10] Use ubus for set parameter values
From: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Date: Fri, 28 Dec 2012 16:59:46 +0100
Cc: freecwmp@lukaperkov.net, jogo@openwrt.org, Mohamed <mohamed.kallel@pivasoftware.com>, Ahmed Zribi <ahmed.zribi@pivasoftware.com>
In-reply-to: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
Sender: freecwmp-bounce@linux-mips.org
From: Mohamed <mohamed.kallel@pivasoftware.com>

update set parameter values in order to execute external command and get 
response via ubus
Contributed by Inteno Broadband Technology AB

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/freecwmp.sh                 |   50 ++++++++++++++-
 ext/openwrt/scripts/functions/common            |   22 +++++++
 ext/openwrt/scripts/functions/device_hosts      |    2 +-
 ext/openwrt/scripts/functions/device_info       |   12 +++-
 ext/openwrt/scripts/functions/device_ip         |    2 +-
 ext/openwrt/scripts/functions/device_routing    |    2 +-
 ext/openwrt/scripts/functions/device_users      |    2 +-
 ext/openwrt/scripts/functions/lan_device        |    4 +-
 ext/openwrt/scripts/functions/management_server |   21 +++++-
 ext/openwrt/scripts/functions/misc              |    2 +-
 ext/openwrt/scripts/functions/wan_device        |    5 +-
 src/external.c                                  |   35 ++++++++++-
 src/external.h                                  |    4 +-
 src/ubus.c                                      |   74 +++++++++++++++++++++++
 src/xml.c                                       |   28 +++++++--
 15 files changed, 238 insertions(+), 27 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index efc4cc0..294f2f0 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -24,6 +24,7 @@ USAGE: $0 [flags] command [parameter] [values]
 command:
   get [value|notification|tags|name|all]
   set [value|notification|tag]
+  apply [value]
   download
   factory_reset
   reboot
@@ -91,6 +92,9 @@ case "$1" in
        reboot)
                action="reboot"
                ;;
+       apply)
+               action="apply_value"
+               ;;
 esac
 
 if [ -z "$action" ]; then
@@ -220,10 +224,26 @@ if [ "$action" = "get_name" -o "$action" = "get_all" ]; 
then
 fi
 
 if [ "$action" = "set_value" ]; then
-       for function_name in $set_value_functions
-       do
-               $function_name "$__arg1" "$__arg2"
-       done
+       if [ ${FLAGS_force} -eq ${FLAGS_FALSE} ]; then
+               __tmp_arg="Device."
+               # TODO: don't check only string length ; but this is only used
+               #       for getting correct prefix of CWMP parameter anyway
+               if [  ${#__arg1} -lt ${#__tmp_arg} ]; then
+                       echo "CWMP parameters usualy begin with 
'InternetGatewayDevice.' or 'Device.'     "
+                       echo "if you want to force script execution with 
provided parameter use '-f' flag."
+                       exit -1
+               fi
+       fi
+       freecwmp_check_fault "$__arg1"
+       fault_code="$?"
+       if [ "$fault_code" = "0" ]; then
+               freecwmp_execute_functions "$set_value_functions" "$__arg1" 
"$__arg2"
+               fault_code="$?"
+       fi
+       if [ "$fault_code" != "0" ]; then
+               let fault_code=$fault_code+9000
+               freecwmp_set_parameter_fault "$__arg1" "$fault_code"
+       fi
 fi
 
 if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
@@ -305,6 +325,28 @@ if [ "$action" = "reboot" ]; then
        fi
 fi
 
+if [ "$action" = "apply_value" ]; then
+       __fault_count=`cat /var/state/freecwmp 2> /dev/null |wc -l 2> /dev/null`
+       let __fault_count=$__fault_count/3
+       if [ "$__fault_count" = "0" ]; then
+               # applying
+               /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+               if [ "$action" = "apply_value" ]; then 
+                       ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 
set_parameter_values_status '{ "status": "0" }' 2> /dev/null
+               fi
+       else
+               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 freecwmp.@fault[$i].parameter 2> /dev/null`
+                       local fault_code=`/sbin/uci ${UCI_CONFIG_DIR:+-c 
$UCI_CONFIG_DIR} -P /var/state get freecwmp.@fault[$i].fault_code 2> /dev/null`
+                       freecwmp_fault_output "$parm" "$fault_code"
+               done
+               rm -rf /var/state/freecwmp 2> /dev/null
+               /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert freecwmp
+       fi
+fi
+
 if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
        echo "[debug] exited at \"`date`\""
 fi
diff --git a/ext/openwrt/scripts/functions/common 
b/ext/openwrt/scripts/functions/common
index 2bfba9a..f6a3e8b 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -69,6 +69,18 @@ freecwmp_ubus_output() {
                ;;
        esac
 }
+
+freecwmp_fault_output() {
+local parameter="$1"
+local fault_code="$2"
+local success="$3"
+case "$action" in
+       apply_value)
+       ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET}  call tr069 
set_parameter_values_fault '{ "parameter": "'$parameter'", "fault_code": 
"'$fault_code'" }' 2> /dev/null
+       ;;
+esac
+}
+
 freecwmp_value_output() {
        local tmp_value=${FLAGS_value}
        FLAGS_value=${FLAGS_TRUE}
@@ -341,6 +353,16 @@ fi
 return $E_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
+                       add freecwmp fault
+                       set freecwmp.@fault[-1].parameter="$_parm"
+                       set freecwmp.@fault[-1].fault_code="$_fault"
+EOF
+}
+
 freecwmp_execute_functions()
 {
        local function_list="$1"
diff --git a/ext/openwrt/scripts/functions/device_hosts 
b/ext/openwrt/scripts/functions/device_hosts
index 2365c88..330125a 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -194,4 +194,4 @@ get_device_hosts_name() { return $E_INVALID_PARAMETER_NAME; 
}
 
 get_device_hosts_notification() { return $E_INVALID_PARAMETER_NAME; }
 
-set_device_hosts() { return; }
+set_device_hosts() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index e9de6d2..37b930e 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -377,24 +377,30 @@ set_device_info() {
 case "$1" in
        InternetGatewayDevice.DeviceInfo.Manufacturer)
        set_device_info_manufacturer "$2"
+       return 0
        ;;
        InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
        set_device_info_oui "$2"
+       return 0
        ;;
        InternetGatewayDevice.DeviceInfo.ProductClass)
        set_device_info_product_class "$2"
+       return 0
        ;;
        InternetGatewayDevice.DeviceInfo.SerialNumber)
        set_device_info_serial_number "$2"
+       return 0
        ;;
        InternetGatewayDevice.DeviceInfo.HardwareVersion)
        set_device_info_hardware_version "$2"
+       return 0
        ;;
        InternetGatewayDevice.DeviceInfo.SoftwareVersion)
        set_device_info_software_version "$2"
+       return 0
        ;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $E_INVALID_PARAMETER_NAME
 }
 
 check_parameter_device_info_generic() {
@@ -457,8 +463,8 @@ get_device_info_generic_notification() {
 }
 
 set_device_info_generic() {
-       check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 
]; then return 0; fi
+       check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 
]; then return $E_INVALID_PARAMETER_NAME; fi
 
        freecwmp_set_parameter_value "$1" "$2"
-       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+       return 0
 }
diff --git a/ext/openwrt/scripts/functions/device_ip 
b/ext/openwrt/scripts/functions/device_ip
index 0be4860..dc2147d 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -127,4 +127,4 @@ get_device_ip_name() { return $E_INVALID_PARAMETER_NAME; }
 
 get_device_ip_notification() { return $E_INVALID_PARAMETER_NAME; }
 
-set_device_ip() { return; }
+set_device_ip() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_routing 
b/ext/openwrt/scripts/functions/device_routing
index f3b186c..dff6f4d 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -357,4 +357,4 @@ get_device_routing_name() { return 
$E_INVALID_PARAMETER_NAME; }
 
 get_device_routing_notification() { return $E_INVALID_PARAMETER_NAME; }
 
-set_device_routing() { return; }
+set_device_routing() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_users 
b/ext/openwrt/scripts/functions/device_users
index 7988df5..f8264e0 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -131,4 +131,4 @@ get_device_users_name() { return $E_INVALID_PARAMETER_NAME; 
}
 
 get_device_users_notification() { return $E_INVALID_PARAMETER_NAME; }
 
-set_device_users() { return; }
+set_device_users() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 8fdf12b..5d5c84f 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -224,10 +224,12 @@ set_lan_device() {
 case "$1" in
        InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
        set_wlan_enable 0 "$2"
+       return 0
        ;;
        InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
        set_wlan_ssid 0 "$2"
+       return 0
        ;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $E_INVALID_PARAMETER_NAME
 }
diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index e40758c..1dd69e1 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -672,45 +672,58 @@ set_management_server() {
 case "$1" in
        InternetGatewayDevice.ManagementServer.URL)
        set_management_server_url "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.Username)
        set_management_server_username "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.Password)
        set_management_server_password "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
        set_management_server_periodic_inform_enable "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
        set_management_server_periodic_inform_interval "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
        set_management_server_connection_request_url "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
        set_management_server_connection_request_username "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
        set_management_server_connection_request_password "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
        set_management_server_x_freecwmp_org__acs_scheme "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
-       get_management_server_x_freecwmp_org__acs_hostname "$2"
+       set_management_server_x_freecwmp_org__acs_hostname "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
        set_management_server_x_freecwmp_org__acs_port "$2"
+       return 0
        ;;
        InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
        set_management_server_x_freecwmp_org__acs_path "$2"
+       return 0
        ;;
        
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
        set_management_server_x_freecwmp_org__connection_request_port "$2"
+       return 0
        ;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $E_INVALID_PARAMETER_NAME
 }
 
 check_parameter_management_server_generic() {
@@ -748,8 +761,8 @@ get_management_server_generic_notification() {
 }
 
 set_management_server_generic() {
-       check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return 0; fi
+       check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return $E_INVALID_PARAMETER_NAME; fi
 
        freecwmp_set_parameter_value "$1" "$2"
-       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+       return 0
 }
diff --git a/ext/openwrt/scripts/functions/misc 
b/ext/openwrt/scripts/functions/misc
index fe0686f..457e284 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -31,4 +31,4 @@ get_misc_name () { return $E_INVALID_PARAMETER_NAME; }
 
 get_misc_notification () { return $E_INVALID_PARAMETER_NAME; }
 
-set_misc() { return; }
+set_misc() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index 0944bca..699450f 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -450,13 +450,16 @@ set_wan_device() {
 case "$1" in
        
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
        set_wan_device_wan_ppp_enable "$2"
+       return 0
        ;;
        
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
        set_wan_device_wan_ppp_username "$2"
+       return 0
        ;;
        
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
        set_wan_device_wan_ppp_password "$2"
+       return 0
        ;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $E_INVALID_PARAMETER_NAME
 }
diff --git a/src/external.c b/src/external.c
index 80c8108..e4da88b 100644
--- a/src/external.c
+++ b/src/external.c
@@ -28,6 +28,8 @@
 static struct uloop_process uproc;
 pthread_t ubus_thread;
 LIST_HEAD(external_list_parameter);
+char *external_method_status = NULL;
+char *external_method_fault = NULL;
 
 void *thread_uloop_run(void *v)
 {
@@ -66,6 +68,18 @@ void external_free_list_parameter()
        }
 }
 
+void external_set_param_val_resp_status(char *status)
+{
+       free(external_method_status);
+       external_method_status = status ? strdup(status) : NULL;
+}
+
+void external_fetch_set_param_val_resp_status(char **status)
+{
+       *status = external_method_status;
+       external_method_status = NULL;
+}
+
 int external_get_action_data(char *action, char *name, char **value)
 {
        struct external_parameter *external_parameter;
@@ -238,9 +252,25 @@ int external_set_action_write(char *action, char *name, 
char *value)
        return 0;
 }
 
-int external_set_action_execute()
+int external_set_action_execute(char *action)
 {
        lfc_log_message(NAME, L_NOTICE, "executing set script\n");
+       FILE *fp;
+
+       if (access(fc_script_actions, R_OK | W_OK | F_OK) == -1)
+               return -1;
+
+       fp = fopen(fc_script_actions, "a");
+       if (!fp) return -1;
+
+#ifdef DUMMY_MODE
+       fprintf(fp, "/bin/sh `pwd`/%s --ubus apply %s\n", fc_script, action);
+#else
+       fprintf(fp, "/bin/sh %s --ubus apply %s\n", fc_script, action);
+#endif
+
+       fclose(fp);
+       pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
 
        if ((uproc.pid = fork()) == -1) {
                return -1;
@@ -267,6 +297,9 @@ int external_set_action_execute()
                DD("waiting for child to exit");
        }
 
+       pthread_cancel(ubus_thread);
+       pthread_join(ubus_thread,NULL);
+
        // TODO: add some kind of checks
 
        if (remove(fc_script_actions) != 0)
diff --git a/src/external.h b/src/external.h
index 4e64a99..e51b784 100644
--- a/src/external.h
+++ b/src/external.h
@@ -31,12 +31,14 @@ struct external_parameter {
        char *fault_code;
 };
 
+void external_set_param_val_resp_status (char *status);
+void external_fetch_set_param_val_resp_status (char **status);
 int external_get_action(char *action, char *name, char *arg);
 int external_get_action_data(char *action, char *name, char **value);
 int external_get_action_write(char *action, char *name, char *arg);
 int external_get_action_execute();
 int external_set_action_write(char *action, char *name, char *value);
-int external_set_action_execute();
+int external_set_action_execute(char *action);
 int external_simple(char *arg);
 int external_download(char *url, char *size);
 void external_add_list_paramameter(char *param_name, char *param_data, char 
*param_type, char *fault_code);
diff --git a/src/ubus.c b/src/ubus.c
index 4825b5f..3de874f 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -279,11 +279,85 @@ freecwmpd_handle_get_param_attributes(struct ubus_context 
*ctx, struct ubus_obje
        return 0;
 }
 
+static enum set_param_values_fault {
+       SET_PARAM_VALUES_FAULT_PARAM,
+       SET_PARAM_VALUES_FAULT__FAULT,
+       __SET_PARAM_VALUES_FAULT_MAX
+};
+
+static const struct blobmsg_policy set_param_values_fault_policy[] = {
+       [SET_PARAM_VALUES_FAULT_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+       [SET_PARAM_VALUES_FAULT__FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_values_fault(struct ubus_context *ctx, struct 
ubus_object *obj,
+                       struct ubus_request_data *req, const char *method,
+                       struct blob_attr *msg)
+{
+       struct blob_attr *tb[__SET_PARAM_VALUES_FAULT_MAX];
+
+       blobmsg_parse(set_param_values_fault_policy, 
ARRAY_SIZE(set_param_values_fault_policy), tb,
+                     blob_data(msg), blob_len(msg));
+
+       if (!tb[SET_PARAM_VALUES_FAULT_PARAM])
+               return UBUS_STATUS_INVALID_ARGUMENT;
+
+       if (!tb[SET_PARAM_VALUES_FAULT__FAULT])
+               return UBUS_STATUS_INVALID_ARGUMENT;
+
+
+       lfc_log_message(NAME, L_NOTICE,
+                            "triggered ubus set_parameter_values_fault for the 
parameter %s\n",
+                            blobmsg_data(tb[SET_PARAM_VALUES_FAULT_PARAM]));
+
+
+       
external_add_list_paramameter(blobmsg_data(tb[SET_PARAM_VALUES_FAULT_PARAM]),
+                                               NULL,
+                                               NULL,
+                                               
blobmsg_data(tb[SET_PARAM_VALUES_FAULT__FAULT]));
+
+       return 0;
+}
+
+static enum set_param_values_status {
+       SET_PARAM_VALUES_STATUS_STATUS,
+       __SET_PARAM_VALUES_STATUS_MAX
+};
+
+static const struct blobmsg_policy set_param_values_status_policy[] = {
+       [SET_PARAM_VALUES_STATUS_STATUS] = { .name = "status", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_values_status(struct ubus_context *ctx, struct 
ubus_object *obj,
+                       struct ubus_request_data *req, const char *method,
+                       struct blob_attr *msg)
+{
+       struct blob_attr *tb[__SET_PARAM_VALUES_STATUS_MAX];
+
+       blobmsg_parse(set_param_values_status_policy, 
ARRAY_SIZE(set_param_values_status_policy), tb,
+                     blob_data(msg), blob_len(msg));
+
+       if (!tb[SET_PARAM_VALUES_STATUS_STATUS])
+               return UBUS_STATUS_INVALID_ARGUMENT;
+
+
+       lfc_log_message(NAME, L_NOTICE,
+                            "triggered ubus set_parameter_values_status\n");
+
+       
external_set_param_val_resp_status(blobmsg_data(tb[SET_PARAM_VALUES_STATUS_STATUS]));
+
+       return 0;
+}
+
 static const struct ubus_method freecwmp_methods[] = {
        UBUS_METHOD("notify", freecwmpd_handle_notify, notify_policy),
        UBUS_METHOD("inform", freecwmpd_handle_inform, inform_policy),
        UBUS_METHOD("command", freecwmpd_handle_command, command_policy),
        UBUS_METHOD("get_parameter_values", freecwmpd_handle_get_param_values, 
get_param_values_policy),
+       UBUS_METHOD("set_parameter_values_fault", 
freecwmpd_handle_set_param_values_fault, set_param_values_fault_policy),
+       UBUS_METHOD("set_parameter_values_status", 
freecwmpd_handle_set_param_values_status, set_param_values_status_policy),
        UBUS_METHOD("get_parameter_names", freecwmpd_handle_get_param_names, 
get_param_names_policy),
        UBUS_METHOD("get_parameter_attributes", 
freecwmpd_handle_get_param_attributes, get_param_attributes_policy),
 };
diff --git a/src/xml.c b/src/xml.c
index 92fc046..2fb7434 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -574,6 +574,7 @@ int xml_handle_set_parameter_values(mxml_node_t *body_in,
        mxml_node_t *b = body_in;
        char *parameter_name = NULL;
        char *parameter_value = NULL;
+       char *status=NULL;
 
        while (b) {
                if (b && b->type == MXML_TEXT &&
@@ -598,25 +599,38 @@ int xml_handle_set_parameter_values(mxml_node_t *body_in,
                b = mxmlWalkNext(b, body_in, MXML_DESCEND);
        }
 
-       if (external_set_action_execute())
+       if (external_set_action_execute("value"))
                return -1;
 
+       // TODO add here check for fault return from ubus
+
+       external_fetch_set_param_val_resp_status(&status);
+       if(!status) {
+               //TODO return a fault message here
+               return -1;
+       }
+
        config_load();
 
        b = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
                            NULL, NULL, MXML_DESCEND);
-       if (!b) return -1;
+       if (!b) goto error;
 
        b = mxmlNewElement(b, "cwmp:SetParameterValuesResponse");
-       if (!b) return -1;
+       if (!b) goto error;
 
        b = mxmlNewElement(b, "Status");
-       if (!b) return -1;
+       if (!b) goto error;
 
-       b = mxmlNewText(b, 0, "1");
-       if (!b) return -1;
+       b = mxmlNewText(b, 0, status);
+       if (!b) goto error;
        
+       free(status);
        return 0;
+
+error:
+       free(status);
+       return-1;
 }
 
 int xml_handle_get_parameter_values(mxml_node_t *body_in,
@@ -898,7 +912,7 @@ static int xml_handle_set_parameter_attributes(mxml_node_t 
*body_in,
                b = mxmlWalkNext(b, n, MXML_DESCEND);
        }
 
-       if (external_set_action_execute())
+       if (external_set_action_execute("notification"))
                return -1;
 
        b = mxmlFindElement(tree_out, tree_out, "soap_env:Body", NULL, NULL, 
MXML_DESCEND);
-- 
1.7.4.1


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