From mohamed.kallel@pivasoftware.com Thu Dec  6 14:10:46 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:11:00 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:49346 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823127Ab2LFNKqRyF9u (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:10:46 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis)
        id 0MTcE0-1TXu2b0vAG-00R74a; Thu, 06 Dec 2012 14:10:39 +0100
Message-ID: <50C09942.1020904@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:10:26 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net, luka.perkov@lukaperkov.net
Subject: NEW PATCH version
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:7dn91Spim0cmOzpKseL7t1ojKXo29rhcamYQsGCm7Cn
 MT1L3CKLAiuL7tciCgJV14TldmHW5fOFnrVnXo8XJT+MPR5B/k
 A3Yy4TLehgb3D37Es+BFJVg5t5uDYHgaawbADzhMgbJtplANg4
 E8aEzm5is68S9zQuaqYj+nFXUBg93mWNcjOxyU8doV2JSs61s3
 5kmOOX6YYix4JSMqsIeRvMxao8dYlNm2oMUUY+qXAkZu4BTiT0
 LCd5tTpHSCnteGwpdaq52NCnVThccPUIAZzLJdXXfjm4Hoy6A5
 gpQNbAyE3uWBTSJKoTDg4GoVe3OGlsgH4ayEuOodSlZG5a6n32
 SqVOJwyHxy/Dnr+Lfdb0YeVSduayc0s3+4hdAzb2Y
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 75
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

As agreed, please find following the patch(s) updated (with your remarks).
As said before theses patches contains:

- communication from script to the core via ubus
- GetParameterValues method supporting many parameters
-  GetParameterNames method added

Regards
Mohamed KALLEL

------------------------ubus_data_model.patch---------------------------------

 >From 18e2d931a89158a69e7f25705dbf2dbb1f41d3fd Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:33:01 +0100
Subject: [PATCH 01/27] add ubus listner get_parameter_values. This 
listener allows to get the freecwmp output from extenal command.
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/external.c |   13 +++++++++++++
  src/external.h |   10 ++++++++++
  src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/external.c b/src/external.c
index 9ac7b36..c9c768f 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,6 +25,19 @@
  #include "freecwmp.h"

  static struct uloop_process uproc;
+LIST_HEAD(external_list_parameter);
+
+void external_add_list_paramameter(char *param_name, char *param_data, 
char *param_type, char *fault_code)
+{
+    struct external_parameter *external_parameter;
+    struct list_head *ilist; int i =0;
+    external_parameter = calloc(1, sizeof(struct external_parameter));
+ list_add_tail(&external_parameter->list,&external_list_parameter);
+    if (param_name) external_parameter->name = strdup(param_name);
+    if (param_data) external_parameter->data = strdup(param_data);
+    if (param_type) external_parameter->type = strdup(param_type);
+    if (fault_code) external_parameter->fault_code = strdup(fault_code);
+}

  int external_get_action(char *action, char *name, char **value)
  {
diff --git a/src/external.h b/src/external.h
index 8606266..64b4c6b 100644
--- a/src/external.h
+++ b/src/external.h
@@ -9,6 +9,7 @@

  #ifndef _FREECWMP_EXTERNAL_H__
  #define _FREECWMP_EXTERNAL_H__
+#include <libubox/list.h>

  #ifdef DUMMY_MODE
  static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
@@ -17,11 +18,20 @@ static char *fc_script = "/usr/sbin/freecwmp";
  #endif
  static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";

+struct external_parameter {
+    struct list_head list;
+    char *name;
+    char *data; /* notification for GetParameterAttribute; writable for 
GetParameterNames; value for GetParameterValues*/
+    char *type;
+    char *fault_code;
+};
+
  int external_get_action(char *action, char *name, char **value);
  int external_set_action_write(char *action, char *name, char *value);
  int external_set_action_execute();
  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);

  #endif

diff --git a/src/ubus.c b/src/ubus.c
index c10170d..d5437f9 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -16,6 +16,7 @@
  #include "config.h"
  #include "cwmp.h"
  #include "freecwmp.h"
+#include "external.h"

  static struct ubus_context *ctx = NULL;
  static struct ubus_object main_object;
@@ -157,10 +158,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, 
struct ubus_object *obj,
      return 0;
  }

+static enum get_param_values {
+    GET_PARAM_VALUES_PARAM,
+    GET_PARAM_VALUES_VALUE,
+    GET_PARAM_VALUES_TYPE,
+    GET_PARAM_VALUES_FAULT,
+    __GET_PARAM_VALUES_MAX
+};
+
+static const struct blobmsg_policy get_param_values_policy[] = {
+    [GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_VALUE] = { .name = "value", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_TYPE] = { .name = "type", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct 
ubus_object *obj,
+            struct ubus_request_data *req, const char *method,
+            struct blob_attr *msg)
+{
+    struct blob_attr *tb[__GET_PARAM_VALUES_MAX];
+
+    blobmsg_parse(get_param_values_policy, 
ARRAY_SIZE(get_param_values_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    if (!tb[GET_PARAM_VALUES_PARAM])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus get_parameter_values for the parameter 
%s\n",
+                 blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
+
+ external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
+            tb[GET_PARAM_VALUES_VALUE]? 
blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,
+            tb[GET_PARAM_VALUES_TYPE]? 
blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",
+            tb[GET_PARAM_VALUES_FAULT]? 
blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);
+
+    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),
  };

  static struct ubus_object_type main_object_type =
-- 
1.7.4.1


 >From 5f74d7947e48e1d3d140f5842cbad955d0686a7e Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:37:07 +0100
Subject: [PATCH 02/27] get_parameter values handler from xml is 
supporting many parameters from external ubus output
    Contributed by Inteno Broadband Technology AB && PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  bin/Makefile.am |    3 +-
  configure.ac    |    3 ++
  src/external.c  |   95 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
  src/external.h  |    6 +++-
  src/freecwmp.c  |   17 ++++++++++
  src/xml.c       |   66 +++++++++++++++++++++++--------------
  6 files changed, 163 insertions(+), 27 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 78cb111..ac96905 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,5 +48,6 @@ freecwmpd_LDADD =        \
      $(LIBUBUS_LIBS)        \
      $(MICROXML_LIBS)    \
      $(LIBCURL_LIBS)        \
-    $(LIBZSTREAM_LIBS)
+    $(LIBZSTREAM_LIBS)    \
+    $(LIBPTHREAD_LIBS)

diff --git a/configure.ac b/configure.ac
index c646c3a..38d3df4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
  LIBUBUS_LIBS='-lubus'
  AC_SUBST([LIBUBUS_LIBS])

+LIBPTHREAD_LIBS='-lpthread'
+AC_SUBST([LIBPTHREAD_LIBS])
+
  AM_COND_IF([HTTP_CURL], [
   AC_DEFINE(HTTP_CURL)
   PKG_CHECK_MODULES(LIBCURL, [libcurl])
diff --git a/src/external.c b/src/external.c
index c9c768f..94ae9b8 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,8 +25,15 @@
  #include "freecwmp.h"

  static struct uloop_process uproc;
+pthread_t ubus_thread;
  LIST_HEAD(external_list_parameter);

+void *thread_uloop_run (void *v)
+{
+    uloop_run();
+    return NULL;
+}
+
  void external_add_list_paramameter(char *param_name, char *param_data, 
char *param_type, char *fault_code)
  {
      struct external_parameter *external_parameter;
@@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name, 
char *param_data, char *par
      if (fault_code) external_parameter->fault_code = strdup(fault_code);
  }

+void external_free_list_parameter()
+{
+    struct external_parameter *external_parameter;
+    while (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+}
+
  int external_get_action(char *action, char *name, char **value)
  {
      freecwmp_log_message(NAME, L_NOTICE,
@@ -121,6 +142,80 @@ error:
      return -1;
  }

+int external_get_action_write(char *action, char *name, char *arg)
+{
+    freecwmp_log_message(NAME, L_NOTICE,
+        "adding to get %s script '%s'\n", action, name);
+
+    FILE *fp;
+
+    if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
+        fp = fopen(fc_script_get_actions, "a");
+        if (!fp) return -1;
+    } else {
+        fp = fopen(fc_script_get_actions, "w");
+        if (!fp) return -1;
+
+        fprintf(fp, "#!/bin/sh\n");
+
+        if (chmod(fc_script_get_actions,
+            strtol("0700", 0, 8)) < 0) {
+            return -1;
+    }
+    }
+
+#ifdef DUMMY_MODE
+    fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action, 
name, arg?arg:"");
+#else
+    fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name, 
arg?arg:"");
+#endif
+
+    fclose(fp);
+
+    return 0;
+}
+
+int external_get_action_execute()
+{
+    freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
+
+    pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
+
+    if ((uproc.pid = fork()) == -1) {
+        return -1;
+    }
+
+    if (uproc.pid == 0) {
+        /* child */
+
+        const char *argv[3];
+        int i = 0;
+        argv[i++] = "/bin/sh";
+        argv[i++] = fc_script_get_actions;
+        argv[i++] = NULL;
+
+        execvp(argv[0], (char **) argv);
+        exit(ESRCH);
+
+    } else if (uproc.pid < 0)
+    return -1;
+
+    /* parent */
+    int status;
+    while (wait(&status) != uproc.pid) {
+        DD("waiting for child to exit");
+    }
+
+    pthread_cancel(ubus_thread);
+    pthread_join(ubus_thread,NULL);
+
+    // TODO: add some kind of checks
+
+    remove(fc_script_get_actions);
+
+    return 0;
+}
+
  int external_set_action_write(char *action, char *name, char *value)
  {
      freecwmp_log_message(NAME, L_NOTICE,
diff --git a/src/external.h b/src/external.h
index 64b4c6b..c6df2ea 100644
--- a/src/external.h
+++ b/src/external.h
@@ -16,7 +16,8 @@ static char *fc_script = 
"./ext/openwrt/scripts/freecwmp.sh";
  #else
  static char *fc_script = "/usr/sbin/freecwmp";
  #endif
-static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
+static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
+static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";

  struct external_parameter {
      struct list_head list;
@@ -27,11 +28,14 @@ struct external_parameter {
  };

  int external_get_action(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_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);
+void external_free_list_parameter();

  #endif

diff --git a/src/freecwmp.c b/src/freecwmp.c
index 4ef8395..f4c9cb1 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -18,6 +18,7 @@
  #include <arpa/inet.h>
  #include <linux/netlink.h>
  #include <linux/rtnetlink.h>
+#include <signal.h>

  #include <libfreecwmp.h>
  #include <libubox/uloop.h>
@@ -194,11 +195,27 @@ netlink_init(void)
      return 0;
  }

+void signal_kill_all_handler(int sig)
+{
+     pthread_exit(NULL);
+}
+
+
+
  int main (int argc, char **argv)
  {
      freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");

      bool foreground = false;
+    struct sigaction sigint_action;
+
+    sigint_action.sa_handler = &signal_kill_all_handler;
+    sigemptyset (&sigint_action.sa_mask);
+    /* reset handler in case when pthread_cancel didn't stop
+       threads for some reason */
+    sigint_action.sa_flags = SA_RESETHAND;
+    sigaction(SIGTERM, &sigint_action, NULL);
+

      setlocale(LC_CTYPE, "");
      umask(0037);
diff --git a/src/xml.c b/src/xml.c
index 9fa036b..23b9ec7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -21,6 +21,8 @@
  #include "messages.h"
  #include "time.h"

+extern struct list_head external_list_parameter;
+
  struct rpc_method {
      const char *name;
      int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
@@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
                      mxml_node_t *tree_in,
                      mxml_node_t *tree_out)
  {
-    mxml_node_t *n, *b = body_in;
+    mxml_node_t *n, *parameter_list, *b = body_in;
+    struct external_parameter *external_parameter;
      char *parameter_name = NULL;
      char *parameter_value = NULL;
-    char *c;
+    char *c=NULL;
      int counter = 0;

      n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
@@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
              !strcmp(b->parent->value.element.name, "string")) {
              parameter_name = b->value.text.string;
          }
-
+        if (b && b->type == MXML_ELEMENT && /* added in order to 
support GetParameterValues with empty string*/
+            !strcmp(b->value.element.name, "string") &&
+            !b->child) {
+            parameter_name = "";
+        }
          if (parameter_name) {
              if (!config_get_cwmp(parameter_name, &parameter_value)) {
+ 
external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);
+                FREE(parameter_value);
                  // got the parameter value using libuci
-            } else if (!external_get_action("value",
-                    parameter_name, &parameter_value)) {
+            } else if 
(!external_get_action_write("value",parameter_name, NULL)) {
                  // got the parameter value via external script
              } else {
                  // error occurred when getting parameter value
                  goto out;
              }
-            counter++;
+        }
+        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+        parameter_name = NULL;
+    }

-            n = mxmlFindElement(tree_out, tree_out, "ParameterList", 
NULL, NULL, MXML_DESCEND);
-            if (!n) goto out;
+    if (external_get_action_execute())
+        goto out;
+
+    parameter_list = mxmlFindElement(tree_out, tree_out, 
"ParameterList", NULL, NULL, MXML_DESCEND);
+    if (!parameter_list) goto out;
+
+    while (external_list_parameter.next!=&external_list_parameter) {
+
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);

-            n = mxmlNewElement(n, "ParameterValueStruct");
+        if (external_parameter->fault_code && 
external_parameter->fault_code[0]=='9')
+            goto out; // KMD TODO return FAULT message the fault code 
is in ->fault_code
+
+        n = mxmlNewElement(parameter_list, "ParameterValueStruct");
              if (!n) goto out;

              n = mxmlNewElement(n, "Name");
              if (!n) goto out;

-            n = mxmlNewText(n, 0, parameter_name);
+        n = mxmlNewText(n, 0, external_parameter->name);
              if (!n) goto out;

              n = n->parent->parent;
@@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
              if (!n) goto out;

  #ifdef ACS_MULTI
-            mxmlElementSetAttr(n, "xsi:type", "xsd:string");
+        mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
  #endif
-            n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
+        n = mxmlNewText(n, 0, external_parameter->data? 
external_parameter->data : "");
              if (!n) goto out;

-            /*
-             * three day's work to finally find memory leak if we
-             * free parameter_name;
-             * it points to: b->value.text.string
-             *
-             * also, parameter_value can be NULL so we don't do checks
-             */
-            parameter_name = NULL;
-        }
+        counter++;

-        FREE(parameter_value);
-        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
      }

  #ifdef ACS_MULTI
@@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
      FREE(c);
  #endif

-    FREE(parameter_value);
      return 0;

  out:
-    FREE(parameter_value);
+    external_free_list_parameter();
      return -1;
  }

-- 
1.7.4.1


 >From 9efe02b6ae49b65b6103f4f41dec23a260626e40 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:55:52 +0100
Subject: [PATCH 03/27] add in the scripts the functions needed to 
communicate data to ubus handler for the get_parameter_values ubus handler
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/freecwmp.sh      |   51 
++++++++++++++++++++++++++++------
  ext/openwrt/scripts/functions/common |   23 +++++++++++++++
  2 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh 
b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..f2bebc8 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,21 +113,54 @@ handle_scripts() {
  config_load freecwmp
  config_foreach handle_scripts "scripts"

+# Fault code
+
+FAULT_CPE_NO_FAULT="0"
+FAULT_CPE_REQUEST_DENIED="1"
+FAULT_CPE_INTERNAL_ERROR="2"
+FAULT_CPE_INVALID_ARGUMENTS="3"
+FAULT_CPE_RESOURCES_EXCEEDED="4"
+FAULT_CPE_INVALID_PARAMETER_NAME="5"
+FAULT_CPE_INVALID_PARAMETER_TYPE="6"
+FAULT_CPE_INVALID_PARAMETER_VALUE="7"
+FAULT_CPE_NON_WRITABLE_PARAMETER="8"
+FAULT_CPE_NOTIFICATION_REJECTED="9"
+FAULT_CPE_DOWNLOAD_FAILURE="10"
+FAULT_CPE_UPLOAD_FAILURE="11"
+FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
+FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
+FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
+FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
+FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
+FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
+
  if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
-    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
+    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 $get_value_functions
      do
          $function_name "$__arg1"
+                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
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    fi
  fi

  if [ "$action" = "set_value" ]; then
diff --git a/ext/openwrt/scripts/functions/common 
b/ext/openwrt/scripts/functions/common
index 7e3000a..082e067 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE} 
]; then
  fi
  }

+ubus_freecwmp_output() {
+local parameter="$1"
+local value="$2"
+local type="$3"
+local fault_code="$4"
+
+if [ "$type" = "" ]; then
+    type="xsd:string"
+fi
+
+case "$action" in
+    get_value)
+    ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", 
"value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 
2> /dev/null
+    ;;
+esac
+}
  freecwmp_value_output() {
      freecwmp_output "$1" "$2" "V"
  }
@@ -249,3 +265,10 @@ EOF
      sh "$lock" &
  fi
  }
+
+freecwmp_check_fault() {
+if [ "$1" = "." ]; then
+    return $FAULT_CPE_INVALID_PARAMETER_NAME
+fi
+return $FAULT_CPE_NO_FAULT
+}
-- 
1.7.4.1


 >From 9f3c3bea934e079853aed0ac27d91fb1bbe115d5 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:59:14 +0100
Subject: [PATCH 04/27] Update device_hosts to support communicte data of 
get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_hosts |   22 +++++++++++-----------
  1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_hosts 
b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..8909df6 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -44,7 +44,7 @@ local parameter=`echo -n $1 | sed 
"s/InternetGatewayDevice\.LANDevice\.1\./Devic
  case "$parameter" in
      Device.Hosts.HostNumberOfEntries)
      let local val=$num_static_leases+$num_dynamic_leases
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
      ;;
  esac
@@ -66,7 +66,7 @@ if [ $rc -eq 0 ]; then
          local sed_cmd=`echo -n \'$num; echo p\'`
          val=`eval sed -n $sed_cmd $leases_file | awk '{ print $2 }'`
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -74,7 +74,7 @@ freecwmp_parse_formated_parameter "$parameter" 
"Device.Hosts.Host.{i}.IPAddress"
  if [ $rc -eq 0 ]; then
      local val
      get_device_hosts_ip_address "$leases_file" "$num" 
"$num_static_leases" "$num_dynamic_leases" "val"
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -88,7 +88,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -gt 0 -a $num -le $num_dynamic_leases ]; then
          val="DHCP"
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -107,7 +107,7 @@ if [ $rc -eq 0 ]; then
          local t2=`date +%s`
          let val=$t1-$t2
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -131,7 +131,7 @@ if [ $rc -eq 0 ]; then
          val=`eval sed -n $sed_cmd $leases_file | awk '{ print $4 }'`
          if [ "x$val" == "x*" ]; then val=""; fi
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -144,7 +144,7 @@ if [ $rc -eq 0 ]; then
      get_device_hosts_ip_address "$leases_file" "$num" 
"$num_static_leases" "$num_dynamic_leases" "ip"
      val=`ping -c 1 $ip 2>&1 > /dev/null ; echo $?`
      let val=!$val
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -156,7 +156,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -le $n ]; then
          val=1
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -168,7 +168,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -le $n ]; then
          val=0
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -182,10 +182,10 @@ if [ $rc -eq 0 ]; then
      if [ $num2 -eq 1 ]; then
          get_device_hosts_ip_address "$leases_file" "$num1" 
"$num_static_leases" "$num_dynamic_leases" "val"
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

  # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 
support yet)
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
-- 
1.7.4.1


 >From b61d8e55d0ef3de480a78fa088b126d5b38db152 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:01:31 +0100
Subject: [PATCH 05/27] Update device_info script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info |   32 
+++++++++++++++++++---------
  1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index 4423b8b..86ff5c9 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -3,7 +3,7 @@

  get_device_info_manufacturer() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].manufacturer 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
  }

  set_device_info_manufacturer() {
@@ -12,7 +12,7 @@ set_device_info_manufacturer() {

  get_device_info_oui() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].oui 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" 
"$val"
  }

  set_device_info_oui() {
@@ -21,7 +21,7 @@ set_device_info_oui() {

  get_device_info_product_class() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].product_class 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" 
"$val"
  }

  set_device_info_product_class() {
@@ -30,7 +30,7 @@ set_device_info_product_class() {

  get_device_info_serial_number() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].serial_number 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
  }

  set_device_info_serial_number() {
@@ -39,7 +39,7 @@ set_device_info_serial_number() {

  get_device_info_hardware_version() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].hardware_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" 
"$val"
  }

  set_device_info_hardware_version() {
@@ -48,7 +48,7 @@ set_device_info_hardware_version() {

  get_device_info_software_version() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].software_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" 
"$val"
  }

  set_device_info_software_version() {
@@ -57,7 +57,7 @@ set_device_info_software_version() {

  get_device_info_uptime() {
  local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
  }

  get_device_info_device_log() {
@@ -67,7 +67,7 @@ if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
  else
      val=`dmesg | tail -n10`
  fi
-freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
  }

  get_device_info() {
@@ -81,6 +81,7 @@ case "$1" in
      get_device_info_software_version
      get_device_info_uptime
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.)
      get_device_info_manufacturer
@@ -91,32 +92,42 @@ case "$1" in
      get_device_info_software_version
      get_device_info_uptime
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.Manufacturer)
      get_device_info_manufacturer
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
      get_device_info_oui
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ProductClass)
      get_device_info_product_class
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SerialNumber)
      get_device_info_serial_number
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.HardwareVersion)
      get_device_info_hardware_version
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SoftwareVersion)
      get_device_info_software_version
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.UpTime)
      get_device_info_uptime
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.DeviceLog)
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_device_info() {
@@ -161,10 +172,11 @@ return 1
  }

  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_get_parameter_value "val" "$1"
-    freecwmp_value_output "$1" "$val"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
  }

  set_device_info_generic() {
-- 
1.7.4.1


 >From 91e36ad7421668100895447e65a4fedfba208b33 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:04:01 +0100
Subject: [PATCH 06/27] Update device_routing script to support 
communicte data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_routing |   33 
+++++++++++++------------
  1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_routing 
b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..ca6dab1 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -85,7 +85,7 @@ local parameter=$1

  case "$parameter" in
      Device.Routing.RouterNumberOfEntries)
-    freecwmp_output "$parameter" "1"
+    ubus_freecwmp_output "$parameter" "1"
      return
      ;;
  esac
@@ -101,7 +101,7 @@ if [ $rc -eq 0 ]; then
      else
          val="0"
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -113,7 +113,7 @@ if [ $rc -eq 0 ]; then
      else
          val="Disabled"
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -134,7 +134,7 @@ if [ $rc -eq 0 ]; then
      else
          return
      fi
-    freecwmp_output "$parameter" "$total"
+    ubus_freecwmp_output "$parameter" "$total"
      return
  fi

@@ -146,7 +146,7 @@ if [ $rc -eq 0 ]; then
      else
          return
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -166,15 +166,15 @@ if [ $rc -eq 0 ]; then
              return
          fi
          if [ $num2 -gt $static ]; then
-            freecwmp_output "$parameter" "Enabled"
+            ubus_freecwmp_output "$parameter" "Enabled"
              return
          fi
          if [ $num2 -le $inactive ]; then
-            freecwmp_output "$parameter" "Error: not active but enabled"
+            ubus_freecwmp_output "$parameter" "Error: not active but 
enabled"
              return
          fi
          if [ $num2 -le $static ]; then
-            freecwmp_output "$parameter" "Enabled"
+            ubus_freecwmp_output "$parameter" "Enabled"
              return
          fi
      else
@@ -197,11 +197,11 @@ if [ $rc -eq 0 ]; then
              return
          fi
          if [ $num2 -gt $static ]; then
-            freecwmp_output "$parameter" "0"
+            ubus_freecwmp_output "$parameter" "0"
              return
          fi
          if [ $num2 -le $static ]; then
-            freecwmp_output "$parameter" "1"
+            ubus_freecwmp_output "$parameter" "1"
              return
          fi
      else
@@ -230,7 +230,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              target=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].target 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$target"
+        ubus_freecwmp_output "$parameter" "$target"
          return
      else
          return
@@ -258,7 +258,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              netmask=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].netmask 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$netmask"
+        ubus_freecwmp_output "$parameter" "$netmask"
          return
      else
          return
@@ -288,7 +288,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              gateway=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].gateway 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$gateway"
+        ubus_freecwmp_output "$parameter" "$gateway"
          return
      else
          return
@@ -315,7 +315,7 @@ if [ $rc -eq 0 ]; then
          elif [ $num2 -le $static ]; then
              val="Static"
          fi
-        freecwmp_output "$parameter" "$val"
+        ubus_freecwmp_output "$parameter" "$val"
          return
      else
          return
@@ -343,11 +343,12 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              metric=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].metric 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$metric"
+        ubus_freecwmp_output "$parameter" "$metric"
          return
      else
          return
      fi
  fi
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
+
-- 
1.7.4.1


 >From 33dbf86bc1acdb5b12589225de0fa1c79c51627b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:05:26 +0100
Subject: [PATCH 07/27]  Update device_users script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_users |   13 +++++++------
  1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_users 
b/ext/openwrt/scripts/functions/device_users
index 0d377f7..d8dba61 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -6,7 +6,7 @@ local parameter="$1"
  case "$parameter" in
      Device.Users.UserNumberOfEntries)
      local val=`wc -l /etc/passwd | awk '{ print $1 }'`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
      ;;
  esac
@@ -21,7 +21,7 @@ if [ $rc -eq 0 ]; then
      # TODO: this is very system dependent, for now just look at users 
shell
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' 
| wc -l`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -30,7 +30,7 @@ if [ $rc -eq 0 ]; then
      # TODO: this is very system dependent, for now just look at users 
shell
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' 
| wc -l`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -38,7 +38,7 @@ freecwmp_parse_formated_parameter "$parameter" 
"Device.Users.User.{i}.Username"
  if [ $rc -eq 0 ]; then
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | awk -F ':' '{ print 
$1 }'`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -48,15 +48,16 @@ if [ $rc -eq 0 ]; then
      #   local sed_cmd=`echo -n \'$num; echo p\'`
      #   local val=`eval sed -n $sed_cmd /etc/shadow | awk -F ':' '{ 
print $2 }'`
      #   freecwmp_value_output "$parameter" "$val"
-    freecwmp_value_output "$parameter" ""
+    ubus_freecwmp_output "$parameter" ""
      return
  fi

  freecwmp_parse_formated_parameter "$parameter" 
"Device.Users.User.{i}.Language" "rc" "num"
  if [ $rc -eq 0 ]; then
-    freecwmp_value_output "$parameter" ""
+    ubus_freecwmp_output "$parameter" ""
      return
  fi
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_device_users() {
-- 
1.7.4.1


 >From 5d2f27eaebb4c5762a915b428b3d11e1ce6d2cff Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:07:28 +0100
Subject: [PATCH 08/27] Update lan_device script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/lan_device |   13 +++++++++++--
  1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 5ba513c..fa9dda4 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -3,6 +3,7 @@

  get_wlan_enable() {
  local num="$1"
+local type="xsd:boolean"
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-device[$num].disabled 2> /dev/null`
  let num=$num+1
  if [ "$val" = "1" ]; then
@@ -10,7 +11,7 @@ if [ "$val" = "1" ]; then
  else
      val="1"
  fi
-freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" 
"$type"
  }

  set_wlan_enable() {
@@ -29,7 +30,7 @@ get_wlan_ssid() {
  local num="$1"
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-iface[$num].ssid 2> /dev/null`
  let num=$num+1
-freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
  }

  set_wlan_ssid() {
@@ -44,30 +45,38 @@ case "$1" in
      InternetGatewayDevice.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
      get_wlan_enable 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_lan_device() {
-- 
1.7.4.1


 >From 7b88e2ac25543be6c319822d96ae379395f55fc3 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:09:08 +0100
Subject: [PATCH 09/27] Update management_server script to support 
communicte data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/management_server |   72 
++++++++++++++++++-----
  1 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index 9d1447e..eca3a61 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -10,7 +10,7 @@ local 
port=`get_management_server_x_freecwmp_org__acs_port`
  local path=`get_management_server_x_freecwmp_org__acs_path`
  FLAGS_value=$tmp
  local val=`echo $scheme://$hostname:$port$path`
-freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
  }

  set_management_server_url() {
@@ -46,7 +46,7 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform 
'{ "event": "value_change

  get_management_server_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].username 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" 
"$val"
  }

  set_management_server_username() {
@@ -55,7 +55,7 @@ set_management_server_username() {

  get_management_server_password() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].password 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" 
"$val"
  }

  set_management_server_password() {
@@ -65,7 +65,7 @@ set_management_server_password() {
  get_management_server_periodic_inform_enable() {
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
  freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
  }

  set_management_server_periodic_inform_enable() {
@@ -76,7 +76,7 @@ freecwmp_set_parameter_value "$parm" "$1"
  get_management_server_periodic_inform_interval() {
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
  freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
  }

  set_management_server_periodic_inform_interval() {
@@ -100,12 +100,12 @@ else
      val=$default_management_server_connection_request_url
  fi

-freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
  }

  get_management_server_connection_request_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].username 2> /dev/null`
-freecwmp_value_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
  }

  set_management_server_connection_request_username() {
@@ -114,7 +114,7 @@ set_management_server_connection_request_username() {

  get_management_server_connection_request_password() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].password 2> /dev/null`
-freecwmp_value_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
  }

  set_management_server_connection_request_password() {
@@ -125,7 +125,12 @@ set_management_server_connection_request_password() {

  get_management_server_x_freecwmp_org__acs_scheme() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].scheme 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_scheme() {
@@ -134,7 +139,12 @@ set_management_server_x_freecwmp_org__acs_scheme() {

  get_management_server_x_freecwmp_org__acs_hostname() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].hostname 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_hostname() {
@@ -147,7 +157,12 @@ fi

  get_management_server_x_freecwmp_org__acs_port() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].port 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_port() {
@@ -156,7 +171,12 @@ set_management_server_x_freecwmp_org__acs_port() {

  get_management_server_x_freecwmp_org__acs_path() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].path 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_path() {
@@ -165,7 +185,12 @@ set_management_server_x_freecwmp_org__acs_path() {

  get_management_server_x_freecwmp_org__connection_request_port() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].port 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port" 
"$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__connection_request_port() {
@@ -188,6 +213,7 @@ case "$1" in
      get_management_server_x_freecwmp_org__acs_port
      get_management_server_x_freecwmp_org__acs_path
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.)
      get_management_server_url
@@ -203,47 +229,62 @@ case "$1" in
      get_management_server_x_freecwmp_org__acs_port
      get_management_server_x_freecwmp_org__acs_path
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.URL)
      get_management_server_url
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Username)
      get_management_server_username
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Password)
      get_management_server_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
      get_management_server_periodic_inform_enable
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
      get_management_server_periodic_inform_interval
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
      get_management_server_connection_request_url
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
      get_management_server_connection_request_username
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
      get_management_server_connection_request_password
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
      get_management_server_x_freecwmp_org__acs_scheme
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
      get_management_server_x_freecwmp_org__acs_hostname
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
      get_management_server_x_freecwmp_org__acs_port
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
      get_management_server_x_freecwmp_org__acs_path
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_management_server() {
@@ -301,10 +342,11 @@ return 1
  }

  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_get_parameter_value "val" "$1"
-    freecwmp_value_output "$1" "$val"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
  }

  set_management_server_generic() {
-- 
1.7.4.1


 >From dfb8cb80b1353170d74cb15ebf1dc0b5d0254f41 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:11:29 +0100
Subject: [PATCH 10/27] Update misc script to support communicte data of 
get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/misc |    8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/misc 
b/ext/openwrt/scripts/functions/misc
index 2e0210c..13f2142 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -3,21 +3,25 @@

  get_misc_cpu_usage() {
  local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ 
print $1 }' | awk -F'.' '{ print $2 }'`
-freecwmp_value_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
+ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
  }

  get_misc_process_number() {
  local val=`ps | grep -v COMMAND | wc -l`
-freecwmp_value_output 
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val"
+local type="xsd:unsignedInt"
+ubus_freecwmp_output 
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "$type"
  }

  get_misc() {
  case "$1" in
      Device.DeviceInfo.ProcessStatus.CPUUsage)
      get_misc_cpu_usage
+    return $FAULT_CPE_NO_FAULT
      ;;
      Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
      get_misc_process_number
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
-- 
1.7.4.1


 >From 1c3ddcdb4827bbecf99220963031c934a9b1fbe1 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:14:35 +0100
Subject: [PATCH 11/27] Update wan_device script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/wan_device |   39 
+++++++++++++++++++++++++----
  1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index 77cb63f..a8b6361 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -4,26 +4,37 @@
  get_wan_device_mng_status() {
  # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; 
Disconneting ; Disconnected
  local val="Connected"
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" 
"$val" "xsd:boolean"
  }

  get_wan_device_mng_interface_ip() {
  local val
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
  if [ -z "$default_wan_device_mng_interface_ip" ]; then
      val=`network_get_ipaddr val mng`
  else
      val=$default_wan_device_mng_interface_ip
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress" 
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  get_wan_device_mng_interface_mac() {
+local val=""
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
  if [ -z "$default_wan_device_mng_interface_mac" ]; then
      val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.mng.macaddr`
  else
      val=$default_wan_device_mng_interface_mac
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress" 
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  get_wan_device_wan_ppp_enable() {
@@ -31,7 +42,7 @@ local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c 
$UCI_CONFIG_DIR} get network.wan.auto
  if [ -z $val ]; then
      val="1"
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" 
"$val" "xsd:boolean"
  }

  set_wan_device_wan_ppp_enable() {
@@ -47,7 +58,7 @@ fi

  get_wan_device_wan_ppp_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.username 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" 
"$val"
  }

  set_wan_device_wan_ppp_username() {
@@ -55,7 +66,9 @@ set_wan_device_wan_ppp_username() {
  }

  get_wan_device_wan_ppp_password() {
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" 
""
+local val=""
+val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.password 2> /dev/null`
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" 
"$val"
  }

  set_wan_device_wan_ppp_password() {
@@ -71,6 +84,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.)
      get_wan_device_mng_status
@@ -79,6 +93,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.)
      get_wan_device_mng_status
@@ -87,6 +102,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
      get_wan_device_mng_status
@@ -95,6 +111,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
      get_wan_device_mng_status
@@ -103,36 +120,46 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
      get_wan_device_mng_status
      get_wan_device_mng_interface_ip
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
      get_wan_device_mng_status
      get_wan_device_mng_interface_ip
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
      get_wan_device_mng_status
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
      get_wan_device_mng_interface_ip
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
      get_wan_device_wan_ppp_enable
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
      get_wan_device_wan_ppp_username
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_wan_device() {
-- 
1.7.4.1


 >From 4ef165928bbd8e532f8f587ebf45789fdb44ba74 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:17:34 +0100
Subject: [PATCH 12/27] update inform in order to get parameters from 
ubus instead from pipe
    Contributed by PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/xml.c |   40 ++++++++++++++++++----------------------
  1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/xml.c b/src/xml.c
index 23b9ec7..612c0bb 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
  {
      mxml_node_t *tree, *b;
      char *c, *tmp;
+    struct external_parameter *external_parameter;

  #ifdef DUMMY_MODE
      FILE *fp;
@@ -337,37 +338,31 @@ int xml_prepare_inform_message(char **msg_out)
      if (mxmlGetType(b) != MXML_ELEMENT)
          goto error;

-    tmp = 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
-    b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-    if (!b) goto error;
-
-    b = b->parent->next->next;
-    if (mxmlGetType(b) != MXML_ELEMENT)
+    external_get_action_write("value", 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", 
NULL);
+    external_get_action_write("value", 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
+    if (external_get_action_execute())
          goto error;

-    c = NULL;
-    if (external_get_action("value", tmp, &c)) goto error;
-    if (c) {
-        b = mxmlNewText(b, 0, c);
-        FREE(c);
-        if (!b) goto error;
-    }
-
-    tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
-    b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-    if (!b) goto error;
+    while (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        b = mxmlFindElementText(tree, tree, external_parameter->name, 
MXML_DESCEND);
+        if (!b) continue;

      b = b->parent->next->next;
      if (mxmlGetType(b) != MXML_ELEMENT)
          goto error;

-    c = NULL;
-    if (external_get_action("value", tmp, &c)) goto error;
-    if (c) {
-        b = mxmlNewText(b, 0, c);
-        FREE(c);
+        if (external_parameter->data) {
+            b = mxmlNewText(b, 0, external_parameter->data);
          if (!b) goto error;
      }
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }

      if (xml_prepare_notifications_inform(tree))
          goto error;
@@ -378,6 +373,7 @@ int xml_prepare_inform_message(char **msg_out)
      return 0;

  error:
+    external_free_list_parameter();
      mxmlDelete(tree);
      return -1;
  }
-- 
1.7.4.1


 >From 71814340a261a18fd3002a67863ce0fcd295a0bf Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:20:12 +0100
Subject: [PATCH 13/27] Add 3rd argument in the ubus handler of 
notification. The 3rd argument is the type of the parameter
   This agument could be  used in the response of get parameter attribute
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/cwmp.c |    2 +-
  src/cwmp.h |    2 +-
  src/ubus.c |    5 ++++-
  3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index 1bf9b2a..b75c762 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -245,7 +245,7 @@ void cwmp_clear_events(void)
      pthread_mutex_unlock(&event_lock);
  }

-void cwmp_add_notification(char *parameter, char *value)
+void cwmp_add_notification(char *parameter, char *value, char *type)
  {
      char *c = NULL;
      external_get_action("notification", parameter, &c);
diff --git a/src/cwmp.h b/src/cwmp.h
index 5703db0..1d8afac 100644
--- a/src/cwmp.h
+++ b/src/cwmp.h
@@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
  void cwmp_remove_event(int code);
  void cwmp_clear_events(void);

-void cwmp_add_notification(char *parameter, char *value);
+void cwmp_add_notification(char *parameter, char *value, char *type);
  void cwmp_clear_notifications(void);

  int cwmp_set_parameter_write_handler(char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index d5437f9..0fd1def 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct 
uloop_timeout *timeout)
  static enum notify {
      NOTIFY_PARAM,
      NOTIFY_VALUE,
+    NOTIFY_TYPE,
      __NOTIFY_MAX
  };

  static const struct blobmsg_policy notify_policy[] = {
      [NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
      [NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+    [NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
  };

  static int
@@ -66,7 +68,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx, 
struct ubus_object *obj,
                   "triggered ubus notification parameter %s\n",
                   blobmsg_data(tb[NOTIFY_PARAM]));
      cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
-                  blobmsg_data(tb[NOTIFY_VALUE]));
+            blobmsg_data(tb[NOTIFY_VALUE]),
+            tb[NOTIFY_TYPE]? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);

      return 0;
  }
-- 
1.7.4.1


 >From 227820f9866cb0375238b0615f32498c283a0110 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:23:07 +0100
Subject: [PATCH 14/27] add xml message get_parameter_name handler.
    Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/cwmp.c     |    2 +-
  src/external.c |   70 +++++++++++++-----------------------
  src/external.h |    3 +-
  src/ubus.c     |   39 ++++++++++++++++++++
  src/xml.c      |  111 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++-
  src/xml.h      |    4 ++
  6 files changed, 181 insertions(+), 48 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index b75c762..7de19e3 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -248,7 +248,7 @@ void cwmp_clear_events(void)
  void cwmp_add_notification(char *parameter, char *value, char *type)
  {
      char *c = NULL;
-    external_get_action("notification", parameter, &c);
+    external_get_action_data("notification", parameter, &c);
      if (!c) return;

      struct notification *n = NULL;
diff --git a/src/external.c b/src/external.c
index 94ae9b8..4973d1a 100644
--- a/src/external.c
+++ b/src/external.c
@@ -60,14 +60,32 @@ void external_free_list_parameter()
      }
  }

-int external_get_action(char *action, char *name, char **value)
+int external_get_action_data(char *action, char *name, char **value)
+{
+    struct external_parameter *external_parameter;
+    external_get_action(action, name, NULL);
+    if (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        if (external_parameter->data)
+            *value = external_parameter->data;
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+    external_free_list_parameter();
+    return 0;
+}
+
+int external_get_action(char *action, char *name, char *arg /* arg is 
added for GetParameterNames NextLevel argument*/)
  {
      freecwmp_log_message(NAME, L_NOTICE,
                   "executing get %s '%s'\n", action, name);

-    int pfds[2];
-    if (pipe(pfds) < 0)
-        return -1;
+
+    pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);

      if ((uproc.pid = fork()) == -1)
          goto error;
@@ -79,66 +97,28 @@ int external_get_action(char *action, char *name, 
char **value)
          int i = 0;
          argv[i++] = "/bin/sh";
          argv[i++] = fc_script;
-        argv[i++] = "--newline";
-        argv[i++] = "--value";
          argv[i++] = "get";
          argv[i++] = action;
          argv[i++] = name;
+        if(arg) argv[i++] = arg;
          argv[i++] = NULL;

-        close(pfds[0]);
-        dup2(pfds[1], 1);
-        close(pfds[1]);
-
          execvp(argv[0], (char **) argv);
          exit(ESRCH);

      } else if (uproc.pid < 0)
          goto error;

-    /* parent */
-    close(pfds[1]);
-
      int status;
      while (wait(&status) != uproc.pid) {
          DD("waiting for child to exit");
      }
+    pthread_cancel(ubus_thread);
+    pthread_join(ubus_thread,NULL);

-    char buffer[64];
-    ssize_t rxed;
-    char *c;
-    int t;
-
-    *value = NULL;
-    while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
-        if (*value)
-            t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
-        else
-            t = asprintf(&c, "%.*s", (int) rxed, buffer);
-
-        if (t == -1) goto error;
-
-        free(*value);
-        *value = strdup(c);
-        free(c);
-    }
-
-    if (!strlen(*value)) {
-        FREE(*value);
-        goto done;
-    }
-
-    if (rxed < 0)
-        goto error;
-
-done:
-    close(pfds[0]);
      return 0;

  error:
-    FREE(*c);
-    FREE(*value);
-    close(pfds[0]);
      return -1;
  }

diff --git a/src/external.h b/src/external.h
index c6df2ea..8e82c39 100644
--- a/src/external.h
+++ b/src/external.h
@@ -27,7 +27,8 @@ struct external_parameter {
      char *fault_code;
  };

-int external_get_action(char *action, char *name, char **value);
+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);
diff --git a/src/ubus.c b/src/ubus.c
index 0fd1def..cbf94b0 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct 
ubus_context *ctx, struct ubus_object *
      return 0;
  }

+static enum get_param_names {
+    GET_PARAM_NAMES_PARAM,
+    GET_PARAM_NAMES_WRITABLE,
+    GET_PARAM_NAMES_FAULT,
+    __GET_PARAM_NAMES_MAX
+};
+
+static const struct blobmsg_policy get_param_names_policy[] = {
+    [GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct 
ubus_object *obj,
+            struct ubus_request_data *req, const char *method,
+            struct blob_attr *msg)
+{
+    struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
+
+    blobmsg_parse(get_param_names_policy, 
ARRAY_SIZE(get_param_names_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    if (!tb[GET_PARAM_NAMES_PARAM])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus get_parameter_names for the parameter 
%s\n",
+                 blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
+
+ external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
+            tb[GET_PARAM_NAMES_WRITABLE]? 
blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
+            NULL,
+            tb[GET_PARAM_NAMES_FAULT]? 
blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
+
+    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("get_parameter_names", 
freecwmpd_handle_get_param_names, get_param_names_policy),
  };

  static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index 612c0bb..c735244 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -51,6 +51,7 @@ static struct cwmp_namespaces
  const struct rpc_method rpc_methods[] = {
      { "SetParameterValues", xml_handle_set_parameter_values },
      { "GetParameterValues", xml_handle_get_parameter_values },
+    { "GetParameterNames", xml_handle_get_parameter_names },
      { "SetParameterAttributes", xml_handle_set_parameter_attributes },
      { "Download", xml_handle_download },
      { "FactoryReset", xml_handle_factory_reset },
@@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
          free(external_parameter->fault_code);
          free(external_parameter);
      }
-
  #ifdef ACS_MULTI
      b = mxmlFindElement(tree_out, tree_out, "ParameterList",
                  NULL, NULL, MXML_DESCEND);
@@ -736,6 +736,115 @@ out:
      return -1;
  }

+int xml_handle_get_parameter_names(mxml_node_t *body_in,
+                    mxml_node_t *tree_in,
+                    mxml_node_t *tree_out)
+{
+    mxml_node_t *n, *parameter_list, *b = body_in;
+    struct external_parameter *external_parameter;
+    char *parameter_name = NULL;
+    char *NextLevel = NULL;
+    char *c;
+    int counter = 0;
+
+    n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
+                NULL, NULL, MXML_DESCEND);
+    if (!n) return -1;
+
+    n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
+    if (!n) return -1;
+
+    n = mxmlNewElement(n, "ParameterList");
+    if (!n) return -1;
+
+#ifdef ACS_MULTI
+    mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
+#endif
+
+    while (b) {
+        if (b && b->type == MXML_TEXT &&
+            b->value.text.string &&
+            b->parent->type == MXML_ELEMENT &&
+            !strcmp(b->parent->value.element.name, "ParameterPath")) {
+            parameter_name = b->value.text.string;
+        }
+        if (b && b->type == MXML_ELEMENT && /* added in order to 
support GetParameterNames with empty ParameterPath*/
+            !strcmp(b->value.element.name, "ParameterPath") &&
+            !b->child) {
+            parameter_name = "";
+        }
+        if (b && b->type == MXML_TEXT &&
+            b->value.text.string &&
+            b->parent->type == MXML_ELEMENT &&
+            !strcmp(b->parent->value.element.name, "NextLevel")) {
+            NextLevel = b->value.text.string;
+        }
+        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+    }
+    if (parameter_name && NextLevel) {
+        if (!external_get_action("name", parameter_name, NextLevel)) {
+            // got the parameter value via external script
+        } else {
+            // error occurred when getting parameter value
+            goto out;
+        }
+    }
+
+    parameter_list = mxmlFindElement(tree_out, tree_out, 
"ParameterList", NULL, NULL, MXML_DESCEND);
+    if (!parameter_list) goto out;
+
+    while (external_list_parameter.next!=&external_list_parameter) {
+
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+
+        if (external_parameter->fault_code && 
external_parameter->fault_code[0]=='9')
+            goto out; // KMD TODO return FAULT message the fault code 
is in ->fault_code
+
+        n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
+        if (!n) goto out;
+
+        n = mxmlNewElement(n, "Name");
+        if (!n) goto out;
+
+        n = mxmlNewText(n, 0, external_parameter->name);
+        if (!n) goto out;
+
+        n = n->parent->parent;
+        n = mxmlNewElement(n, "Writable");
+        if (!n) goto out;
+
+        n = mxmlNewText(n, 0, external_parameter->data);
+        if (!n) goto out;
+
+        counter++;
+
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+
+#ifdef ACS_MULTI
+    b = mxmlFindElement(tree_out, tree_out, "ParameterList",
+                NULL, NULL, MXML_DESCEND);
+    if (!b) goto out;
+
+    if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
+        goto out;
+
+    mxmlElementSetAttr(b, "soap_enc:arrayType", c);
+    FREE(c);
+#endif
+
+    return 0;
+
+out:
+    external_free_list_parameter();
+    return -1;
+}
+
  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
                             mxml_node_t *tree_in,
                             mxml_node_t *tree_out) {
diff --git a/src/xml.h b/src/xml.h
index 8f63192..a9191eb 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -26,6 +26,10 @@ static int 
xml_handle_get_parameter_values(mxml_node_t *body_in,
                         mxml_node_t *tree_in,
                         mxml_node_t *tree_out);

+static int xml_handle_get_parameter_names(mxml_node_t *body_in,
+                       mxml_node_t *tree_in,
+                       mxml_node_t *tree_out);
+
  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
                             mxml_node_t *tree_in,
                             mxml_node_t *tree_out);
-- 
1.7.4.1


 >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


 >From dca6e0b2becaf71ed40ddacf61446bb6c5989d5e Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:27:48 +0100
Subject: [PATCH 16/27] update the script device_info in order to output 
parameters with ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info |  199 
+++++++++++++++++++++++++++--
  1 files changed, 187 insertions(+), 12 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index 86ff5c9..c3c6c33 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -2,7 +2,15 @@
  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>

  get_device_info_manufacturer() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].manufacturer 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].manufacturer 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" 
"$val"
  }

@@ -11,7 +19,15 @@ set_device_info_manufacturer() {
  }

  get_device_info_oui() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].oui 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].oui 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
  }

@@ -20,7 +36,15 @@ set_device_info_oui() {
  }

  get_device_info_product_class() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].product_class 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].product_class 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" 
"$val"
  }

@@ -29,7 +53,15 @@ set_device_info_product_class() {
  }

  get_device_info_serial_number() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].serial_number 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].serial_number 2> /dev/null`
+    ;;
+    get_name)
+    local val="0"
+    ;;
+esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" 
"$val"
  }

@@ -38,7 +70,15 @@ set_device_info_serial_number() {
  }

  get_device_info_hardware_version() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].hardware_version 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].hardware_version 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
  }

@@ -47,7 +87,15 @@ set_device_info_hardware_version() {
  }

  get_device_info_software_version() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].software_version 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].software_version 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
  }

@@ -56,17 +104,32 @@ set_device_info_software_version() {
  }

  get_device_info_uptime() {
-local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
+local val=""
+case "$action" in
+    get_value)
+    val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
  }

  get_device_info_device_log() {
  local val=""
-if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
-    val=`dmesg | tail -n1`
-else
-    val=`dmesg | tail -n10`
-fi
+case "$action" in
+    get_value)
+    if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
+        val=`dmesg | tail -n1`
+    else
+        val=`dmesg | tail -n10`
+    fi
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
  }

@@ -130,6 +193,94 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_device_info_name() {
+case "$1" in
+    InternetGatewayDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
+    if [ "$2" = "0" ]; then
+        get_device_info_manufacturer
+        get_device_info_oui
+        get_device_info_product_class
+        get_device_info_serial_number
+        get_device_info_hardware_version
+        get_device_info_software_version
+        get_device_info_uptime
+        get_device_info_device_log
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.)
+    ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
+    get_device_info_manufacturer
+    get_device_info_oui
+    get_device_info_product_class
+    get_device_info_serial_number
+    get_device_info_hardware_version
+    get_device_info_software_version
+    get_device_info_uptime
+    get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.Manufacturer)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_manufacturer
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_oui
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ProductClass)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_product_class
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SerialNumber)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_serial_number
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.HardwareVersion)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_hardware_version
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_software_version
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.UpTime)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_uptime
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.DeviceLog)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_device_info() {
  case "$1" in
      InternetGatewayDevice.DeviceInfo.Manufacturer)
@@ -179,6 +330,30 @@ get_device_info_generic() {
      return $FAULT_CPE_NO_FAULT
  }

+get_device_info_generic_name() {
+    local val=""
+    case "$1" in
+    InternetGatewayDevice.DeviceInfo.ModelName|\
+    InternetGatewayDevice.DeviceInfo.Description|\
+    InternetGatewayDevice.DeviceInfo.ModemFirmwareVersion|\
+    InternetGatewayDevice.DeviceInfo.EnabledOptions|\
+    InternetGatewayDevice.DeviceInfo.AdditionalHardwareVersion|\
+    InternetGatewayDevice.DeviceInfo.AdditionalSoftwareVersion|\
+    InternetGatewayDevice.DeviceInfo.SpecVersion|\
+    InternetGatewayDevice.DeviceInfo.FirstUseDate)
+    val="0"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ProvisioningCode)
+    val="1"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_device_info_generic() {
      check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return 0; fi

-- 
1.7.4.1


 >From 23258b38a86cbe5e03c550c8e7a1a05eabfe6776 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:30:19 +0100
Subject: [PATCH 17/27] update the script lan_device in order to output 
parameters with ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/lan_device |   98 
++++++++++++++++++++++++++++-
  1 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index fa9dda4..712b5e8 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -4,7 +4,10 @@
  get_wlan_enable() {
  local num="$1"
  local type="xsd:boolean"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-device[$num].disabled 2> /dev/null`
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-device[$num].disabled 2> /dev/null`
  let num=$num+1
  if [ "$val" = "1" ]; then
      val="0"
@@ -12,6 +15,13 @@ else
      val="1"
  fi
  ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" 
"$type"
+    ;;
+    get_name)
+    val="1"
+    let num=$num+1
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+    ;;
+esac
  }

  set_wlan_enable() {
@@ -28,9 +38,20 @@ delay_command "wifi" "wifi" "45"

  get_wlan_ssid() {
  local num="$1"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-iface[$num].ssid 2> /dev/null`
-let num=$num+1
-ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+local val=""
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-iface[$num].ssid 2> /dev/null`
+    let num=$num+1
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+    ;;
+    get_name)
+    val="1"
+    let num=$num+1
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+    ;;
+esac
+
  }

  set_wlan_ssid() {
@@ -79,6 +100,75 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_lan_device_name() {
+case "$1" in
+    InternetGatewayDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+    if [ "$2" = "0" ]; then
+        ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+        ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+        ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+        get_wlan_enable 0
+        get_wlan_ssid 0
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+    ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+    if [ "$2" = "0" ]; then
+        ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+        ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+        get_wlan_enable 0
+        get_wlan_ssid 0
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.)
+    ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+    if [ "$2" = "0" ]; then
+        ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+        get_wlan_enable 0
+        get_wlan_ssid 0
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+    if [ "$2" = "0" ]; then
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+    if [ "$2" = "0" ]; then
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wlan_enable 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_lan_device() {
  case "$1" in
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
-- 
1.7.4.1


 >From c07ba0be14b2491bc7046fc670a186ecec2fbc11 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:33:17 +0100
Subject: [PATCH 18/27] update the script management_server in order to 
output parameters with ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/config/freecwmp                     |   12 +-
  ext/openwrt/scripts/functions/lan_device        |   22 +-
  ext/openwrt/scripts/functions/management_server |  323 
++++++++++++++++++++---
  3 files changed, 307 insertions(+), 50 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 3b2b4c3..1379afd 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -29,25 +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 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 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 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 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 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 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/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 712b5e8..64910e2 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -8,13 +8,13 @@ local val=""
  case "$action" in
      get_value)
      val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-device[$num].disabled 2> /dev/null`
-let num=$num+1
-if [ "$val" = "1" ]; then
-    val="0"
-else
-    val="1"
-fi
-ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" 
"$type"
+    let num=$num+1
+    if [ "$val" = "1" ]; then
+        val="0"
+    else
+        val="1"
+    fi
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" 
"$type"
      ;;
      get_name)
      val="1"
@@ -138,16 +138,16 @@ case "$1" in
      ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
      ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
      if [ "$2" = "0" ]; then
-    get_wlan_enable 0
-    get_wlan_ssid 0
+        get_wlan_enable 0
+        get_wlan_ssid 0
      fi
      return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
      ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
      if [ "$2" = "0" ]; then
-    get_wlan_enable 0
-    get_wlan_ssid 0
+        get_wlan_enable 0
+        get_wlan_ssid 0
      fi
      return $FAULT_CPE_NO_FAULT
      ;;
diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index eca3a61..eed16d1 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -9,8 +9,16 @@ local 
hostname=`get_management_server_x_freecwmp_org__acs_hostname`
  local port=`get_management_server_x_freecwmp_org__acs_port`
  local path=`get_management_server_x_freecwmp_org__acs_path`
  FLAGS_value=$tmp
-local val=`echo $scheme://$hostname:$port$path`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+    get_value)
+    val=`echo $scheme://$hostname:$port$path`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_url() {
@@ -45,8 +53,17 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 
inform '{ "event": "value_change
  }

  get_management_server_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].username 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" 
"$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].username 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_username() {
@@ -54,8 +71,17 @@ set_management_server_username() {
  }

  get_management_server_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].password 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" 
"$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].password 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_password() {
@@ -63,9 +89,18 @@ set_management_server_password() {
  }

  get_management_server_periodic_inform_enable() {
+local val=""
+local type="xsd:boolean"
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
+case "$action" in
+    get_value)
+    freecwmp_get_parameter_value "val" "$parm"
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
  }

  set_management_server_periodic_inform_enable() {
@@ -74,9 +109,18 @@ freecwmp_set_parameter_value "$parm" "$1"
  }

  get_management_server_periodic_inform_interval() {
+local val=""
+local type="xsd:unsignedInt"
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
+case "$action" in
+    get_value)
+    freecwmp_get_parameter_value "val" "$parm"
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
  }

  set_management_server_periodic_inform_interval() {
@@ -86,26 +130,42 @@ freecwmp_set_parameter_value "$parm" "$1"

  get_management_server_connection_request_url() {
  local val
-if [ -z "$default_management_server_connection_request_url" ]; then
-    local tmp=${FLAGS_value}
-    FLAGS_value=${FLAGS_TRUE}
-    local ip=`get_wan_device_mng_interface_ip`
-    local 
port=`get_management_server_x_freecwmp_org__connection_request_port`
-    FLAGS_value=$tmp
-
-    if [ -n "$ip" -a -n "$port" ]; then
-        val="http://$ip:$port/"
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestURL"
+case "$action" in
+    get_value)
+    if [ -z "$default_management_server_connection_request_url" ]; then
+        local tmp=${FLAGS_value}
+        FLAGS_value=${FLAGS_TRUE}
+        local ip=`get_wan_device_mng_interface_ip`
+        local 
port=`get_management_server_x_freecwmp_org__connection_request_port`
+        FLAGS_value=$tmp
+
+        if [ -n "$ip" -a -n "$port" ]; then
+            val="http://$ip:$port/"
+        fi
+    else
+        val=$default_management_server_connection_request_url
      fi
-else
-    val=$default_management_server_connection_request_url
-fi
-
-ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  get_management_server_connection_request_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].username 2> /dev/null`
-ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+local val=""
+local 
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].username 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_connection_request_username() {
@@ -113,8 +173,17 @@ set_management_server_connection_request_username() {
  }

  get_management_server_connection_request_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].password 2> /dev/null`
-ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+local val=""
+local 
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].password 2> /dev/null`
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_connection_request_password() {
@@ -124,8 +193,16 @@ set_management_server_connection_request_password() {
  # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime

  get_management_server_x_freecwmp_org__acs_scheme() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].scheme 2> /dev/null`
+local val=""
  local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].scheme 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -138,8 +215,16 @@ set_management_server_x_freecwmp_org__acs_scheme() {
  }

  get_management_server_x_freecwmp_org__acs_hostname() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].hostname 2> /dev/null`
+local val=""
  local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].hostname 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -156,8 +241,16 @@ fi
  }

  get_management_server_x_freecwmp_org__acs_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].port 2> /dev/null`
+local val=""
  local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].port 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -170,8 +263,16 @@ set_management_server_x_freecwmp_org__acs_port() {
  }

  get_management_server_x_freecwmp_org__acs_path() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].path 2> /dev/null`
+local val=""
  local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].path 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -184,8 +285,16 @@ set_management_server_x_freecwmp_org__acs_path() {
  }

  get_management_server_x_freecwmp_org__connection_request_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].port 2> /dev/null`
+local val=""
  local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].port 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -287,6 +396,146 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_management_server_name() {
+case "$1" in
+    InternetGatewayDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+    if [ "$2" = "0" ]; then
+        get_management_server_url
+        get_management_server_username
+        get_management_server_password
+        get_management_server_periodic_inform_enable
+        get_management_server_periodic_inform_interval
+        get_management_server_connection_request_url
+        get_management_server_connection_request_username
+        get_management_server_connection_request_password
+        get_management_server_x_freecwmp_org__acs_scheme
+        get_management_server_x_freecwmp_org__acs_hostname
+        get_management_server_x_freecwmp_org__acs_port
+        get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.)
+    ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+    get_management_server_url
+    get_management_server_username
+    get_management_server_password
+    get_management_server_periodic_inform_enable
+    get_management_server_periodic_inform_interval
+    get_management_server_connection_request_url
+    get_management_server_connection_request_username
+    get_management_server_connection_request_password
+    get_management_server_x_freecwmp_org__acs_scheme
+    get_management_server_x_freecwmp_org__acs_hostname
+    get_management_server_x_freecwmp_org__acs_port
+    get_management_server_x_freecwmp_org__acs_path
+    get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.URL)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_url
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Username)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Password)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_periodic_inform_enable
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_periodic_inform_interval
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_connection_request_url
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_connection_request_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_connection_request_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_x_freecwmp_org__acs_scheme
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_x_freecwmp_org__acs_hostname
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_x_freecwmp_org__acs_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_x_freecwmp_org__acs_path
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.ParameterKey)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_management_server_parameter_key
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_management_server() {
  case "$1" in
      InternetGatewayDevice.ManagementServer.URL)
@@ -349,6 +598,14 @@ get_management_server_generic() {
      return $FAULT_CPE_NO_FAULT
  }

+get_management_server_generic_name() {
+    check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ 
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+    local val="1"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
+}
+
  set_management_server_generic() {
      check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ 
"$_tmp" -eq 1 ]; then return 0; fi

-- 
1.7.4.1


 >From 56c0be1075a4964dfb83ffdc093acaa27d209550 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:40:47 +0100
Subject: [PATCH 19/27] update the script wan_device in order to output 
parameters with ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/freecwmp.sh          |  127 +++++++++---------
  ext/openwrt/scripts/functions/wan_device |  223 
+++++++++++++++++++++++++++---
  src/freecwmp.c                           |    2 +-
  3 files changed, 267 insertions(+), 85 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh 
b/ext/openwrt/scripts/freecwmp.sh
index c5a0d53..a2f2bc1 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -1,5 +1,6 @@
  #!/bin/sh
  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

  . /lib/functions.sh
  . /usr/share/libubox/jshn.sh
@@ -68,10 +69,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" = "name" ]; then
+            __arg1="$3"
+            __arg2=`echo $4| tr '[A-Z]' '[a-z]'`
+            action="get_name"
          elif [ "$2" = "all" ]; then
              __arg1="$3"
              action="get_all"
@@ -111,7 +112,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 get_name_functions "$section" "get_name_function"
      config_get set_value_functions "$section" "set_value_function"
  }

@@ -142,16 +143,57 @@ FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
  FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"

  if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
-    no_fault="0"
-    freecwmp_check_fault "$__arg1"
-    fault_code="$?"
-    if [ "$fault_code" = "0" ]; then
-        if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" 
= "" \) ]; then
-            __arg1="InternetGatewayDevice."
+    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 $get_value_functions
+        do
+            $function_name "$__arg1"
+            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
-    for function_name in $get_value_functions
-    do
-        $function_name "$__arg1"
+    if [ "$fault_code" != "0" ]; then
+        let fault_code=$fault_code+9000
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    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"
@@ -159,55 +201,14 @@ if [ "$action" = "get_value" -o "$action" = 
"get_all" ]; then
                  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
-        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
-    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
+            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
diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index a8b6361..9c7cd14 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -1,20 +1,38 @@
  #!/bin/sh
  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

  get_wan_device_mng_status() {
  # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; 
Disconneting ; Disconnected
-local val="Connected"
-ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" 
"$val" "xsd:boolean"
+local val=""
+local type="xsd:boolean"
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
+case "$action" in
+    get_value)
+    val="Connected"
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
  }

  get_wan_device_mng_interface_ip() {
-local val
+local val=""
  local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
-if [ -z "$default_wan_device_mng_interface_ip" ]; then
-    val=`network_get_ipaddr val mng`
-else
-    val=$default_wan_device_mng_interface_ip
-fi
+case "$action" in
+    get_value)
+    if [ -z "$default_wan_device_mng_interface_ip" ]; then
+        val=`network_get_ipaddr val mng`
+    else
+        val=$default_wan_device_mng_interface_ip
+    fi
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -25,11 +43,18 @@ fi
  get_wan_device_mng_interface_mac() {
  local val=""
  local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
-if [ -z "$default_wan_device_mng_interface_mac" ]; then
-    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.mng.macaddr`
-else
-    val=$default_wan_device_mng_interface_mac
-fi
+case "$action" in
+    get_value)
+    if [ -z "$default_wan_device_mng_interface_mac" ]; then
+        val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.mng.macaddr`
+    else
+        val=$default_wan_device_mng_interface_mac
+    fi
+    ;;
+    get_name)
+    val="0"
+    ;;
+esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
  else
@@ -38,11 +63,21 @@ fi
  }

  get_wan_device_wan_ppp_enable() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.auto 2> /dev/null`
-if [ -z $val ]; then
+local val=""
+local type="xsd:boolean"
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.auto 2> /dev/null`
+    if [ -z $val ]; then
+        val="1"
+    fi
+    ;;
+    get_name)
      val="1"
-fi
-ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" 
"$val" "xsd:boolean"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
  }

  set_wan_device_wan_ppp_enable() {
@@ -57,8 +92,17 @@ fi
  }

  get_wan_device_wan_ppp_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.username 2> /dev/null`
-ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" 
"$val"
+local val=""
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.username 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_wan_device_wan_ppp_username() {
@@ -67,8 +111,16 @@ set_wan_device_wan_ppp_username() {

  get_wan_device_wan_ppp_password() {
  local val=""
-val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.password 2> /dev/null`
-ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" 
"$val"
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case "$action" in
+    get_value)
+    val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.password 2> /dev/null`
+    ;;
+    get_name)
+    val="1"
+    ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
  }

  set_wan_device_wan_ppp_password() {
@@ -162,6 +214,135 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_wan_device_name() {
+case "$1" in
+    InternetGatewayDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+    if [ "$2" = "0" ]; then
+        get_wan_device_mng_status
+        get_wan_device_mng_interface_ip
+        get_wan_device_mng_interface_mac
+        get_wan_device_wan_ppp_enable
+        get_wan_device_wan_ppp_username
+        get_wan_device_wan_ppp_password
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.)
+    ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+    ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+    if [ "$2" = "0" ]; then
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.)
+    ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+    if [ "$2" = "0" ]; then
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+    if [ "$2" = "0" ]; then
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." 
"1"
+    if [ "$2" = "0" ]; then
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." 
"1"
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." 
"1"
+    if [ "$2" = "0" ]; then
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    fi
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+    ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." 
"1"
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_mng_status
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_mng_interface_ip
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_wan_ppp_enable
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_wan_ppp_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+    if [ "$2" = "1" ]; then
+        return $FAULT_CPE_INVALID_ARGUMENTS
+    fi
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_wan_device() {
  case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
diff --git a/src/freecwmp.c b/src/freecwmp.c
index f4c9cb1..eb2783c 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -197,7 +197,7 @@ netlink_init(void)

  void signal_kill_all_handler(int sig)
  {
-     pthread_exit(NULL);
+    pthread_exit(NULL);
  }


-- 
1.7.4.1


 >From 845c72048d1986a27482f97dd2d157068533023c Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:48:25 +0100
Subject: [PATCH 20/27] update the get notification in order to put the 
returned data via ubus instead of pipe
   TODO: develop the xml handle message to perform send of 
GetParameterAttributeResponse
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/config/freecwmp          |    6 ++++
  ext/openwrt/scripts/freecwmp.sh      |   27 +++++++++++++++++++-
  ext/openwrt/scripts/functions/common |   21 +++++++++++++++-
  src/ubus.c                           |   43 
++++++++++++++++++++++++++++++++++
  4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 1379afd..1f72c27 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -30,24 +30,30 @@ config scripts
      list location /usr/share/freecwmp/functions/device_info
      list get_value_function get_device_info
      list get_name_function get_device_info_name
+    list get_notification_function get_device_info_notification
      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 get_notification_function get_device_info_generic_notification
      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 get_notification_function get_lan_device_notification
      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 get_notification_function get_management_server_notification
      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 get_notification_function 
get_management_server_generic_notification
      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 get_notification_function get_wan_device_notification
      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 a2f2bc1..02a923e 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,6 +113,7 @@ handle_scripts() {
      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 get_notification_functions "$section" 
"get_notification_function"
      config_get set_value_functions "$section" "set_value_function"
  }

@@ -219,8 +220,30 @@ if [ "$action" = "set_value" ]; then
  fi

  if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
-    freecwmp_get_parameter_notification "x_notification" "$__arg1"
-    freecwmp_notification_output "$__arg1" "$x_notification"
+    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 $get_notification_functions
+        do
+            $function_name "$__arg1"
+            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
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    fi
  fi

  if [ "$action" = "set_notification" ]; then
diff --git a/ext/openwrt/scripts/functions/common 
b/ext/openwrt/scripts/functions/common
index abba220..fd98a01 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -51,7 +51,9 @@ case "$action" in
      get_name)
      ubus call tr069 get_parameter_names '{"parameter": "'$parameter'", 
"writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
      ;;
-
+    get_notification)
+    ubus call tr069 get_parameter_attributes '{"parameter": 
"'$parameter'", "notification": "'$value'", 
"fault_code":"'$fault_code'"}' 2> /dev/null
+    ;;
  esac
  }
  freecwmp_value_output() {
@@ -151,6 +153,9 @@ freecwmp_config_notifications() {
          if [ "$item" = "$3" ]; then
              eval "export -- \"$4=2\""
              return 0
+        elif [ "`echo $3|grep $item`" = "$3" ]; then
+            eval "export -- \"$4=2\""
+            return 0
          fi
      done
      for item in $__passive
@@ -158,6 +163,9 @@ freecwmp_config_notifications() {
          if [ "$item" = "$3" ]; then
              eval "export -- \"$4=1\""
              return 0
+        elif [ "`echo $3|grep $item`" = "$3" ]; then
+            eval "export -- \"$4=1\""
+            return 0
          fi
      done
  }
@@ -193,7 +201,18 @@ freecwmp_get_parameter_notification() {
      local _dest="$1"
      local _parm="$2"
      local _val
+    local _parent
      config_foreach freecwmp_config_notifications "notifications" "get" 
"$_parm" "_val"
+    if [ "$_val" = "" ]; then
+        if [ "`echo $_parm|grep '\.$'`" = "" ]; then
+            _parent="${_parm%.*}."
+            config_foreach freecwmp_config_notifications 
"notifications" "get" "$_parent" "_val"
+        else
+            _parent="${_parm%.*.}."
+            config_foreach freecwmp_config_notifications 
"notifications" "get" "$_parent" "_val"
+        fi
+    fi
+    if [ "$_val" = "" ];then _val="0" ;fi
      eval "export -- \"$_dest=$_val\""
  }

diff --git a/src/ubus.c b/src/ubus.c
index cbf94b0..072b2a1 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -5,6 +5,7 @@
   *    (at your option) any later version.
   *
   *    Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+ *    Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
   */

  #include <unistd.h>
@@ -239,12 +240,54 @@ freecwmpd_handle_get_param_names(struct 
ubus_context *ctx, struct ubus_object *o
      return 0;
  }

+static enum get_param_attributes {
+    GET_PARAM_ATTRIBUTES_PARAM,
+    GET_PARAM_ATTRIBUTES_NOTIF,
+    GET_PARAM_ATTRIBUTES_FAULT,
+    __GET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy get_param_attributes_policy[] = {
+    [GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct 
ubus_object *obj,
+            struct ubus_request_data *req, const char *method,
+            struct blob_attr *msg)
+{
+    struct blob_attr *tb[__GET_PARAM_ATTRIBUTES_MAX];
+
+    blobmsg_parse(get_param_attributes_policy, 
ARRAY_SIZE(get_param_attributes_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus get_parameter_attributes for the 
parameter %s\n",
+                 blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
+
+ 
external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
+                      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
+                      NULL,
+ blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
+
+    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("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),
  };

  static struct ubus_object_type main_object_type =
-- 
1.7.4.1


 >From c05e7e39bb9573bdfaeb58af08165746b238ba12 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:54:48 +0100
Subject: [PATCH 21/27] update the data model parameter scripts in order 
to output parameter and notification values via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info       |   94 +++++++++++++++
  ext/openwrt/scripts/functions/lan_device        |   50 ++++++++
  ext/openwrt/scripts/functions/management_server |  143 
+++++++++++++++++++++++
  ext/openwrt/scripts/functions/wan_device        |  105 +++++++++++++++++
  4 files changed, 392 insertions(+), 0 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index c3c6c33..2be20b5 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -1,5 +1,6 @@
  #!/bin/sh
  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

  get_device_info_manufacturer() {
  local val=""
@@ -10,6 +11,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.Manufacturer"
+    ;;
  esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" 
"$val"
  }
@@ -27,6 +31,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+    ;;
  esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
  }
@@ -44,6 +51,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.ProductClass"
+    ;;
  esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" 
"$val"
  }
@@ -61,6 +71,9 @@ case "$action" in
      get_name)
      local val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.SerialNumber"
+    ;;
  esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" 
"$val"
  }
@@ -78,6 +91,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.HardwareVersion"
+    ;;
  esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
  }
@@ -95,6 +111,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+    ;;
  esac
  ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
  }
@@ -112,6 +131,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.UpTime"
+    ;;
  esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
  }
@@ -129,6 +151,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.DeviceInfo.DeviceLog"
+    ;;
  esac
  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
  }
@@ -281,6 +306,66 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_device_info_notification() {
+case "$1" in
+    InternetGatewayDevice.)
+    get_device_info_manufacturer
+    get_device_info_oui
+    get_device_info_product_class
+    get_device_info_serial_number
+    get_device_info_hardware_version
+    get_device_info_software_version
+    get_device_info_uptime
+    get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.)
+    get_device_info_manufacturer
+    get_device_info_oui
+    get_device_info_product_class
+    get_device_info_serial_number
+    get_device_info_hardware_version
+    get_device_info_software_version
+    get_device_info_uptime
+    get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.Manufacturer)
+    get_device_info_manufacturer
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+    get_device_info_oui
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ProductClass)
+    get_device_info_product_class
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SerialNumber)
+    get_device_info_serial_number
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.HardwareVersion)
+    get_device_info_hardware_version
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+    get_device_info_software_version
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.UpTime)
+    get_device_info_uptime
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.DeviceLog)
+    get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_device_info() {
  case "$1" in
      InternetGatewayDevice.DeviceInfo.Manufacturer)
@@ -354,6 +439,15 @@ get_device_info_generic_name() {
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_device_info_generic_notification() {
+    check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+    local val
+    freecwmp_get_parameter_notification "val" "$1"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
+}
+
  set_device_info_generic() {
      check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return 0; fi

diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 64910e2..949f11c 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -1,5 +1,6 @@
  #!/bin/sh
  # Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

  get_wlan_enable() {
  local num="$1"
@@ -21,6 +22,11 @@ case "$action" in
      let num=$num+1
      ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
      ;;
+    get_notification)
+    let num=$num+1
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+    ;;
  esac
  }

@@ -50,6 +56,11 @@ case "$action" in
      let num=$num+1
      ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
      ;;
+    get_notification)
+    let num=$num+1
+    freecwmp_get_parameter_notification "val" 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+    ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+    ;;
  esac

  }
@@ -169,6 +180,45 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_lan_device_notification() {
+case "$1" in
+    InternetGatewayDevice.)
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.)
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.)
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+    get_wlan_enable 0
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+    get_wlan_enable 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+    get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_lan_device() {
  case "$1" in
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index eed16d1..b1e759d 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -1,5 +1,6 @@
  #!/bin/sh
  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

  get_management_server_url() {
  local tmp=${FLAGS_value}
@@ -17,6 +18,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -62,6 +66,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -80,6 +87,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -99,6 +109,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val" "$type"
  }
@@ -119,6 +132,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val" "$type"
  }
@@ -150,6 +166,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -164,6 +183,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -182,6 +204,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -202,6 +227,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -224,6 +252,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -250,6 +281,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -272,6 +306,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -294,6 +331,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -536,6 +576,100 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_management_server_notification() {
+case "$1" in
+    InternetGatewayDevice.)
+    get_management_server_url
+    get_management_server_username
+    get_management_server_password
+    get_management_server_periodic_inform_enable
+    get_management_server_periodic_inform_interval
+    get_management_server_connection_request_url
+    get_management_server_connection_request_username
+    get_management_server_connection_request_password
+    get_management_server_x_freecwmp_org__acs_scheme
+    get_management_server_x_freecwmp_org__acs_hostname
+    get_management_server_x_freecwmp_org__acs_port
+    get_management_server_x_freecwmp_org__acs_path
+    get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.)
+    get_management_server_url
+    get_management_server_username
+    get_management_server_password
+    get_management_server_periodic_inform_enable
+    get_management_server_periodic_inform_interval
+    get_management_server_connection_request_url
+    get_management_server_connection_request_username
+    get_management_server_connection_request_password
+    get_management_server_x_freecwmp_org__acs_scheme
+    get_management_server_x_freecwmp_org__acs_hostname
+    get_management_server_x_freecwmp_org__acs_port
+    get_management_server_x_freecwmp_org__acs_path
+    get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.URL)
+    get_management_server_url
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Username)
+    get_management_server_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Password)
+    get_management_server_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+    get_management_server_periodic_inform_enable
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+    get_management_server_periodic_inform_interval
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+    get_management_server_connection_request_url
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+    get_management_server_connection_request_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+    get_management_server_connection_request_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+    get_management_server_x_freecwmp_org__acs_scheme
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+    get_management_server_x_freecwmp_org__acs_hostname
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+    get_management_server_x_freecwmp_org__acs_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+    get_management_server_x_freecwmp_org__acs_path
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+    get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.ParameterKey)
+    get_management_server_parameter_key
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_management_server() {
  case "$1" in
      InternetGatewayDevice.ManagementServer.URL)
@@ -606,6 +740,15 @@ get_management_server_generic_name() {
      return $FAULT_CPE_NO_FAULT
  }

+get_management_server_generic_notification() {
+    check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ 
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+    local val
+    freecwmp_get_parameter_notification "val" "$1"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
+}
+
  set_management_server_generic() {
      check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ 
"$_tmp" -eq 1 ]; then return 0; fi

diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index 9c7cd14..02ba365 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -14,6 +14,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val" "$type"
  }
@@ -32,6 +35,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -54,6 +60,9 @@ case "$action" in
      get_name)
      val="0"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
      ubus_freecwmp_output "$parm" "$val"
@@ -76,6 +85,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val" "$type"
  }
@@ -101,6 +113,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -119,6 +134,9 @@ case "$action" in
      get_name)
      val="1"
      ;;
+    get_notification)
+    freecwmp_get_parameter_notification "val" "$parm"
+    ;;
  esac
  ubus_freecwmp_output "$parm" "$val"
  }
@@ -343,6 +361,93 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+get_wan_device_notification() {
+case "$1" in
+    InternetGatewayDevice.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    get_wan_device_wan_ppp_enable
+    get_wan_device_wan_ppp_username
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+    get_wan_device_mng_status
+    get_wan_device_mng_interface_ip
+    get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+    get_wan_device_mng_status
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+    get_wan_device_mng_interface_ip
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+    get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+    get_wan_device_wan_ppp_enable
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+    get_wan_device_wan_ppp_username
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+    get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  set_wan_device() {
  case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
-- 
1.7.4.1


 >From 88b4d1d784e713e59455079dca11a7548fee2f4b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:59:55 +0100
Subject: [PATCH 22/27] update xml handler set parameter values in order 
to execute external command and get response via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/external.c |   36 ++++++++++++++++++++++++++-
  src/external.h |    5 +++-
  src/ubus.c     |   73 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  src/xml.c      |   25 +++++++++++++-----
  4 files changed, 130 insertions(+), 9 deletions(-)

diff --git a/src/external.c b/src/external.c
index 4973d1a..7eec751 100644
--- a/src/external.c
+++ b/src/external.c
@@ -5,6 +5,7 @@
   *    (at your option) any later version.
   *
   *    Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *    Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
   */

  #include <errno.h>
@@ -27,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)
  {
@@ -60,6 +63,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;
@@ -229,9 +244,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)
  {
      freecwmp_log_message(NAME, L_NOTICE, "executing set script\n");
+    FILE *fp;
+
+    if (access(fc_script_set_actions, R_OK | W_OK | F_OK) == -1)
+        return -1;
+
+    fp = fopen(fc_script_set_actions, "a");
+    if (!fp) return -1;
+
+#ifdef DUMMY_MODE
+    fprintf(fp, "/bin/sh `pwd`/%s apply %s\n", fc_script, action);
+#else
+    fprintf(fp, "/bin/sh %s 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;
@@ -258,6 +289,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_set_actions) != 0)
diff --git a/src/external.h b/src/external.h
index 8e82c39..77165ee 100644
--- a/src/external.h
+++ b/src/external.h
@@ -5,6 +5,7 @@
   *    (at your option) any later version.
   *
   *    Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *    Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
   */

  #ifndef _FREECWMP_EXTERNAL_H__
@@ -27,12 +28,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 072b2a1..e852ed4 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,11 +281,84 @@ 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;
+
+
+    freecwmp_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;
+
+
+    freecwmp_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 c735244..a8f82c7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -578,6 +578,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 &&
@@ -602,25 +603,35 @@ 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 KMD add here check for fault return from ubus
+
+    external_fetch_set_param_val_resp_status(&status);
+    if(!status) return -1; //TODO KMD return a fault message here
+
      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,
@@ -899,7 +910,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


 >From a9c1843214b8f281e1df7136bf989f3d07e5e7bc Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:03:15 +0100
Subject: [PATCH 23/27] update common script and freecwmp.sh script in 
order to have the functions for set parameter values working with ubus
    Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/freecwmp.sh      |   58 
+++++++++++++++++++++++++++++++--
  ext/openwrt/scripts/functions/common |   20 ++++++++++++
  2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh 
b/ext/openwrt/scripts/freecwmp.sh
index 02a923e..54c0924 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -90,6 +90,15 @@ case "$1" in
      reboot)
          action="reboot"
          ;;
+    apply)
+        if [ "$2" = "notification" ]; then
+            action="apply_notification"
+        elif [ "$2" = "value" ]; then
+            action="apply_value"
+        else
+            action="apply_value"
+        fi
+        ;;
  esac

  if [ -z "$action" ]; then
@@ -213,10 +222,30 @@ 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
+    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_value_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_notification" -o "$action" = "get_all" ]; then
@@ -295,6 +324,27 @@ if [ "$action" = "reboot" ]; then
      fi
  fi

+if [ \( "$action" = "apply_notification" \) -o \( "$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 call tr069 
set_parameter_values_status '{"status": "0"}'; fi
+    else
+        let n=$__fault_count-1
+        for i in `seq 0 $n`
+        do
+            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"
+        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 fd98a01..f701eb9 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -56,6 +56,16 @@ case "$action" in
      ;;
  esac
  }
+
+ubus_freecwmp_fault_output() {
+local parameter="$1"
+local fault_code="$2"
+case "$action" in
+    apply_value)
+    ubus call tr069 set_parameter_values_fault '{"parameter": 
"'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null
+    ;;
+esac
+}
  freecwmp_value_output() {
      freecwmp_output "$1" "$2" "V"
  }
@@ -295,3 +305,13 @@ if [ "$1" = "." ]; then
  fi
  return $FAULT_CPE_NO_FAULT
  }
+
+freecwmp_set_parameter_fault() {
+    local _parm="$1"
+    local _fault="$2"
+        /sbin/uci -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
+}
-- 
1.7.4.1


 >From 329db01dec815e97e2a7e081f1f21a5b88499467 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:22:09 +0100
Subject: [PATCH 24/27] update dm script to send the output of set 
parameter function to the ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info       |   62 +++++++-
  ext/openwrt/scripts/functions/lan_device        |   33 +++--
  ext/openwrt/scripts/functions/management_server |  178 
+++++++++++++++++------
  ext/openwrt/scripts/functions/wan_device        |   41 ++++--
  4 files changed, 238 insertions(+), 76 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index 2be20b5..5fe2823 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -19,7 +19,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
  }

  set_device_info_manufacturer() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].manufacturer="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.Manufacturer"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].manufacturer="$val"
+    ;;
+esac
  }

  get_device_info_oui() {
@@ -39,7 +45,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
  }

  set_device_info_oui() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].oui="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].oui="$val"
+    ;;
+esac
  }

  get_device_info_product_class() {
@@ -59,7 +71,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
  }

  set_device_info_product_class() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].product_class="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ProductClass"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].product_class="$val"
+    ;;
+esac
  }

  get_device_info_serial_number() {
@@ -79,7 +97,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
  }

  set_device_info_serial_number() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].serial_number="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SerialNumber"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].serial_number="$val"
+    ;;
+esac
  }

  get_device_info_hardware_version() {
@@ -99,7 +123,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
  }

  set_device_info_hardware_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].hardware_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.HardwareVersion"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].hardware_version="$val"
+    ;;
+esac
  }

  get_device_info_software_version() {
@@ -119,7 +149,13 @@ ubus_freecwmp_output 
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
  }

  set_device_info_software_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].software_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].software_version="$val"
+    ;;
+esac
  }

  get_device_info_uptime() {
@@ -370,24 +406,31 @@ set_device_info() {
  case "$1" in
      InternetGatewayDevice.DeviceInfo.Manufacturer)
      set_device_info_manufacturer "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
      set_device_info_oui "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ProductClass)
      set_device_info_product_class "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SerialNumber)
      set_device_info_serial_number "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.HardwareVersion)
      set_device_info_hardware_version "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SoftwareVersion)
      set_device_info_software_version "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
  }

  check_parameter_device_info_generic() {
@@ -449,8 +492,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_set_parameter_value "$1" "$2"
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    return $FAULT_CPE_NO_FAULT
  }
diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 949f11c..db90021 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -33,13 +33,18 @@ esac
  set_wlan_enable() {
  local num="$1"
  local val="$2"
-if [ "$val" = "1" ]; then
-    val="0"
-else
-    val="1"
-fi
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-device[$num].disabled="$val"
+local 
parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+case $action in
+    set_value)
+    if [ "$val" = "1" ]; then
+        val="0"
+    else
+        val="1"
+    fi
+    delay_command "wifi" "wifi" "45"
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-device[$num].disabled="$val"
+    ;;
+esac
  }

  get_wlan_ssid() {
@@ -68,8 +73,13 @@ esac
  set_wlan_ssid() {
  local num="$1"
  local val="$2"
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-iface[$num].ssid="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+case $action in
+    set_value)
+    delay_command "wifi" "wifi" "45"
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-iface[$num].ssid="$val"
+    ;;
+esac
  }

  get_lan_device() {
@@ -223,10 +233,13 @@ set_lan_device() {
  case "$1" in
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
      set_wlan_enable 0 "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
      set_wlan_ssid 0 "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
  }
diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index b1e759d..37b1cb0 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -26,34 +26,39 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_url() {
-local url=$1
-local scheme
-local hostname
-local path
-local port
-
-scheme=`echo $url | awk -F "://" '{ print $1 }'`
-hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" 
'{ print $1 }' | awk -F "/" '{ print $1 }'`
-port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F 
'/' '{ print $1 }'`
-
-if [ -z "$port" ]; then
-    port=80
-    path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
-    echo 123 $path
-else
-    path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
-fi
-
-if [ -z "$path" ]; then
-    path="/"
-fi
-
-set_management_server_x_freecwmp_org__acs_scheme $scheme
-set_management_server_x_freecwmp_org__acs_hostname $hostname
-set_management_server_x_freecwmp_org__acs_port $port
-set_management_server_x_freecwmp_org__acs_path $path
-
-ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": 
"value_change" }' &
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+    set_value)
+    local url=$1
+    local scheme
+    local hostname
+    local path
+    local port
+
+    scheme=`echo $url | awk -F "://" '{ print $1 }'`
+    hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F 
":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
+    port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | 
awk -F '/' '{ print $1 }'`
+
+    if [ -z "$port" ]; then
+        port=80
+        path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
+        echo 123 $path
+    else
+        path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print 
$2 }'`
+    fi
+
+    if [ -z "$path" ]; then
+        path="/"
+    fi
+
+    set_management_server_x_freecwmp_org__acs_scheme $scheme
+    set_management_server_x_freecwmp_org__acs_hostname $hostname
+    set_management_server_x_freecwmp_org__acs_port $port
+    set_management_server_x_freecwmp_org__acs_path $path
+
+    ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": 
"value_change" }' &
+    ;;
+esac
  }

  get_management_server_username() {
@@ -74,7 +79,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].username="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].username="$val"
+    ;;
+esac
  }

  get_management_server_password() {
@@ -95,7 +106,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].password="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].password="$val"
+    ;;
+esac
  }

  get_management_server_periodic_inform_enable() {
@@ -117,8 +134,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
  }

  set_management_server_periodic_inform_enable() {
+local val=$1
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+    set_value)
+    freecwmp_set_parameter_value "$parm" "$val"
+    ;;
+esac
  }

  get_management_server_periodic_inform_interval() {
@@ -140,8 +162,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
  }

  set_management_server_periodic_inform_interval() {
+local val=$1
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+    set_value)
+    freecwmp_set_parameter_value "$parm" "$val"
+    ;;
+esac
  }

  get_management_server_connection_request_url() {
@@ -191,7 +218,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_connection_request_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].username="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].username="$val"
+    ;;
+esac
  }

  get_management_server_connection_request_password() {
@@ -212,7 +245,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_management_server_connection_request_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].password="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].password="$val"
+    ;;
+esac
  }

  # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
@@ -239,7 +278,13 @@ fi
  }

  set_management_server_x_freecwmp_org__acs_scheme() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].scheme="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].scheme="$val"
+    ;;
+esac
  }

  get_management_server_x_freecwmp_org__acs_hostname() {
@@ -264,11 +309,17 @@ fi
  }

  set_management_server_x_freecwmp_org__acs_hostname() {
-if [ -z "$default_management_server_acs_hostname" ]; then
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].hostname="$1"
-else
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
-fi
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+    set_value)
+    if [ -z "$default_management_server_acs_hostname" ]; then
+            /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].hostname="$val"
+    else
+        /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
+    fi
+    ;;
+esac
  }

  get_management_server_x_freecwmp_org__acs_port() {
@@ -293,7 +344,13 @@ fi
  }

  set_management_server_x_freecwmp_org__acs_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].port="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].port="$val"
+    ;;
+esac
  }

  get_management_server_x_freecwmp_org__acs_path() {
@@ -318,7 +375,13 @@ fi
  }

  set_management_server_x_freecwmp_org__acs_path() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].path="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].path="$val"
+    ;;
+esac
  }

  get_management_server_x_freecwmp_org__connection_request_port() {
@@ -343,7 +406,13 @@ fi
  }

  set_management_server_x_freecwmp_org__connection_request_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].port="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].port="$val"
+    ;;
+esac
  }

  get_management_server() {
@@ -674,45 +743,59 @@ set_management_server() {
  case "$1" in
      InternetGatewayDevice.ManagementServer.URL)
      set_management_server_url "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Username)
      set_management_server_username "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Password)
      set_management_server_password "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
      set_management_server_periodic_inform_enable "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
      set_management_server_periodic_inform_interval "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
      set_management_server_connection_request_url "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
      set_management_server_connection_request_username "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
      set_management_server_connection_request_password "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
      set_management_server_x_freecwmp_org__acs_scheme "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
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 $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
      set_management_server_x_freecwmp_org__acs_port "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
      set_management_server_x_freecwmp_org__acs_path "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
      set_management_server_x_freecwmp_org__connection_request_port "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  check_parameter_management_server_generic() {
@@ -750,8 +833,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_set_parameter_value "$1" "$2"
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    return $FAULT_CPE_NO_FAULT
  }
diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index 02ba365..c8f1887 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -94,13 +94,18 @@ ubus_freecwmp_output "$parm" "$val" "$type"

  set_wan_device_wan_ppp_enable() {
  local val=$1
-if [ "$val" -eq 0 ]; then
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
-    ifdown wan &
-elif [ "$val" -eq 1 ]; then
-    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
-    ifup wan &
-fi
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case $action in
+    set_value)
+    if [ "$val" -eq 0 ]; then
+        /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.auto=0
+        ifdown wan &
+    elif [ "$val" -eq 1 ]; then
+        /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.auto=1
+        ifup wan &
+    fi
+    ;;
+esac
  }

  get_wan_device_wan_ppp_username() {
@@ -121,7 +126,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_wan_device_wan_ppp_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.username="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case $action in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.username="$val"
+    ;;
+esac
  }

  get_wan_device_wan_ppp_password() {
@@ -142,7 +153,13 @@ ubus_freecwmp_output "$parm" "$val"
  }

  set_wan_device_wan_ppp_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.password="$1"
+local val=$1
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case $action in
+    set_value)
+    /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.password="$1"
+    ;;
+esac
  }

  get_wan_device() {
@@ -452,13 +469,17 @@ set_wan_device() {
  case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
      set_wan_device_wan_ppp_enable "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
      set_wan_device_wan_ppp_username "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
      set_wan_device_wan_ppp_password "$2"
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
-- 
1.7.4.1


 >From 873f6809f16148a6371362717918f8e79ce19a0b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:28:48 +0100
Subject: [PATCH 25/27] add ubus listner for set parameter attribute
    Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/external.c |   16 ++++++++++++++++
  src/external.h |    2 ++
  src/ubus.c     |   31 +++++++++++++++++++++++++++++++
  src/xml.c      |   20 +++++++++++++++++---
  4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/src/external.c b/src/external.c
index 7eec751..a033781 100644
--- a/src/external.c
+++ b/src/external.c
@@ -75,6 +75,22 @@ void external_fetch_set_param_val_resp_status(char 
**status)
      external_method_status = NULL;
  }

+void external_set_param_attr_resp (char *status, char *fault)
+{
+    free(external_method_status);
+    external_method_status = status ? strdup(status) : NULL;
+    free(external_method_fault);
+    external_method_fault = fault ? strdup(fault) : NULL;
+}
+
+void external_fetch_set_param_attr_resp (char **status, char **fault)
+{
+    *status = external_method_status;
+    external_method_status = NULL;
+    *fault = external_method_fault;
+    external_method_fault = NULL;
+}
+
  int external_get_action_data(char *action, char *name, char **value)
  {
      struct external_parameter *external_parameter;
diff --git a/src/external.h b/src/external.h
index 77165ee..489d215 100644
--- a/src/external.h
+++ b/src/external.h
@@ -30,6 +30,8 @@ struct external_parameter {

  void external_set_param_val_resp_status (char *status);
  void external_fetch_set_param_val_resp_status (char **status);
+void external_set_param_attr_resp (char *status, char *fault);
+void external_fetch_set_param_attr_resp (char **status, char **fault);
  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);
diff --git a/src/ubus.c b/src/ubus.c
index e852ed4..8502805 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,6 +281,36 @@ freecwmpd_handle_get_param_attributes(struct 
ubus_context *ctx, struct ubus_obje
      return 0;
  }

+static enum set_param_attributes {
+    SET_PARAM_ATTRIBUTES_SUCCESS,
+    SET_PARAM_ATTRIBUTES_FAULT,
+    __SET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy set_param_attributes_policy[] = {
+        [SET_PARAM_ATTRIBUTES_SUCCESS] = { .name = "success", .type = 
BLOBMSG_TYPE_STRING },
+    [SET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_attributes(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_ATTRIBUTES_MAX];
+
+    blobmsg_parse(set_param_attributes_policy, 
ARRAY_SIZE(set_param_attributes_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus set_parameter_attributes\n");
+
+    external_set_param_attr_resp(tb[SET_PARAM_ATTRIBUTES_SUCCESS] ? 
blobmsg_data(tb[SET_PARAM_ATTRIBUTES_SUCCESS]) : NULL,
+            tb[SET_PARAM_ATTRIBUTES_FAULT] ? 
blobmsg_data(tb[SET_PARAM_ATTRIBUTES_FAULT]) : NULL);
+
+    return 0;
+}
+
  static enum set_param_values_fault {
      SET_PARAM_VALUES_FAULT_PARAM,
      SET_PARAM_VALUES_FAULT__FAULT,
@@ -361,6 +391,7 @@ static const struct ubus_method freecwmp_methods[] = {
      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),
+    UBUS_METHOD("set_parameter_attributes", 
freecwmpd_handle_set_param_attributes, set_param_attributes_policy),
  };

  static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index a8f82c7..e46c50c 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -6,6 +6,7 @@
   *
   *    Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
   *    Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
+ *  Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
   */

  #include <stdbool.h>
@@ -861,7 +862,7 @@ static int 
xml_handle_set_parameter_attributes(mxml_node_t *body_in,
                             mxml_node_t *tree_out) {

      mxml_node_t *n, *b = body_in;
-    char *c, *parameter_name, *parameter_notification;
+    char *c, *parameter_name, *parameter_notification, *success=NULL, 
*fault=NULL;
      uint8_t attr_notification_update;

      /* handle cwmp:SetParameterAttributes */
@@ -913,15 +914,28 @@ static int 
xml_handle_set_parameter_attributes(mxml_node_t *body_in,
      if (external_set_action_execute("notification"))
          return -1;

+    external_fetch_set_param_attr_resp(&success, &fault);
+
+    if (fault && fault[0]=='9') goto error; //TODO KMD return a fault 
message here with fault indicated in the fault string
+
+    if(!success) goto error; //TODO KMD return a fault message here
+
      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:SetParameterAttributesResponse");
-    if (!b) return -1;
+    if (!b) goto error;

      config_load();

+    free(success);
+    free(fault);
      return 0;
+
+error:
+    free(success);
+    free(fault);
+    return -1;
  }

  static int xml_handle_download(mxml_node_t *body_in,
-- 
1.7.4.1


 >From c638d7c256a7c08c4c66a8bc5564a4b6d72b145d Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:32:09 +0100
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


Signed-off-by: Mohamed <mohamed.kallel@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


 >From 88706661923710a0c775178b106eb40c6cdccb1f Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:38:00 +0100
Subject: [PATCH 27/27] update the dm script function to communicate the 
output of set parameter attribute with ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info       |   61 +++++++++++++
  ext/openwrt/scripts/functions/lan_device        |   30 ++++++
  ext/openwrt/scripts/functions/management_server |  108 
+++++++++++++++++++++++
  ext/openwrt/scripts/functions/wan_device        |   37 ++++++++
  4 files changed, 236 insertions(+), 0 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index 5fe2823..08255de 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -25,6 +25,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].manufacturer="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -51,6 +54,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].oui="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -77,6 +83,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].product_class="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -103,6 +112,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].serial_number="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -129,6 +141,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].hardware_version="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -155,6 +170,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@device[0].software_version="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -433,6 +451,41 @@ return $FAULT_CPE_INVALID_PARAMETER_NAME
  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
  }

+set_device_info_notification() {
+case "$1" in
+    InternetGatewayDevice.DeviceInfo.)
+    freecwmp_set_parameter_notification "$1" "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.Manufacturer)
+    set_device_info_manufacturer "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+    set_device_info_oui "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.ProductClass)
+    set_device_info_product_class "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SerialNumber)
+    set_device_info_serial_number "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.HardwareVersion)
+    set_device_info_hardware_version "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+    set_device_info_software_version "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+}
+
  check_parameter_device_info_generic() {
  case "$1" in
      InternetGatewayDevice.DeviceInfo.ModelName|\
@@ -498,3 +551,11 @@ set_device_info_generic() {
      # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
      return $FAULT_CPE_NO_FAULT
  }
+
+set_device_info_generic_notification() {
+    check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
-eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+    freecwmp_set_parameter_notification "$1" "$2"
+    # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    return $FAULT_CPE_NO_FAULT
+}
diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index db90021..a8a94e5 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -44,6 +44,10 @@ case $action in
      delay_command "wifi" "wifi" "45"
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-device[$num].disabled="$val"
      ;;
+    set_notification)
+    let num=$num+1
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -79,6 +83,10 @@ case $action in
      delay_command "wifi" "wifi" "45"
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
wireless.@wifi-iface[$num].ssid="$val"
      ;;
+    set_notification)
+    let num=$num+1
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -243,3 +251,25 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
  }
+
+set_lan_device_notification() {
+case "$1" in
+    InternetGatewayDevice.LANDevice.|\
+    InternetGatewayDevice.LANDevice.1.|\
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.|\
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+    freecwmp_set_parameter_notification "$1" "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+    set_wlan_enable 0 "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+    set_wlan_ssid 0 "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+}
diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index 37b1cb0..532addd 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -58,6 +58,10 @@ case "$action" in

      ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": 
"value_change" }' &
      ;;
+    set_notification)
+    local val=$1
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -85,6 +89,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].username="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -112,6 +119,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].password="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -140,6 +150,9 @@ case "$action" in
      set_value)
      freecwmp_set_parameter_value "$parm" "$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -168,6 +181,9 @@ case "$action" in
      set_value)
      freecwmp_set_parameter_value "$parm" "$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -224,6 +240,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].username="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -251,6 +270,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].password="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -284,6 +306,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].scheme="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -319,6 +344,9 @@ case "$action" in
          /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
      fi
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -350,6 +378,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].port="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -381,6 +412,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@acs[0].path="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -412,6 +446,9 @@ case "$action" in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
freecwmp.@local[0].port="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -798,6 +835,69 @@ esac
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

+set_management_server_notification() {
+case "$1" in
+    InternetGatewayDevice.ManagementServer.)
+    freecwmp_set_parameter_notification "$1" "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.URL)
+    set_management_server_url "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Username)
+    set_management_server_username "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.Password)
+    set_management_server_password "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+    set_management_server_periodic_inform_enable "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+    set_management_server_periodic_inform_interval "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+    InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+    set_management_server_connection_request_url "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+    set_management_server_connection_request_username "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+    set_management_server_connection_request_password "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+    set_management_server_x_freecwmp_org__acs_scheme "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+    set_management_server_x_freecwmp_org__acs_hostname "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+    set_management_server_x_freecwmp_org__acs_port "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+    set_management_server_x_freecwmp_org__acs_path "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+    set_management_server_x_freecwmp_org__connection_request_port "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
  check_parameter_management_server_generic() {
  case "$1" in
      InternetGatewayDevice.ManagementServer.UpgradesManaged)
@@ -839,3 +939,11 @@ set_management_server_generic() {
      # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
      return $FAULT_CPE_NO_FAULT
  }
+
+set_management_server_generic_notification() {
+    check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ 
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+    freecwmp_set_parameter_notification "$1" "$2"
+    # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+    return $FAULT_CPE_NO_FAULT
+}
diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index c8f1887..7a12eb5 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -105,6 +105,9 @@ case $action in
          ifup wan &
      fi
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -132,6 +135,9 @@ case $action in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.username="$val"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -159,6 +165,9 @@ case $action in
      set_value)
      /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
network.wan.password="$1"
      ;;
+    set_notification)
+    freecwmp_set_parameter_notification "$parm" "$val"
+    ;;
  esac
  }

@@ -483,3 +492,31 @@ esac
  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
  return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
+
+set_wan_device_notification() {
+case "$1" in
+    InternetGatewayDevice.WANDevice.|\
+    InternetGatewayDevice.WANDevice.1.|\
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.|\
+    InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.|\
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.|\
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+    freecwmp_set_parameter_notification "$1" "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+    set_wan_device_wan_ppp_enable "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+    set_wan_device_wan_ppp_username "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+ 
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+    set_wan_device_wan_ppp_password "$2"
+    return $FAULT_CPE_NO_FAULT
+    ;;
+esac
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
-- 
1.7.4.1




From mohamed.kallel@pivasoftware.com Thu Dec  6 14:33:11 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:33:16 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:50323 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823127Ab2LFNdLz0CoU (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:33:11 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0LsJrw-1T0lSp2goq-0123fJ; Thu, 06 Dec 2012 14:33:05 +0100
Message-ID: <50C09E88.4070407@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:32:56 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [01/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:WnBy8TMb49BXmPlxU/B20Mu2kUkg0RE4b+di1yGW7Op
 1R4xIU/PM2sR3BmOHnURALsj+gsOevcs8h28jsUvqewg1RBWEk
 U0aCVViFvd67zIK7suasBVyeafpJo6H6ctb96Ip9aXzDA6ltzW
 NbokiguXT0MXobGz0/AOjtlw+AKc52HLdcaw9c3e+AnHGiLkSD
 g5/rFu2xuJxLWPwUNdkPCJv1GpAcLrF/QUTvNpHowYK7K1rQNe
 WdHaf2Dj2vI3GzoUsB53bicgK2uIKVDj5i/vGEK/ts+8/QFDwP
 SKfWBGBImoNph8CRyEj+MeIcHwuaRejxTSIsDKMvVoeV8GARuA
 rIF4BXPuOPj+gnEnicrOGZ0DVmDbcpyyL1/jbNiSf
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 76
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [01/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [01/27] 
---------------------------------

 >From 18e2d931a89158a69e7f25705dbf2dbb1f41d3fd Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:33:01 +0100
Subject: [PATCH 01/27] add ubus listner get_parameter_values. This 
listener allows to get the freecwmp output from extenal command.
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/external.c |   13 +++++++++++++
  src/external.h |   10 ++++++++++
  src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/external.c b/src/external.c
index 9ac7b36..c9c768f 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,6 +25,19 @@
  #include "freecwmp.h"

  static struct uloop_process uproc;
+LIST_HEAD(external_list_parameter);
+
+void external_add_list_paramameter(char *param_name, char *param_data, 
char *param_type, char *fault_code)
+{
+    struct external_parameter *external_parameter;
+    struct list_head *ilist; int i =0;
+    external_parameter = calloc(1, sizeof(struct external_parameter));
+ list_add_tail(&external_parameter->list,&external_list_parameter);
+    if (param_name) external_parameter->name = strdup(param_name);
+    if (param_data) external_parameter->data = strdup(param_data);
+    if (param_type) external_parameter->type = strdup(param_type);
+    if (fault_code) external_parameter->fault_code = strdup(fault_code);
+}

  int external_get_action(char *action, char *name, char **value)
  {
diff --git a/src/external.h b/src/external.h
index 8606266..64b4c6b 100644
--- a/src/external.h
+++ b/src/external.h
@@ -9,6 +9,7 @@

  #ifndef _FREECWMP_EXTERNAL_H__
  #define _FREECWMP_EXTERNAL_H__
+#include <libubox/list.h>

  #ifdef DUMMY_MODE
  static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
@@ -17,11 +18,20 @@ static char *fc_script = "/usr/sbin/freecwmp";
  #endif
  static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";

+struct external_parameter {
+    struct list_head list;
+    char *name;
+    char *data; /* notification for GetParameterAttribute; writable for 
GetParameterNames; value for GetParameterValues*/
+    char *type;
+    char *fault_code;
+};
+
  int external_get_action(char *action, char *name, char **value);
  int external_set_action_write(char *action, char *name, char *value);
  int external_set_action_execute();
  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);

  #endif

diff --git a/src/ubus.c b/src/ubus.c
index c10170d..d5437f9 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -16,6 +16,7 @@
  #include "config.h"
  #include "cwmp.h"
  #include "freecwmp.h"
+#include "external.h"

  static struct ubus_context *ctx = NULL;
  static struct ubus_object main_object;
@@ -157,10 +158,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, 
struct ubus_object *obj,
      return 0;
  }

+static enum get_param_values {
+    GET_PARAM_VALUES_PARAM,
+    GET_PARAM_VALUES_VALUE,
+    GET_PARAM_VALUES_TYPE,
+    GET_PARAM_VALUES_FAULT,
+    __GET_PARAM_VALUES_MAX
+};
+
+static const struct blobmsg_policy get_param_values_policy[] = {
+    [GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_VALUE] = { .name = "value", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_TYPE] = { .name = "type", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct 
ubus_object *obj,
+            struct ubus_request_data *req, const char *method,
+            struct blob_attr *msg)
+{
+    struct blob_attr *tb[__GET_PARAM_VALUES_MAX];
+
+    blobmsg_parse(get_param_values_policy, 
ARRAY_SIZE(get_param_values_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    if (!tb[GET_PARAM_VALUES_PARAM])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus get_parameter_values for the parameter 
%s\n",
+                 blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
+
+ external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
+            tb[GET_PARAM_VALUES_VALUE]? 
blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,
+            tb[GET_PARAM_VALUES_TYPE]? 
blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",
+            tb[GET_PARAM_VALUES_FAULT]? 
blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);
+
+    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),
  };

  static struct ubus_object_type main_object_type =
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:34:52 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:34:53 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:65452 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823165Ab2LFNewC-zCQ (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:34:52 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MVWV0-1Tg7ru3pFe-00YkoA; Thu, 06 Dec 2012 14:34:46 +0100
Message-ID: <50C09EEE.90100@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:34:38 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [02/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:wioqqWoJP7cThK6wQqZoouhMb/N8wD6brXGJe87SHoJ
 HR25C83KqaUNJHKn8Cao4C412r39oL6aUrr8tw2eSkrwYz1OhV
 HYgzQ/D03+70vAZTDzpnC+AVrfvorboWVtxUqlsTCgnld2plQ7
 vw43pivw/H7DuU+WjjqyYWSkdYg0cPGJwL9Q/VY+u0CJ2MRFHr
 BjO0Q97H+30SBCxzYUDCp/jmkZypkS0dMRhC9YfpAYt5TCc2iv
 q9MTvoh9eUAjDG+Nf/2mgAcQ4D1f5h7mfFQWvkz7Js1G8z6epe
 lDClGstEofREHLDi+MTr5Hez3V7jn1DmmAGjCV0Il+P0a8unmE
 O53g//8x1iECWQoCBlt0dvIc++fDVUfewRAHa23ko
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 77
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [02/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [02/27] 
---------------------------------

 >From 5f74d7947e48e1d3d140f5842cbad955d0686a7e Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:37:07 +0100
Subject: [PATCH 02/27] get_parameter values handler from xml is 
supporting many parameters from external ubus output
    Contributed by Inteno Broadband Technology AB && PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  bin/Makefile.am |    3 +-
  configure.ac    |    3 ++
  src/external.c  |   95 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
  src/external.h  |    6 +++-
  src/freecwmp.c  |   17 ++++++++++
  src/xml.c       |   66 +++++++++++++++++++++++--------------
  6 files changed, 163 insertions(+), 27 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 78cb111..ac96905 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,5 +48,6 @@ freecwmpd_LDADD =        \
      $(LIBUBUS_LIBS)        \
      $(MICROXML_LIBS)    \
      $(LIBCURL_LIBS)        \
-    $(LIBZSTREAM_LIBS)
+    $(LIBZSTREAM_LIBS)    \
+    $(LIBPTHREAD_LIBS)

diff --git a/configure.ac b/configure.ac
index c646c3a..38d3df4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
  LIBUBUS_LIBS='-lubus'
  AC_SUBST([LIBUBUS_LIBS])

+LIBPTHREAD_LIBS='-lpthread'
+AC_SUBST([LIBPTHREAD_LIBS])
+
  AM_COND_IF([HTTP_CURL], [
   AC_DEFINE(HTTP_CURL)
   PKG_CHECK_MODULES(LIBCURL, [libcurl])
diff --git a/src/external.c b/src/external.c
index c9c768f..94ae9b8 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,8 +25,15 @@
  #include "freecwmp.h"

  static struct uloop_process uproc;
+pthread_t ubus_thread;
  LIST_HEAD(external_list_parameter);

+void *thread_uloop_run (void *v)
+{
+    uloop_run();
+    return NULL;
+}
+
  void external_add_list_paramameter(char *param_name, char *param_data, 
char *param_type, char *fault_code)
  {
      struct external_parameter *external_parameter;
@@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name, 
char *param_data, char *par
      if (fault_code) external_parameter->fault_code = strdup(fault_code);
  }

+void external_free_list_parameter()
+{
+    struct external_parameter *external_parameter;
+    while (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+}
+
  int external_get_action(char *action, char *name, char **value)
  {
      freecwmp_log_message(NAME, L_NOTICE,
@@ -121,6 +142,80 @@ error:
      return -1;
  }

+int external_get_action_write(char *action, char *name, char *arg)
+{
+    freecwmp_log_message(NAME, L_NOTICE,
+        "adding to get %s script '%s'\n", action, name);
+
+    FILE *fp;
+
+    if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
+        fp = fopen(fc_script_get_actions, "a");
+        if (!fp) return -1;
+    } else {
+        fp = fopen(fc_script_get_actions, "w");
+        if (!fp) return -1;
+
+        fprintf(fp, "#!/bin/sh\n");
+
+        if (chmod(fc_script_get_actions,
+            strtol("0700", 0, 8)) < 0) {
+            return -1;
+    }
+    }
+
+#ifdef DUMMY_MODE
+    fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action, 
name, arg?arg:"");
+#else
+    fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name, 
arg?arg:"");
+#endif
+
+    fclose(fp);
+
+    return 0;
+}
+
+int external_get_action_execute()
+{
+    freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
+
+    pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
+
+    if ((uproc.pid = fork()) == -1) {
+        return -1;
+    }
+
+    if (uproc.pid == 0) {
+        /* child */
+
+        const char *argv[3];
+        int i = 0;
+        argv[i++] = "/bin/sh";
+        argv[i++] = fc_script_get_actions;
+        argv[i++] = NULL;
+
+        execvp(argv[0], (char **) argv);
+        exit(ESRCH);
+
+    } else if (uproc.pid < 0)
+    return -1;
+
+    /* parent */
+    int status;
+    while (wait(&status) != uproc.pid) {
+        DD("waiting for child to exit");
+    }
+
+    pthread_cancel(ubus_thread);
+    pthread_join(ubus_thread,NULL);
+
+    // TODO: add some kind of checks
+
+    remove(fc_script_get_actions);
+
+    return 0;
+}
+
  int external_set_action_write(char *action, char *name, char *value)
  {
      freecwmp_log_message(NAME, L_NOTICE,
diff --git a/src/external.h b/src/external.h
index 64b4c6b..c6df2ea 100644
--- a/src/external.h
+++ b/src/external.h
@@ -16,7 +16,8 @@ static char *fc_script = 
"./ext/openwrt/scripts/freecwmp.sh";
  #else
  static char *fc_script = "/usr/sbin/freecwmp";
  #endif
-static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
+static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
+static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";

  struct external_parameter {
      struct list_head list;
@@ -27,11 +28,14 @@ struct external_parameter {
  };

  int external_get_action(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_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);
+void external_free_list_parameter();

  #endif

diff --git a/src/freecwmp.c b/src/freecwmp.c
index 4ef8395..f4c9cb1 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -18,6 +18,7 @@
  #include <arpa/inet.h>
  #include <linux/netlink.h>
  #include <linux/rtnetlink.h>
+#include <signal.h>

  #include <libfreecwmp.h>
  #include <libubox/uloop.h>
@@ -194,11 +195,27 @@ netlink_init(void)
      return 0;
  }

+void signal_kill_all_handler(int sig)
+{
+     pthread_exit(NULL);
+}
+
+
+
  int main (int argc, char **argv)
  {
      freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");

      bool foreground = false;
+    struct sigaction sigint_action;
+
+    sigint_action.sa_handler = &signal_kill_all_handler;
+    sigemptyset (&sigint_action.sa_mask);
+    /* reset handler in case when pthread_cancel didn't stop
+       threads for some reason */
+    sigint_action.sa_flags = SA_RESETHAND;
+    sigaction(SIGTERM, &sigint_action, NULL);
+

      setlocale(LC_CTYPE, "");
      umask(0037);
diff --git a/src/xml.c b/src/xml.c
index 9fa036b..23b9ec7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -21,6 +21,8 @@
  #include "messages.h"
  #include "time.h"

+extern struct list_head external_list_parameter;
+
  struct rpc_method {
      const char *name;
      int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
@@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
                      mxml_node_t *tree_in,
                      mxml_node_t *tree_out)
  {
-    mxml_node_t *n, *b = body_in;
+    mxml_node_t *n, *parameter_list, *b = body_in;
+    struct external_parameter *external_parameter;
      char *parameter_name = NULL;
      char *parameter_value = NULL;
-    char *c;
+    char *c=NULL;
      int counter = 0;

      n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
@@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
              !strcmp(b->parent->value.element.name, "string")) {
              parameter_name = b->value.text.string;
          }
-
+        if (b && b->type == MXML_ELEMENT && /* added in order to 
support GetParameterValues with empty string*/
+            !strcmp(b->value.element.name, "string") &&
+            !b->child) {
+            parameter_name = "";
+        }
          if (parameter_name) {
              if (!config_get_cwmp(parameter_name, &parameter_value)) {
+ 
external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);
+                FREE(parameter_value);
                  // got the parameter value using libuci
-            } else if (!external_get_action("value",
-                    parameter_name, &parameter_value)) {
+            } else if 
(!external_get_action_write("value",parameter_name, NULL)) {
                  // got the parameter value via external script
              } else {
                  // error occurred when getting parameter value
                  goto out;
              }
-            counter++;
+        }
+        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+        parameter_name = NULL;
+    }

-            n = mxmlFindElement(tree_out, tree_out, "ParameterList", 
NULL, NULL, MXML_DESCEND);
-            if (!n) goto out;
+    if (external_get_action_execute())
+        goto out;
+
+    parameter_list = mxmlFindElement(tree_out, tree_out, 
"ParameterList", NULL, NULL, MXML_DESCEND);
+    if (!parameter_list) goto out;
+
+    while (external_list_parameter.next!=&external_list_parameter) {
+
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);

-            n = mxmlNewElement(n, "ParameterValueStruct");
+        if (external_parameter->fault_code && 
external_parameter->fault_code[0]=='9')
+            goto out; // KMD TODO return FAULT message the fault code 
is in ->fault_code
+
+        n = mxmlNewElement(parameter_list, "ParameterValueStruct");
              if (!n) goto out;

              n = mxmlNewElement(n, "Name");
              if (!n) goto out;

-            n = mxmlNewText(n, 0, parameter_name);
+        n = mxmlNewText(n, 0, external_parameter->name);
              if (!n) goto out;

              n = n->parent->parent;
@@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
              if (!n) goto out;

  #ifdef ACS_MULTI
-            mxmlElementSetAttr(n, "xsi:type", "xsd:string");
+        mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
  #endif
-            n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
+        n = mxmlNewText(n, 0, external_parameter->data? 
external_parameter->data : "");
              if (!n) goto out;

-            /*
-             * three day's work to finally find memory leak if we
-             * free parameter_name;
-             * it points to: b->value.text.string
-             *
-             * also, parameter_value can be NULL so we don't do checks
-             */
-            parameter_name = NULL;
-        }
+        counter++;

-        FREE(parameter_value);
-        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
      }

  #ifdef ACS_MULTI
@@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
      FREE(c);
  #endif

-    FREE(parameter_value);
      return 0;

  out:
-    FREE(parameter_value);
+    external_free_list_parameter();
      return -1;
  }

-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:36:16 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:36:17 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:52612 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825665Ab2LFNgQLMq4K (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:36:16 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0MNh30-1TnjAA32fy-006oim; Thu, 06 Dec 2012 14:36:10 +0100
Message-ID: <50C09F41.602@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:36:01 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [03/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:UaEtyixVkFeSNcRgyvDQWNxv1x3N0p/O8zZRXvWFQs4
 COzz1TPG1RF3EbOP98O7RffXqK5aPoNiT6ut3dmbaIDIgUrwCG
 6Xqae+UJ6GiyMA04l+W4gF8dBZtp8GqgKlxoruJmpqFFxHbeV5
 ZtjKncul8/HCrLRa3+nwXxnWhKEfQcCSCqQMeghDbnsvy5rJta
 eJQbRlUhzh1u2dazW6igbJD+aBIGGQrorMkIsJVvVyulWLKwcL
 O4tFph2l3nlqEs6umiy9FG8nHQ5mCJr5kkngD2HItNrsL+FoLC
 15S1tmvxkrTeILwbCanviqgZEhFwtzKGVhUT1aNi9YLosZwGP6
 QDeFSxfXGRTIz0ArSgm6GKL+/dWrnZWoZnU/UZJCM
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 78
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [03/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [03/27] 
---------------------------------

 >From 9efe02b6ae49b65b6103f4f41dec23a260626e40 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:55:52 +0100
Subject: [PATCH 03/27] add in the scripts the functions needed to 
communicate data to ubus handler for the get_parameter_values ubus handler
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/freecwmp.sh      |   51 
++++++++++++++++++++++++++++------
  ext/openwrt/scripts/functions/common |   23 +++++++++++++++
  2 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh 
b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..f2bebc8 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,21 +113,54 @@ handle_scripts() {
  config_load freecwmp
  config_foreach handle_scripts "scripts"

+# Fault code
+
+FAULT_CPE_NO_FAULT="0"
+FAULT_CPE_REQUEST_DENIED="1"
+FAULT_CPE_INTERNAL_ERROR="2"
+FAULT_CPE_INVALID_ARGUMENTS="3"
+FAULT_CPE_RESOURCES_EXCEEDED="4"
+FAULT_CPE_INVALID_PARAMETER_NAME="5"
+FAULT_CPE_INVALID_PARAMETER_TYPE="6"
+FAULT_CPE_INVALID_PARAMETER_VALUE="7"
+FAULT_CPE_NON_WRITABLE_PARAMETER="8"
+FAULT_CPE_NOTIFICATION_REJECTED="9"
+FAULT_CPE_DOWNLOAD_FAILURE="10"
+FAULT_CPE_UPLOAD_FAILURE="11"
+FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
+FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
+FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
+FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
+FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
+FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
+
  if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
-    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
+    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 $get_value_functions
      do
          $function_name "$__arg1"
+                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
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    fi
  fi

  if [ "$action" = "set_value" ]; then
diff --git a/ext/openwrt/scripts/functions/common 
b/ext/openwrt/scripts/functions/common
index 7e3000a..082e067 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE} 
]; then
  fi
  }

+ubus_freecwmp_output() {
+local parameter="$1"
+local value="$2"
+local type="$3"
+local fault_code="$4"
+
+if [ "$type" = "" ]; then
+    type="xsd:string"
+fi
+
+case "$action" in
+    get_value)
+    ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", 
"value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 
2> /dev/null
+    ;;
+esac
+}
  freecwmp_value_output() {
      freecwmp_output "$1" "$2" "V"
  }
@@ -249,3 +265,10 @@ EOF
      sh "$lock" &
  fi
  }
+
+freecwmp_check_fault() {
+if [ "$1" = "." ]; then
+    return $FAULT_CPE_INVALID_PARAMETER_NAME
+fi
+return $FAULT_CPE_NO_FAULT
+}
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 14:37:42 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:37:46 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:60648 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNhmKhDTx (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:37:42 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MTaYl-1TZpN31JTT-00SSV6; Thu, 06 Dec 2012 14:37:35 +0100
Message-ID: <50C09F97.9060302@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:37:27 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [04/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:m5ntOJKUSilMnx5mM4hoB3r4hnItMcEYAlTSBRjrV/S
 cIRRjzYMLQNxfK2DRqoaWefHtvBIL9bmd1fHz+Jikzb+qqAbM8
 oEe4vBhCjUxbqA4Qu1yf8kN49kLaRd3AZgVdZFHVeTgwmOg70b
 UiMwxRi45MEuz/oQdMHVTPiHgqGpmfTi8GsHH2Lc8jMLlm4hzZ
 zXquEeVvKap/xD+ISMUZz5uDAbMIu93t8eU0yDzlWY+2aNVFHF
 vbRoQRValhwkiT7J5hJ1qlOpwAClCr2wU2EW1XC/lvfh4Tu8la
 gdytV11O/3+iFV1tJN8+G0LqnZQqtrQOnMunL9gqYxfsdW+frG
 m0G418gR7EbqBwXMQEdpUDmbAiUPCUBs8sMmFf0+3
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 79
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [04/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [04/27] 
---------------------------------


 >From 9f3c3bea934e079853aed0ac27d91fb1bbe115d5 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:59:14 +0100
Subject: [PATCH 04/27] Update device_hosts to support communicte data of 
get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_hosts |   22 +++++++++++-----------
  1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_hosts 
b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..8909df6 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -44,7 +44,7 @@ local parameter=`echo -n $1 | sed 
"s/InternetGatewayDevice\.LANDevice\.1\./Devic
  case "$parameter" in
      Device.Hosts.HostNumberOfEntries)
      let local val=$num_static_leases+$num_dynamic_leases
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
      ;;
  esac
@@ -66,7 +66,7 @@ if [ $rc -eq 0 ]; then
          local sed_cmd=`echo -n \'$num; echo p\'`
          val=`eval sed -n $sed_cmd $leases_file | awk '{ print $2 }'`
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -74,7 +74,7 @@ freecwmp_parse_formated_parameter "$parameter" 
"Device.Hosts.Host.{i}.IPAddress"
  if [ $rc -eq 0 ]; then
      local val
      get_device_hosts_ip_address "$leases_file" "$num" 
"$num_static_leases" "$num_dynamic_leases" "val"
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -88,7 +88,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -gt 0 -a $num -le $num_dynamic_leases ]; then
          val="DHCP"
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -107,7 +107,7 @@ if [ $rc -eq 0 ]; then
          local t2=`date +%s`
          let val=$t1-$t2
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -131,7 +131,7 @@ if [ $rc -eq 0 ]; then
          val=`eval sed -n $sed_cmd $leases_file | awk '{ print $4 }'`
          if [ "x$val" == "x*" ]; then val=""; fi
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -144,7 +144,7 @@ if [ $rc -eq 0 ]; then
      get_device_hosts_ip_address "$leases_file" "$num" 
"$num_static_leases" "$num_dynamic_leases" "ip"
      val=`ping -c 1 $ip 2>&1 > /dev/null ; echo $?`
      let val=!$val
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -156,7 +156,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -le $n ]; then
          val=1
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -168,7 +168,7 @@ if [ $rc -eq 0 ]; then
      if [ $num -le $n ]; then
          val=0
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -182,10 +182,10 @@ if [ $rc -eq 0 ]; then
      if [ $num2 -eq 1 ]; then
          get_device_hosts_ip_address "$leases_file" "$num1" 
"$num_static_leases" "$num_dynamic_leases" "val"
      fi
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

  # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 
support yet)
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:39:05 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:39:06 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:51817 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNjF2faAh (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:39:05 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0MZ9ey-1TSMZS0Ak0-00LcKt; Thu, 06 Dec 2012 14:38:59 +0100
Message-ID: <50C09FEB.4050001@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:38:51 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [05/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:4ZYnyT8Zw57xyANsPCx2fIgAoUOj5JLXNww+WuXc6RI
 3nJ1MiFXdXtUl26OIlL2KXxHyOhleRx5aWqJg4fyJaHEqMY56d
 deqT3AKutk2htV3Zs8POXIWueawOz8vtTn5aIVsxM0X6z/eCd3
 yjrPHpeKCrfYuGaCTazk/PvjQlVAJkVNIMxmuAZWMcJSa+3utV
 hFpRof97QvHWEM89H9QsHOsbKHbzxoylAXn/60OO4UqToqzVOK
 Zkxl85QuyHEs0bpD2WMr2ZooMJgQMSGHgRw+5KoK0fXt0GOlZT
 7Avab9WOOZ+L6xVKnTeGLcERQ0JYW1FD1cB4gn6YJxFmFVmaI/
 3fGVKB3XvZU7QSlRjSFGCXEFxqie8KFFTxrKmyk7N
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 80
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [05/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [05/27] 
---------------------------------


 >From b61d8e55d0ef3de480a78fa088b126d5b38db152 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:01:31 +0100
Subject: [PATCH 05/27] Update device_info script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_info |   32 
+++++++++++++++++++---------
  1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info 
b/ext/openwrt/scripts/functions/device_info
index 4423b8b..86ff5c9 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -3,7 +3,7 @@

  get_device_info_manufacturer() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].manufacturer 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
  }

  set_device_info_manufacturer() {
@@ -12,7 +12,7 @@ set_device_info_manufacturer() {

  get_device_info_oui() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].oui 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" 
"$val"
  }

  set_device_info_oui() {
@@ -21,7 +21,7 @@ set_device_info_oui() {

  get_device_info_product_class() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].product_class 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" 
"$val"
  }

  set_device_info_product_class() {
@@ -30,7 +30,7 @@ set_device_info_product_class() {

  get_device_info_serial_number() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].serial_number 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
  }

  set_device_info_serial_number() {
@@ -39,7 +39,7 @@ set_device_info_serial_number() {

  get_device_info_hardware_version() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].hardware_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" 
"$val"
  }

  set_device_info_hardware_version() {
@@ -48,7 +48,7 @@ set_device_info_hardware_version() {

  get_device_info_software_version() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@device[0].software_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" 
"$val"
  }

  set_device_info_software_version() {
@@ -57,7 +57,7 @@ set_device_info_software_version() {

  get_device_info_uptime() {
  local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
  }

  get_device_info_device_log() {
@@ -67,7 +67,7 @@ if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
  else
      val=`dmesg | tail -n10`
  fi
-freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
  }

  get_device_info() {
@@ -81,6 +81,7 @@ case "$1" in
      get_device_info_software_version
      get_device_info_uptime
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.)
      get_device_info_manufacturer
@@ -91,32 +92,42 @@ case "$1" in
      get_device_info_software_version
      get_device_info_uptime
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.Manufacturer)
      get_device_info_manufacturer
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
      get_device_info_oui
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.ProductClass)
      get_device_info_product_class
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SerialNumber)
      get_device_info_serial_number
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.HardwareVersion)
      get_device_info_hardware_version
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.SoftwareVersion)
      get_device_info_software_version
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.UpTime)
      get_device_info_uptime
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.DeviceInfo.DeviceLog)
      get_device_info_device_log
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_device_info() {
@@ -161,10 +172,11 @@ return 1
  }

  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_get_parameter_value "val" "$1"
-    freecwmp_value_output "$1" "$val"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
  }

  set_device_info_generic() {
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:40:22 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:40:22 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:63893 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNkWAJy6- (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:40:22 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0LzFY5-1T3CT11dxJ-014r7j; Thu, 06 Dec 2012 14:40:15 +0100
Message-ID: <50C0A037.1050601@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:40:07 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [06/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:OTn9c3iM/esYQPB0FfrIccKNiPwV0DAyoa3bD6L9ZfL
 U6nd7NfVkxt/TrFuaNZtLzVyBu6UjGuAfAVgLCF1Y5IxBEmDZG
 rvv7SVNstBPVJVbjW2R8IuTRc62vDKOpkCyk2t8CPq0/dlvBbF
 6+7hxxX50+eU3VNknPVYRTI0PPiIxqziR2m51ZFRHB+w1T1Qqr
 6pNgjNECV2ZOiYM+2Wj99RV3N210Ji0zcJ61Lxy8qPULZz33mw
 v2xs0x3mKaNk6kF0V3t8ju/Z/SuFTm40BRLOV1MNP0wJlxslAB
 fs6thgH+3iK3ImGpBbs6WFzFD9S+hNRJW/GpleHZrbIWzncyYN
 U4hljnpOFOoTx+BseAtRPI2y6c57waHxNJ9Y2mJVl
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 81
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [06/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [06/27] 
---------------------------------


 >From 91e36ad7421668100895447e65a4fedfba208b33 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:04:01 +0100
Subject: [PATCH 06/27] Update device_routing script to support 
communicte data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_routing |   33 
+++++++++++++------------
  1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_routing 
b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..ca6dab1 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -85,7 +85,7 @@ local parameter=$1

  case "$parameter" in
      Device.Routing.RouterNumberOfEntries)
-    freecwmp_output "$parameter" "1"
+    ubus_freecwmp_output "$parameter" "1"
      return
      ;;
  esac
@@ -101,7 +101,7 @@ if [ $rc -eq 0 ]; then
      else
          val="0"
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -113,7 +113,7 @@ if [ $rc -eq 0 ]; then
      else
          val="Disabled"
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -134,7 +134,7 @@ if [ $rc -eq 0 ]; then
      else
          return
      fi
-    freecwmp_output "$parameter" "$total"
+    ubus_freecwmp_output "$parameter" "$total"
      return
  fi

@@ -146,7 +146,7 @@ if [ $rc -eq 0 ]; then
      else
          return
      fi
-    freecwmp_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -166,15 +166,15 @@ if [ $rc -eq 0 ]; then
              return
          fi
          if [ $num2 -gt $static ]; then
-            freecwmp_output "$parameter" "Enabled"
+            ubus_freecwmp_output "$parameter" "Enabled"
              return
          fi
          if [ $num2 -le $inactive ]; then
-            freecwmp_output "$parameter" "Error: not active but enabled"
+            ubus_freecwmp_output "$parameter" "Error: not active but 
enabled"
              return
          fi
          if [ $num2 -le $static ]; then
-            freecwmp_output "$parameter" "Enabled"
+            ubus_freecwmp_output "$parameter" "Enabled"
              return
          fi
      else
@@ -197,11 +197,11 @@ if [ $rc -eq 0 ]; then
              return
          fi
          if [ $num2 -gt $static ]; then
-            freecwmp_output "$parameter" "0"
+            ubus_freecwmp_output "$parameter" "0"
              return
          fi
          if [ $num2 -le $static ]; then
-            freecwmp_output "$parameter" "1"
+            ubus_freecwmp_output "$parameter" "1"
              return
          fi
      else
@@ -230,7 +230,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              target=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].target 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$target"
+        ubus_freecwmp_output "$parameter" "$target"
          return
      else
          return
@@ -258,7 +258,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              netmask=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].netmask 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$netmask"
+        ubus_freecwmp_output "$parameter" "$netmask"
          return
      else
          return
@@ -288,7 +288,7 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              gateway=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].gateway 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$gateway"
+        ubus_freecwmp_output "$parameter" "$gateway"
          return
      else
          return
@@ -315,7 +315,7 @@ if [ $rc -eq 0 ]; then
          elif [ $num2 -le $static ]; then
              val="Static"
          fi
-        freecwmp_output "$parameter" "$val"
+        ubus_freecwmp_output "$parameter" "$val"
          return
      else
          return
@@ -343,11 +343,12 @@ if [ $rc -eq 0 ]; then
              let local i=$static-$num2
              metric=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} 
get network.@route[$i].metric 2> /dev/null`
          fi
-        freecwmp_output "$parameter" "$metric"
+        ubus_freecwmp_output "$parameter" "$metric"
          return
      else
          return
      fi
  fi
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
+
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:41:47 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:41:48 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:54094 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNlr3GOQP (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:41:47 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis)
        id 0MFOim-1TutSC1Jau-00F4Tt; Thu, 06 Dec 2012 14:41:41 +0100
Message-ID: <50C0A08D.8010807@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:41:33 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [07/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:ETqQxbc/5vQ0Zxlz0rr1l3TcPWTXtOaudYqo8dHkZ5G
 0xnwfWZ36lrVxYjHcBLWzCs/wZTavdQFmbXtwczc4QXNYo+i1M
 t364u+5TI1DSxrfwgrxWSmEZIgA8qEbmLSMiBPCWmVIBwi4roM
 CYbbO8lPHtQ+Gap9JqACaz1Sjy+tr1kuq1qH7anY3zlFbvyhSm
 5Ok2az2zk3+AXRGImGuemrHP2glpiptsXJWYufdjCBS9wHolZR
 00ooq3z7850D3rJPkx0EEEFsB+9ycnD9hsvegL7+apxfLEE6S2
 X/5j7ECYmhkypPViRa682A076sVs2ZT2zPOPUQKhH9YBAiq8vt
 WoDaftrRbheLiqA/DsJ7LsTHVhsR+NndlRrTAzisc
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 82
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [07/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [07/27] 
---------------------------------


 >From 33dbf86bc1acdb5b12589225de0fa1c79c51627b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:05:26 +0100
Subject: [PATCH 07/27]  Update device_users script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/device_users |   13 +++++++------
  1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_users 
b/ext/openwrt/scripts/functions/device_users
index 0d377f7..d8dba61 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -6,7 +6,7 @@ local parameter="$1"
  case "$parameter" in
      Device.Users.UserNumberOfEntries)
      local val=`wc -l /etc/passwd | awk '{ print $1 }'`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
      ;;
  esac
@@ -21,7 +21,7 @@ if [ $rc -eq 0 ]; then
      # TODO: this is very system dependent, for now just look at users 
shell
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' 
| wc -l`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -30,7 +30,7 @@ if [ $rc -eq 0 ]; then
      # TODO: this is very system dependent, for now just look at users 
shell
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' 
| wc -l`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -38,7 +38,7 @@ freecwmp_parse_formated_parameter "$parameter" 
"Device.Users.User.{i}.Username"
  if [ $rc -eq 0 ]; then
      local sed_cmd=`echo -n \'$num; echo p\'`
      local val=`eval sed -n $sed_cmd /etc/passwd | awk -F ':' '{ print 
$1 }'`
-    freecwmp_value_output "$parameter" "$val"
+    ubus_freecwmp_output "$parameter" "$val"
      return
  fi

@@ -48,15 +48,16 @@ if [ $rc -eq 0 ]; then
      #   local sed_cmd=`echo -n \'$num; echo p\'`
      #   local val=`eval sed -n $sed_cmd /etc/shadow | awk -F ':' '{ 
print $2 }'`
      #   freecwmp_value_output "$parameter" "$val"
-    freecwmp_value_output "$parameter" ""
+    ubus_freecwmp_output "$parameter" ""
      return
  fi

  freecwmp_parse_formated_parameter "$parameter" 
"Device.Users.User.{i}.Language" "rc" "num"
  if [ $rc -eq 0 ]; then
-    freecwmp_value_output "$parameter" ""
+    ubus_freecwmp_output "$parameter" ""
      return
  fi
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_device_users() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 14:43:01 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:43:02 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:60080 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825665Ab2LFNnBdxfoe (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:43:01 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0MdZVI-1TWo4I3h3E-00Q0KM; Thu, 06 Dec 2012 14:42:56 +0100
Message-ID: <50C0A0D8.6060308@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:42:48 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [08/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:kucI+8uB1bu5LTsoKNYHFOei529HBN/QRbAWqKTbmuq
 nLcRPnr5eV4AVIuVJJxhZCN1IVxnMqTAZ2XZQG1wpx8xywRZiG
 qDSEyzvwml4PaMPiDbpHS/adjdGjXJpt32ChUOI/A9Gse4l26O
 RGmKYtFbyo67mywZSLSou8xiajTc/gkU9CcDT99AcQCi7Sw2Rs
 NGxu6iL7JFcCAHob12VEEd9Wd+hxiDFOjqsY4MooDqJiaYqwAy
 27v1eZsc5DNTfwor4YNA36ikrcBT+UD8M4yMXZcbLggXybOk2M
 QNPSOgsvE6C1NubSVsdPBxOYgykn7tB04hUTOM6NBLEEGh8olz
 jjS+Q88//0na+VAGEfvl+Ua/4q5BnY34niog0VD1p
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 83
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [08/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [08/27] 
---------------------------------


 >From 5d2f27eaebb4c5762a915b428b3d11e1ce6d2cff Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:07:28 +0100
Subject: [PATCH 08/27] Update lan_device script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/lan_device |   13 +++++++++++--
  1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/lan_device 
b/ext/openwrt/scripts/functions/lan_device
index 5ba513c..fa9dda4 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -3,6 +3,7 @@

  get_wlan_enable() {
  local num="$1"
+local type="xsd:boolean"
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-device[$num].disabled 2> /dev/null`
  let num=$num+1
  if [ "$val" = "1" ]; then
@@ -10,7 +11,7 @@ if [ "$val" = "1" ]; then
  else
      val="1"
  fi
-freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" 
"$type"
  }

  set_wlan_enable() {
@@ -29,7 +30,7 @@ get_wlan_ssid() {
  local num="$1"
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
wireless.@wifi-iface[$num].ssid 2> /dev/null`
  let num=$num+1
-freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
  }

  set_wlan_ssid() {
@@ -44,30 +45,38 @@ case "$1" in
      InternetGatewayDevice.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
      get_wlan_enable 0
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
      get_wlan_enable 0
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
      get_wlan_ssid 0
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_lan_device() {
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:44:40 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:44:45 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:54831 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNoksqAkb (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:44:40 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis)
        id 0LnYoV-1TFpSJ2WXn-00hpN8; Thu, 06 Dec 2012 14:44:34 +0100
Message-ID: <50C0A139.4040209@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:44:25 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [09/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:SyRj1xgW8BYEW5lvOL9XzzbRQwhZ92ryULI6vO47WE3
 uXqrFJ+VD3lu99Lz1GtBE5pevmk1D0bCag01x13Ifp5jwJqbon
 OZZz0bjJO0vlwUucIj01+2XT/2zRj2RY8Z/8HjxIRXhAgq8UlU
 B58sbuFLLHXvXBPiTPINrgXUV7yyFLajE1x1I86YezmYW0U/E1
 FbkynxpW+U3/ufaXyvfqOKPc3k1QcUpTDJWUz9v5zFL0zphf0s
 Zhc2ronzD/73tU1iRiA3xpuQCplsCOM3/zYnA/32+FSWgJZYFi
 wIntlue6wUq1wfGwXO9V1F1TZRXDhXChQ3I7Gn3NAKqL4msFm+
 1zKmXYV4HMfWtZ9uCmsdvSlP74qqMRxWIYo87m1uf
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 84
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [09/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [09/27] 
---------------------------------

 >From 7b88e2ac25543be6c319822d96ae379395f55fc3 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:09:08 +0100
Subject: [PATCH 09/27] Update management_server script to support 
communicte data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/management_server |   72 
++++++++++++++++++-----
  1 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/ext/openwrt/scripts/functions/management_server 
b/ext/openwrt/scripts/functions/management_server
index 9d1447e..eca3a61 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -10,7 +10,7 @@ local 
port=`get_management_server_x_freecwmp_org__acs_port`
  local path=`get_management_server_x_freecwmp_org__acs_path`
  FLAGS_value=$tmp
  local val=`echo $scheme://$hostname:$port$path`
-freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
  }

  set_management_server_url() {
@@ -46,7 +46,7 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform 
'{ "event": "value_change

  get_management_server_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].username 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" 
"$val"
  }

  set_management_server_username() {
@@ -55,7 +55,7 @@ set_management_server_username() {

  get_management_server_password() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].password 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" 
"$val"
  }

  set_management_server_password() {
@@ -65,7 +65,7 @@ set_management_server_password() {
  get_management_server_periodic_inform_enable() {
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
  freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
  }

  set_management_server_periodic_inform_enable() {
@@ -76,7 +76,7 @@ freecwmp_set_parameter_value "$parm" "$1"
  get_management_server_periodic_inform_interval() {
  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
  freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
  }

  set_management_server_periodic_inform_interval() {
@@ -100,12 +100,12 @@ else
      val=$default_management_server_connection_request_url
  fi

-freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
  }

  get_management_server_connection_request_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].username 2> /dev/null`
-freecwmp_value_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
  }

  set_management_server_connection_request_username() {
@@ -114,7 +114,7 @@ set_management_server_connection_request_username() {

  get_management_server_connection_request_password() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].password 2> /dev/null`
-freecwmp_value_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
  }

  set_management_server_connection_request_password() {
@@ -125,7 +125,12 @@ set_management_server_connection_request_password() {

  get_management_server_x_freecwmp_org__acs_scheme() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].scheme 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_scheme() {
@@ -134,7 +139,12 @@ set_management_server_x_freecwmp_org__acs_scheme() {

  get_management_server_x_freecwmp_org__acs_hostname() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].hostname 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_hostname() {
@@ -147,7 +157,12 @@ fi

  get_management_server_x_freecwmp_org__acs_port() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].port 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_port() {
@@ -156,7 +171,12 @@ set_management_server_x_freecwmp_org__acs_port() {

  get_management_server_x_freecwmp_org__acs_path() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@acs[0].path 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path" "$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__acs_path() {
@@ -165,7 +185,12 @@ set_management_server_x_freecwmp_org__acs_path() {

  get_management_server_x_freecwmp_org__connection_request_port() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
freecwmp.@local[0].port 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port" 
"$val"
+local 
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  set_management_server_x_freecwmp_org__connection_request_port() {
@@ -188,6 +213,7 @@ case "$1" in
      get_management_server_x_freecwmp_org__acs_port
      get_management_server_x_freecwmp_org__acs_path
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.)
      get_management_server_url
@@ -203,47 +229,62 @@ case "$1" in
      get_management_server_x_freecwmp_org__acs_port
      get_management_server_x_freecwmp_org__acs_path
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.URL)
      get_management_server_url
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Username)
      get_management_server_username
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.Password)
      get_management_server_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
      get_management_server_periodic_inform_enable
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
      get_management_server_periodic_inform_interval
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
      get_management_server_connection_request_url
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
      get_management_server_connection_request_username
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
      get_management_server_connection_request_password
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
      get_management_server_x_freecwmp_org__acs_scheme
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
      get_management_server_x_freecwmp_org__acs_hostname
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
      get_management_server_x_freecwmp_org__acs_port
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
      get_management_server_x_freecwmp_org__acs_path
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
      get_management_server_x_freecwmp_org__connection_request_port
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_management_server() {
@@ -301,10 +342,11 @@ return 1
  }

  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi

      freecwmp_get_parameter_value "val" "$1"
-    freecwmp_value_output "$1" "$val"
+    ubus_freecwmp_output "$1" "$val"
+    return $FAULT_CPE_NO_FAULT
  }

  set_management_server_generic() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 14:45:50 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:45:51 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:63493 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNpuYmqTi (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:45:50 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis)
        id 0M944P-1Tsxa63XeH-00CM6a; Thu, 06 Dec 2012 14:45:45 +0100
Message-ID: <50C0A181.9050509@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:45:37 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [10/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:DGQHMQwvHAR8Tvsyb5U13lGqZTjZ2mUE9LmMp2Bol5y
 +/OQR7MD7Rfz2DpspNt959S06ILU+0AOQBbVs8ReMC6Wh6iTG8
 q7sXa3ZX2ZgIyKmsAuPqig3ujmtxUqRMo/9QNaaJxcYY3DCfxz
 h0cBwSwGChtJ0E927mOEZ+EAh9d2Xc+0ePVk4NTx+eFpjue3Xq
 QVC3sWNkTob5bIoxU89SAuNt3pR0XIfo2MCKUBChlupNPuTqE9
 nQFvYfBMuXDz/DNaX+6rpYps/seVry7kCpVQQcTH8K5OXRvbKN
 trYbupkQXGw5jM4vWaSwVyAPfv3/inZGvDchzGt8CWt1llP2B9
 Q3Hkyd29LO+GGDGJ+/dRt2gtJj1FbFRFV6z1MvOTj
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 85
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [10/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [10/27] 
---------------------------------


 >From dfb8cb80b1353170d74cb15ebf1dc0b5d0254f41 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:11:29 +0100
Subject: [PATCH 10/27] Update misc script to support communicte data of 
get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/misc |    8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/misc 
b/ext/openwrt/scripts/functions/misc
index 2e0210c..13f2142 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -3,21 +3,25 @@

  get_misc_cpu_usage() {
  local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ 
print $1 }' | awk -F'.' '{ print $2 }'`
-freecwmp_value_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
+ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
  }

  get_misc_process_number() {
  local val=`ps | grep -v COMMAND | wc -l`
-freecwmp_value_output 
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val"
+local type="xsd:unsignedInt"
+ubus_freecwmp_output 
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "$type"
  }

  get_misc() {
  case "$1" in
      Device.DeviceInfo.ProcessStatus.CPUUsage)
      get_misc_cpu_usage
+    return $FAULT_CPE_NO_FAULT
      ;;
      Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
      get_misc_process_number
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:47:02 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:47:03 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:60222 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6824760Ab2LFNrCvdRWt (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:47:02 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis)
        id 0Ldqqt-1TGrcq1Apf-00iN4V; Thu, 06 Dec 2012 14:46:57 +0100
Message-ID: <50C0A1C8.8020409@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:46:48 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net
Subject: ubus data model patch [11/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:5mznaR9589ewVcfr2jIJvjc1gxnwEtdeh22lNWWmTj2
 bDRjS6hopttckwHTH7NU9yxsYZqnO1YINRBNkZ/f7yEQYHj+YK
 g2CiMuvI7nMkLFc7Up4ujtTTyAHEFMPhDX+75aJyVugMU2cdOc
 vfs/MSJL0lNwVNoJFmXX2rDUesptOuTS9oEjkOwSMyNoG0iYwv
 9sp2fRfoahYx5AJD9qX40x5NwTWgJSmvDPDGYcKahEqOns9VvO
 rNiyuiaCdoX864/0m5I1p53nZgAVOqIkt8JHwtoN23gWtf1mNL
 fKtuUbfcO5lFfu4uikJnb7HRM/T6Uewm89vfPrp0iUFpExta99
 JFsYGtHnHyIfqu8Rf5ByJJ0LRG/dvX/Agr9EBsI4E
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 86
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [11/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [11/27] 
---------------------------------


 >From 1c3ddcdb4827bbecf99220963031c934a9b1fbe1 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:14:35 +0100
Subject: [PATCH 11/27] Update wan_device script to support communicte 
data of get parameter values to the core via ubus
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  ext/openwrt/scripts/functions/wan_device |   39 
+++++++++++++++++++++++++----
  1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/wan_device 
b/ext/openwrt/scripts/functions/wan_device
index 77cb63f..a8b6361 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -4,26 +4,37 @@
  get_wan_device_mng_status() {
  # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; 
Disconneting ; Disconnected
  local val="Connected"
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" 
"$val" "xsd:boolean"
  }

  get_wan_device_mng_interface_ip() {
  local val
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
  if [ -z "$default_wan_device_mng_interface_ip" ]; then
      val=`network_get_ipaddr val mng`
  else
      val=$default_wan_device_mng_interface_ip
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress" 
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  get_wan_device_mng_interface_mac() {
+local val=""
+local 
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
  if [ -z "$default_wan_device_mng_interface_mac" ]; then
      val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.mng.macaddr`
  else
      val=$default_wan_device_mng_interface_mac
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress" 
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+    ubus_freecwmp_output "$parm" "$val"
+else
+    freecwmp_output "$parm" "$val"
+fi
  }

  get_wan_device_wan_ppp_enable() {
@@ -31,7 +42,7 @@ local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c 
$UCI_CONFIG_DIR} get network.wan.auto
  if [ -z $val ]; then
      val="1"
  fi
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" 
"$val" "xsd:boolean"
  }

  set_wan_device_wan_ppp_enable() {
@@ -47,7 +58,7 @@ fi

  get_wan_device_wan_ppp_username() {
  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.username 2> /dev/null`
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" 
"$val"
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" 
"$val"
  }

  set_wan_device_wan_ppp_username() {
@@ -55,7 +66,9 @@ set_wan_device_wan_ppp_username() {
  }

  get_wan_device_wan_ppp_password() {
-freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" 
""
+local val=""
+val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get 
network.wan.password 2> /dev/null`
+ubus_freecwmp_output 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" 
"$val"
  }

  set_wan_device_wan_ppp_password() {
@@ -71,6 +84,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.)
      get_wan_device_mng_status
@@ -79,6 +93,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.)
      get_wan_device_mng_status
@@ -87,6 +102,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
      get_wan_device_mng_status
@@ -95,6 +111,7 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
      InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
      get_wan_device_mng_status
@@ -103,36 +120,46 @@ case "$1" in
      get_wan_device_wan_ppp_enable
      get_wan_device_wan_ppp_username
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
      get_wan_device_mng_status
      get_wan_device_mng_interface_ip
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
      get_wan_device_mng_status
      get_wan_device_mng_interface_ip
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
      get_wan_device_mng_status
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
      get_wan_device_mng_interface_ip
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
      get_wan_device_mng_interface_mac
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
      get_wan_device_wan_ppp_enable
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
      get_wan_device_wan_ppp_username
+    return $FAULT_CPE_NO_FAULT
      ;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
      get_wan_device_wan_ppp_password
+    return $FAULT_CPE_NO_FAULT
      ;;
  esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
  }

  set_wan_device() {
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:49:08 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:49:09 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:55968 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825665Ab2LFNtI43Y0g (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:49:08 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis)
        id 0MYYR3-1TcXLY3ui1-00VDaR; Thu, 06 Dec 2012 14:49:03 +0100
Message-ID: <50C0A247.7070206@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:48:55 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [12/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:fyWQNxbtwSZgspTbBh9a2uMVkt9S5zn8/KQgtqf/GJy
 TNF09g3t/QpP8WKo6+m022gYf35O9DAW7a4IUJ63ouI0rZBpUZ
 kp7kVKS5I7vEH8jbOEaA9OAMr3p1CQSGlkPcoSKeFKyjKdBpas
 ubBtjLKg7s7sLTOmmmu0mjEMvE96iVp+eHJZQ8OEiC/qOddkwm
 YZ15tTpkfe7Ol9CspUI84NcFJkMpZX8PRfWJbKAnrxhWXb0gHt
 3GZsb6fjsYWI9TH/as3FnI7DHMmPcWJafDoOUe++EVdQ+2NFHQ
 reJXmUXhLmQU6GHoaUKctK/cjFa4qu+92DDuyl4HhRf45Xrii5
 Pk3qtbwaotik9WvyaO3t9FCtvo5lu74Nu+bblKBBT
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 87
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [12/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [12/27] 
---------------------------------

 >From 4ef165928bbd8e532f8f587ebf45789fdb44ba74 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:17:34 +0100
Subject: [PATCH 12/27] update inform in order to get parameters from 
ubus instead from pipe
    Contributed by PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/xml.c |   40 ++++++++++++++++++----------------------
  1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/xml.c b/src/xml.c
index 23b9ec7..612c0bb 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
  {
      mxml_node_t *tree, *b;
      char *c, *tmp;
+    struct external_parameter *external_parameter;

  #ifdef DUMMY_MODE
      FILE *fp;
@@ -337,37 +338,31 @@ int xml_prepare_inform_message(char **msg_out)
      if (mxmlGetType(b) != MXML_ELEMENT)
          goto error;

-    tmp = 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
-    b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-    if (!b) goto error;
-
-    b = b->parent->next->next;
-    if (mxmlGetType(b) != MXML_ELEMENT)
+    external_get_action_write("value", 
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", 
NULL);
+    external_get_action_write("value", 
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
+    if (external_get_action_execute())
          goto error;

-    c = NULL;
-    if (external_get_action("value", tmp, &c)) goto error;
-    if (c) {
-        b = mxmlNewText(b, 0, c);
-        FREE(c);
-        if (!b) goto error;
-    }
-
-    tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
-    b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-    if (!b) goto error;
+    while (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        b = mxmlFindElementText(tree, tree, external_parameter->name, 
MXML_DESCEND);
+        if (!b) continue;

      b = b->parent->next->next;
      if (mxmlGetType(b) != MXML_ELEMENT)
          goto error;

-    c = NULL;
-    if (external_get_action("value", tmp, &c)) goto error;
-    if (c) {
-        b = mxmlNewText(b, 0, c);
-        FREE(c);
+        if (external_parameter->data) {
+            b = mxmlNewText(b, 0, external_parameter->data);
          if (!b) goto error;
      }
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }

      if (xml_prepare_notifications_inform(tree))
          goto error;
@@ -378,6 +373,7 @@ int xml_prepare_inform_message(char **msg_out)
      return 0;

  error:
+    external_free_list_parameter();
      mxmlDelete(tree);
      return -1;
  }
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:50:54 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:50:54 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:53581 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825665Ab2LFNuyDsI6l (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:50:54 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0M5cGS-1SwMww32eu-00xxQ2; Thu, 06 Dec 2012 14:50:48 +0100
Message-ID: <50C0A2AC.6070803@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:50:36 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [13/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:gl2KztcQvAzm7B6c0taMDLxmbZ6l3XJH7dwH/mVYVeQ
 e+HZtJ+mtTlOHipXjkt+Z+PG/x2+sIovLuLZPTYPf9rg5iNG0d
 pbGDOi1q0xPgnEZmXzkblJvpxPbv9YpN3dUJTYjiXfXLJwYFsE
 5BwdxEPHNfyix2if3b/s+/62fCwFGrcLq6PkMLzKvPDrKKy64D
 el/ul8t6f4zCbRBmghTSWYf7CQTvUgwSuW3fOr3sFiEx5lE4vn
 VIBzQk131qrmWixqUF4R2CfNHB3XOEHW3g9ADTX8uFgznbxs2/
 BAr/GiUH/ACfhLPwfme6iOIFoqDb/EHywB2qnPzOlekHjRNvnS
 rfMI7StyRsqITbi/tfxCb62OKAP5i5JDzFYXOTaCy
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 88
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [13/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [13/27] 
---------------------------------


 >From 71814340a261a18fd3002a67863ce0fcd295a0bf Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:20:12 +0100
Subject: [PATCH 13/27] Add 3rd argument in the ubus handler of 
notification. The 3rd argument is the type of the parameter
   This agument could be  used in the response of get parameter attribute
    Contributed by Inteno Broadband Technology AB


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/cwmp.c |    2 +-
  src/cwmp.h |    2 +-
  src/ubus.c |    5 ++++-
  3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index 1bf9b2a..b75c762 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -245,7 +245,7 @@ void cwmp_clear_events(void)
      pthread_mutex_unlock(&event_lock);
  }

-void cwmp_add_notification(char *parameter, char *value)
+void cwmp_add_notification(char *parameter, char *value, char *type)
  {
      char *c = NULL;
      external_get_action("notification", parameter, &c);
diff --git a/src/cwmp.h b/src/cwmp.h
index 5703db0..1d8afac 100644
--- a/src/cwmp.h
+++ b/src/cwmp.h
@@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
  void cwmp_remove_event(int code);
  void cwmp_clear_events(void);

-void cwmp_add_notification(char *parameter, char *value);
+void cwmp_add_notification(char *parameter, char *value, char *type);
  void cwmp_clear_notifications(void);

  int cwmp_set_parameter_write_handler(char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index d5437f9..0fd1def 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct 
uloop_timeout *timeout)
  static enum notify {
      NOTIFY_PARAM,
      NOTIFY_VALUE,
+    NOTIFY_TYPE,
      __NOTIFY_MAX
  };

  static const struct blobmsg_policy notify_policy[] = {
      [NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
      [NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+    [NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
  };

  static int
@@ -66,7 +68,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx, 
struct ubus_object *obj,
                   "triggered ubus notification parameter %s\n",
                   blobmsg_data(tb[NOTIFY_PARAM]));
      cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
-                  blobmsg_data(tb[NOTIFY_VALUE]));
+            blobmsg_data(tb[NOTIFY_VALUE]),
+            tb[NOTIFY_TYPE]? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);

      return 0;
  }
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:52:34 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:52:39 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:58414 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825665Ab2LFNwe1gyQi (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:52:34 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0Lsdqf-1T0zcR3sk5-012f5o; Thu, 06 Dec 2012 14:52:29 +0100
Message-ID: <50C0A314.8060906@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:52:20 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [14/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:0e7ITNyYJos+4QyRZ3j8QSNKFC3AllGjS1bwFegsG7U
 v4tyVNmLRE9JvXD9m6GKMSzQSAh4Sku2/IT7aS4NUTGzDtgrm1
 jNQPAkJ6ycsxd8CHHPiLgK/SV7/fwrYqtumVE7LmHqlWcaLnjB
 s9TfGnJ+W8X4ZgRCqnoYErzxJHFWBXrE62A9x0jb6J7WFv0P7l
 6VKKh0yd3LIrokcj6MBr2VDVacaVP8D5bWMf0aoaG9GeMOsB8D
 T9n2mAlheNZX4M6DcT41PPMz2l1WdO6w2EoDkGC7G2486PtMV6
 EKrhGDAs9Cmt43nxHLVbyvb5v1Ba6McZ9MWUZBjqYU8VSxolSh
 mBiZ/ixkvP5TZ0AJNe3VKoQO9wkFnlMFGGN1DB/Mu
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 89
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

   ubus data model patch [14/27] enclosed

Regards
MOHAMED Kallel

------------------------ubus data model patch [14/27] 
---------------------------------


 >From 227820f9866cb0375238b0615f32498c283a0110 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:23:07 +0100
Subject: [PATCH 14/27] add xml message get_parameter_name handler.
    Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
  src/cwmp.c     |    2 +-
  src/external.c |   70 +++++++++++++-----------------------
  src/external.h |    3 +-
  src/ubus.c     |   39 ++++++++++++++++++++
  src/xml.c      |  111 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++-
  src/xml.h      |    4 ++
  6 files changed, 181 insertions(+), 48 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index b75c762..7de19e3 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -248,7 +248,7 @@ void cwmp_clear_events(void)
  void cwmp_add_notification(char *parameter, char *value, char *type)
  {
      char *c = NULL;
-    external_get_action("notification", parameter, &c);
+    external_get_action_data("notification", parameter, &c);
      if (!c) return;

      struct notification *n = NULL;
diff --git a/src/external.c b/src/external.c
index 94ae9b8..4973d1a 100644
--- a/src/external.c
+++ b/src/external.c
@@ -60,14 +60,32 @@ void external_free_list_parameter()
      }
  }

-int external_get_action(char *action, char *name, char **value)
+int external_get_action_data(char *action, char *name, char **value)
+{
+    struct external_parameter *external_parameter;
+    external_get_action(action, name, NULL);
+    if (external_list_parameter.next!=&external_list_parameter) {
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+        if (external_parameter->data)
+            *value = external_parameter->data;
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+    external_free_list_parameter();
+    return 0;
+}
+
+int external_get_action(char *action, char *name, char *arg /* arg is 
added for GetParameterNames NextLevel argument*/)
  {
      freecwmp_log_message(NAME, L_NOTICE,
                   "executing get %s '%s'\n", action, name);

-    int pfds[2];
-    if (pipe(pfds) < 0)
-        return -1;
+
+    pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);

      if ((uproc.pid = fork()) == -1)
          goto error;
@@ -79,66 +97,28 @@ int external_get_action(char *action, char *name, 
char **value)
          int i = 0;
          argv[i++] = "/bin/sh";
          argv[i++] = fc_script;
-        argv[i++] = "--newline";
-        argv[i++] = "--value";
          argv[i++] = "get";
          argv[i++] = action;
          argv[i++] = name;
+        if(arg) argv[i++] = arg;
          argv[i++] = NULL;

-        close(pfds[0]);
-        dup2(pfds[1], 1);
-        close(pfds[1]);
-
          execvp(argv[0], (char **) argv);
          exit(ESRCH);

      } else if (uproc.pid < 0)
          goto error;

-    /* parent */
-    close(pfds[1]);
-
      int status;
      while (wait(&status) != uproc.pid) {
          DD("waiting for child to exit");
      }
+    pthread_cancel(ubus_thread);
+    pthread_join(ubus_thread,NULL);

-    char buffer[64];
-    ssize_t rxed;
-    char *c;
-    int t;
-
-    *value = NULL;
-    while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
-        if (*value)
-            t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
-        else
-            t = asprintf(&c, "%.*s", (int) rxed, buffer);
-
-        if (t == -1) goto error;
-
-        free(*value);
-        *value = strdup(c);
-        free(c);
-    }
-
-    if (!strlen(*value)) {
-        FREE(*value);
-        goto done;
-    }
-
-    if (rxed < 0)
-        goto error;
-
-done:
-    close(pfds[0]);
      return 0;

  error:
-    FREE(*c);
-    FREE(*value);
-    close(pfds[0]);
      return -1;
  }

diff --git a/src/external.h b/src/external.h
index c6df2ea..8e82c39 100644
--- a/src/external.h
+++ b/src/external.h
@@ -27,7 +27,8 @@ struct external_parameter {
      char *fault_code;
  };

-int external_get_action(char *action, char *name, char **value);
+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);
diff --git a/src/ubus.c b/src/ubus.c
index 0fd1def..cbf94b0 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct 
ubus_context *ctx, struct ubus_object *
      return 0;
  }

+static enum get_param_names {
+    GET_PARAM_NAMES_PARAM,
+    GET_PARAM_NAMES_WRITABLE,
+    GET_PARAM_NAMES_FAULT,
+    __GET_PARAM_NAMES_MAX
+};
+
+static const struct blobmsg_policy get_param_names_policy[] = {
+    [GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = 
BLOBMSG_TYPE_STRING },
+    [GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = 
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct 
ubus_object *obj,
+            struct ubus_request_data *req, const char *method,
+            struct blob_attr *msg)
+{
+    struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
+
+    blobmsg_parse(get_param_names_policy, 
ARRAY_SIZE(get_param_names_policy), tb,
+              blob_data(msg), blob_len(msg));
+
+    if (!tb[GET_PARAM_NAMES_PARAM])
+        return UBUS_STATUS_INVALID_ARGUMENT;
+
+    freecwmp_log_message(NAME, L_NOTICE,
+                 "triggered ubus get_parameter_names for the parameter 
%s\n",
+                 blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
+
+ external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
+            tb[GET_PARAM_NAMES_WRITABLE]? 
blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
+            NULL,
+            tb[GET_PARAM_NAMES_FAULT]? 
blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
+
+    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("get_parameter_names", 
freecwmpd_handle_get_param_names, get_param_names_policy),
  };

  static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index 612c0bb..c735244 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -51,6 +51,7 @@ static struct cwmp_namespaces
  const struct rpc_method rpc_methods[] = {
      { "SetParameterValues", xml_handle_set_parameter_values },
      { "GetParameterValues", xml_handle_get_parameter_values },
+    { "GetParameterNames", xml_handle_get_parameter_names },
      { "SetParameterAttributes", xml_handle_set_parameter_attributes },
      { "Download", xml_handle_download },
      { "FactoryReset", xml_handle_factory_reset },
@@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t 
*body_in,
          free(external_parameter->fault_code);
          free(external_parameter);
      }
-
  #ifdef ACS_MULTI
      b = mxmlFindElement(tree_out, tree_out, "ParameterList",
                  NULL, NULL, MXML_DESCEND);
@@ -736,6 +736,115 @@ out:
      return -1;
  }

+int xml_handle_get_parameter_names(mxml_node_t *body_in,
+                    mxml_node_t *tree_in,
+                    mxml_node_t *tree_out)
+{
+    mxml_node_t *n, *parameter_list, *b = body_in;
+    struct external_parameter *external_parameter;
+    char *parameter_name = NULL;
+    char *NextLevel = NULL;
+    char *c;
+    int counter = 0;
+
+    n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
+                NULL, NULL, MXML_DESCEND);
+    if (!n) return -1;
+
+    n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
+    if (!n) return -1;
+
+    n = mxmlNewElement(n, "ParameterList");
+    if (!n) return -1;
+
+#ifdef ACS_MULTI
+    mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
+#endif
+
+    while (b) {
+        if (b && b->type == MXML_TEXT &&
+            b->value.text.string &&
+            b->parent->type == MXML_ELEMENT &&
+            !strcmp(b->parent->value.element.name, "ParameterPath")) {
+            parameter_name = b->value.text.string;
+        }
+        if (b && b->type == MXML_ELEMENT && /* added in order to 
support GetParameterNames with empty ParameterPath*/
+            !strcmp(b->value.element.name, "ParameterPath") &&
+            !b->child) {
+            parameter_name = "";
+        }
+        if (b && b->type == MXML_TEXT &&
+            b->value.text.string &&
+            b->parent->type == MXML_ELEMENT &&
+            !strcmp(b->parent->value.element.name, "NextLevel")) {
+            NextLevel = b->value.text.string;
+        }
+        b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+    }
+    if (parameter_name && NextLevel) {
+        if (!external_get_action("name", parameter_name, NextLevel)) {
+            // got the parameter value via external script
+        } else {
+            // error occurred when getting parameter value
+            goto out;
+        }
+    }
+
+    parameter_list = mxmlFindElement(tree_out, tree_out, 
"ParameterList", NULL, NULL, MXML_DESCEND);
+    if (!parameter_list) goto out;
+
+    while (external_list_parameter.next!=&external_list_parameter) {
+
+        external_parameter = list_entry(external_list_parameter.next, 
struct external_parameter, list);
+
+        if (external_parameter->fault_code && 
external_parameter->fault_code[0]=='9')
+            goto out; // KMD TODO return FAULT message the fault code 
is in ->fault_code
+
+        n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
+        if (!n) goto out;
+
+        n = mxmlNewElement(n, "Name");
+        if (!n) goto out;
+
+        n = mxmlNewText(n, 0, external_parameter->name);
+        if (!n) goto out;
+
+        n = n->parent->parent;
+        n = mxmlNewElement(n, "Writable");
+        if (!n) goto out;
+
+        n = mxmlNewText(n, 0, external_parameter->data);
+        if (!n) goto out;
+
+        counter++;
+
+        list_del(&external_parameter->list);
+        free(external_parameter->name);
+        free(external_parameter->data);
+        free(external_parameter->type);
+        free(external_parameter->fault_code);
+        free(external_parameter);
+    }
+
+#ifdef ACS_MULTI
+    b = mxmlFindElement(tree_out, tree_out, "ParameterList",
+                NULL, NULL, MXML_DESCEND);
+    if (!b) goto out;
+
+    if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
+        goto out;
+
+    mxmlElementSetAttr(b, "soap_enc:arrayType", c);
+    FREE(c);
+#endif
+
+    return 0;
+
+out:
+    external_free_list_parameter();
+    return -1;
+}
+
  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
                             mxml_node_t *tree_in,
                             mxml_node_t *tree_out) {
diff --git a/src/xml.h b/src/xml.h
index 8f63192..a9191eb 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -26,6 +26,10 @@ static int 
xml_handle_get_parameter_values(mxml_node_t *body_in,
                         mxml_node_t *tree_in,
                         mxml_node_t *tree_out);

+static int xml_handle_get_parameter_names(mxml_node_t *body_in,
+                       mxml_node_t *tree_in,
+                       mxml_node_t *tree_out);
+
  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
                             mxml_node_t *tree_in,
                             mxml_node_t *tree_out);
-- 
1.7.4.1



From mohamed.kallel@pivasoftware.com Thu Dec  6 14:53:42 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 14:53:47 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:49206 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6826530Ab2LFNxmeg9pk (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 14:53:42 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0M4DMF-1SqZCe0tKF-00r5js; Thu, 06 Dec 2012 14:53:36 +0100
Message-ID: <50C0A358.6050700@pivasoftware.com>
Date:   Thu, 06 Dec 2012 14:53:28 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org
CC:     freecwmp@lukaperkov.net
Subject: ubus data model patch [15/27]
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:sNmmaWfnQpxD1ZlLTwAqRcIRu5WE2X+IGOaASS+Avwq
 y+yVopxz9ZVpH8E5MlBSdH2DwpFZqqSBPObjH0yFyRHMvvoLoK
 mcrDG+xiyWvR8i9Sy8ywk9zaHfNNb4lNNB2h5TzNdcuLt31QEX
 AvnuX1S0CKAbziSdN6AKefeYbgPp6HEEvhVJo4czzIOaSaa1Lu
 AtWdXpfsdd/YgsUnuA3R2GqQgpxMl+ml3IGmnp/FROklWPpR2U
 D+atX2hlas4+tyEoVbozjZKOScJuen2QwNrP8LjNhonWJzkbCg
 /mMIQjzEtmdtmAFOQ5Ojo0mzAnptmVnohIP0nQiOGbnLAvlK3N
 hGu2pXgAZKq6842RMHk1rg/1c/YzmbenOLak0Gew3
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 90
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

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



From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:37 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:38 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:50482 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831871Ab2LFP5hGiIFT (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:37 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MLyRQ-1ToN420u0y-007rtu; Thu, 06 Dec 2012 16:57:30 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>
Subject: [PATCH 00/27] Data model with ubus
Date:   Thu,  6 Dec 2012 16:54:25 +0100
Message-Id: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:BAmFSO/Q2VpQQiHeZq1xZ7Y6eow00hhNuc+sQaOha6u
 7ZfOYiW3WecplhXHhwiIbUxWDo5nB3I0ibb8YbkDakbx8JMdl3
 U0UzUopukc8q1UR7q4AL+vrsH2xVYW7eB/WoF45d9JGfWMVM4t
 QLtzGKK+qs4UQgg+sJnspr+HcN5yKXN8ARJSyNXeG1/Ux9xwkv
 M20DdJ6hc+nHtDhGdXe4qsiYvRib4EPnz5QGcL3LlV294l8rES
 FRYIeMeTLzkLvlG/zp26f9Bhh7z3j6BHei00s30um9p0SjI8nt
 rZn6GFLdMxlOITpPouVDMxdwsGT98QBH8oBPosf80w0ANCdxx6
 OqnAqkcJvLrpipdFNgfcr4WZ/bd1Jw6OQbVVhEPemPiemUYLdf
 6itG2PdryvBq/Sd8GmaFuIU9ZmOMp9dXizZD1NW2B3kN/yqE3U
 DrtV2
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 91
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

As summary, The following patches contains:

  communication from script to the core via ubus
  GetParameterValues method supporting many parameters
  GetParameterNames method added

Regards
Mohamed KALLEL

Mohamed (27):
  add ubus listner get_parameter_values. This listener allows to get
    the freecwmp output from extenal command.       Contributed by
    Inteno Broadband Technology AB
  get_parameter values handler from xml is supporting many parameters
    from external ubus output       Contributed by Inteno Broadband
    Technology AB && PIVA SOFTWARE
  add in the scripts the functions needed to communicate data to ubus
    handler for the get_parameter_values ubus handler       Contributed
    by Inteno Broadband Technology AB
  Update device_hosts to support communicte data of get parameter
    values to the core via ubus       Contributed by Inteno Broadband
    Technology AB
  Update device_info script to support communicte data of get parameter
    values to the core via ubus       Contributed by Inteno Broadband
    Technology AB
  Update device_routing script to support communicte data of get
    parameter values to the core via ubus       Contributed by Inteno
    Broadband Technology AB
  Update device_users script to support communicte data of get
    parameter values to the core via ubus       Contributed by Inteno
    Broadband Technology AB
  Update lan_device script to support communicte data of get parameter
    values to the core via ubus       Contributed by Inteno Broadband
    Technology AB
  Update management_server script to support communicte data of get
    parameter values to the core via ubus       Contributed by Inteno
    Broadband Technology AB
  Update misc script to support communicte data of get parameter values
    to the core via ubus       Contributed by Inteno Broadband
    Technology AB
  Update wan_device script to support communicte data of get parameter
    values to the core via ubus       Contributed by Inteno Broadband
    Technology AB
  update inform in order to get parameters from ubus instead from pipe 
         Contributed by PIVA SOFTWARE
  Add 3rd argument in the ubus handler of notification. The 3rd
    argument is the type of the parameter      This agument could be 
    used in the response of get parameter attribute       Contributed
    by Inteno Broadband Technology AB
  add xml message get_parameter_name handler.       Contributed by
    Inteno Broadband Technology AB & PIVA SOFTWARE
  add the common function and adapt the script freecwmp.sh in order to
    support get parameter names       Contributed by Inteno Broadband
    Technology AB
  update the script device_info in order to output parameters with ubus
          Contributed by Inteno Broadband Technology AB
  update the script lan_device in order to output parameters with ubus 
         Contributed by Inteno Broadband Technology AB
  update the script management_server in order to output parameters
    with ubus       Contributed by Inteno Broadband Technology AB
  update the script wan_device in order to output parameters with ubus 
         Contributed by Inteno Broadband Technology AB
  update the get notification in order to put the returned data via
    ubus instead of pipe      TODO: develop the xml handle message to
    perform send of GetParameterAttributeResponse       Contributed by
    Inteno Broadband Technology AB
  update the data model parameter scripts in order to output parameter
    and notification values via ubus       Contributed by Inteno
    Broadband Technology AB
  update xml handler set parameter values in order to execute external
    command and get response via ubus       Contributed by Inteno
    Broadband Technology AB
  update common script and freecwmp.sh script in order to have the
    functions for set parameter values working with ubus      
    Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
  update dm script to send the output of set parameter function to the
    ubus       Contributed by Inteno Broadband Technology AB
  add ubus listner for set parameter attribute       Contributed by
    Inteno Broadband Technology AB & PIVA SOFTWARE
  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
  update the dm script function to communicate the output of set
    parameter attribute with ubus       Contributed by Inteno Broadband
    Technology AB

 bin/Makefile.am                                 |    3 +-
 configure.ac                                    |    3 +
 ext/openwrt/config/freecwmp                     |   18 +
 ext/openwrt/scripts/freecwmp.sh                 |  219 ++++++-
 ext/openwrt/scripts/functions/common            |   69 ++
 ext/openwrt/scripts/functions/device_hosts      |   22 +-
 ext/openwrt/scripts/functions/device_info       |  448 ++++++++++++-
 ext/openwrt/scripts/functions/device_routing    |   33 +-
 ext/openwrt/scripts/functions/device_users      |   13 +-
 ext/openwrt/scripts/functions/lan_device        |  232 ++++++-
 ext/openwrt/scripts/functions/management_server |  808 ++++++++++++++++++++---
 ext/openwrt/scripts/functions/misc              |    8 +-
 ext/openwrt/scripts/functions/wan_device        |  427 +++++++++++-
 src/cwmp.c                                      |    4 +-
 src/cwmp.h                                      |    2 +-
 src/external.c                                  |  218 +++++--
 src/external.h                                  |   26 +-
 src/freecwmp.c                                  |   17 +
 src/ubus.c                                      |  233 +++++++-
 src/xml.c                                       |  260 ++++++--
 src/xml.h                                       |    4 +
 21 files changed, 2741 insertions(+), 326 deletions(-)

-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:38 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:43 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:58487 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831874Ab2LFP5ht71t2 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:37 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MCID3-1Tpkd80eUz-009FTX; Thu, 06 Dec 2012 16:57:32 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 01/27] add ubus listner get_parameter_values. This listener allows to get the freecwmp output from extenal command. Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:26 +0100
Message-Id: <1354809292-2467-2-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:m3+ix7lATSRm3dRaOHaRj5DYFreLjktqlqKKxieOPP8
 AEGZ2UXQbryEG3TH/+6l9KqTzByUNEi1MYaPts4djoFF5psdIC
 szVdF09zCsF8HZwlgrIBR763cJlmwUNT7BYR0tBpnho0CKFQhe
 gJQ0DgdL4A329+MMpW6/AeUts5C5nr3ikloKQvdSdsEsbRrNyK
 LXRktupFaUmAjEjniNEEwU+h5a/fmKp/nbgzLVLDf8dJU2FMpf
 vXXKJ5X8F5VnpDuRh/YwXqf9AzXReikWUNK89OclOEvtyJu1zM
 t4cZhBX7AIpCw5Wk3KeGbnftvFIa4Y8UoASNvjWRvqd+BV97gt
 cXQ/36N+P1PZuDqIKLF75ggjw2zL7wb+35687Hr5d0Xe+wP82T
 r+wd4efnd7r/OmHR5drOQ+N0zdJ8QGL7jXlTLZUHIgZo+tJriw
 Ks62z
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 92
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 src/external.c |   13 +++++++++++++
 src/external.h |   10 ++++++++++
 src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/external.c b/src/external.c
index 9ac7b36..c9c768f 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,6 +25,19 @@
 #include "freecwmp.h"
 
 static struct uloop_process uproc;
+LIST_HEAD(external_list_parameter);
+
+void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
+{
+	struct external_parameter *external_parameter;
+	struct list_head *ilist; int i =0;
+	external_parameter = calloc(1, sizeof(struct external_parameter));
+	list_add_tail(&external_parameter->list,&external_list_parameter);
+	if (param_name) external_parameter->name = strdup(param_name);
+	if (param_data) external_parameter->data = strdup(param_data);
+	if (param_type) external_parameter->type = strdup(param_type);
+	if (fault_code) external_parameter->fault_code = strdup(fault_code);
+}
 
 int external_get_action(char *action, char *name, char **value)
 {
diff --git a/src/external.h b/src/external.h
index 8606266..64b4c6b 100644
--- a/src/external.h
+++ b/src/external.h
@@ -9,6 +9,7 @@
 
 #ifndef _FREECWMP_EXTERNAL_H__
 #define _FREECWMP_EXTERNAL_H__
+#include <libubox/list.h>
 
 #ifdef DUMMY_MODE
 static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
@@ -17,11 +18,20 @@ static char *fc_script = "/usr/sbin/freecwmp";
 #endif
 static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
 
+struct external_parameter {
+	struct list_head list;
+	char *name;
+	char *data; /* notification for GetParameterAttribute; writable for GetParameterNames; value for GetParameterValues*/
+	char *type;
+	char *fault_code;
+};
+
 int external_get_action(char *action, char *name, char **value);
 int external_set_action_write(char *action, char *name, char *value);
 int external_set_action_execute();
 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);
 
 #endif
 
diff --git a/src/ubus.c b/src/ubus.c
index c10170d..d5437f9 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -16,6 +16,7 @@
 #include "config.h"
 #include "cwmp.h"
 #include "freecwmp.h"
+#include "external.h"
 
 static struct ubus_context *ctx = NULL;
 static struct ubus_object main_object;
@@ -157,10 +158,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
 	return 0;
 }
 
+static enum get_param_values {
+	GET_PARAM_VALUES_PARAM,
+	GET_PARAM_VALUES_VALUE,
+	GET_PARAM_VALUES_TYPE,
+	GET_PARAM_VALUES_FAULT,
+	__GET_PARAM_VALUES_MAX
+};
+
+static const struct blobmsg_policy get_param_values_policy[] = {
+	[GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_VALUES_MAX];
+
+	blobmsg_parse(get_param_values_policy, ARRAY_SIZE(get_param_values_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_VALUES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	freecwmp_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_values for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
+			tb[GET_PARAM_VALUES_VALUE]? blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,
+			tb[GET_PARAM_VALUES_TYPE]? blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",
+			tb[GET_PARAM_VALUES_FAULT]? blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);
+
+	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),
 };
 
 static struct ubus_object_type main_object_type =
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:44 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:45 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:50755 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831875Ab2LFP5i2lipM (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:38 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MekHI-1TVbC010gq-00OQqY; Thu, 06 Dec 2012 16:57:33 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 02/27] get_parameter values handler from xml is supporting many parameters from external ubus output Contributed by Inteno Broadband Technology AB && PIVA SOFTWARE
Date:   Thu,  6 Dec 2012 16:54:27 +0100
Message-Id: <1354809292-2467-3-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:2nnN8E/w0QgI0HLuojOp2m4AMfUNXoyVT6IeMdhoj3h
 bhwcxeimi3gLCaGYYHNtsua+6TB+IlMa72qG+TAlyD3mM5oCAr
 LkjCs02CHVks+TaRpqaHdBQzj+o0gUzvMKJpHAWXUjlb1rSAfn
 4tGYvM9LmxBfALdDQU0//W4J0AmY9ljltxB9/MPQ8fCRzMQlKz
 v5CAsRJcAq0SyorcMn5fII9I5MYrSHstpDnWXSpxWg7oaY4VbN
 iiZgCYvd7ZWNnmw4wFtUTlvzfbYOPmy0takmHLQGDCMT1x2dUR
 A0O5AE61xmAR8Vd60EhWWCBY83c533OqgufvoFb2xVyBe9fZb2
 kFbk5P+hHortqTWqd+bnl1CxQTyaHkD+T4fs8emSEyzb09Il3u
 RciYRMD0R7SjBJYYSGRyC1Djp0oUECepqoOt2dFdSwWXCD0LNj
 jI+gb
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 93
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 bin/Makefile.am |    3 +-
 configure.ac    |    3 ++
 src/external.c  |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/external.h  |    6 +++-
 src/freecwmp.c  |   17 ++++++++++
 src/xml.c       |   66 +++++++++++++++++++++++--------------
 6 files changed, 163 insertions(+), 27 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 78cb111..ac96905 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,5 +48,6 @@ freecwmpd_LDADD =		\
 	$(LIBUBUS_LIBS)		\
 	$(MICROXML_LIBS)	\
 	$(LIBCURL_LIBS)		\
-	$(LIBZSTREAM_LIBS)
+	$(LIBZSTREAM_LIBS)	\
+	$(LIBPTHREAD_LIBS)
 
diff --git a/configure.ac b/configure.ac
index c646c3a..38d3df4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
 LIBUBUS_LIBS='-lubus'
 AC_SUBST([LIBUBUS_LIBS])
 
+LIBPTHREAD_LIBS='-lpthread'
+AC_SUBST([LIBPTHREAD_LIBS])
+
 AM_COND_IF([HTTP_CURL], [
  AC_DEFINE(HTTP_CURL)
  PKG_CHECK_MODULES(LIBCURL, [libcurl])
diff --git a/src/external.c b/src/external.c
index c9c768f..94ae9b8 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,8 +25,15 @@
 #include "freecwmp.h"
 
 static struct uloop_process uproc;
+pthread_t ubus_thread;
 LIST_HEAD(external_list_parameter);
 
+void *thread_uloop_run (void *v)
+{
+	uloop_run();
+	return NULL;
+}
+
 void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
 {
 	struct external_parameter *external_parameter;
@@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name, char *param_data, char *par
 	if (fault_code) external_parameter->fault_code = strdup(fault_code);
 }
 
+void external_free_list_parameter()
+{
+	struct external_parameter *external_parameter;
+	while (external_list_parameter.next!=&external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		list_del(&external_parameter->list);
+		free(external_parameter->name);
+		free(external_parameter->data);
+		free(external_parameter->type);
+		free(external_parameter->fault_code);
+		free(external_parameter);
+	}
+}
+
 int external_get_action(char *action, char *name, char **value)
 {
 	freecwmp_log_message(NAME, L_NOTICE,
@@ -121,6 +142,80 @@ error:
 	return -1;
 }
 
+int external_get_action_write(char *action, char *name, char *arg)
+{
+	freecwmp_log_message(NAME, L_NOTICE,
+		"adding to get %s script '%s'\n", action, name);
+
+	FILE *fp;
+
+	if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
+		fp = fopen(fc_script_get_actions, "a");
+		if (!fp) return -1;
+	} else {
+		fp = fopen(fc_script_get_actions, "w");
+		if (!fp) return -1;
+
+		fprintf(fp, "#!/bin/sh\n");
+
+		if (chmod(fc_script_get_actions,
+			strtol("0700", 0, 8)) < 0) {
+			return -1;
+	}
+	}
+
+#ifdef DUMMY_MODE
+	fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action, name, arg?arg:"");
+#else
+	fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name, arg?arg:"");
+#endif
+
+	fclose(fp);
+
+	return 0;
+}
+
+int external_get_action_execute()
+{
+	freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
+
+	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
+
+	if ((uproc.pid = fork()) == -1) {
+		return -1;
+	}
+
+	if (uproc.pid == 0) {
+		/* child */
+
+		const char *argv[3];
+		int i = 0;
+		argv[i++] = "/bin/sh";
+		argv[i++] = fc_script_get_actions;
+		argv[i++] = NULL;
+
+		execvp(argv[0], (char **) argv);
+		exit(ESRCH);
+
+	} else if (uproc.pid < 0)
+	return -1;
+
+	/* parent */
+	int status;
+	while (wait(&status) != uproc.pid) {
+		DD("waiting for child to exit");
+	}
+
+	pthread_cancel(ubus_thread);
+	pthread_join(ubus_thread,NULL);
+
+	// TODO: add some kind of checks
+
+	remove(fc_script_get_actions);
+
+	return 0;
+}
+
 int external_set_action_write(char *action, char *name, char *value)
 {
 	freecwmp_log_message(NAME, L_NOTICE,
diff --git a/src/external.h b/src/external.h
index 64b4c6b..c6df2ea 100644
--- a/src/external.h
+++ b/src/external.h
@@ -16,7 +16,8 @@ static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
 #else
 static char *fc_script = "/usr/sbin/freecwmp";
 #endif
-static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
+static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
+static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";
 
 struct external_parameter {
 	struct list_head list;
@@ -27,11 +28,14 @@ struct external_parameter {
 };
 
 int external_get_action(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_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);
+void external_free_list_parameter();
 
 #endif
 
diff --git a/src/freecwmp.c b/src/freecwmp.c
index 4ef8395..f4c9cb1 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -18,6 +18,7 @@
 #include <arpa/inet.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
+#include <signal.h>
 
 #include <libfreecwmp.h>
 #include <libubox/uloop.h>
@@ -194,11 +195,27 @@ netlink_init(void)
 	return 0;
 }
 
+void signal_kill_all_handler(int sig)
+{
+     pthread_exit(NULL);
+}
+
+
+
 int main (int argc, char **argv)
 {
 	freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");
 
 	bool foreground = false;
+	struct sigaction sigint_action;
+
+	sigint_action.sa_handler = &signal_kill_all_handler;
+	sigemptyset (&sigint_action.sa_mask);
+	/* reset handler in case when pthread_cancel didn't stop
+	   threads for some reason */
+	sigint_action.sa_flags = SA_RESETHAND;
+	sigaction(SIGTERM, &sigint_action, NULL);
+
 
 	setlocale(LC_CTYPE, "");
 	umask(0037);
diff --git a/src/xml.c b/src/xml.c
index 9fa036b..23b9ec7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -21,6 +21,8 @@
 #include "messages.h"
 #include "time.h"
 
+extern struct list_head external_list_parameter;
+
 struct rpc_method {
 	const char *name;
 	int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
@@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 				    mxml_node_t *tree_in,
 				    mxml_node_t *tree_out)
 {
-	mxml_node_t *n, *b = body_in;
+	mxml_node_t *n, *parameter_list, *b = body_in;
+	struct external_parameter *external_parameter;
 	char *parameter_name = NULL;
 	char *parameter_value = NULL;
-	char *c;
+	char *c=NULL;
 	int counter = 0;
 
 	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
@@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 		    !strcmp(b->parent->value.element.name, "string")) {
 			parameter_name = b->value.text.string;
 		}
-
+		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterValues with empty string*/
+			!strcmp(b->value.element.name, "string") &&
+			!b->child) {
+			parameter_name = "";
+		}
 		if (parameter_name) {
 			if (!config_get_cwmp(parameter_name, &parameter_value)) {
+				external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);
+				FREE(parameter_value);
 				// got the parameter value using libuci
-			} else if (!external_get_action("value",
-					parameter_name, &parameter_value)) {
+			} else if (!external_get_action_write("value",parameter_name, NULL)) {
 				// got the parameter value via external script
 			} else {
 				// error occurred when getting parameter value
 				goto out;
 			}
-			counter++;
+		}
+		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+		parameter_name = NULL;
+	}
 
-			n = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
-			if (!n) goto out;
+	if (external_get_action_execute())
+		goto out;
+
+	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
+	if (!parameter_list) goto out;
+
+	while (external_list_parameter.next!=&external_list_parameter) {
+
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
 
-			n = mxmlNewElement(n, "ParameterValueStruct");
+		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
+			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code
+
+		n = mxmlNewElement(parameter_list, "ParameterValueStruct");
 			if (!n) goto out;
 
 			n = mxmlNewElement(n, "Name");
 			if (!n) goto out;
 
-			n = mxmlNewText(n, 0, parameter_name);
+		n = mxmlNewText(n, 0, external_parameter->name);
 			if (!n) goto out;
 
 			n = n->parent->parent;
@@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 			if (!n) goto out;
 
 #ifdef ACS_MULTI
-			mxmlElementSetAttr(n, "xsi:type", "xsd:string");
+		mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
 #endif
-			n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
+		n = mxmlNewText(n, 0, external_parameter->data? external_parameter->data : "");
 			if (!n) goto out;
 
-			/*
-			 * three day's work to finally find memory leak if we
-			 * free parameter_name;
-			 * it points to: b->value.text.string
-			 *
-			 * also, parameter_value can be NULL so we don't do checks
-			 */
-			parameter_name = NULL;
-		}
+		counter++;
 		
-		FREE(parameter_value);
-		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+		list_del(&external_parameter->list);
+		free(external_parameter->name);
+		free(external_parameter->data);
+		free(external_parameter->type);
+		free(external_parameter->fault_code);
+		free(external_parameter);
 	}
 
 #ifdef ACS_MULTI
@@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 	FREE(c);
 #endif
 
-	FREE(parameter_value);
 	return 0;
 
 out:
-	FREE(parameter_value);
+	external_free_list_parameter();
 	return -1;
 }
 
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:46 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:47 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:61319 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831876Ab2LFP5k3x91U (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:40 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MWzzA-1TdKQ51Yay-00WA4k; Thu, 06 Dec 2012 16:57:34 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 03/27] add in the scripts the functions needed to communicate data to ubus handler for the get_parameter_values ubus handler Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:28 +0100
Message-Id: <1354809292-2467-4-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:54qWWISpuPrxbmH9P/2ClXh7GwIjRGkN5qYRwsXo0Zl
 G6Rx6/+B8uY79Za6Vg+ApysFJ5lZgv6+OwMPGLAy/BH4yfIhlq
 p4sKH1+N2eNeZYV2ae3uKin59zjLjxjuOtoF3Yz/kY0KJWVaGZ
 CnX/dkwNYinCqJprxbTA9v+lhJuXuartflJAaaPgf/66hGYi1N
 ekga4prtRfU27NgqmSIxRu+X48n1pi3rvt4uzLWH+WUc4Thc21
 400ONkwcvNq5t+TlqqZ3ApPXkkpvPbT1wTV3f45PTHG2kladkR
 7auaUwT2j7AqKZjFsl7MQfMZ366RRby7TS7nTrud4PnbsNNGLz
 dy5v4VfMSSLfcrDOpmsNi7EYRwy4P7CJbpFQENoarsKJY7M6he
 WSlkXYhtMFfSeBHxThUHlPM4ATiteTZwnmCfedrNFmhPDR6WYV
 zKuT0
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 94
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/freecwmp.sh      |   51 ++++++++++++++++++++++++++++------
 ext/openwrt/scripts/functions/common |   23 +++++++++++++++
 2 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..f2bebc8 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,21 +113,54 @@ handle_scripts() {
 config_load freecwmp
 config_foreach handle_scripts "scripts"
 
+# Fault code
+
+FAULT_CPE_NO_FAULT="0"
+FAULT_CPE_REQUEST_DENIED="1"
+FAULT_CPE_INTERNAL_ERROR="2"
+FAULT_CPE_INVALID_ARGUMENTS="3"
+FAULT_CPE_RESOURCES_EXCEEDED="4"
+FAULT_CPE_INVALID_PARAMETER_NAME="5"
+FAULT_CPE_INVALID_PARAMETER_TYPE="6"
+FAULT_CPE_INVALID_PARAMETER_VALUE="7"
+FAULT_CPE_NON_WRITABLE_PARAMETER="8"
+FAULT_CPE_NOTIFICATION_REJECTED="9"
+FAULT_CPE_DOWNLOAD_FAILURE="10"
+FAULT_CPE_UPLOAD_FAILURE="11"
+FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
+FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
+FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
+FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
+FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
+FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
+
 if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
-	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
+    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 $get_value_functions
 	do
 		$function_name "$__arg1"
+				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
+        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+    fi
 fi
 
 if [ "$action" = "set_value" ]; then
diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
index 7e3000a..082e067 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE} ]; then
 fi
 }
 
+ubus_freecwmp_output() {
+local parameter="$1"
+local value="$2"
+local type="$3"
+local fault_code="$4"
+
+if [ "$type" = "" ]; then
+	type="xsd:string"
+fi
+
+case "$action" in
+	get_value)
+	ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", "value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 2> /dev/null
+	;;
+esac
+}
 freecwmp_value_output() {
 	freecwmp_output "$1" "$2" "V"
 }
@@ -249,3 +265,10 @@ EOF
 	sh "$lock" &
 fi
 }
+
+freecwmp_check_fault() {
+if [ "$1" = "." ]; then
+	return $FAULT_CPE_INVALID_PARAMETER_NAME
+fi
+return $FAULT_CPE_NO_FAULT
+}
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:47 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:52 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:62947 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831877Ab2LFP5kysc0T (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:40 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LbacF-1TJB251qKB-00l489; Thu, 06 Dec 2012 16:57:35 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 04/27] Update device_hosts to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:29 +0100
Message-Id: <1354809292-2467-5-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:i0HtMQTlIXdd22+EOZUdQtD0V2tyDgWcscDl2kfj2Cp
 YP52Taumv661Fu7MmelcN0dJjuHirG/CmIYNAbUe8/FWFnGbZD
 GySDt/s07u6bmNA1J5dmlIL4qgi+pk6AjgSqB0LnKo/z/L+8pt
 br4IseKrY7rRz7iq7u9yeq1vMABQ+N9B0wZFj/SgdOwLVWHTAu
 Dmh7fyr8Sh/IzdEQL7jo+NgsuXPgjzRALa7JCch+yNxO6PabRe
 YRm3X+DH+KyIw7s+dbTi+y42iYkTB0LYpeJ63No+d1ss2z/lbI
 9SSfYw1AJTFxfng2AxyD22Wz0I6lfMxqpBUD/AacHmtwVN6QVr
 dhtdbM33cnWcuWdv2eKjYXmuoX6S20tSYeK6Nm3V9iKvpSea2q
 jrL4mby8/Jh11iZoBJDdD0Ix9mmOrY0KhTJnuRQnpdTRmomD7V
 CzY9D
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 95
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_hosts |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_hosts b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..8909df6 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -44,7 +44,7 @@ local parameter=`echo -n $1 | sed "s/InternetGatewayDevice\.LANDevice\.1\./Devic
 case "$parameter" in
 	Device.Hosts.HostNumberOfEntries)
 	let local val=$num_static_leases+$num_dynamic_leases
-	freecwmp_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 	;;
 esac
@@ -66,7 +66,7 @@ if [ $rc -eq 0 ]; then
 		local sed_cmd=`echo -n \'$num; echo p\'`
 		val=`eval sed -n $sed_cmd $leases_file | awk '{ print $2 }'`
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -74,7 +74,7 @@ freecwmp_parse_formated_parameter "$parameter" "Device.Hosts.Host.{i}.IPAddress"
 if [ $rc -eq 0 ]; then
 	local val
 	get_device_hosts_ip_address "$leases_file" "$num" "$num_static_leases" "$num_dynamic_leases" "val"
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -88,7 +88,7 @@ if [ $rc -eq 0 ]; then
 	if [ $num -gt 0 -a $num -le $num_dynamic_leases ]; then
 		val="DHCP"
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -107,7 +107,7 @@ if [ $rc -eq 0 ]; then
 		local t2=`date +%s`
 		let val=$t1-$t2
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -131,7 +131,7 @@ if [ $rc -eq 0 ]; then
 		val=`eval sed -n $sed_cmd $leases_file | awk '{ print $4 }'`
 		if [ "x$val" == "x*" ]; then val=""; fi
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -144,7 +144,7 @@ if [ $rc -eq 0 ]; then
 	get_device_hosts_ip_address "$leases_file" "$num" "$num_static_leases" "$num_dynamic_leases" "ip"
 	val=`ping -c 1 $ip 2>&1 > /dev/null ; echo $?`
 	let val=!$val
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -156,7 +156,7 @@ if [ $rc -eq 0 ]; then
 	if [ $num -le $n ]; then
 		val=1
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -168,7 +168,7 @@ if [ $rc -eq 0 ]; then
 	if [ $num -le $n ]; then
 		val=0
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -182,10 +182,10 @@ if [ $rc -eq 0 ]; then
 	if [ $num2 -eq 1 ]; then
 		get_device_hosts_ip_address "$leases_file" "$num1" "$num_static_leases" "$num_dynamic_leases" "val"
 	fi
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
 # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 support yet)
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:52 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:53 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:64223 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831878Ab2LFP5ltoSjK (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:41 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LgXtF-1TLwC22fjx-00npYF; Thu, 06 Dec 2012 16:57:36 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 05/27] Update device_info script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:30 +0100
Message-Id: <1354809292-2467-6-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:sXXLyEL6xE7h8pcaoJyDpbGSJADO9yoz/U6CYWfmKze
 Sq0eM6fj1mfadHdwuV6OJwxHkgqif/1bOztCCbv290Z7w4z3FI
 u+nrawPZ8sjWv8AwHMhp/U3rUQ+zFly+1EGSv+XvvxiQFvnP1m
 4BZhZVyLcJH1Gh7j7fjh+xz9kTcMjGX9plViS7EsLpkxFOOLw1
 tVhdWwA7FF8c2sKvZ5cnLp0Q5YYkKNpSGbnsfxlFzp3sdvn6r6
 qSgzDYRtKqAVvXEd7reBA0Y5dw/uxW5we6RcVC4nh3Vpfd2Plh
 soPlKoCcmgAmCLdGMA2V3cp8hstM1UPIZR8o9ik5sgjpQZCj7F
 NHycffI8THuW9EPjju3MCk79wzUg5xk6WLQ6nhvbrklu9v/lfm
 7QBFi+O5fQ4amx+a3fbO3zpWM4DqRMAyArwybWjgdiSwuW1Ela
 8T7wL
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 96
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_info |   32 +++++++++++++++++++---------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
index 4423b8b..86ff5c9 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -3,7 +3,7 @@
 
 get_device_info_manufacturer() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
 }
 
 set_device_info_manufacturer() {
@@ -12,7 +12,7 @@ set_device_info_manufacturer() {
 
 get_device_info_oui() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
 }
 
 set_device_info_oui() {
@@ -21,7 +21,7 @@ set_device_info_oui() {
 
 get_device_info_product_class() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
 }
 
 set_device_info_product_class() {
@@ -30,7 +30,7 @@ set_device_info_product_class() {
 
 get_device_info_serial_number() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
 }
 
 set_device_info_serial_number() {
@@ -39,7 +39,7 @@ set_device_info_serial_number() {
 
 get_device_info_hardware_version() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
 }
 
 set_device_info_hardware_version() {
@@ -48,7 +48,7 @@ set_device_info_hardware_version() {
 
 get_device_info_software_version() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
 }
 
 set_device_info_software_version() {
@@ -57,7 +57,7 @@ set_device_info_software_version() {
 
 get_device_info_uptime() {
 local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
 }
 
 get_device_info_device_log() {
@@ -67,7 +67,7 @@ if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
 else
 	val=`dmesg | tail -n10`
 fi
-freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
 }
 
 get_device_info() {
@@ -81,6 +81,7 @@ case "$1" in
 	get_device_info_software_version
 	get_device_info_uptime
 	get_device_info_device_log
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.)
 	get_device_info_manufacturer
@@ -91,32 +92,42 @@ case "$1" in
 	get_device_info_software_version
 	get_device_info_uptime
 	get_device_info_device_log
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.Manufacturer)
 	get_device_info_manufacturer
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
 	get_device_info_oui
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.ProductClass)
 	get_device_info_product_class
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.SerialNumber)
 	get_device_info_serial_number
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.HardwareVersion)
 	get_device_info_hardware_version
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
 	get_device_info_software_version
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.UpTime)
 	get_device_info_uptime
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.DeviceLog)
 	get_device_info_device_log
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
 set_device_info() {
@@ -161,10 +172,11 @@ return 1
 }
 
 get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
 
 	freecwmp_get_parameter_value "val" "$1"
-	freecwmp_value_output "$1" "$val"
+	ubus_freecwmp_output "$1" "$val"
+	return $FAULT_CPE_NO_FAULT
 }
 
 set_device_info_generic() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:54 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:55 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:63702 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831879Ab2LFP5mwf1TT (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:42 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LrsY2-1T2Kyc3OF4-013Yt2; Thu, 06 Dec 2012 16:57:37 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 06/27] Update device_routing script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:31 +0100
Message-Id: <1354809292-2467-7-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:A8u/LI1ViUivUxcJnQS3NJANAmLPD5yP+tkB/64fR55
 VU48M4yPsOLhp1ukfxEKOuuiUQVpNpNjcQedHx938Az44gfIcX
 4v0SaS4yggidG9Arm5YsA04LXszCrofLkMr4WMpH5TAvLXPrwc
 tX9FgVSgeu2HeJOW63xEwuFhVWvmh302xkClpzDO3/xPyFYsdo
 8Jj/zHpcXOzLo0XWGh3Wd+SF5z5ur6wnKG6wmvPmz8DKs0NZ/p
 JjCi6uYJE6fdSAzgMPnGtUNP2yRUBB7cnbpsLmB8kUURx7mw3G
 qGkHGOyfk4AU74IlHa+e9XTFxFzfyNHgroSsLKwXImd9dK8mNk
 QDi5t9QWb2KsqMSuToU15N6qYqjPCCM4HZSe8EjDiEhb/OiLY3
 fnsGfJM7IDLEotD6LTecol6jtrvrxj3onp5F16iXy5IgDK5tN2
 Zw7T2
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 97
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_routing |   33 +++++++++++++------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_routing b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..ca6dab1 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -85,7 +85,7 @@ local parameter=$1
 
 case "$parameter" in
 	Device.Routing.RouterNumberOfEntries)
-	freecwmp_output "$parameter" "1"
+	ubus_freecwmp_output "$parameter" "1"
 	return
 	;;
 esac
@@ -101,7 +101,7 @@ if [ $rc -eq 0 ]; then
 	else
 		val="0"
 	fi
-	freecwmp_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -113,7 +113,7 @@ if [ $rc -eq 0 ]; then
 	else
 		val="Disabled"
 	fi
-	freecwmp_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -134,7 +134,7 @@ if [ $rc -eq 0 ]; then
 	else
 		return
 	fi
-	freecwmp_output "$parameter" "$total"
+	ubus_freecwmp_output "$parameter" "$total"
 	return
 fi
 
@@ -146,7 +146,7 @@ if [ $rc -eq 0 ]; then
 	else
 		return
 	fi
-	freecwmp_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -166,15 +166,15 @@ if [ $rc -eq 0 ]; then
 			return
 		fi
 		if [ $num2 -gt $static ]; then
-			freecwmp_output "$parameter" "Enabled"
+			ubus_freecwmp_output "$parameter" "Enabled"
 			return
 		fi
 		if [ $num2 -le $inactive ]; then
-			freecwmp_output "$parameter" "Error: not active but enabled"
+			ubus_freecwmp_output "$parameter" "Error: not active but enabled"
 			return
 		fi
 		if [ $num2 -le $static ]; then
-			freecwmp_output "$parameter" "Enabled"
+			ubus_freecwmp_output "$parameter" "Enabled"
 			return
 		fi
 	else
@@ -197,11 +197,11 @@ if [ $rc -eq 0 ]; then
 			return
 		fi
 		if [ $num2 -gt $static ]; then
-			freecwmp_output "$parameter" "0"
+			ubus_freecwmp_output "$parameter" "0"
 			return
 		fi
 		if [ $num2 -le $static ]; then
-			freecwmp_output "$parameter" "1"
+			ubus_freecwmp_output "$parameter" "1"
 			return
 		fi
 	else
@@ -230,7 +230,7 @@ if [ $rc -eq 0 ]; then
 			let local i=$static-$num2
 			target=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].target 2> /dev/null`
 		fi
-		freecwmp_output "$parameter" "$target"
+		ubus_freecwmp_output "$parameter" "$target"
 		return
 	else
 		return
@@ -258,7 +258,7 @@ if [ $rc -eq 0 ]; then
 			let local i=$static-$num2
 			netmask=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].netmask 2> /dev/null`
 		fi
-		freecwmp_output "$parameter" "$netmask"
+		ubus_freecwmp_output "$parameter" "$netmask"
 		return
 	else
 		return
@@ -288,7 +288,7 @@ if [ $rc -eq 0 ]; then
 			let local i=$static-$num2
 			gateway=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].gateway 2> /dev/null`
 		fi
-		freecwmp_output "$parameter" "$gateway"
+		ubus_freecwmp_output "$parameter" "$gateway"
 		return
 	else
 		return
@@ -315,7 +315,7 @@ if [ $rc -eq 0 ]; then
 		elif [ $num2 -le $static ]; then
 			val="Static"
 		fi
-		freecwmp_output "$parameter" "$val"
+		ubus_freecwmp_output "$parameter" "$val"
 		return
 	else
 		return
@@ -343,11 +343,12 @@ if [ $rc -eq 0 ]; then
 			let local i=$static-$num2
 			metric=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].metric 2> /dev/null`
 		fi
-		freecwmp_output "$parameter" "$metric"
+		ubus_freecwmp_output "$parameter" "$metric"
 		return
 	else
 		return
 	fi
 fi
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
+
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:56 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:56 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:54313 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831874Ab2LFP5omTWgD (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:44 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Le53E-1TNrzx3Xki-00plME; Thu, 06 Dec 2012 16:57:38 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 07/27]  Update device_users script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:32 +0100
Message-Id: <1354809292-2467-8-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:Gk1RRt4n9NpfmEmzv9niQJ5u8ptnHhWp7STuDiUaODD
 5wZHdkPbKlrCsjqD5HQe3K8HoRU+jTCOPODc1kEGoI9h7Sg4+F
 tLs+Nml5/2932/dE+iDQ+/tzMo6iXHL8YRQlcy+vXyfR3zcWIC
 FHpJzNYZJ7+W+LAik8TOzlJGM89UwY3Anbt5LREHRC+Y6I2cru
 xSyDxw1n/JsMAWNBjY40xFEoVHcoNdZMheH1RgEXLPaiKJpG+/
 ade4raMRLPSu+b6sNRlvF6fIrPQ2upun7/s/Tx5A6ZcWzecf1B
 5DP/Us1A4i6qj7SeMPK8Ash3Tm9bkeH8m+OfI9f3w7TJMZ1iUS
 QIGTXoD492Y6EjNrkkFZLuAsHJybouJqIrXO2nn8n9L91X0TgC
 7FSxq7cuqAAwJptzsAaZ0DGQcUDIb4r6N+Y2m0AnhUprzmZTCd
 LZ6Sx
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 98
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_users |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_users b/ext/openwrt/scripts/functions/device_users
index 0d377f7..d8dba61 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -6,7 +6,7 @@ local parameter="$1"
 case "$parameter" in
 	Device.Users.UserNumberOfEntries)
 	local val=`wc -l /etc/passwd | awk '{ print $1 }'`
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 	;;
 esac
@@ -21,7 +21,7 @@ if [ $rc -eq 0 ]; then
 	# TODO: this is very system dependent, for now just look at users shell
 	local sed_cmd=`echo -n \'$num; echo p\'`
 	local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' | wc -l`
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -30,7 +30,7 @@ if [ $rc -eq 0 ]; then
 	# TODO: this is very system dependent, for now just look at users shell
 	local sed_cmd=`echo -n \'$num; echo p\'`
 	local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' | wc -l`
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -38,7 +38,7 @@ freecwmp_parse_formated_parameter "$parameter" "Device.Users.User.{i}.Username"
 if [ $rc -eq 0 ]; then
 	local sed_cmd=`echo -n \'$num; echo p\'`
 	local val=`eval sed -n $sed_cmd /etc/passwd | awk -F ':' '{ print $1 }'`
-	freecwmp_value_output "$parameter" "$val"
+	ubus_freecwmp_output "$parameter" "$val"
 	return
 fi
 
@@ -48,15 +48,16 @@ if [ $rc -eq 0 ]; then
 	#   local sed_cmd=`echo -n \'$num; echo p\'`
 	#   local val=`eval sed -n $sed_cmd /etc/shadow | awk -F ':' '{ print $2 }'`
 	#   freecwmp_value_output "$parameter" "$val"
-	freecwmp_value_output "$parameter" ""
+	ubus_freecwmp_output "$parameter" ""
 	return
 fi
 
 freecwmp_parse_formated_parameter "$parameter" "Device.Users.User.{i}.Language" "rc" "num"
 if [ $rc -eq 0 ]; then
-	freecwmp_value_output "$parameter" ""
+	ubus_freecwmp_output "$parameter" ""
 	return
 fi
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
 set_device_users() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:57:57 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:57:58 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:63660 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831881Ab2LFP5qCq1tn (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:46 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MORHR-1TmRFf3l5x-005w5v; Thu, 06 Dec 2012 16:57:39 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 08/27] Update lan_device script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:33 +0100
Message-Id: <1354809292-2467-9-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:qhnwV4TkVE3qHpXdzahmWSNjJ7pzpSXtayiN4/Y3aUk
 HD57lPu3w9aKsRsWqp+O4c5emMZE0jobZtkheIzEO1dET1yiGC
 uNQ6vMRyeSGjKenYh8/lEs8UU15KSD0v7TML4fDlnj0anlj0Ka
 tqJumnns9Z94g3pMmVL/kI4itXJ8pzUDYUXPITDnJhAWK+aQlG
 K0KfCFIk3F2UJFTCN1duZr+99DxOAU8vtNJTjHpDnrKYuFTiGh
 Q6An2ueufRecpB5ZrZIxCoAP69FHiej0Zy/mfAlO+T49jj1V+z
 PF8M9Gu/nFWymXlqysnB06q8rWHWeVk+GTeGbeg8fQnc3tFldb
 P42CapYoAR6CdlpfhngsKQrObc3n24Zrv75BhsLUAQiqtrn0jq
 nlq/doOpLVbn0JKrF0UZWQRMs2K0+Ye+RMZXC4kZsPFnmOqOGi
 EGy2W
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 99
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/lan_device |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index 5ba513c..fa9dda4 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -3,6 +3,7 @@
 
 get_wlan_enable() {
 local num="$1"
+local type="xsd:boolean"
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
 let num=$num+1
 if [ "$val" = "1" ]; then
@@ -10,7 +11,7 @@ if [ "$val" = "1" ]; then
 else
 	val="1"
 fi
-freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
 }
 
 set_wlan_enable() {
@@ -29,7 +30,7 @@ get_wlan_ssid() {
 local num="$1"
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
 let num=$num+1
-freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
 }
 
 set_wlan_ssid() {
@@ -44,30 +45,38 @@ case "$1" in
 	InternetGatewayDevice.)
 	get_wlan_enable 0
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.)
 	get_wlan_enable 0
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.)
 	get_wlan_enable 0
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
 	get_wlan_enable 0
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
 	get_wlan_enable 0
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
 	get_wlan_enable 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
 	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
 set_lan_device() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:00 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:02 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:56519 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831875Ab2LFP5rYqGU8 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:47 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MSa8q-1TYuZN0Q8C-00RkEQ; Thu, 06 Dec 2012 16:57:41 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 10/27] Update misc script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:35 +0100
Message-Id: <1354809292-2467-11-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:VjIrn259b5YsPM89aCHVJeCSBar3fJBEVirK5gPdOas
 HGyA9V6dsILRhS5Gb0WPn5dX8dFuVhqnFk44IZAu63dsrkwyJP
 QrOm0ka20WXq75bZgeaHeYb5LHDYJKuzHrSZ/7Or3A762GlPMj
 Oe/jKUjzzKTlIUFVJD+CyX3dBftMlhOUFKGkUGPMZ2na0mpbhx
 ziORrzJ5r/axUGB1NdNzz9hP1Irz58aSTVNGrOpa7MijyiEOSC
 8xSA/GiRnv3YNuH0F1x6iAZNhHBeYLzblym3qcSG/6keC9KZe2
 kOiNx2IAb5jTkYluIgF9xgyvsB3cDHC+mz8i8+IJ8nc/kZWFYk
 jo4hY+5pCaAHqCsFsvMlGuOeyajqmc82xlt9pUWt26PLjE8yjR
 xNz0EYNvzbu2H/Y+oHjpsCkPFpOMry6bdieu6l2V6ck0CssN+J
 nu2egHyd0GjzuD+6se8HjD+su1A==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 100
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/misc |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/functions/misc b/ext/openwrt/scripts/functions/misc
index 2e0210c..13f2142 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -3,21 +3,25 @@
 
 get_misc_cpu_usage() {
 local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ print $1 }' | awk -F'.' '{ print $2 }'`
-freecwmp_value_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
+ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
 }
 
 get_misc_process_number() {
 local val=`ps | grep -v COMMAND | wc -l`
-freecwmp_value_output "Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val"
+local type="xsd:unsignedInt"
+ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "$type"
 }
 
 get_misc() {
 case "$1" in
 	Device.DeviceInfo.ProcessStatus.CPUUsage)
 	get_misc_cpu_usage
+	return $FAULT_CPE_NO_FAULT
 	;;
 	Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
 	get_misc_process_number
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:02 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:03 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:55515 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831882Ab2LFP5szW5eZ (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:48 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0M1GjQ-1Srqb00C6a-00t4lu; Thu, 06 Dec 2012 16:57:42 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 11/27] Update wan_device script to support communicte data of get parameter values to the core via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:36 +0100
Message-Id: <1354809292-2467-12-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:0TXdh2sXES3ZzlePqEnrxvzaQxqWc/86egkJfJ6biQc
 awNbCiiipyYwnD3oVDKXC0AZWyJVLCTsdwjW5o9f+VbzprZ4/M
 ElAedjkQoiqv/INXaAgvRiBNZAwhdyl3DlzbgvoulnCPuSFq04
 ExOFy+gDI8oGeCZn/a1N/cetkeo6SOfPd/pA3+Wp6rRS1UaKCj
 43egHXDSyyXojReR6GNq/kBuqD61S0Z8nNhMA/TrPdZySgf0Fn
 UAmlwVfuNAubbYSrdJdJFghrYZtIvr/aXw08xOGuCIvFMBlxfL
 aIg5ZsFxBYbyxgoDxEA6C0nvcwrVm2y/tKMUswdqptXkLZfy3c
 WuNGBl/HB7/Ib/LM2JOHayplaPEmaB0qjA6PVbBIXfMvlPISII
 23KfQlG7pYb0nqi+bp7lXzRjsRBKucTt7kV+0CPH9IdX6cTPzw
 xG69gaw4x0F2gn/OcSOqeAzqfsw==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 101
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/wan_device |   39 +++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
index 77cb63f..a8b6361 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -4,26 +4,37 @@
 get_wan_device_mng_status() {
 # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; Disconneting ; Disconnected 
 local val="Connected"
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val" "xsd:boolean"
 }
 
 get_wan_device_mng_interface_ip() {
 local val
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
 if [ -z "$default_wan_device_mng_interface_ip" ]; then
 	val=`network_get_ipaddr val mng`
 else
 	val=$default_wan_device_mng_interface_ip
 fi
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress" "$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+	ubus_freecwmp_output "$parm" "$val"
+else
+	freecwmp_output "$parm" "$val"
+fi
 }
 
 get_wan_device_mng_interface_mac() {
+local val=""
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
 if [ -z "$default_wan_device_mng_interface_mac" ]; then
 	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
 else
 	val=$default_wan_device_mng_interface_mac
 fi
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress" "$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+	ubus_freecwmp_output "$parm" "$val"
+else
+	freecwmp_output "$parm" "$val"
+fi
 }
 
 get_wan_device_wan_ppp_enable() {
@@ -31,7 +42,7 @@ local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto
 if [ -z $val ]; then
 	val="1"
 fi
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val" "xsd:boolean"
 }
 
 set_wan_device_wan_ppp_enable() {
@@ -47,7 +58,7 @@ fi
 
 get_wan_device_wan_ppp_username() {
 local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
 }
 
 set_wan_device_wan_ppp_username() {
@@ -55,7 +66,9 @@ set_wan_device_wan_ppp_username() {
 }
 
 get_wan_device_wan_ppp_password() {
-freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" ""
+local val=""
+val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
+ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" "$val"
 }
 
 set_wan_device_wan_ppp_password() {
@@ -71,6 +84,7 @@ case "$1" in
 	get_wan_device_wan_ppp_enable
 	get_wan_device_wan_ppp_username
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.)
 	get_wan_device_mng_status
@@ -79,6 +93,7 @@ case "$1" in
 	get_wan_device_wan_ppp_enable
 	get_wan_device_wan_ppp_username
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.)
 	get_wan_device_mng_status
@@ -87,6 +102,7 @@ case "$1" in
 	get_wan_device_wan_ppp_enable
 	get_wan_device_wan_ppp_username
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
 	get_wan_device_mng_status
@@ -95,6 +111,7 @@ case "$1" in
 	get_wan_device_wan_ppp_enable
 	get_wan_device_wan_ppp_username
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
 	get_wan_device_mng_status
@@ -103,36 +120,46 @@ case "$1" in
 	get_wan_device_wan_ppp_enable
 	get_wan_device_wan_ppp_username
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
 	get_wan_device_mng_status
 	get_wan_device_mng_interface_ip
 	get_wan_device_mng_interface_mac
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
 	get_wan_device_mng_status
 	get_wan_device_mng_interface_ip
 	get_wan_device_mng_interface_mac
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
 	get_wan_device_mng_status
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
 	get_wan_device_mng_interface_ip
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
 	get_wan_device_mng_interface_mac
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
 	get_wan_device_wan_ppp_enable
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
 	get_wan_device_wan_ppp_username
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
 	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
 set_wan_device() {
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:04 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:05 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:60450 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831873Ab2LFP5txoHZ1 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:49 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Lutsn-1SykTO0iwb-00zyeZ; Thu, 06 Dec 2012 16:57:43 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 12/27] update inform in order to get parameters from ubus instead from pipe Contributed by PIVA SOFTWARE
Date:   Thu,  6 Dec 2012 16:54:37 +0100
Message-Id: <1354809292-2467-13-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:LiFgDXaeRoHRinjP8j8p04BbFjaN3dKHjiOnvnHMkfD
 bD/lS0tAf6HR5rVzu0D7yvWK5IsJDwaIF215ApNLpkadFmBqym
 WsegISuXrOIzexsBF1xci+TuO1lhs3GoYnjzGOJLNoCDuYOiR/
 ICJ2LqgHhQWDNk7cb7iFKDFiH/B+eOMAIJqrndg2A74bEa+kgr
 pxrltmCG5/sjI9ob7vAj/3z2/tLvFj1ToPH1EXJPprGcHlrWHX
 RTAfhaSbRYekmhFxXaxvoEvYXo6+TLtWXlhSVAtqYDCFY1ONtd
 vf9dERZjbNnvZaTE6cMRwKw+whAEloJ3ZQiPRGk3Kl0nxsxUnF
 MCLkULGFHRTpPz5yDkvMeYfSzgAZ151lNgmIq7E28t7ZDoxbnW
 MwjbU2o5HyjaZJKuvWh+r1f++dXb9cvDX5PTvZbTJyza4QFqp3
 d9ORtfVQLEfYUkj3RegdQ3u2qKA==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 102
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 src/xml.c |   40 ++++++++++++++++++----------------------
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/xml.c b/src/xml.c
index 23b9ec7..612c0bb 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
 {
 	mxml_node_t *tree, *b;
 	char *c, *tmp;
+	struct external_parameter *external_parameter;
 
 #ifdef DUMMY_MODE
 	FILE *fp;
@@ -337,37 +338,31 @@ int xml_prepare_inform_message(char **msg_out)
 	if (mxmlGetType(b) != MXML_ELEMENT)
 		goto error;
 
-	tmp = "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
-	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-	if (!b) goto error;
-
-	b = b->parent->next->next;
-	if (mxmlGetType(b) != MXML_ELEMENT)
+	external_get_action_write("value", "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", NULL);
+	external_get_action_write("value", "InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
+	if (external_get_action_execute())
 		goto error;
 
-	c = NULL;
-	if (external_get_action("value", tmp, &c)) goto error;
-	if (c) {
-		b = mxmlNewText(b, 0, c);
-		FREE(c);
-		if (!b) goto error;
-	}
-
-	tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
-	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-	if (!b) goto error;
+	while (external_list_parameter.next!=&external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		b = mxmlFindElementText(tree, tree, external_parameter->name, MXML_DESCEND);
+		if (!b) continue;
 
 	b = b->parent->next->next;
 	if (mxmlGetType(b) != MXML_ELEMENT)
 		goto error;
 
-	c = NULL;
-	if (external_get_action("value", tmp, &c)) goto error;
-	if (c) {
-		b = mxmlNewText(b, 0, c);
-		FREE(c);
+		if (external_parameter->data) {
+			b = mxmlNewText(b, 0, external_parameter->data);
 		if (!b) goto error;
 	}
+		list_del(&external_parameter->list);
+		free(external_parameter->name);
+		free(external_parameter->data);
+		free(external_parameter->type);
+		free(external_parameter->fault_code);
+		free(external_parameter);
+	}
 
 	if (xml_prepare_notifications_inform(tree))
 		goto error;
@@ -378,6 +373,7 @@ int xml_prepare_inform_message(char **msg_out)
 	return 0;
 
 error:
+	external_free_list_parameter();
 	mxmlDelete(tree);
 	return -1;
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:05 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:10 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:65132 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831883Ab2LFP5upo0Gv (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:50 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LsR2m-1T0gHQ0fDU-011uSY; Thu, 06 Dec 2012 16:57:44 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 13/27] Add 3rd argument in the ubus handler of notification. The 3rd argument is the type of the parameter This agument could be  used in the response of get parameter attribute Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:38 +0100
Message-Id: <1354809292-2467-14-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:m0ofEQgHIm2vizP916J0rmD8amhKrsPz2ee22VgdyBq
 /5/qaarrxBc0IwaYJe1bdOAFPH19C/dLoCKiFpoOxzPVykylxz
 CQON4SfDrBx9FzhGQgbdGelt2P1l117x+ixq4aXiXKs+Xhc0MF
 5Qe6iD9rKR073onNDpn3IRqJxYA1llMd06zoVtHHwaz1YH+Zqe
 alzsKKstFJ22COVjGj23IuR0c2UNTqgyV3iJ+57vEIPBgZ/tnQ
 AQmeonZb9tUscS88TOPXoIT3/Ur2usZokqDuo7AI2jWoOSANcC
 xnA5Cz3UNONqxGgBasBd4d3gXJOeo8RBcHX1odcVF5JWgFvI4Q
 TboCSx7qj1am3d/rmfjvkm/DBtZzA9JYCNL0tVbLjaiSlqH1Yu
 vc1CzE6KgPhQTFn1W2WLmL6/2gGIo1kD5Rjxip6XIPCDj6nZc4
 hQxjlbmXcyeru1IScx867N1LRXg==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 103
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 src/cwmp.c |    2 +-
 src/cwmp.h |    2 +-
 src/ubus.c |    5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index 1bf9b2a..b75c762 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -245,7 +245,7 @@ void cwmp_clear_events(void)
 	pthread_mutex_unlock(&event_lock);
 }
 
-void cwmp_add_notification(char *parameter, char *value)
+void cwmp_add_notification(char *parameter, char *value, char *type)
 {
 	char *c = NULL;
 	external_get_action("notification", parameter, &c);
diff --git a/src/cwmp.h b/src/cwmp.h
index 5703db0..1d8afac 100644
--- a/src/cwmp.h
+++ b/src/cwmp.h
@@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
 void cwmp_remove_event(int code);
 void cwmp_clear_events(void);
 
-void cwmp_add_notification(char *parameter, char *value);
+void cwmp_add_notification(char *parameter, char *value, char *type);
 void cwmp_clear_notifications(void);
 
 int cwmp_set_parameter_write_handler(char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index d5437f9..0fd1def 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct uloop_timeout *timeout)
 static enum notify {
 	NOTIFY_PARAM,
 	NOTIFY_VALUE,
+	NOTIFY_TYPE,
 	__NOTIFY_MAX
 };
 
 static const struct blobmsg_policy notify_policy[] = {
 	[NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
 	[NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+	[NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
 };
 
 static int
@@ -66,7 +68,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
 			     "triggered ubus notification parameter %s\n",
 			     blobmsg_data(tb[NOTIFY_PARAM]));
 	cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
-			      blobmsg_data(tb[NOTIFY_VALUE]));
+			blobmsg_data(tb[NOTIFY_VALUE]),
+			tb[NOTIFY_TYPE]? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);
 
 	return 0;
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:11 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:12 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:56015 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831880Ab2LFP5v5RDfu (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:51 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Lsz0c-1T1EVn0goc-012SQK; Thu, 06 Dec 2012 16:57:46 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 14/27] add xml message get_parameter_name handler. Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Date:   Thu,  6 Dec 2012 16:54:39 +0100
Message-Id: <1354809292-2467-15-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:fK7hdaBj4pjvdB6QKde8tUXKQIlyBjF3gudiW8DsVcV
 nl5SitxoCNP5JkASDCzNK0Zy1/qSc8VHgrW89Ma9OIC1K6gHVX
 d+UJ46jXzUPUh4AcubpfmoH+zJppFP27mtlmjdGI6OL3ocF53b
 viucfPpL3EQuNSCa4JSgmn4iOiVVK1rNSaqabUgjwvY+Z//C/E
 wsV7lgfq3O//v3S8l4pSid/TqAUYakBJyKr0R66u/Nzdsomm74
 mqc6VbjbmtW2j/SQ6w44jX6IvFPrguFps3xAF//QMzZ34rne5a
 vll65ruUBHS+OSPgVAgJaQnKJHEJqqRzcAKuIyH46+uTKDvECx
 AHlbloaMj0+hqY4PPxdOXANU6+0hxUR5hLp9I0+cnNzqUoHGJs
 QhUAgU8D6OxkqR7wc7lgAzAaP6fbA4bjkVsHo10T7pTLKC/8DU
 eP0vn3jX8gPwusafGNCWqD37OaA==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 104
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 src/cwmp.c     |    2 +-
 src/external.c |   70 +++++++++++++-----------------------
 src/external.h |    3 +-
 src/ubus.c     |   39 ++++++++++++++++++++
 src/xml.c      |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/xml.h      |    4 ++
 6 files changed, 181 insertions(+), 48 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index b75c762..7de19e3 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -248,7 +248,7 @@ void cwmp_clear_events(void)
 void cwmp_add_notification(char *parameter, char *value, char *type)
 {
 	char *c = NULL;
-	external_get_action("notification", parameter, &c);
+	external_get_action_data("notification", parameter, &c);
 	if (!c) return;
 
 	struct notification *n = NULL;
diff --git a/src/external.c b/src/external.c
index 94ae9b8..4973d1a 100644
--- a/src/external.c
+++ b/src/external.c
@@ -60,14 +60,32 @@ void external_free_list_parameter()
 	}
 }
 
-int external_get_action(char *action, char *name, char **value)
+int external_get_action_data(char *action, char *name, char **value)
+{
+	struct external_parameter *external_parameter;
+	external_get_action(action, name, NULL);
+	if (external_list_parameter.next!=&external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		if (external_parameter->data)
+			*value = external_parameter->data;
+		list_del(&external_parameter->list);
+		free(external_parameter->name);
+		free(external_parameter->data);
+		free(external_parameter->type);
+		free(external_parameter->fault_code);
+		free(external_parameter);
+	}
+	external_free_list_parameter();
+	return 0;
+}
+
+int external_get_action(char *action, char *name, char *arg /* arg is added for GetParameterNames NextLevel argument*/)
 {
 	freecwmp_log_message(NAME, L_NOTICE,
 			     "executing get %s '%s'\n", action, name);
 
-	int pfds[2];
-	if (pipe(pfds) < 0)
-		return -1;
+
+	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
 
 	if ((uproc.pid = fork()) == -1)
 		goto error;
@@ -79,66 +97,28 @@ int external_get_action(char *action, char *name, char **value)
 		int i = 0;
 		argv[i++] = "/bin/sh";
 		argv[i++] = fc_script;
-		argv[i++] = "--newline";
-		argv[i++] = "--value";
 		argv[i++] = "get";
 		argv[i++] = action;
 		argv[i++] = name;
+		if(arg) argv[i++] = arg;
 		argv[i++] = NULL;
 
-		close(pfds[0]);
-		dup2(pfds[1], 1);
-		close(pfds[1]);
-
 		execvp(argv[0], (char **) argv);
 		exit(ESRCH);
 
 	} else if (uproc.pid < 0)
 		goto error;
 
-	/* parent */
-	close(pfds[1]);
-
 	int status;
 	while (wait(&status) != uproc.pid) {
 		DD("waiting for child to exit");
 	}
+	pthread_cancel(ubus_thread);
+	pthread_join(ubus_thread,NULL);
 
-	char buffer[64];
-	ssize_t rxed;
-	char *c;
-	int t;
-
-	*value = NULL;
-	while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
-		if (*value)
-			t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
-		else
-			t = asprintf(&c, "%.*s", (int) rxed, buffer);
-
-		if (t == -1) goto error;
-
-		free(*value);
-		*value = strdup(c);
-		free(c);
-	}
-
-	if (!strlen(*value)) {
-		FREE(*value);
-		goto done;
-	}
-
-	if (rxed < 0)
-		goto error;
-
-done:
-	close(pfds[0]);
 	return 0;
 
 error:
-	FREE(*c);
-	FREE(*value);
-	close(pfds[0]);
 	return -1;
 }
 
diff --git a/src/external.h b/src/external.h
index c6df2ea..8e82c39 100644
--- a/src/external.h
+++ b/src/external.h
@@ -27,7 +27,8 @@ struct external_parameter {
 	char *fault_code;
 };
 
-int external_get_action(char *action, char *name, char **value);
+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);
diff --git a/src/ubus.c b/src/ubus.c
index 0fd1def..cbf94b0 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *
 	return 0;
 }
 
+static enum get_param_names {
+	GET_PARAM_NAMES_PARAM,
+	GET_PARAM_NAMES_WRITABLE,
+	GET_PARAM_NAMES_FAULT,
+	__GET_PARAM_NAMES_MAX
+};
+
+static const struct blobmsg_policy get_param_names_policy[] = {
+	[GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
+
+	blobmsg_parse(get_param_names_policy, ARRAY_SIZE(get_param_names_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_NAMES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	freecwmp_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_names for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
+			tb[GET_PARAM_NAMES_WRITABLE]? blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
+			NULL,
+			tb[GET_PARAM_NAMES_FAULT]? blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
+
+	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("get_parameter_names", freecwmpd_handle_get_param_names, get_param_names_policy),
 };
 
 static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index 612c0bb..c735244 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -51,6 +51,7 @@ static struct cwmp_namespaces
 const struct rpc_method rpc_methods[] = {
 	{ "SetParameterValues", xml_handle_set_parameter_values },
 	{ "GetParameterValues", xml_handle_get_parameter_values },
+	{ "GetParameterNames", xml_handle_get_parameter_names },
 	{ "SetParameterAttributes", xml_handle_set_parameter_attributes },
 	{ "Download", xml_handle_download },
 	{ "FactoryReset", xml_handle_factory_reset },
@@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 		free(external_parameter->fault_code);
 		free(external_parameter);
 	}
-
 #ifdef ACS_MULTI
 	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
 			    NULL, NULL, MXML_DESCEND);
@@ -736,6 +736,115 @@ out:
 	return -1;
 }
 
+int xml_handle_get_parameter_names(mxml_node_t *body_in,
+				    mxml_node_t *tree_in,
+				    mxml_node_t *tree_out)
+{
+	mxml_node_t *n, *parameter_list, *b = body_in;
+	struct external_parameter *external_parameter;
+	char *parameter_name = NULL;
+	char *NextLevel = NULL;
+	char *c;
+	int counter = 0;
+
+	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
+			    NULL, NULL, MXML_DESCEND);
+	if (!n) return -1;
+
+	n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
+	if (!n) return -1;
+
+	n = mxmlNewElement(n, "ParameterList");
+	if (!n) return -1;
+
+#ifdef ACS_MULTI
+	mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
+#endif
+
+	while (b) {
+		if (b && b->type == MXML_TEXT &&
+			b->value.text.string &&
+			b->parent->type == MXML_ELEMENT &&
+			!strcmp(b->parent->value.element.name, "ParameterPath")) {
+			parameter_name = b->value.text.string;
+		}
+		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterNames with empty ParameterPath*/
+			!strcmp(b->value.element.name, "ParameterPath") &&
+			!b->child) {
+			parameter_name = "";
+		}
+		if (b && b->type == MXML_TEXT &&
+			b->value.text.string &&
+			b->parent->type == MXML_ELEMENT &&
+			!strcmp(b->parent->value.element.name, "NextLevel")) {
+			NextLevel = b->value.text.string;
+		}
+		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+	}
+	if (parameter_name && NextLevel) {
+		if (!external_get_action("name", parameter_name, NextLevel)) {
+			// got the parameter value via external script
+		} else {
+			// error occurred when getting parameter value
+			goto out;
+		}
+	}
+
+	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
+	if (!parameter_list) goto out;
+
+	while (external_list_parameter.next!=&external_list_parameter) {
+
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+
+		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
+			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code
+
+		n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
+		if (!n) goto out;
+
+		n = mxmlNewElement(n, "Name");
+		if (!n) goto out;
+
+		n = mxmlNewText(n, 0, external_parameter->name);
+		if (!n) goto out;
+
+		n = n->parent->parent;
+		n = mxmlNewElement(n, "Writable");
+		if (!n) goto out;
+
+		n = mxmlNewText(n, 0, external_parameter->data);
+		if (!n) goto out;
+
+		counter++;
+
+		list_del(&external_parameter->list);
+		free(external_parameter->name);
+		free(external_parameter->data);
+		free(external_parameter->type);
+		free(external_parameter->fault_code);
+		free(external_parameter);
+	}
+
+#ifdef ACS_MULTI
+	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
+			    NULL, NULL, MXML_DESCEND);
+	if (!b) goto out;
+
+	if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
+		goto out;
+
+	mxmlElementSetAttr(b, "soap_enc:arrayType", c);
+	FREE(c);
+#endif
+
+	return 0;
+
+out:
+	external_free_list_parameter();
+	return -1;
+}
+
 static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 					       mxml_node_t *tree_in,
 					       mxml_node_t *tree_out) {
diff --git a/src/xml.h b/src/xml.h
index 8f63192..a9191eb 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -26,6 +26,10 @@ static int xml_handle_get_parameter_values(mxml_node_t *body_in,
 					   mxml_node_t *tree_in,
 					   mxml_node_t *tree_out);
 
+static int xml_handle_get_parameter_names(mxml_node_t *body_in,
+					   mxml_node_t *tree_in,
+					   mxml_node_t *tree_out);
+
 static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 					       mxml_node_t *tree_in,
 					       mxml_node_t *tree_out);
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:12 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:13 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:51023 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831877Ab2LFP5xR-N1e (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:53 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0M9XrD-1TtcFZ1nQd-00D6pB; Thu, 06 Dec 2012 16:57:47 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
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
Date:   Thu,  6 Dec 2012 16:54:40 +0100
Message-Id: <1354809292-2467-16-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:kfyHdUWMpqwLG2qv8siENknn09LZmTXiVTQQCgFAS/m
 SWUhCXVrJw2UUdbepTMF9sFk5SA+O5++IfxYGyGhGHArNCedft
 4J0O84/owTXztJj+EOQ5t6/PR72+FgAs8PCCaESU5trpPyXaQw
 zDCxr/LqVO0Qxx1Pk1Sv54QjqosOQKr+6Lq8VMIgYHHczD3+QE
 pVGDGC5VU0q9TlSHVazP00ZPBRZtyj3wZO8pfT/O+VcrqAfxyW
 j78rE8BwjkT/6JiNebQkLOpB0ykZCVNfsY6QRk5bFJuw1awL/v
 D8vdYV02k7w0ooLW3xqMwac3MVf6Lbo8wqbMkqVuNt9eQeEpxT
 8pWGCJJ+8nRA4yJKaU1kWlLVZ2/7n6b2L5bjWD+1C76onYCzLA
 JCV3is9mJvnSFAQr3nyC33TLCx30hAmkrEYwv4Y1HECgiplhfe
 +Dxam1aCUrJQrwaLb/DZ0DnuFjg==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 105
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


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      |   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


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:14 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:15 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:49626 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831885Ab2LFP5xoghBm (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:53 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LqU2T-1TC02U2R4z-00dtOt; Thu, 06 Dec 2012 16:57:48 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 16/27] update the script device_info in order to output parameters with ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:41 +0100
Message-Id: <1354809292-2467-17-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:dihHl+hjQUG9OHgb4rsn6Plx6308bZpKICZKN8sLwLI
 eD/BRbNaDk9OUVYgxv9SgHzWJoNr6e6tBSUes42CeczIcSV7RQ
 An8RKfB+uHqWTQTfc24b/7BX2GYdHqw7uDJJXWNWEcf2iS9suu
 N/En1FmgQJv4eSlMgas2wscazC5sRxPUMgdrFhnR5y9VzM1Nah
 bJVwDnJdCw04dI5+NqoscpuDJF8eV/qBMdlyxmlxnvhzZDtl1f
 wosSr3WKhnM4xFGZW3ov/4nicwg2Xo6yuXbDZlrnEUEIgXT4Lw
 fcB/91L66XhWZIKsLngISxCD9+AKZHsb+uvrzZn9UglFG8JpDX
 GFPWI11ue9GAdRTZ/YsB566CgUUaZ8VB129iU8Af3Khdvk2yQn
 +ZAnZ3zV3Gv24PS+YLoHNZyc8M98ApcgH25seUUm+wm7que8N9
 KmXucOxH+eJqmPqQR8jus9+Xiww==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 106
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_info |  199 +++++++++++++++++++++++++++--
 1 files changed, 187 insertions(+), 12 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
index 86ff5c9..c3c6c33 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -2,7 +2,15 @@
 # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
 
 get_device_info_manufacturer() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
 }
 
@@ -11,7 +19,15 @@ set_device_info_manufacturer() {
 }
 
 get_device_info_oui() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
 }
 
@@ -20,7 +36,15 @@ set_device_info_oui() {
 }
 
 get_device_info_product_class() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
 }
 
@@ -29,7 +53,15 @@ set_device_info_product_class() {
 }
 
 get_device_info_serial_number() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
+	;;
+	get_name)
+	local val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
 }
 
@@ -38,7 +70,15 @@ set_device_info_serial_number() {
 }
 
 get_device_info_hardware_version() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
 }
 
@@ -47,7 +87,15 @@ set_device_info_hardware_version() {
 }
 
 get_device_info_software_version() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
 }
 
@@ -56,17 +104,32 @@ set_device_info_software_version() {
 }
 
 get_device_info_uptime() {
-local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
+local val=""
+case "$action" in
+	get_value)
+	val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
 }
 
 get_device_info_device_log() {
 local val=""
-if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
-	val=`dmesg | tail -n1`
-else
-	val=`dmesg | tail -n10`
-fi
+case "$action" in
+	get_value)
+	if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
+		val=`dmesg | tail -n1`
+	else
+		val=`dmesg | tail -n10`
+	fi
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
 }
 
@@ -130,6 +193,94 @@ esac
 return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
+get_device_info_name() {
+case "$1" in
+	InternetGatewayDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
+	if [ "$2" = "0" ]; then
+		get_device_info_manufacturer
+		get_device_info_oui
+		get_device_info_product_class
+		get_device_info_serial_number
+		get_device_info_hardware_version
+		get_device_info_software_version
+		get_device_info_uptime
+		get_device_info_device_log
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.)
+	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
+	get_device_info_manufacturer
+	get_device_info_oui
+	get_device_info_product_class
+	get_device_info_serial_number
+	get_device_info_hardware_version
+	get_device_info_software_version
+	get_device_info_uptime
+	get_device_info_device_log
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.Manufacturer)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_manufacturer
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_oui
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.ProductClass)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_product_class
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.SerialNumber)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_serial_number
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.HardwareVersion)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_hardware_version
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_software_version
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.UpTime)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_uptime
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.DeviceLog)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_device_info_device_log
+	return $FAULT_CPE_NO_FAULT
+	;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
 set_device_info() {
 case "$1" in
 	InternetGatewayDevice.DeviceInfo.Manufacturer)
@@ -179,6 +330,30 @@ get_device_info_generic() {
 	return $FAULT_CPE_NO_FAULT
 }
 
+get_device_info_generic_name() {
+	local val=""
+	case "$1" in
+	InternetGatewayDevice.DeviceInfo.ModelName|\
+	InternetGatewayDevice.DeviceInfo.Description|\
+	InternetGatewayDevice.DeviceInfo.ModemFirmwareVersion|\
+	InternetGatewayDevice.DeviceInfo.EnabledOptions|\
+	InternetGatewayDevice.DeviceInfo.AdditionalHardwareVersion|\
+	InternetGatewayDevice.DeviceInfo.AdditionalSoftwareVersion|\
+	InternetGatewayDevice.DeviceInfo.SpecVersion|\
+	InternetGatewayDevice.DeviceInfo.FirstUseDate)
+	val="0"
+	ubus_freecwmp_output "$1" "$val"
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.DeviceInfo.ProvisioningCode)
+	val="1"
+	ubus_freecwmp_output "$1" "$val"
+	return $FAULT_CPE_NO_FAULT
+	;;
+	esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
 set_device_info_generic() {
 	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
 
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:16 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:17 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:49449 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831878Ab2LFP5z0GEnQ (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:55 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0M1ohG-1SsOpC2qja-00tcjg; Thu, 06 Dec 2012 16:57:49 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 17/27] update the script lan_device in order to output parameters with ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:42 +0100
Message-Id: <1354809292-2467-18-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:c4ljIxqYzqmkcGYvaUL5SQN8m1+jRoCZjqdbajk46Y2
 rf6xw0qqj42otVbjsS9wjiFbGiI4tkASFb+ZGA09+UpMjPxxGi
 tSsrJmfDuvmjzA+3KxJHzu8lgqNNB9p0X+DCVxutL9kJ3UqoPh
 A955gbvFlQfTfB3I/tfAIoz78RZ0Uvgaju8bS8Fghma6Af18Ew
 04GTPg7a64RzEQOUQgnI9axee1g6yBS8WQo/zhaez8Ju53p4EP
 yRTYz23QeF8CuFGQlluR3WlhbeZ7kTWQ0btx+DRnmZTKxHpMma
 KO/gAZ9oSzn+mLRjSoRVywS60gbCUx1KDAPiWZYnqCVcX1xQbS
 hwgLs1q/m+tCDVGoJNfreniQJe1XX/IWvf7U24sUMwM7bjWzwu
 IINw5YoMYHsr3jlqGttZpfQaZs7cvh7WcwcaV9Hsn8uY3sZjA4
 LrBWvwJUrV7VnsLOIsH267KnD8w==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 107
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/scripts/functions/lan_device |   98 ++++++++++++++++++++++++++++-
 1 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index fa9dda4..712b5e8 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -4,7 +4,10 @@
 get_wlan_enable() {
 local num="$1"
 local type="xsd:boolean"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
 let num=$num+1
 if [ "$val" = "1" ]; then
 	val="0"
@@ -12,6 +15,13 @@ else
 	val="1"
 fi
 ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
+	;;
+	get_name)
+	val="1"
+	let num=$num+1
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+	;;
+esac
 }
 
 set_wlan_enable() {
@@ -28,9 +38,20 @@ delay_command "wifi" "wifi" "45"
 
 get_wlan_ssid() {
 local num="$1"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
-let num=$num+1
-ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+local val=""
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
+	let num=$num+1
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+	;;
+	get_name)
+	val="1"
+	let num=$num+1
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+	;;
+esac
+
 }
 
 set_wlan_ssid() {
@@ -79,6 +100,75 @@ esac
 return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
+get_lan_device_name() {
+case "$1" in
+	InternetGatewayDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+	if [ "$2" = "0" ]; then
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+		get_wlan_enable 0
+		get_wlan_ssid 0
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+	if [ "$2" = "0" ]; then
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+		get_wlan_enable 0
+		get_wlan_ssid 0
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.1.)
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+	if [ "$2" = "0" ]; then
+		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+		get_wlan_enable 0
+		get_wlan_ssid 0
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+	if [ "$2" = "0" ]; then
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+	if [ "$2" = "0" ]; then
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wlan_enable 0
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wlan_ssid 0
+	return $FAULT_CPE_NO_FAULT
+	;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
 set_lan_device() {
 case "$1" in
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:17 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:20 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:54497 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831886Ab2LFP5zzPaZW (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:55 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Mb9Nj-1TS0gw2ptz-00Kq5B; Thu, 06 Dec 2012 16:57:50 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 18/27] update the script management_server in order to output parameters with ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:43 +0100
Message-Id: <1354809292-2467-19-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:t99CnQhVD9aHXmSWnU4KbVd7h6V80nFbms6MvbP3xeP
 XWncJsWM0v8677J9j05RuX+ocGfYPJoeUOspEhnhhJm71h3azC
 UYYU6AnbbskyivHPqrWsONtrnEaAuMYkrz7khHQY1Tkn/zNbil
 CqnqNrLpeMJBBkmXExUiz+NcNV/pLrBIMSEQ8ROygPKC5BZrJC
 3gXuy+wIfBKofpDvfaajOJBRJbgn5h2jN9ZWrqkPB98L3RLwCA
 zZCTIdo6VDQvWJEdra1ODnmh1Hr97FEOPvvpNcdgOPHmbCEgbk
 yR+mHloP2sNA/UemI3lexoQ/qUSiOtJrz1Tpm6Ik305Ej55SPA
 1LKr/hIAFf2WQX0L2k/Y7jZ7EEY7QV2x9ONBub28W8OSHz7mR9
 lN9ebGlVfUMS7VKJJyMJ0X1i6suomxxfLBXPaT6xuV3q4k46xi
 c1k/2zcccMmYV9/Q6iN5D6VsllA==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 108
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 ext/openwrt/config/freecwmp                     |   12 +-
 ext/openwrt/scripts/functions/lan_device        |   22 +-
 ext/openwrt/scripts/functions/management_server |  323 ++++++++++++++++++++---
 3 files changed, 307 insertions(+), 50 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 3b2b4c3..1379afd 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -29,25 +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 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 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 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 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 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 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/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index 712b5e8..64910e2 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -8,13 +8,13 @@ local val=""
 case "$action" in
 	get_value)
 	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
-let num=$num+1
-if [ "$val" = "1" ]; then
-	val="0"
-else
-	val="1"
-fi
-ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
+	let num=$num+1
+	if [ "$val" = "1" ]; then
+		val="0"
+	else
+		val="1"
+	fi
+	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
 	;;
 	get_name)
 	val="1"
@@ -138,16 +138,16 @@ case "$1" in
 	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
 	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
 	if [ "$2" = "0" ]; then
-	get_wlan_enable 0
-	get_wlan_ssid 0
+		get_wlan_enable 0
+		get_wlan_ssid 0
 	fi
 	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
 	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
 	if [ "$2" = "0" ]; then
-	get_wlan_enable 0
-	get_wlan_ssid 0
+		get_wlan_enable 0
+		get_wlan_ssid 0
 	fi
 	return $FAULT_CPE_NO_FAULT
 	;;
diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
index eca3a61..eed16d1 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -9,8 +9,16 @@ local hostname=`get_management_server_x_freecwmp_org__acs_hostname`
 local port=`get_management_server_x_freecwmp_org__acs_port`
 local path=`get_management_server_x_freecwmp_org__acs_path`
 FLAGS_value=$tmp
-local val=`echo $scheme://$hostname:$port$path`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+	get_value)
+	val=`echo $scheme://$hostname:$port$path`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_url() {
@@ -45,8 +53,17 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change
 }
 
 get_management_server_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].username 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].username 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_username() {
@@ -54,8 +71,17 @@ set_management_server_username() {
 }
 
 get_management_server_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].password 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].password 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_password() {
@@ -63,9 +89,18 @@ set_management_server_password() {
 }
 
 get_management_server_periodic_inform_enable() {
+local val=""
+local type="xsd:boolean"
 local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
+case "$action" in
+	get_value)
+	freecwmp_get_parameter_value "val" "$parm"
+	;;
+	get_name)
+	val="1"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 set_management_server_periodic_inform_enable() {
@@ -74,9 +109,18 @@ freecwmp_set_parameter_value "$parm" "$1"
 }
 
 get_management_server_periodic_inform_interval() {
+local val=""
+local type="xsd:unsignedInt"
 local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
+case "$action" in
+	get_value)
+	freecwmp_get_parameter_value "val" "$parm"
+	;;
+	get_name)
+	val="1"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 set_management_server_periodic_inform_interval() {
@@ -86,26 +130,42 @@ freecwmp_set_parameter_value "$parm" "$1"
 
 get_management_server_connection_request_url() {
 local val
-if [ -z "$default_management_server_connection_request_url" ]; then
-	local tmp=${FLAGS_value}
-	FLAGS_value=${FLAGS_TRUE}
-	local ip=`get_wan_device_mng_interface_ip`
-	local port=`get_management_server_x_freecwmp_org__connection_request_port`
-	FLAGS_value=$tmp
-
-	if [ -n "$ip" -a -n "$port" ]; then
-		val="http://$ip:$port/"
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestURL"
+case "$action" in
+	get_value)
+	if [ -z "$default_management_server_connection_request_url" ]; then
+		local tmp=${FLAGS_value}
+		FLAGS_value=${FLAGS_TRUE}
+		local ip=`get_wan_device_mng_interface_ip`
+		local port=`get_management_server_x_freecwmp_org__connection_request_port`
+		FLAGS_value=$tmp
+	
+		if [ -n "$ip" -a -n "$port" ]; then
+			val="http://$ip:$port/"
+		fi
+	else
+		val=$default_management_server_connection_request_url
 	fi
-else
-	val=$default_management_server_connection_request_url
-fi
-
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 get_management_server_connection_request_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].username 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].username 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_connection_request_username() {
@@ -113,8 +173,17 @@ set_management_server_connection_request_username() {
 }
 
 get_management_server_connection_request_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].password 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].password 2> /dev/null`
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_connection_request_password() {
@@ -124,8 +193,16 @@ set_management_server_connection_request_password() {
 # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
 
 get_management_server_x_freecwmp_org__acs_scheme() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].scheme 2> /dev/null`
+local val=""
 local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].scheme 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -138,8 +215,16 @@ set_management_server_x_freecwmp_org__acs_scheme() {
 }
 
 get_management_server_x_freecwmp_org__acs_hostname() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].hostname 2> /dev/null`
+local val=""
 local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].hostname 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -156,8 +241,16 @@ fi
 }
 
 get_management_server_x_freecwmp_org__acs_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].port 2> /dev/null`
+local val=""
 local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].port 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -170,8 +263,16 @@ set_management_server_x_freecwmp_org__acs_port() {
 }
 
 get_management_server_x_freecwmp_org__acs_path() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].path 2> /dev/null`
+local val=""
 local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].path 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -184,8 +285,16 @@ set_management_server_x_freecwmp_org__acs_path() {
 }
 
 get_management_server_x_freecwmp_org__connection_request_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].port 2> /dev/null`
+local val=""
 local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].port 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -287,6 +396,146 @@ esac
 return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
+get_management_server_name() {
+case "$1" in
+	InternetGatewayDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+	if [ "$2" = "0" ]; then
+		get_management_server_url
+		get_management_server_username
+		get_management_server_password
+		get_management_server_periodic_inform_enable
+		get_management_server_periodic_inform_interval
+		get_management_server_connection_request_url
+		get_management_server_connection_request_username
+		get_management_server_connection_request_password
+		get_management_server_x_freecwmp_org__acs_scheme
+		get_management_server_x_freecwmp_org__acs_hostname
+		get_management_server_x_freecwmp_org__acs_port
+		get_management_server_x_freecwmp_org__acs_path
+		get_management_server_x_freecwmp_org__connection_request_port
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.)
+	ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+	get_management_server_url
+	get_management_server_username
+	get_management_server_password
+	get_management_server_periodic_inform_enable
+	get_management_server_periodic_inform_interval
+	get_management_server_connection_request_url
+	get_management_server_connection_request_username
+	get_management_server_connection_request_password
+	get_management_server_x_freecwmp_org__acs_scheme
+	get_management_server_x_freecwmp_org__acs_hostname
+	get_management_server_x_freecwmp_org__acs_port
+	get_management_server_x_freecwmp_org__acs_path
+	get_management_server_x_freecwmp_org__connection_request_port
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.URL)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_url
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.Username)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_username
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.Password)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_password
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_periodic_inform_enable
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_periodic_inform_interval
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_connection_request_url
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_connection_request_username
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_connection_request_password
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_x_freecwmp_org__acs_scheme
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_x_freecwmp_org__acs_hostname
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_x_freecwmp_org__acs_port
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_x_freecwmp_org__acs_path
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_x_freecwmp_org__connection_request_port
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.ManagementServer.ParameterKey)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_management_server_parameter_key
+	return $FAULT_CPE_NO_FAULT
+	;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
 set_management_server() {
 case "$1" in
 	InternetGatewayDevice.ManagementServer.URL)
@@ -349,6 +598,14 @@ get_management_server_generic() {
 	return $FAULT_CPE_NO_FAULT
 }
 
+get_management_server_generic_name() {
+	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+	local val="1"
+	ubus_freecwmp_output "$1" "$val"
+	return $FAULT_CPE_NO_FAULT
+}
+
 set_management_server_generic() {
 	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
 
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:20 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:22 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:64355 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831874Ab2LFP55rQXJb (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:57 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0LpeYo-1TDNcG3dCg-00fGiC; Thu, 06 Dec 2012 16:57:51 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 19/27] update the script wan_device in order to output parameters with ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:44 +0100
Message-Id: <1354809292-2467-20-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:4yjLSOs4NmkS9LinGC+znCSsbl6eSfL4OmvvSj/DCsc
 fVgeIV98y+ElwXwTguoOlTHHrDIvN9XUbR0MzxeUGsHyDSlXE5
 OMrgcJUw7jkkY841gZiFGJKn/3zx4KPABlaWW/LoXhW4zRiIRQ
 CndwlLNH/2KR06gfKlyYT0uOJ54pnwidz3dh3w6Sw+O2g/qARm
 7Stxsd5RLVLcAJiDH/SdXJ+gGRCDVr/YLk70Kk5xRiWho+J1I1
 RPo442/HX8qFtBt4fFzvtbshmC1NqIXi5PC4iZAqycPoCQne4V
 JxH0fV1L5Z3xXeGYuQTqi2bVseyEPl+bZXsmC40woA7g4gGytH
 FYZZ9HSeukRt+JtWXGhPtRShpB7nTkIt5CCzFMtu/VibhsOuMq
 Dp4TJ3JdTpYTaq7xirpzBpeYtju8d2HIa3yTcbhK7xa+aMiP5A
 4diBtX0D2k9CU6CtxJ3uN09b++w==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 109
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/freecwmp.sh          |  127 +++++++++---------
 ext/openwrt/scripts/functions/wan_device |  223 +++++++++++++++++++++++++++---
 src/freecwmp.c                           |    2 +-
 3 files changed, 267 insertions(+), 85 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index c5a0d53..a2f2bc1 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
 
 . /lib/functions.sh
 . /usr/share/libubox/jshn.sh
@@ -68,10 +69,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" = "name" ]; then
+			__arg1="$3"
+			__arg2=`echo $4| tr '[A-Z]' '[a-z]'`
+			action="get_name"
 		elif [ "$2" = "all" ]; then
 			__arg1="$3"
 			action="get_all"
@@ -111,7 +112,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 get_name_functions "$section" "get_name_function"
 	config_get set_value_functions "$section" "set_value_function"
 }
 
@@ -142,16 +143,57 @@ FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
 FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
 
 if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
-    no_fault="0"
-    freecwmp_check_fault "$__arg1"
-    fault_code="$?"
-    if [ "$fault_code" = "0" ]; then
-        if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" = "" \) ]; then
-            __arg1="InternetGatewayDevice."
+	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 $get_value_functions
+		do
+			$function_name "$__arg1"
+			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
-	for function_name in $get_value_functions
-	do
-		$function_name "$__arg1"
+	if [ "$fault_code" != "0" ]; then
+		let fault_code=$fault_code+9000
+		ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+	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"
@@ -159,55 +201,14 @@ if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
 				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
-        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
-    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
+			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
diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
index a8b6361..9c7cd14 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -1,20 +1,38 @@
 #!/bin/sh
 # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
 
 get_wan_device_mng_status() {
 # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; Disconneting ; Disconnected 
-local val="Connected"
-ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val" "xsd:boolean"
+local val=""
+local type="xsd:boolean"
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
+case "$action" in
+	get_value)
+	val="Connected"
+	;;
+	get_name)
+	val="0"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 get_wan_device_mng_interface_ip() {
-local val
+local val=""
 local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
-if [ -z "$default_wan_device_mng_interface_ip" ]; then
-	val=`network_get_ipaddr val mng`
-else
-	val=$default_wan_device_mng_interface_ip
-fi
+case "$action" in
+	get_value)
+	if [ -z "$default_wan_device_mng_interface_ip" ]; then
+		val=`network_get_ipaddr val mng`
+	else
+		val=$default_wan_device_mng_interface_ip
+	fi
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -25,11 +43,18 @@ fi
 get_wan_device_mng_interface_mac() {
 local val=""
 local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
-if [ -z "$default_wan_device_mng_interface_mac" ]; then
-	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
-else
-	val=$default_wan_device_mng_interface_mac
-fi
+case "$action" in
+	get_value)
+	if [ -z "$default_wan_device_mng_interface_mac" ]; then
+		val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
+	else
+		val=$default_wan_device_mng_interface_mac
+	fi
+	;;
+	get_name)
+	val="0"
+	;;
+esac
 if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
 	ubus_freecwmp_output "$parm" "$val"
 else
@@ -38,11 +63,21 @@ fi
 }
 
 get_wan_device_wan_ppp_enable() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto 2> /dev/null`
-if [ -z $val ]; then
+local val=""
+local type="xsd:boolean"
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto 2> /dev/null`
+	if [ -z $val ]; then
+		val="1"
+	fi
+	;;
+	get_name)
 	val="1"
-fi
-ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val" "xsd:boolean"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 set_wan_device_wan_ppp_enable() {
@@ -57,8 +92,17 @@ fi
 }
 
 get_wan_device_wan_ppp_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
+local val=""
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_wan_device_wan_ppp_username() {
@@ -67,8 +111,16 @@ set_wan_device_wan_ppp_username() {
 
 get_wan_device_wan_ppp_password() {
 local val=""
-val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" "$val"
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case "$action" in
+	get_value)
+	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
+	;;
+	get_name)
+	val="1"
+	;;
+esac
+ubus_freecwmp_output "$parm" "$val"
 }
 
 set_wan_device_wan_ppp_password() {
@@ -162,6 +214,135 @@ esac
 return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
+get_wan_device_name() {
+case "$1" in
+	InternetGatewayDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+	if [ "$2" = "0" ]; then
+		get_wan_device_mng_status
+		get_wan_device_mng_interface_ip
+		get_wan_device_mng_interface_mac
+		get_wan_device_wan_ppp_enable
+		get_wan_device_wan_ppp_username
+		get_wan_device_wan_ppp_password
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+	if [ "$2" = "0" ]; then
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+	if [ "$2" = "0" ]; then
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+	if [ "$2" = "0" ]; then
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." "1"
+	if [ "$2" = "0" ]; then
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." "1"
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." "1"
+	if [ "$2" = "0" ]; then
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	fi
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." "1"
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_mng_status
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_mng_interface_ip
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_mng_interface_mac
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_wan_ppp_enable
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_wan_ppp_username
+	return $FAULT_CPE_NO_FAULT
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+	if [ "$2" = "1" ]; then
+		return $FAULT_CPE_INVALID_ARGUMENTS
+	fi
+	get_wan_device_wan_ppp_password
+	return $FAULT_CPE_NO_FAULT
+	;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
 set_wan_device() {
 case "$1" in
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
diff --git a/src/freecwmp.c b/src/freecwmp.c
index f4c9cb1..eb2783c 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -197,7 +197,7 @@ netlink_init(void)
 
 void signal_kill_all_handler(int sig)
 {
-     pthread_exit(NULL);
+	pthread_exit(NULL);
 }
 
 
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:22 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:24 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:49749 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831888Ab2LFP57RGK70 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:57:59 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0M1XiL-1Ss7gH0Tt3-00tLt5; Thu, 06 Dec 2012 16:57:53 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 20/27] update the get notification in order to put the returned data via ubus instead of pipe TODO: develop the xml handle message to perform send of GetParameterAttributeResponse Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:45 +0100
Message-Id: <1354809292-2467-21-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:TvaEANyw4rcjr6DkR0lc4Dac9NjKmGOwLV1bX/YYJk3
 ieg6SzU7Ig0gkGd0n9ZiwgbnoHhhXKT2nQ/R0zdqgaQSB04iV7
 px9cJDV/KBgEnhSqDOUP2TN2UKjgx2B2rHLJww4Rcf0bIwcCho
 l9v0/PE/+czCZr4fzq9oAv0zzapHX5chHoKzFPLVtSRwQ1j+rW
 Z9a9HVjaRo7Gnw+laPTTesbKWiaBKNER6fLSRi6D9gjhOtUzP5
 yX64Uw1p94LuM9cB576R3AzrHqmrRp0sFqM598iNGWrYjs36FF
 PiSNZxc1CJTkgJac1fzJj3tAqhluFxfNjir2ToOSoFjBp+jNZp
 LBTTrfqU4F6/I2F4M7Acn0tojO6lgjUkD4ttkvcWmSCa0MhaPa
 5/8ETftRqCb92zeHEOOMz7L0DOnxpTi6CUjtRPzI9GE0Cc2lDL
 EWLSH7R2NbAvOpP7bXIuqHkfGAQ==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 110
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


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      |   27 +++++++++++++++++++-
 ext/openwrt/scripts/functions/common |   21 +++++++++++++++-
 src/ubus.c                           |   43 ++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 1379afd..1f72c27 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -30,24 +30,30 @@ config scripts
 	list location /usr/share/freecwmp/functions/device_info
 	list get_value_function get_device_info
 	list get_name_function get_device_info_name
+	list get_notification_function get_device_info_notification
 	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 get_notification_function get_device_info_generic_notification
 	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 get_notification_function get_lan_device_notification
 	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 get_notification_function get_management_server_notification
 	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 get_notification_function get_management_server_generic_notification
 	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 get_notification_function get_wan_device_notification
 	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 a2f2bc1..02a923e 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,6 +113,7 @@ handle_scripts() {
 	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 get_notification_functions "$section" "get_notification_function"
 	config_get set_value_functions "$section" "set_value_function"
 }
 
@@ -219,8 +220,30 @@ if [ "$action" = "set_value" ]; then
 fi
 
 if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
-	freecwmp_get_parameter_notification "x_notification" "$__arg1"
-	freecwmp_notification_output "$__arg1" "$x_notification"
+	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 $get_notification_functions
+		do
+			$function_name "$__arg1"
+			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
+		ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+	fi
 fi
 
 if [ "$action" = "set_notification" ]; then
diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
index abba220..fd98a01 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -51,7 +51,9 @@ case "$action" in
 	get_name)
 	ubus call tr069 get_parameter_names '{"parameter": "'$parameter'", "writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
 	;;
- 
+	get_notification)
+	ubus call tr069 get_parameter_attributes '{"parameter": "'$parameter'", "notification": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
+	;;
 esac
 }
 freecwmp_value_output() {
@@ -151,6 +153,9 @@ freecwmp_config_notifications() {
 		if [ "$item" = "$3" ]; then
 			eval "export -- \"$4=2\""
 			return 0
+		elif [ "`echo $3|grep $item`" = "$3" ]; then
+			eval "export -- \"$4=2\""
+			return 0
 		fi
 	done
 	for item in $__passive
@@ -158,6 +163,9 @@ freecwmp_config_notifications() {
 		if [ "$item" = "$3" ]; then
 			eval "export -- \"$4=1\""
 			return 0
+		elif [ "`echo $3|grep $item`" = "$3" ]; then
+			eval "export -- \"$4=1\""
+			return 0
 		fi
 	done
 }
@@ -193,7 +201,18 @@ freecwmp_get_parameter_notification() {
 	local _dest="$1"
 	local _parm="$2"
 	local _val
+	local _parent
 	config_foreach freecwmp_config_notifications "notifications" "get" "$_parm" "_val"
+	if [ "$_val" = "" ]; then
+		if [ "`echo $_parm|grep '\.$'`" = "" ]; then
+			_parent="${_parm%.*}."
+			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
+		else
+			_parent="${_parm%.*.}."
+			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
+		fi
+	fi
+	if [ "$_val" = "" ];then _val="0" ;fi
 	eval "export -- \"$_dest=$_val\""
 }
 
diff --git a/src/ubus.c b/src/ubus.c
index cbf94b0..072b2a1 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <unistd.h>
@@ -239,12 +240,54 @@ freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *o
 	return 0;
 }
 
+static enum get_param_attributes {
+	GET_PARAM_ATTRIBUTES_PARAM,
+	GET_PARAM_ATTRIBUTES_NOTIF,
+	GET_PARAM_ATTRIBUTES_FAULT,
+	__GET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy get_param_attributes_policy[] = {
+	[GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_ATTRIBUTES_MAX];
+
+	blobmsg_parse(get_param_attributes_policy, ARRAY_SIZE(get_param_attributes_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	freecwmp_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_attributes for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
+				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
+				      NULL,
+				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
+
+	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("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),
 };
 
 static struct ubus_object_type main_object_type =
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:26 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:27 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:63837 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831871Ab2LFP6BEV41W (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:58:01 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Mddoi-1TWhhO3o6u-00PXJG; Thu, 06 Dec 2012 16:57:55 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 22/27] update xml handler set parameter values in order to execute external command and get response via ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:47 +0100
Message-Id: <1354809292-2467-23-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:hMVoXE9N14Js091ePlvkYiNXZaYTvB7xMMFzsrFxiEV
 mZIkRrSl7TZFUY5RpDanZXKwsrd6DHRFfX3tquilWzHCZWAVLP
 GRSIeaI0xfuYtE35GOMFGgtj31BhRgQaQd+kveRVdxv6xldVWj
 un9uXENN1Y5Ps8s9EacrrGHSgjxmPuCZ2LFlGQF/OT067DqZzD
 +b4N4Oexvo/abU3gKG18bEFCtDh/kgT/oLpHR8fY7NQvfY9Sor
 R1lz59pC9MPrrdtDgEWQ9CgiknH4pJqbE0xkCwJeC4Y9SQ9bJY
 QE8R0Zj3un7DApPilkVN5bWbeKKsXnUx7xTC4fBJ/xBGK9VqU7
 P41Us3ILDu/eLjZLHFnKwmaaBiu+e6hylGFvw6f+I4FaSt4aoq
 YdfKdUijN3P/qzFMSKCqKjveaQk70SCQacZYhmJhCRvyAOA3YQ
 QB4+aNoLJe9d/1Cd0pHqooOS8YQ==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 111
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
 src/external.c |   36 ++++++++++++++++++++++++++-
 src/external.h |    5 +++-
 src/ubus.c     |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/xml.c      |   25 +++++++++++++-----
 4 files changed, 130 insertions(+), 9 deletions(-)

diff --git a/src/external.c b/src/external.c
index 4973d1a..7eec751 100644
--- a/src/external.c
+++ b/src/external.c
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <errno.h>
@@ -27,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)
 {
@@ -60,6 +63,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;
@@ -229,9 +244,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)
 {
 	freecwmp_log_message(NAME, L_NOTICE, "executing set script\n");
+	FILE *fp;
+
+	if (access(fc_script_set_actions, R_OK | W_OK | F_OK) == -1)
+		return -1;
+
+	fp = fopen(fc_script_set_actions, "a");
+	if (!fp) return -1;
+
+#ifdef DUMMY_MODE
+	fprintf(fp, "/bin/sh `pwd`/%s apply %s\n", fc_script, action);
+#else
+	fprintf(fp, "/bin/sh %s 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;
@@ -258,6 +289,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_set_actions) != 0)
diff --git a/src/external.h b/src/external.h
index 8e82c39..77165ee 100644
--- a/src/external.h
+++ b/src/external.h
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #ifndef _FREECWMP_EXTERNAL_H__
@@ -27,12 +28,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 072b2a1..e852ed4 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,11 +281,84 @@ 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;
+
+
+	freecwmp_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;
+
+
+	freecwmp_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 c735244..a8f82c7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -578,6 +578,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 &&
@@ -602,25 +603,35 @@ 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 KMD add here check for fault return from ubus
+
+	external_fetch_set_param_val_resp_status(&status);
+	if(!status) return -1; //TODO KMD return a fault message here
+
 	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,
@@ -899,7 +910,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


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:28 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:29 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:58627 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831889Ab2LFP6CVkLt5 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:58:02 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MEnBC-1TweY206H4-00G95c; Thu, 06 Dec 2012 16:57:56 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 23/27] update common script and freecwmp.sh script in order to have the functions for set parameter values working with ubus Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Date:   Thu,  6 Dec 2012 16:54:48 +0100
Message-Id: <1354809292-2467-24-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:hUhgBeuW1FVwQ/Ehq3whbSfrxCyH/1JL0nokMOBZ4nF
 Jg7U6XjVolTqSOlBvSwFEpNx7Tu/lzF7UOBPnvdUeyfRv4ozsB
 PMXl1MssnO9Wvlo0/wnYAICvzCeaIkfgmhCYSsRF0UBXywO4gW
 eYrqjvfrhPHk3dlil9Wn7t0fBYUBN04QSuJLXBdbVgzJgpnxlj
 C2wJ8TA2Zf8/w0PqZwdK3pqZRUi8u46aLknkviCgMBGJNhjQBm
 vawIOkPzEh2z9cQg5T0NahbpEilWezqius0OFIryYUDCi2SGpf
 DkQ813HukipCGLSdrnkuroq8ajSGqT+gD4mXN/4ds5NffM673z
 0Cc+BCqskq5rYAE9jkaDN9Ugcau9MKk3CXtfmEj5cRR+zZzxfG
 3F8n/IEOMMbCQgeHO3wrZ4w7ppzK0OUTlElxjajKWa04yC7Uli
 Gn1fj4EXl8PBeptQlfX+UY7eMHw==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 112
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/freecwmp.sh      |   58 +++++++++++++++++++++++++++++++--
 ext/openwrt/scripts/functions/common |   20 ++++++++++++
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index 02a923e..54c0924 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -90,6 +90,15 @@ case "$1" in
 	reboot)
 		action="reboot"
 		;;
+	apply)
+		if [ "$2" = "notification" ]; then
+			action="apply_notification"
+		elif [ "$2" = "value" ]; then
+			action="apply_value"
+		else
+			action="apply_value"
+		fi
+		;;
 esac
 
 if [ -z "$action" ]; then
@@ -213,10 +222,30 @@ 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
+	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_value_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_notification" -o "$action" = "get_all" ]; then
@@ -295,6 +324,27 @@ if [ "$action" = "reboot" ]; then
 	fi
 fi
 
+if [ \( "$action" = "apply_notification" \) -o \( "$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 call tr069 set_parameter_values_status '{"status": "0"}'; fi
+	else
+		let n=$__fault_count-1
+		for i in `seq 0 $n`
+		do
+			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"
+		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 fd98a01..f701eb9 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -56,6 +56,16 @@ case "$action" in
 	;;
 esac
 }
+ 
+ubus_freecwmp_fault_output() {
+local parameter="$1"
+local fault_code="$2"
+case "$action" in
+	apply_value)
+	ubus call tr069 set_parameter_values_fault '{"parameter": "'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null
+	;;
+esac
+}
 freecwmp_value_output() {
 	freecwmp_output "$1" "$2" "V"
 }
@@ -295,3 +305,13 @@ if [ "$1" = "." ]; then
 fi
 return $FAULT_CPE_NO_FAULT
 }
+
+freecwmp_set_parameter_fault() {
+	local _parm="$1"
+	local _fault="$2"
+		/sbin/uci -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
+}
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:29 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:31 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:62070 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831892Ab2LFP6DlPQo0 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:58:03 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MSr7l-1TZBjs0A0z-00S1Lb; Thu, 06 Dec 2012 16:57:57 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 24/27] update dm script to send the output of set parameter function to the ubus Contributed by Inteno Broadband Technology AB
Date:   Thu,  6 Dec 2012 16:54:49 +0100
Message-Id: <1354809292-2467-25-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:bQSYrBiypxbXNd4ntgGFsh8Y+ZdDOdpUMx3vMRw5kQH
 f0YiCjehwuEhtdW7N1uAl/fq4+FKh8aqmG2FfbpU+LJyr4CKjA
 RbDcST/8CGiRfLNWa4MIZGOjRa62tQNzrZjbojmJk0yItuMVNn
 7IKByqEA2aZV7jhuwmYpC5AJXl3Z6BgbNmXyIR0NefEslUaZ7x
 AgkQY22ZTo9h4qP0Q7pi8Z0o0CZ0SMQvSvOPdbzLG3YzWdGa7m
 Jd3AsXVhCZ+sLqlFm7fxAvSIVyUqjfoH1LgIfDuFt9u1ooYAgO
 QwE8TerkCS/nwykXajb+solNpCPJoWi3OLRlUUeI3JaGTBEAC5
 D7uvYDhS8W+G5D/ZQ3WJ0IoI9ilf7eb2Z0eHiYz3+RMaZViVM5
 C3DNbysvkgU/gWjA/D6JXY7ZXwC7js30rF+FwbRik5OsNmFekK
 tmFu/+CD8BMtHfyv77l2v+OP9AQ==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 113
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/functions/device_info       |   62 +++++++-
 ext/openwrt/scripts/functions/lan_device        |   33 +++--
 ext/openwrt/scripts/functions/management_server |  178 +++++++++++++++++------
 ext/openwrt/scripts/functions/wan_device        |   41 ++++--
 4 files changed, 238 insertions(+), 76 deletions(-)

diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
index 2be20b5..5fe2823 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -19,7 +19,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
 }
 
 set_device_info_manufacturer() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].manufacturer="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.Manufacturer"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].manufacturer="$val"
+	;;
+esac
 }
 
 get_device_info_oui() {
@@ -39,7 +45,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
 }
 
 set_device_info_oui() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].oui="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].oui="$val"
+	;;
+esac
 }
 
 get_device_info_product_class() {
@@ -59,7 +71,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
 }
 
 set_device_info_product_class() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].product_class="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ProductClass"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].product_class="$val"
+	;;
+esac
 }
 
 get_device_info_serial_number() {
@@ -79,7 +97,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
 }
 
 set_device_info_serial_number() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].serial_number="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SerialNumber"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].serial_number="$val"
+	;;
+esac
 }
 
 get_device_info_hardware_version() {
@@ -99,7 +123,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
 }
 
 set_device_info_hardware_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].hardware_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.HardwareVersion"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].hardware_version="$val"
+	;;
+esac
 }
 
 get_device_info_software_version() {
@@ -119,7 +149,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
 }
 
 set_device_info_software_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].software_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].software_version="$val"
+	;;
+esac
 }
 
 get_device_info_uptime() {
@@ -370,24 +406,31 @@ set_device_info() {
 case "$1" in
 	InternetGatewayDevice.DeviceInfo.Manufacturer)
 	set_device_info_manufacturer "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
 	set_device_info_oui "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.ProductClass)
 	set_device_info_product_class "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.SerialNumber)
 	set_device_info_serial_number "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.HardwareVersion)
 	set_device_info_hardware_version "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
 	set_device_info_software_version "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
 }
 
 check_parameter_device_info_generic() {
@@ -449,8 +492,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
 
 	freecwmp_set_parameter_value "$1" "$2"
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+	return $FAULT_CPE_NO_FAULT
 }
diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index 949f11c..db90021 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -33,13 +33,18 @@ esac
 set_wlan_enable() {
 local num="$1"
 local val="$2"
-if [ "$val" = "1" ]; then
-	val="0"
-else
-	val="1"
-fi
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+case $action in
+	set_value)
+	if [ "$val" = "1" ]; then
+		val="0"
+	else
+		val="1"
+	fi
+	delay_command "wifi" "wifi" "45"
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
+	;;
+esac
 }
 
 get_wlan_ssid() {
@@ -68,8 +73,13 @@ esac
 set_wlan_ssid() {
 local num="$1"
 local val="$2"
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+case $action in
+	set_value)
+	delay_command "wifi" "wifi" "45"
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
+	;;
+esac
 }
 
 get_lan_device() {
@@ -223,10 +233,13 @@ set_lan_device() {
 case "$1" in
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
 	set_wlan_enable 0 "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
 	set_wlan_ssid 0 "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
 }
diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
index b1e759d..37b1cb0 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -26,34 +26,39 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_url() {
-local url=$1
-local scheme
-local hostname
-local path
-local port
-
-scheme=`echo $url | awk -F "://" '{ print $1 }'`
-hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
-port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F '/' '{ print $1 }'`
-
-if [ -z "$port" ]; then
-	port=80
-	path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
-	echo 123 $path
-else
-	path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
-fi
-
-if [ -z "$path" ]; then
-	path="/"
-fi
-
-set_management_server_x_freecwmp_org__acs_scheme $scheme
-set_management_server_x_freecwmp_org__acs_hostname $hostname
-set_management_server_x_freecwmp_org__acs_port $port
-set_management_server_x_freecwmp_org__acs_path $path
-
-ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+	set_value)
+	local url=$1
+	local scheme
+	local hostname
+	local path
+	local port
+	
+	scheme=`echo $url | awk -F "://" '{ print $1 }'`
+	hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
+	port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F '/' '{ print $1 }'`
+	
+	if [ -z "$port" ]; then
+		port=80
+		path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
+		echo 123 $path
+	else
+		path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
+	fi
+	
+	if [ -z "$path" ]; then
+		path="/"
+	fi
+	
+	set_management_server_x_freecwmp_org__acs_scheme $scheme
+	set_management_server_x_freecwmp_org__acs_hostname $hostname
+	set_management_server_x_freecwmp_org__acs_port $port
+	set_management_server_x_freecwmp_org__acs_path $path
+	
+	ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
+	;;
+esac
 }
 
 get_management_server_username() {
@@ -74,7 +79,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].username="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].username="$val"
+	;;
+esac
 }
 
 get_management_server_password() {
@@ -95,7 +106,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].password="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].password="$val"
+	;;
+esac
 }
 
 get_management_server_periodic_inform_enable() {
@@ -117,8 +134,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 set_management_server_periodic_inform_enable() {
+local val=$1
 local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+	set_value)
+	freecwmp_set_parameter_value "$parm" "$val"
+	;;
+esac
 }
 
 get_management_server_periodic_inform_interval() {
@@ -140,8 +162,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
 }
 
 set_management_server_periodic_inform_interval() {
+local val=$1
 local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+	set_value)
+	freecwmp_set_parameter_value "$parm" "$val"
+	;;
+esac
 }
 
 get_management_server_connection_request_url() {
@@ -191,7 +218,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_connection_request_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].username="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].username="$val"
+	;;
+esac
 }
 
 get_management_server_connection_request_password() {
@@ -212,7 +245,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_management_server_connection_request_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].password="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].password="$val"
+	;;
+esac
 }
 
 # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
@@ -239,7 +278,13 @@ fi
 }
 
 set_management_server_x_freecwmp_org__acs_scheme() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].scheme="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].scheme="$val"
+	;;
+esac
 }
 
 get_management_server_x_freecwmp_org__acs_hostname() {
@@ -264,11 +309,17 @@ fi
 }
 
 set_management_server_x_freecwmp_org__acs_hostname() {
-if [ -z "$default_management_server_acs_hostname" ]; then
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$1"
-else
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
-fi
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+	set_value)
+	if [ -z "$default_management_server_acs_hostname" ]; then
+			/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$val"
+	else
+		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
+	fi
+	;;
+esac
 }
 
 get_management_server_x_freecwmp_org__acs_port() {
@@ -293,7 +344,13 @@ fi
 }
 
 set_management_server_x_freecwmp_org__acs_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].port="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].port="$val"
+	;;
+esac
 }
 
 get_management_server_x_freecwmp_org__acs_path() {
@@ -318,7 +375,13 @@ fi
 }
 
 set_management_server_x_freecwmp_org__acs_path() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].path="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].path="$val"
+	;;
+esac
 }
 
 get_management_server_x_freecwmp_org__connection_request_port() {
@@ -343,7 +406,13 @@ fi
 }
 
 set_management_server_x_freecwmp_org__connection_request_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].port="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].port="$val"
+	;;
+esac
 }
 
 get_management_server() {
@@ -674,45 +743,59 @@ set_management_server() {
 case "$1" in
 	InternetGatewayDevice.ManagementServer.URL)
 	set_management_server_url "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.Username)
 	set_management_server_username "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.Password)
 	set_management_server_password "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
 	set_management_server_periodic_inform_enable "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
 	set_management_server_periodic_inform_interval "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
 	set_management_server_connection_request_url "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
 	set_management_server_connection_request_username "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
 	set_management_server_connection_request_password "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
 	set_management_server_x_freecwmp_org__acs_scheme "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	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 $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
 	set_management_server_x_freecwmp_org__acs_port "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
 	set_management_server_x_freecwmp_org__acs_path "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
 	set_management_server_x_freecwmp_org__connection_request_port "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
 
 check_parameter_management_server_generic() {
@@ -750,8 +833,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
 
 	freecwmp_set_parameter_value "$1" "$2"
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+	return $FAULT_CPE_NO_FAULT
 }
diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
index 02ba365..c8f1887 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -94,13 +94,18 @@ ubus_freecwmp_output "$parm" "$val" "$type"
 
 set_wan_device_wan_ppp_enable() {
 local val=$1
-if [ "$val" -eq 0 ]; then
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
-	ifdown wan &
-elif [ "$val" -eq 1 ]; then
-	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
-	ifup wan &
-fi
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case $action in
+	set_value)
+	if [ "$val" -eq 0 ]; then
+		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
+		ifdown wan &
+	elif [ "$val" -eq 1 ]; then
+		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
+		ifup wan &
+	fi
+	;;
+esac
 }
 
 get_wan_device_wan_ppp_username() {
@@ -121,7 +126,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_wan_device_wan_ppp_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.username="$1"
+local val=$1
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case $action in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.username="$val"
+	;;
+esac
 }
 
 get_wan_device_wan_ppp_password() {
@@ -142,7 +153,13 @@ ubus_freecwmp_output "$parm" "$val"
 }
 
 set_wan_device_wan_ppp_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.password="$1"
+local val=$1
+local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case $action in
+	set_value)
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.password="$1"
+	;;
+esac
 }
 
 get_wan_device() {
@@ -452,13 +469,17 @@ set_wan_device() {
 case "$1" in
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
 	set_wan_device_wan_ppp_enable "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
 	set_wan_device_wan_ppp_username "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
 	set_wan_device_wan_ppp_password "$2"
+	return $FAULT_CPE_NO_FAULT
 	;;
 esac
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:32 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:33 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:57660 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831884Ab2LFP6FLnNxk (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:58:05 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MSr7l-1TZBjv1IH7-00S1Lb; Thu, 06 Dec 2012 16:57:59 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Subject: [PATCH 25/27] add ubus listner for set parameter attribute Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Date:   Thu,  6 Dec 2012 16:54:50 +0100
Message-Id: <1354809292-2467-26-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:ajz1Hp+1RlceFpdRYrd/5dwAUdCOW9FWcEqjB5Nq63n
 RDh2Wfxmm6x/j0WtPxG5CxF5cKEE/p1QSW7YMYYy8bgqzE2bE5
 pjIeQbP02VE7qMTpB+Z9XFUxnX5rJRCJkslLlt39ZYGBWVd3rz
 bQi3x/LhJHPvYq2xpRZljNec2euheoVgaefYneK+OQmmYBm4gV
 KDL/HJu0BvUEPc3jXjmJRmcWsQxgZORYZqmY4Xqnbt1VkDdMMa
 XA2NXa9URWyZYb7uWo7qBrDTFavNXc05925Fi5fqqcE9RxhNCK
 DH+jMYZVUeeKCmHj0lnZGPTaPNHHk+SwbfDJ4E4nRQMrO92orW
 USeR7qXNyIw3G4RTtLbcIVGgaSxxlZBJmbMyHxAj7cXMjMOIZU
 4eIGJZwIw/G/bKwKwIVhW8+yyCgxwhZG4q4D6ZJfw6Tlcn0LuA
 jv4h4jv+rhLUll126MLOZOaHhlA==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 114
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
---
 src/external.c |   16 ++++++++++++++++
 src/external.h |    2 ++
 src/ubus.c     |   31 +++++++++++++++++++++++++++++++
 src/xml.c      |   20 +++++++++++++++++---
 4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/src/external.c b/src/external.c
index 7eec751..a033781 100644
--- a/src/external.c
+++ b/src/external.c
@@ -75,6 +75,22 @@ void external_fetch_set_param_val_resp_status(char **status)
 	external_method_status = NULL;
 }
 
+void external_set_param_attr_resp (char *status, char *fault)
+{
+	free(external_method_status);
+	external_method_status = status ? strdup(status) : NULL;
+	free(external_method_fault);
+	external_method_fault = fault ? strdup(fault) : NULL;
+}
+
+void external_fetch_set_param_attr_resp (char **status, char **fault)
+{
+	*status = external_method_status;
+	external_method_status = NULL;
+	*fault = external_method_fault;
+	external_method_fault = NULL;
+}
+
 int external_get_action_data(char *action, char *name, char **value)
 {
 	struct external_parameter *external_parameter;
diff --git a/src/external.h b/src/external.h
index 77165ee..489d215 100644
--- a/src/external.h
+++ b/src/external.h
@@ -30,6 +30,8 @@ struct external_parameter {
 
 void external_set_param_val_resp_status (char *status);
 void external_fetch_set_param_val_resp_status (char **status);
+void external_set_param_attr_resp (char *status, char *fault);
+void external_fetch_set_param_attr_resp (char **status, char **fault);
 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);
diff --git a/src/ubus.c b/src/ubus.c
index e852ed4..8502805 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,6 +281,36 @@ freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct ubus_obje
 	return 0;
 }
 
+static enum set_param_attributes {
+	SET_PARAM_ATTRIBUTES_SUCCESS,
+	SET_PARAM_ATTRIBUTES_FAULT,
+	__SET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy set_param_attributes_policy[] = {
+		[SET_PARAM_ATTRIBUTES_SUCCESS] = { .name = "success", .type = BLOBMSG_TYPE_STRING },
+	[SET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_attributes(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_ATTRIBUTES_MAX];
+
+	blobmsg_parse(set_param_attributes_policy, ARRAY_SIZE(set_param_attributes_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	freecwmp_log_message(NAME, L_NOTICE,
+			     "triggered ubus set_parameter_attributes\n");
+
+	external_set_param_attr_resp(tb[SET_PARAM_ATTRIBUTES_SUCCESS] ? blobmsg_data(tb[SET_PARAM_ATTRIBUTES_SUCCESS]) : NULL,
+			tb[SET_PARAM_ATTRIBUTES_FAULT] ? blobmsg_data(tb[SET_PARAM_ATTRIBUTES_FAULT]) : NULL);
+
+	return 0;
+}
+
 static enum set_param_values_fault {
 	SET_PARAM_VALUES_FAULT_PARAM,
 	SET_PARAM_VALUES_FAULT__FAULT,
@@ -361,6 +391,7 @@ static const struct ubus_method freecwmp_methods[] = {
 	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),
+	UBUS_METHOD("set_parameter_attributes", freecwmpd_handle_set_param_attributes, set_param_attributes_policy),
 };
 
 static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index a8f82c7..e46c50c 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -6,6 +6,7 @@
  *
  *	Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
  *	Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
+ *  Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <stdbool.h>
@@ -861,7 +862,7 @@ static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 					       mxml_node_t *tree_out) {
 
 	mxml_node_t *n, *b = body_in;
-	char *c, *parameter_name, *parameter_notification;
+	char *c, *parameter_name, *parameter_notification, *success=NULL, *fault=NULL;
 	uint8_t attr_notification_update;
 
 	/* handle cwmp:SetParameterAttributes */
@@ -913,15 +914,28 @@ static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 	if (external_set_action_execute("notification"))
 		return -1;
 
+	external_fetch_set_param_attr_resp(&success, &fault);
+
+	if (fault && fault[0]=='9') goto error; //TODO KMD return a fault message here with fault indicated in the fault string
+
+	if(!success) goto error; //TODO KMD return a fault message here
+
 	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:SetParameterAttributesResponse");
-	if (!b) return -1;
+	if (!b) goto error;
 
 	config_load();
 
+	free(success);
+	free(fault);
 	return 0;
+
+error:
+	free(success);
+	free(fault);
+	return -1;
 }
 
 static int xml_handle_download(mxml_node_t *body_in,
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Thu Dec  6 16:58:33 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Thu, 06 Dec 2012 16:58:38 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:54335 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6831891Ab2LFP6GctmPJ (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Thu, 6 Dec 2012 16:58:06 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0Lr20J-1TCYDM1ULD-00eRMf; Thu, 06 Dec 2012 16:58:00 +0100
From:   Mohamed <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
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
Date:   Thu,  6 Dec 2012 16:54:51 +0100
Message-Id: <1354809292-2467-27-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:t3DtBmadkIgzaAIh9pQIAkaGYGiNmpG7dYiZ+cVoLB2
 VqJ6Ikizr/nAryZsDcacqq71hz5cnBj/AQARDOFhDTwwOcVILL
 9a1iKVm3LWGhNBKA6u+8oI4WTtoYhKCvH8x7pyv50RZBNSRHt5
 NjFjSK2NAOF6y6JhgBB0ndNXmuTbUfi0AGKPQ4QjHMsAKtzWjm
 fWGQBe8HqaItw+Vebs6k4fD6LEE75THIFH4riLLbI5un7jBUPO
 eA4aBarUUGWnAFemksy1q3dT1y0QEY8pp1lniE5paOjSUS0+vs
 1LLZZOmPHfU/hD/dBYAdasFvIz3tDejcD6TPNqumTAGTvch7Uj
 IV8PL7Drc6pCSjLEEzQfiUdQY6mCcYTISXh77HVTzvjaToNbab
 Z5igOHkx0l+vYWzqLsf7s612vfor6ZPkA8eLwnRCabUtns3cF9
 7OJYfIUObICGMboJddu+4bV9UgQ==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 115
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp


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


From freecwmp@lukaperkov.net Sat Dec  8 10:13:15 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 10:13:17 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:40583 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816384Ab2LHJNP3spQF (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 10:13:15 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so445246eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 01:13:10 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=4qy5vRG76PlTc3Tmd6pu10V4SI56D4m3MAX3sHyWzaQ=;
        b=h8gnQaoh4O8naUdH3HF1KYTVWu587vT58XVP+fk7EwWOfKrlTvUKuEC+Scb8otnecF
         50uezJXadLL7b3VLAMebzGOMsyCzSzSP1yM7RujxA2fxgQNWa+MYVJkPhXyrFlDihu7l
         XEIE91opl27WinLlTzJgNk8qqdMKVlrZx+9wZcACSd7TKXaba4Gc2++iVphp2aOQS28N
         kH+yLwBlsV847YylyvBivgQeCcWoEj7owuCGKIQNW2hPic+joplnsJYgr0iHg7vrDb7z
         Sd9uNy34sNSLbKVzFb8Gj07SY96J4CH2lGSXKROazKRP6HSKQBColbBwucMORazu+ECs
         /uuQ==
Received: by 10.14.198.67 with SMTP id u43mr27081881een.7.1354957989878;
        Sat, 08 Dec 2012 01:13:09 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id z8sm28172254eeo.11.2012.12.08.01.13.06
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 01:13:08 -0800 (PST)
Date:   Sat, 8 Dec 2012 10:17:06 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 00/27] Data model with ubus
Message-ID: <20121208091706-30891@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnDwjk7SSilfeAEKnScVyN0K7ujlR9WiOlbeKtFvNaRIby6W/zg09d1ggHf0lSux4eNSYmj
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 116
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Hi Mohamed,

On Thu, Dec 06, 2012 at 04:54:25PM +0100, Mohamed wrote:
> Hi Luka

Please next time put also jogo@openwrt.org in CC.

> As summary, The following patches contains:
> 
>   communication from script to the core via ubus
>   GetParameterValues method supporting many parameters
>   GetParameterNames method added

This is my general comment on your patch series:

* all patches are missing commit messages
* commit messages should be verbose
* commit subject should be shorter and it can not contain "Contributed
  by Inteno Broadband"
* "Contributed by Inteno Broadband" must go in commit message
* don't make coding style errors on one patch and then fix it later in
  the series
* please subscribe to the list so your patches don't get picked up by
  spam filter (that is why I did not deleted anything from my responses)

When sending updated patch make sure you name it PATCHv2 in the subject
instead PATCH only. Also, note the changes that you have made from the
last version. You can use u-boot patch submission guidelines as a
reference:

http://www.denx.de/wiki/U-Boot/Patches

You can look at this patch as an example:

http://lists.denx.de/pipermail/u-boot/2012-July/128709.html

But in your case commit messages must be much more verbose.

Regards,
Luka

> Regards
> Mohamed KALLEL
> 
> Mohamed (27):
>   add ubus listner get_parameter_values. This listener allows to get
>     the freecwmp output from extenal command.       Contributed by
>     Inteno Broadband Technology AB
>   get_parameter values handler from xml is supporting many parameters
>     from external ubus output       Contributed by Inteno Broadband
>     Technology AB && PIVA SOFTWARE
>   add in the scripts the functions needed to communicate data to ubus
>     handler for the get_parameter_values ubus handler       Contributed
>     by Inteno Broadband Technology AB
>   Update device_hosts to support communicte data of get parameter
>     values to the core via ubus       Contributed by Inteno Broadband
>     Technology AB
>   Update device_info script to support communicte data of get parameter
>     values to the core via ubus       Contributed by Inteno Broadband
>     Technology AB
>   Update device_routing script to support communicte data of get
>     parameter values to the core via ubus       Contributed by Inteno
>     Broadband Technology AB
>   Update device_users script to support communicte data of get
>     parameter values to the core via ubus       Contributed by Inteno
>     Broadband Technology AB
>   Update lan_device script to support communicte data of get parameter
>     values to the core via ubus       Contributed by Inteno Broadband
>     Technology AB
>   Update management_server script to support communicte data of get
>     parameter values to the core via ubus       Contributed by Inteno
>     Broadband Technology AB
>   Update misc script to support communicte data of get parameter values
>     to the core via ubus       Contributed by Inteno Broadband
>     Technology AB
>   Update wan_device script to support communicte data of get parameter
>     values to the core via ubus       Contributed by Inteno Broadband
>     Technology AB
>   update inform in order to get parameters from ubus instead from pipe 
>          Contributed by PIVA SOFTWARE
>   Add 3rd argument in the ubus handler of notification. The 3rd
>     argument is the type of the parameter      This agument could be 
>     used in the response of get parameter attribute       Contributed
>     by Inteno Broadband Technology AB
>   add xml message get_parameter_name handler.       Contributed by
>     Inteno Broadband Technology AB & PIVA SOFTWARE
>   add the common function and adapt the script freecwmp.sh in order to
>     support get parameter names       Contributed by Inteno Broadband
>     Technology AB
>   update the script device_info in order to output parameters with ubus
>           Contributed by Inteno Broadband Technology AB
>   update the script lan_device in order to output parameters with ubus 
>          Contributed by Inteno Broadband Technology AB
>   update the script management_server in order to output parameters
>     with ubus       Contributed by Inteno Broadband Technology AB
>   update the script wan_device in order to output parameters with ubus 
>          Contributed by Inteno Broadband Technology AB
>   update the get notification in order to put the returned data via
>     ubus instead of pipe      TODO: develop the xml handle message to
>     perform send of GetParameterAttributeResponse       Contributed by
>     Inteno Broadband Technology AB
>   update the data model parameter scripts in order to output parameter
>     and notification values via ubus       Contributed by Inteno
>     Broadband Technology AB
>   update xml handler set parameter values in order to execute external
>     command and get response via ubus       Contributed by Inteno
>     Broadband Technology AB
>   update common script and freecwmp.sh script in order to have the
>     functions for set parameter values working with ubus      
>     Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
>   update dm script to send the output of set parameter function to the
>     ubus       Contributed by Inteno Broadband Technology AB
>   add ubus listner for set parameter attribute       Contributed by
>     Inteno Broadband Technology AB & PIVA SOFTWARE
>   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
>   update the dm script function to communicate the output of set
>     parameter attribute with ubus       Contributed by Inteno Broadband
>     Technology AB
> 
>  bin/Makefile.am                                 |    3 +-
>  configure.ac                                    |    3 +
>  ext/openwrt/config/freecwmp                     |   18 +
>  ext/openwrt/scripts/freecwmp.sh                 |  219 ++++++-
>  ext/openwrt/scripts/functions/common            |   69 ++
>  ext/openwrt/scripts/functions/device_hosts      |   22 +-
>  ext/openwrt/scripts/functions/device_info       |  448 ++++++++++++-
>  ext/openwrt/scripts/functions/device_routing    |   33 +-
>  ext/openwrt/scripts/functions/device_users      |   13 +-
>  ext/openwrt/scripts/functions/lan_device        |  232 ++++++-
>  ext/openwrt/scripts/functions/management_server |  808 ++++++++++++++++++++---
>  ext/openwrt/scripts/functions/misc              |    8 +-
>  ext/openwrt/scripts/functions/wan_device        |  427 +++++++++++-
>  src/cwmp.c                                      |    4 +-
>  src/cwmp.h                                      |    2 +-
>  src/external.c                                  |  218 +++++--
>  src/external.h                                  |   26 +-
>  src/freecwmp.c                                  |   17 +
>  src/ubus.c                                      |  233 +++++++-
>  src/xml.c                                       |  260 ++++++--
>  src/xml.h                                       |    4 +
>  21 files changed, 2741 insertions(+), 326 deletions(-)
> 
> -- 
> 1.7.4.1
> 

From freecwmp@lukaperkov.net Sat Dec  8 10:30:19 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 10:30:22 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:36135 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816900Ab2LHJaTaQRO2 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 10:30:19 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so677739eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 01:30:14 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=0zDr3Izv+l1CIJWOKVwYOz0NXflIrEsRAjfdqyAakiw=;
        b=hNnly/NecGplwmenhCgVvQwUJWtYs4gjtbD3ArqDpG1gN+9283H2dSbDmPPR36Ffqe
         achzkcdnNAVEAsG5ph31d0FdKiYWFfiWQSNeRpF2U/1boy99VjEJ069Y8ui9j3g2m6Y9
         cHO4BRGRmOPHYhB0v6bw98P3AyxLXYcZ6SE+OuINpvppNh/OO20+lw7iOCu6GlmkoF8v
         b8SxOCVUiC3Clqoat+CqgulavbjjQs04N+gN2UzrLB1Ts4bmUyLOvO4441thK+PW72Ho
         EXGrXjn4K9iMBh7pGR6+Zq+NFZUjet8plXP/6O2wQknhwyIrNEKLjHsMlGZCedpg+EoM
         Ipcg==
Received: by 10.14.173.69 with SMTP id u45mr27036317eel.21.1354959014028;
        Sat, 08 Dec 2012 01:30:14 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id f49sm28263452eep.12.2012.12.08.01.30.12
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 01:30:13 -0800 (PST)
Date:   Sat, 8 Dec 2012 10:34:12 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 01/27] add ubus listner get_parameter_values. This
 listener allows to get the freecwmp output from extenal command. Contributed
 by Inteno Broadband Technology AB
Message-ID: <20121208093412-2277@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-2-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-2-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmVkxGNiSWwkI2YNnwYkdMm9h4pXbI1XQ7FGCNA8AXRA3ZTvv53opB+Tj1Z36skiUTiFqLj
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 117
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:26PM +0100, Mohamed wrote:
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

There is no need to spell ZRIBI so in all patches please change the
above to:

Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>

Or is there a specific reason to spell it ZRIBI?

> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

Add your last name to all patches:

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>

> ---
>  src/external.c |   13 +++++++++++++
>  src/external.h |   10 ++++++++++
>  src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 65 insertions(+), 0 deletions(-)
> 
> diff --git a/src/external.c b/src/external.c
> index 9ac7b36..c9c768f 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -25,6 +25,19 @@
>  #include "freecwmp.h"
>  
>  static struct uloop_process uproc;
> +LIST_HEAD(external_list_parameter);
> +
> +void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
> +{
> +	struct external_parameter *external_parameter;
> +	struct list_head *ilist; int i =0;
> +	external_parameter = calloc(1, sizeof(struct external_parameter));
> +	list_add_tail(&external_parameter->list,&external_list_parameter);

Missing space, should be "list, &external_list_parameter".

> +	if (param_name) external_parameter->name = strdup(param_name);
> +	if (param_data) external_parameter->data = strdup(param_data);
> +	if (param_type) external_parameter->type = strdup(param_type);
> +	if (fault_code) external_parameter->fault_code = strdup(fault_code);
> +}
>  
>  int external_get_action(char *action, char *name, char **value)
>  {
> diff --git a/src/external.h b/src/external.h
> index 8606266..64b4c6b 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -9,6 +9,7 @@
>  
>  #ifndef _FREECWMP_EXTERNAL_H__
>  #define _FREECWMP_EXTERNAL_H__
> +#include <libubox/list.h>
>  
>  #ifdef DUMMY_MODE
>  static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
> @@ -17,11 +18,20 @@ static char *fc_script = "/usr/sbin/freecwmp";
>  #endif
>  static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
>  
> +struct external_parameter {
> +	struct list_head list;
> +	char *name;
> +	char *data; /* notification for GetParameterAttribute; writable for GetParameterNames; value for GetParameterValues*/

Make comment above the struct for every element. Use u-boot multiline
comments.

> +	char *type;
> +	char *fault_code;
> +};
> +
>  int external_get_action(char *action, char *name, char **value);
>  int external_set_action_write(char *action, char *name, char *value);
>  int external_set_action_execute();
>  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);
>  
>  #endif
>  
> diff --git a/src/ubus.c b/src/ubus.c
> index c10170d..d5437f9 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -16,6 +16,7 @@
>  #include "config.h"
>  #include "cwmp.h"
>  #include "freecwmp.h"
> +#include "external.h"
>  
>  static struct ubus_context *ctx = NULL;
>  static struct ubus_object main_object;
> @@ -157,10 +158,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
>  	return 0;
>  }
>  
> +static enum get_param_values {
> +	GET_PARAM_VALUES_PARAM,
> +	GET_PARAM_VALUES_VALUE,
> +	GET_PARAM_VALUES_TYPE,
> +	GET_PARAM_VALUES_FAULT,
> +	__GET_PARAM_VALUES_MAX
> +};
> +
> +static const struct blobmsg_policy get_param_values_policy[] = {
> +	[GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_VALUES_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_VALUES_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
> +};
> +
> +static int
> +freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *obj,
> +			struct ubus_request_data *req, const char *method,
> +			struct blob_attr *msg)
> +{
> +	struct blob_attr *tb[__GET_PARAM_VALUES_MAX];
> +
> +	blobmsg_parse(get_param_values_policy, ARRAY_SIZE(get_param_values_policy), tb,
> +		      blob_data(msg), blob_len(msg));
> +
> +	if (!tb[GET_PARAM_VALUES_PARAM])
> +		return UBUS_STATUS_INVALID_ARGUMENT;
> +
> +	freecwmp_log_message(NAME, L_NOTICE,
> +			     "triggered ubus get_parameter_values for the parameter %s\n",
> +			     blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
> +
> +	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
> +			tb[GET_PARAM_VALUES_VALUE]? blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,

Add missing space before char "?".

> +			tb[GET_PARAM_VALUES_TYPE]? blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",

Add missing space before char "?".

> +			tb[GET_PARAM_VALUES_FAULT]? blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);

Add missing space before char "?".

> +
> +	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),
>  };
>  
>  static struct ubus_object_type main_object_type =
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:26:19 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:26:20 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:61843 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816384Ab2LHK0TA29oE (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:26:19 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so692991eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:26:13 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=imJ+DHcsjiEuqe/+3yQ6kNpN9akZSmgD3ymBKuDCsm8=;
        b=hsa1rbWkfqEQEbU1XHsbgsqzkgRYqdfkABVrtjewErYptAfJmUC1imq1N1iQSQEMYZ
         2SUjWvzWSvQ8OUkxXMpwn8SUtk9Q0xwCCc70pcPtJsttP28i4bvdotfN/mCkc6mKNYgL
         QcRtZZk9KA5ZezZC9vK7vdSnHN2qUEC4ewnxDSImO1iPVmbIrIwr+2AXgFQPVlP9KVg6
         BD/ty2E+qFMPEoEmxQnqZXsGwuPOAhmyWKECLpZ3viGpvTmion6n56oNB8Ff8cuCm1GY
         O0h3o9/FuiD4OuxN5KQFDzUbuI8JVGfIB7iK/4sBYFcBieAxNsjyMFu9VpxuTeEfYL7u
         n/Zw==
Received: by 10.14.221.9 with SMTP id q9mr27719922eep.3.1354962373591;
        Sat, 08 Dec 2012 02:26:13 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id r1sm28599772eeo.2.2012.12.08.02.26.12
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:26:13 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:30:11 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 02/27] get_parameter values handler from xml is
 supporting many parameters from external ubus output Contributed by Inteno
 Broadband Technology AB && PIVA SOFTWARE
Message-ID: <20121208103011-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-3-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-3-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkcjHRY4JryjSZ9+EeYP0UMPjSQltnHULFP5hTZNNNTcdCM5sPx1+TgOCpsUzx9kQrqjZ5V
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 118
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:27PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  bin/Makefile.am |    3 +-
>  configure.ac    |    3 ++
>  src/external.c  |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/external.h  |    6 +++-
>  src/freecwmp.c  |   17 ++++++++++
>  src/xml.c       |   66 +++++++++++++++++++++++--------------
>  6 files changed, 163 insertions(+), 27 deletions(-)
> 
> diff --git a/bin/Makefile.am b/bin/Makefile.am
> index 78cb111..ac96905 100644
> --- a/bin/Makefile.am
> +++ b/bin/Makefile.am
> @@ -48,5 +48,6 @@ freecwmpd_LDADD =		\
>  	$(LIBUBUS_LIBS)		\
>  	$(MICROXML_LIBS)	\
>  	$(LIBCURL_LIBS)		\
> -	$(LIBZSTREAM_LIBS)
> +	$(LIBZSTREAM_LIBS)	\
> +	$(LIBPTHREAD_LIBS)
>  
> diff --git a/configure.ac b/configure.ac
> index c646c3a..38d3df4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
>  LIBUBUS_LIBS='-lubus'
>  AC_SUBST([LIBUBUS_LIBS])
>  
> +LIBPTHREAD_LIBS='-lpthread'
> +AC_SUBST([LIBPTHREAD_LIBS])
> +

This should go after line 30 and not here:

 30 # checks for libraries

>  AM_COND_IF([HTTP_CURL], [
>   AC_DEFINE(HTTP_CURL)
>   PKG_CHECK_MODULES(LIBCURL, [libcurl])
> diff --git a/src/external.c b/src/external.c
> index c9c768f..94ae9b8 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -25,8 +25,15 @@
>  #include "freecwmp.h"
>  
>  static struct uloop_process uproc;
> +pthread_t ubus_thread;
>  LIST_HEAD(external_list_parameter);
>  
> +void *thread_uloop_run (void *v)

No space here "thread_uloop_run(".

> +{
> +	uloop_run();
> +	return NULL;
> +}
> +
>  void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
>  {
>  	struct external_parameter *external_parameter;
> @@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name, char *param_data, char *par
>  	if (fault_code) external_parameter->fault_code = strdup(fault_code);
>  }
>  
> +void external_free_list_parameter()
> +{
> +	struct external_parameter *external_parameter;
> +	while (external_list_parameter.next!=&external_list_parameter) {

Missing space "next != &external".

> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
> +		list_del(&external_parameter->list);
> +		free(external_parameter->name);
> +		free(external_parameter->data);
> +		free(external_parameter->type);
> +		free(external_parameter->fault_code);
> +		free(external_parameter);
> +	}
> +}
> +
>  int external_get_action(char *action, char *name, char **value)
>  {
>  	freecwmp_log_message(NAME, L_NOTICE,
> @@ -121,6 +142,80 @@ error:
>  	return -1;
>  }
>  
> +int external_get_action_write(char *action, char *name, char *arg)
> +{
> +	freecwmp_log_message(NAME, L_NOTICE,
> +		"adding to get %s script '%s'\n", action, name);
> +
> +	FILE *fp;
> +
> +	if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
> +		fp = fopen(fc_script_get_actions, "a");
> +		if (!fp) return -1;
> +	} else {
> +		fp = fopen(fc_script_get_actions, "w");
> +		if (!fp) return -1;
> +
> +		fprintf(fp, "#!/bin/sh\n");
> +
> +		if (chmod(fc_script_get_actions,
> +			strtol("0700", 0, 8)) < 0) {
> +			return -1;
> +	}

Wrong indentation.

> +	}
> +
> +#ifdef DUMMY_MODE
> +	fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action, name, arg?arg:"");
> +#else
> +	fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name, arg?arg:"");
> +#endif

Reformat like in the existing code:

#ifdef DUMMY_MODE
        fprintf(fp, "/bin/sh `pwd`/%s get %s %s '%s'\n", fc_script, action, name, arg ? arg : "");
#else
        fprintf(fp, "/bin/sh %s get %s %s '%s'\n", fc_script, action, name, arg ? arg : "");
#endif

> +
> +	fclose(fp);
> +
> +	return 0;
> +}
> +
> +int external_get_action_execute()
> +{
> +	freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
> +
> +	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
> +
> +	if ((uproc.pid = fork()) == -1) {
> +		return -1;
> +	}
> +
> +	if (uproc.pid == 0) {
> +		/* child */
> +
> +		const char *argv[3];
> +		int i = 0;
> +		argv[i++] = "/bin/sh";
> +		argv[i++] = fc_script_get_actions;
> +		argv[i++] = NULL;
> +
> +		execvp(argv[0], (char **) argv);
> +		exit(ESRCH);
> +
> +	} else if (uproc.pid < 0)
> +	return -1;
> +
> +	/* parent */
> +	int status;
> +	while (wait(&status) != uproc.pid) {
> +		DD("waiting for child to exit");
> +	}
> +
> +	pthread_cancel(ubus_thread);
> +	pthread_join(ubus_thread,NULL);

Missing space.

> +
> +	// TODO: add some kind of checks
> +
> +	remove(fc_script_get_actions);
> +
> +	return 0;
> +}
> +
>  int external_set_action_write(char *action, char *name, char *value)
>  {
>  	freecwmp_log_message(NAME, L_NOTICE,
> diff --git a/src/external.h b/src/external.h
> index 64b4c6b..c6df2ea 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -16,7 +16,8 @@ static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
>  #else
>  static char *fc_script = "/usr/sbin/freecwmp";
>  #endif
> -static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
> +static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
> +static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";

Do we really need both? Why not use just "/tmp/freecwmp_actions.sh"?

>  
>  struct external_parameter {
>  	struct list_head list;
> @@ -27,11 +28,14 @@ struct external_parameter {
>  };
>  
>  int external_get_action(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_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);
> +void external_free_list_parameter();
>  
>  #endif
>  
> diff --git a/src/freecwmp.c b/src/freecwmp.c
> index 4ef8395..f4c9cb1 100644
> --- a/src/freecwmp.c
> +++ b/src/freecwmp.c
> @@ -18,6 +18,7 @@
>  #include <arpa/inet.h>
>  #include <linux/netlink.h>
>  #include <linux/rtnetlink.h>
> +#include <signal.h>
>  
>  #include <libfreecwmp.h>
>  #include <libubox/uloop.h>
> @@ -194,11 +195,27 @@ netlink_init(void)
>  	return 0;
>  }
>  
> +void signal_kill_all_handler(int sig)
> +{
> +     pthread_exit(NULL);

Use tabs and not spaces.

> +}
> +
> +
> +

Too many new lines.

>  int main (int argc, char **argv)
>  {
>  	freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");
>  
>  	bool foreground = false;
> +	struct sigaction sigint_action;
> +
> +	sigint_action.sa_handler = &signal_kill_all_handler;
> +	sigemptyset (&sigint_action.sa_mask);

No space here.

> +	/* reset handler in case when pthread_cancel didn't stop
> +	   threads for some reason */

Use u-boot coding style for multiline comments:

	/*
	 * reset handler in case when pthread_cancel didn't stop
	 * threads for some reason
	 */

> +	sigint_action.sa_flags = SA_RESETHAND;
> +	sigaction(SIGTERM, &sigint_action, NULL);
> +

Too many new lines.

>  
>  	setlocale(LC_CTYPE, "");
>  	umask(0037);
> diff --git a/src/xml.c b/src/xml.c
> index 9fa036b..23b9ec7 100644
> --- a/src/xml.c
> +++ b/src/xml.c
> @@ -21,6 +21,8 @@
>  #include "messages.h"
>  #include "time.h"
>  
> +extern struct list_head external_list_parameter;
> +
>  struct rpc_method {
>  	const char *name;
>  	int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
> @@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  				    mxml_node_t *tree_in,
>  				    mxml_node_t *tree_out)
>  {
> -	mxml_node_t *n, *b = body_in;
> +	mxml_node_t *n, *parameter_list, *b = body_in;
> +	struct external_parameter *external_parameter;
>  	char *parameter_name = NULL;
>  	char *parameter_value = NULL;
> -	char *c;
> +	char *c=NULL;

Missing space. And we don't need to set it to NULL.

>  	int counter = 0;
>  
>  	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
> @@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  		    !strcmp(b->parent->value.element.name, "string")) {
>  			parameter_name = b->value.text.string;
>  		}
> -

Don't remove newline.

> +		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterValues with empty string*/

Use multiline comment above if.

> +			!strcmp(b->value.element.name, "string") &&
> +			!b->child) {
> +			parameter_name = "";

Set it to NULL.

> +		}

Add newline.

>  		if (parameter_name) {
>  			if (!config_get_cwmp(parameter_name, &parameter_value)) {
> +				external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);

Missing spaces.

> +				FREE(parameter_value);
>  				// got the parameter value using libuci
> -			} else if (!external_get_action("value",
> -					parameter_name, &parameter_value)) {
> +			} else if (!external_get_action_write("value",parameter_name, NULL)) {

Missing spaces.

>  				// got the parameter value via external script
>  			} else {
>  				// error occurred when getting parameter value
>  				goto out;
>  			}
> -			counter++;
> +		}
> +		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
> +		parameter_name = NULL;
> +	}
>  
> -			n = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
> -			if (!n) goto out;
> +	if (external_get_action_execute())
> +		goto out;
> +
> +	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
> +	if (!parameter_list) goto out;
> +
> +	while (external_list_parameter.next!=&external_list_parameter) {

Missing spaces.

> +
> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
>  
> -			n = mxmlNewElement(n, "ParameterValueStruct");
> +		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
> +			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code

Use braces and multiline comment. Make comment more readable.

> +
> +		n = mxmlNewElement(parameter_list, "ParameterValueStruct");
>  			if (!n) goto out;
>  
>  			n = mxmlNewElement(n, "Name");
>  			if (!n) goto out;
>  
> -			n = mxmlNewText(n, 0, parameter_name);
> +		n = mxmlNewText(n, 0, external_parameter->name);

Wrong indentation.

>  			if (!n) goto out;
>  
>  			n = n->parent->parent;
> @@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  			if (!n) goto out;
>  
>  #ifdef ACS_MULTI
> -			mxmlElementSetAttr(n, "xsi:type", "xsd:string");
> +		mxmlElementSetAttr(n, "xsi:type", external_parameter->type);

Wrong indentation.

>  #endif
> -			n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
> +		n = mxmlNewText(n, 0, external_parameter->data? external_parameter->data : "");

Wrong indentation. Missing spaces.

>  			if (!n) goto out;
>  
> -			/*
> -			 * three day's work to finally find memory leak if we
> -			 * free parameter_name;
> -			 * it points to: b->value.text.string
> -			 *
> -			 * also, parameter_value can be NULL so we don't do checks
> -			 */
> -			parameter_name = NULL;
> -		}
> +		counter++;
>  		
> -		FREE(parameter_value);
> -		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
> +		list_del(&external_parameter->list);
> +		free(external_parameter->name);
> +		free(external_parameter->data);
> +		free(external_parameter->type);
> +		free(external_parameter->fault_code);
> +		free(external_parameter);
>  	}
>  
>  #ifdef ACS_MULTI
> @@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  	FREE(c);
>  #endif
>  
> -	FREE(parameter_value);
>  	return 0;
>  
>  out:
> -	FREE(parameter_value);
> +	external_free_list_parameter();
>  	return -1;
>  }
>  
> -- 
> 1.7.4.1

Luka

From freecwmp@lukaperkov.net Sat Dec  8 11:28:47 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:28:48 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:60611 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816511Ab2LHK2rH1f2i (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:28:47 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so693709eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:28:41 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=/mH2cVw7//ycwsKK5Lwgr+PKuIpDuZ8neYZl0+znJdM=;
        b=asnV8gmFfcDprUgs46IBjWVJ869rDNadZ49h9ligdyCIRHVRuLX76rhnB1jtH+V/4f
         z9NRYCSNr9KQKW/NwkFy09iQFSo78yabHXAMhujg79muUiJn4ncf0Uc57awyZ0SrM03m
         mjhy+TvuRrwgtiOGQPHJ+WUKZNDNJ4SN4VBmn3MBA9A0iZw4dlHDDZ69vj4RxA6vgb8k
         8rWuG9M8DbDXjM4GmI5a3OFD+044+/PdcllOA4+9r1JKakwHbzo6y8sJStEZg1kENetu
         aEXJDhQ0ZdBOAomT455+chRrU7PqfN0fyDubmXL2nMOj8cy5D22agdM4va3FPsGUvF3D
         TdxQ==
Received: by 10.14.206.197 with SMTP id l45mr27550255eeo.17.1354962521765;
        Sat, 08 Dec 2012 02:28:41 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id 44sm28616778eek.0.2012.12.08.02.28.40
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:28:41 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:32:40 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 03/27] add in the scripts the functions needed to
 communicate data to ubus handler for the get_parameter_values ubus handler
 Contributed by Inteno Broadband Technology AB
Message-ID: <20121208103240-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-4-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-4-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnCQ6Y1fmtj3+x+v0nzsXWGU5pA+lJau1GXsYiY6dZqAzO24taw7FinwrdQjY1s4+vEda/G
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 119
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:28PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  ext/openwrt/scripts/freecwmp.sh      |   51 ++++++++++++++++++++++++++++------
>  ext/openwrt/scripts/functions/common |   23 +++++++++++++++
>  2 files changed, 65 insertions(+), 9 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
> index ccab19f..f2bebc8 100644
> --- a/ext/openwrt/scripts/freecwmp.sh
> +++ b/ext/openwrt/scripts/freecwmp.sh
> @@ -113,21 +113,54 @@ handle_scripts() {
>  config_load freecwmp
>  config_foreach handle_scripts "scripts"
>  
> +# Fault code

Rename to "Fault codes".

> +
> +FAULT_CPE_NO_FAULT="0"

We don't need this one. Use 0 when you need it.

> +FAULT_CPE_REQUEST_DENIED="1"
> +FAULT_CPE_INTERNAL_ERROR="2"
> +FAULT_CPE_INVALID_ARGUMENTS="3"
> +FAULT_CPE_RESOURCES_EXCEEDED="4"
> +FAULT_CPE_INVALID_PARAMETER_NAME="5"
> +FAULT_CPE_INVALID_PARAMETER_TYPE="6"
> +FAULT_CPE_INVALID_PARAMETER_VALUE="7"
> +FAULT_CPE_NON_WRITABLE_PARAMETER="8"
> +FAULT_CPE_NOTIFICATION_REJECTED="9"
> +FAULT_CPE_DOWNLOAD_FAILURE="10"
> +FAULT_CPE_UPLOAD_FAILURE="11"
> +FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
> +FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
> +FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
> +FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
> +FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
> +FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
> +FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
> +FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"

Rename it from "FAULT_CPE_" to "E_". Also, why didn't you use error codes from
the standard?

Error codes should also be added in libfreecwmp. I saw that you are using them
in freecwmp core too.

> +
>  if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
> -	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

NACK. You don't need to remove this.

> +    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 $get_value_functions
>  	do
>  		$function_name "$__arg1"
> +				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
> +        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
> +    fi
>  fi
>  
>  if [ "$action" = "set_value" ]; then
> diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
> index 7e3000a..082e067 100644
> --- a/ext/openwrt/scripts/functions/common
> +++ b/ext/openwrt/scripts/functions/common
> @@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE} ]; then
>  fi
>  }
>  
> +ubus_freecwmp_output() {

Rename to freecwmp_ubus_output. Also, this needs to be integrated with
freecwmp_output function. More about that in other comments.

> +local parameter="$1"
> +local value="$2"
> +local type="$3"
> +local fault_code="$4"
> +
> +if [ "$type" = "" ]; then
> +	type="xsd:string"
> +fi
> +
> +case "$action" in
> +	get_value)
> +	ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", "value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 2> /dev/null

This needs to be used like the uci command:

/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}

You need to pass optional parameter to ubus command where the socket is
located.

> +	;;
> +esac
> +}

Missing newline.

>  freecwmp_value_output() {
>  	freecwmp_output "$1" "$2" "V"
>  }
> @@ -249,3 +265,10 @@ EOF
>  	sh "$lock" &
>  fi
>  }
> +
> +freecwmp_check_fault() {
> +if [ "$1" = "." ]; then
> +	return $FAULT_CPE_INVALID_PARAMETER_NAME
> +fi
> +return $FAULT_CPE_NO_FAULT
> +}
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:30:24 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:30:25 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:34347 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816384Ab2LHKaY4KzWk (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:30:24 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so694201eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:30:19 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=6KbJyB1r3KJzHpTNf+iPKujsfp4zp3og2BTnTS34ow4=;
        b=aGAzc/kxFzjYjVKcTXp0FMi6oMfEKd0cN36uUA4n5IGbqvi3uugFGTJL5qdoJCiHGm
         sNTevdDLmGQ/N3XucxtNGznNg8lyOEO++aVOIsFn0FnmZdsyYpyvw152nvy9iCJ6Fbsk
         L14f1VuiOFcKTOnHHy+DI8RlaYct7ZeKnH/gKrg9PpyLUfvc88T/2FI1ZPbUXjRLRbYA
         Kird0gBCAAYE5tu+0Z9WziuU1FK65UvuTykFpyYE2IG3T4KTDeYnh81oEvvw4b8Bip/e
         kOYHPQAchM9Lk7/7VtYesy/RD1KbeqygPyyTmIIoqlr4klu4xyPR09+eGM22JEuJpYK+
         K+3A==
Received: by 10.14.203.8 with SMTP id e8mr27679278eeo.2.1354962619609;
        Sat, 08 Dec 2012 02:30:19 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id b2sm28601841eep.9.2012.12.08.02.30.18
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:30:19 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:34:17 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 04/27] Update device_hosts to support communicte data of
 get parameter values to the core via ubus Contributed by Inteno Broadband
 Technology AB
Message-ID: <20121208103417-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-5-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-5-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmT3fC37BN56K7umEWeKZGtkNvazqRUUBD9M+hrl35bnStTU3HRzWtwUDLlw+XVRYDCNPMb
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 120
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:29PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK to entire patch. This has to be reworked in a way that we just call
"freecwmp_output" function. freecwmp_output needs to be extended so it can
handle ubus, value and notification output depending on the flags passed to the
main freecwmp script.

For example if we pass --ubus then freecwmp_output will send the output via ubus.

> ---
>  ext/openwrt/scripts/functions/device_hosts |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_hosts b/ext/openwrt/scripts/functions/device_hosts
> index 4c3fcd4..8909df6 100644
> --- a/ext/openwrt/scripts/functions/device_hosts
> +++ b/ext/openwrt/scripts/functions/device_hosts
> @@ -44,7 +44,7 @@ local parameter=`echo -n $1 | sed "s/InternetGatewayDevice\.LANDevice\.1\./Devic
>  case "$parameter" in
>  	Device.Hosts.HostNumberOfEntries)
>  	let local val=$num_static_leases+$num_dynamic_leases
> -	freecwmp_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  	;;
>  esac
> @@ -66,7 +66,7 @@ if [ $rc -eq 0 ]; then
>  		local sed_cmd=`echo -n \'$num; echo p\'`
>  		val=`eval sed -n $sed_cmd $leases_file | awk '{ print $2 }'`
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -74,7 +74,7 @@ freecwmp_parse_formated_parameter "$parameter" "Device.Hosts.Host.{i}.IPAddress"
>  if [ $rc -eq 0 ]; then
>  	local val
>  	get_device_hosts_ip_address "$leases_file" "$num" "$num_static_leases" "$num_dynamic_leases" "val"
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -88,7 +88,7 @@ if [ $rc -eq 0 ]; then
>  	if [ $num -gt 0 -a $num -le $num_dynamic_leases ]; then
>  		val="DHCP"
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -107,7 +107,7 @@ if [ $rc -eq 0 ]; then
>  		local t2=`date +%s`
>  		let val=$t1-$t2
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -131,7 +131,7 @@ if [ $rc -eq 0 ]; then
>  		val=`eval sed -n $sed_cmd $leases_file | awk '{ print $4 }'`
>  		if [ "x$val" == "x*" ]; then val=""; fi
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -144,7 +144,7 @@ if [ $rc -eq 0 ]; then
>  	get_device_hosts_ip_address "$leases_file" "$num" "$num_static_leases" "$num_dynamic_leases" "ip"
>  	val=`ping -c 1 $ip 2>&1 > /dev/null ; echo $?`
>  	let val=!$val
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -156,7 +156,7 @@ if [ $rc -eq 0 ]; then
>  	if [ $num -le $n ]; then
>  		val=1
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -168,7 +168,7 @@ if [ $rc -eq 0 ]; then
>  	if [ $num -le $n ]; then
>  		val=0
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -182,10 +182,10 @@ if [ $rc -eq 0 ]; then
>  	if [ $num2 -eq 1 ]; then
>  		get_device_hosts_ip_address "$leases_file" "$num1" "$num_static_leases" "$num_dynamic_leases" "val"
>  	fi
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
>  # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 support yet)
> -
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:31:42 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:31:43 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:51571 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816384Ab2LHKbmRK0rk (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:31:42 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so694562eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:31:37 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=gdajw08J4EVClc1dWwWSrb05SMi06SzmbHYmO3IoVGU=;
        b=CTX8fSbsr6ZkHhGzXh7vfqe1iR63xOsr3M9W6Vzd6+hNEDv4uKvTVPIaSbwzZGZeDY
         Z0rdfaTt70+g3qAjolz0yzz3IOhYIx0OZzDGz1L3gNRrvp9/idcoumcD1yBtGyMeDB3A
         2enVhx2K5DA2GOz6En9FSvifPXQkkko+xMXHCSjk8K+7Ig3lhKiF3Na1ecI3NbxckoGm
         3gIp2ZwzZNhto2iyU7fyiy9vYPNEfG2RetiVHG2J0o9Y1I04WgthNKYpqyIdY8ETtW2z
         sLqDVg5kxxusezSY5enImB7L+9n97eCXKr1GfwSdjJp2eJc3VZWMw0COGKkQtLM3nPsl
         84OA==
Received: by 10.14.223.135 with SMTP id v7mr27366894eep.41.1354962696921;
        Sat, 08 Dec 2012 02:31:36 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id w3sm28607291eel.17.2012.12.08.02.31.35
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:31:36 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:35:35 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 05/27] Update device_info script to support communicte
 data of get parameter values to the core via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208103535-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-6-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-6-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQllYmQ37C2dTGzyWOyxvIRhaZIC0QHE9VKBVbgozLvu9KJmk23H+F+btyAoHeosCJ2MyvRS
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 121
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:30PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/device_info |   32 +++++++++++++++++++---------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
> index 4423b8b..86ff5c9 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -3,7 +3,7 @@
>  
>  get_device_info_manufacturer() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
>  }
>  
>  set_device_info_manufacturer() {
> @@ -12,7 +12,7 @@ set_device_info_manufacturer() {
>  
>  get_device_info_oui() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
>  }
>  
>  set_device_info_oui() {
> @@ -21,7 +21,7 @@ set_device_info_oui() {
>  
>  get_device_info_product_class() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
>  }
>  
>  set_device_info_product_class() {
> @@ -30,7 +30,7 @@ set_device_info_product_class() {
>  
>  get_device_info_serial_number() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
>  }
>  
>  set_device_info_serial_number() {
> @@ -39,7 +39,7 @@ set_device_info_serial_number() {
>  
>  get_device_info_hardware_version() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
>  }
>  
>  set_device_info_hardware_version() {
> @@ -48,7 +48,7 @@ set_device_info_hardware_version() {
>  
>  get_device_info_software_version() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
>  }
>  
>  set_device_info_software_version() {
> @@ -57,7 +57,7 @@ set_device_info_software_version() {
>  
>  get_device_info_uptime() {
>  local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
>  }
>  
>  get_device_info_device_log() {
> @@ -67,7 +67,7 @@ if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
>  else
>  	val=`dmesg | tail -n10`
>  fi
> -freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
>  }
>  
>  get_device_info() {
> @@ -81,6 +81,7 @@ case "$1" in
>  	get_device_info_software_version
>  	get_device_info_uptime
>  	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.)
>  	get_device_info_manufacturer
> @@ -91,32 +92,42 @@ case "$1" in
>  	get_device_info_software_version
>  	get_device_info_uptime
>  	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.Manufacturer)
>  	get_device_info_manufacturer
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
>  	get_device_info_oui
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.ProductClass)
>  	get_device_info_product_class
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.SerialNumber)
>  	get_device_info_serial_number
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.HardwareVersion)
>  	get_device_info_hardware_version
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
>  	get_device_info_software_version
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.UpTime)
>  	get_device_info_uptime
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.DeviceLog)
>  	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  set_device_info() {
> @@ -161,10 +172,11 @@ return 1
>  }
>  
>  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
>  
>  	freecwmp_get_parameter_value "val" "$1"
> -	freecwmp_value_output "$1" "$val"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
>  }
>  
>  set_device_info_generic() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:32:28 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:32:29 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:45142 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816384Ab2LHKc21QY4Y (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:32:28 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so462033eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:32:23 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=RvikpWy+A2Kt/cnukxUFb6XPR8S7PSaAhBFEwH5MEY0=;
        b=kgw9FVOVNkj3YU0OpNjrD3yJvJeXTqX73lmteyyIYhMPueP6UPOrIVcJq1NOHIrRoY
         s0iCdl8zV8m5hOEmRYmO7f9inbBwFqtvS8PpVVnJ4qNPEFlxfytF9HBH4tLJpnHq6Swb
         LG/+2eGxqK348iOeysHKyjrtd4Zs6OVY+qoS+3IO9MtegLji5kT9aJBsiU/G2q4OltBn
         nh3cTiv/2G7AvjUIVU0Iu5rtRsEmOax34M/t0pk2k9WigRNp1xzHlCKsWiNJ6kCT/VFW
         vN9jm3KAuybr3+5I4EpOSErqBU88qFvMCJL3KCP1n2dPCM5LlwefdVBOfXdZTzVwRKw2
         dY0g==
Received: by 10.14.0.133 with SMTP id 5mr27095542eeb.29.1354962743036;
        Sat, 08 Dec 2012 02:32:23 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id w3sm28611973eel.17.2012.12.08.02.32.21
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:32:22 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:36:21 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 06/27] Update device_routing script to support communicte
 data of get parameter values to the core via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208103621-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-7-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-7-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQn/tiWrgRdJq4aAQAgLdOwPJeiSo0AvIP8BthvaVeBBeIKCepIPDAQDEkopTh2u3FhPodxL
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 122
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:31PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/device_routing |   33 +++++++++++++------------
>  1 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_routing b/ext/openwrt/scripts/functions/device_routing
> index 3dfa418..ca6dab1 100644
> --- a/ext/openwrt/scripts/functions/device_routing
> +++ b/ext/openwrt/scripts/functions/device_routing
> @@ -85,7 +85,7 @@ local parameter=$1
>  
>  case "$parameter" in
>  	Device.Routing.RouterNumberOfEntries)
> -	freecwmp_output "$parameter" "1"
> +	ubus_freecwmp_output "$parameter" "1"
>  	return
>  	;;
>  esac
> @@ -101,7 +101,7 @@ if [ $rc -eq 0 ]; then
>  	else
>  		val="0"
>  	fi
> -	freecwmp_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -113,7 +113,7 @@ if [ $rc -eq 0 ]; then
>  	else
>  		val="Disabled"
>  	fi
> -	freecwmp_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -134,7 +134,7 @@ if [ $rc -eq 0 ]; then
>  	else
>  		return
>  	fi
> -	freecwmp_output "$parameter" "$total"
> +	ubus_freecwmp_output "$parameter" "$total"
>  	return
>  fi
>  
> @@ -146,7 +146,7 @@ if [ $rc -eq 0 ]; then
>  	else
>  		return
>  	fi
> -	freecwmp_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -166,15 +166,15 @@ if [ $rc -eq 0 ]; then
>  			return
>  		fi
>  		if [ $num2 -gt $static ]; then
> -			freecwmp_output "$parameter" "Enabled"
> +			ubus_freecwmp_output "$parameter" "Enabled"
>  			return
>  		fi
>  		if [ $num2 -le $inactive ]; then
> -			freecwmp_output "$parameter" "Error: not active but enabled"
> +			ubus_freecwmp_output "$parameter" "Error: not active but enabled"
>  			return
>  		fi
>  		if [ $num2 -le $static ]; then
> -			freecwmp_output "$parameter" "Enabled"
> +			ubus_freecwmp_output "$parameter" "Enabled"
>  			return
>  		fi
>  	else
> @@ -197,11 +197,11 @@ if [ $rc -eq 0 ]; then
>  			return
>  		fi
>  		if [ $num2 -gt $static ]; then
> -			freecwmp_output "$parameter" "0"
> +			ubus_freecwmp_output "$parameter" "0"
>  			return
>  		fi
>  		if [ $num2 -le $static ]; then
> -			freecwmp_output "$parameter" "1"
> +			ubus_freecwmp_output "$parameter" "1"
>  			return
>  		fi
>  	else
> @@ -230,7 +230,7 @@ if [ $rc -eq 0 ]; then
>  			let local i=$static-$num2
>  			target=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].target 2> /dev/null`
>  		fi
> -		freecwmp_output "$parameter" "$target"
> +		ubus_freecwmp_output "$parameter" "$target"
>  		return
>  	else
>  		return
> @@ -258,7 +258,7 @@ if [ $rc -eq 0 ]; then
>  			let local i=$static-$num2
>  			netmask=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].netmask 2> /dev/null`
>  		fi
> -		freecwmp_output "$parameter" "$netmask"
> +		ubus_freecwmp_output "$parameter" "$netmask"
>  		return
>  	else
>  		return
> @@ -288,7 +288,7 @@ if [ $rc -eq 0 ]; then
>  			let local i=$static-$num2
>  			gateway=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].gateway 2> /dev/null`
>  		fi
> -		freecwmp_output "$parameter" "$gateway"
> +		ubus_freecwmp_output "$parameter" "$gateway"
>  		return
>  	else
>  		return
> @@ -315,7 +315,7 @@ if [ $rc -eq 0 ]; then
>  		elif [ $num2 -le $static ]; then
>  			val="Static"
>  		fi
> -		freecwmp_output "$parameter" "$val"
> +		ubus_freecwmp_output "$parameter" "$val"
>  		return
>  	else
>  		return
> @@ -343,11 +343,12 @@ if [ $rc -eq 0 ]; then
>  			let local i=$static-$num2
>  			metric=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.@route[$i].metric 2> /dev/null`
>  		fi
> -		freecwmp_output "$parameter" "$metric"
> +		ubus_freecwmp_output "$parameter" "$metric"
>  		return
>  	else
>  		return
>  	fi
>  fi
> -
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> +
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:33:40 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:33:41 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:32931 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6817387Ab2LHKdkp3yyi (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:33:40 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so462329eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:33:35 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=sjWvs4SRDGwsnpkfIVAYU6IuAlnD5TuFDfwyYdNFOZM=;
        b=h3nheCqbUZd67+ij7STnx3Jhqop5IcJqRmZ6ho8mNms6KoZfhVcICmxpWX/YYgbmY9
         cGdwVxrGQ54QTgpzvX/Q2UYjrb0onIxm/elpXYOSYo6l5fPRejRMxzlFPZ/RBsygjf83
         GbO3WQLhzFEkE7SDtesPB7ZSu38qJlzfUzuw1KA7rHE4gMIThuS0HiQV3viV32anbcxP
         ZvmiUeyeaVpC3ZR7y6DpN2m70gojYe42uPncYNDefibc3x1606xx7XzFWbkeBst7jUHg
         YD+9LT1vfUpaHC6Sl24Ui2ug1gW986h4ILC3ltlKbgVcxmnO9RIclGAnpbRzaM7ES5mF
         AmOw==
Received: by 10.14.203.2 with SMTP id e2mr27393707eeo.20.1354962815426;
        Sat, 08 Dec 2012 02:33:35 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id f6sm6840042eeo.7.2012.12.08.02.33.34
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:33:34 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:37:33 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 07/27]  Update device_users script to support communicte
 data of get parameter values to the core via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208103733-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-8-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-8-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQliGCuEcqX+tXtW0HrRrgbSw3z98f4JOt+amiYKx69B6QwqKaoTLaiamyAkyvxHpCCq7CzP
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 123
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:32PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/device_users |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_users b/ext/openwrt/scripts/functions/device_users
> index 0d377f7..d8dba61 100644
> --- a/ext/openwrt/scripts/functions/device_users
> +++ b/ext/openwrt/scripts/functions/device_users
> @@ -6,7 +6,7 @@ local parameter="$1"
>  case "$parameter" in
>  	Device.Users.UserNumberOfEntries)
>  	local val=`wc -l /etc/passwd | awk '{ print $1 }'`
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  	;;
>  esac
> @@ -21,7 +21,7 @@ if [ $rc -eq 0 ]; then
>  	# TODO: this is very system dependent, for now just look at users shell
>  	local sed_cmd=`echo -n \'$num; echo p\'`
>  	local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' | wc -l`
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -30,7 +30,7 @@ if [ $rc -eq 0 ]; then
>  	# TODO: this is very system dependent, for now just look at users shell
>  	local sed_cmd=`echo -n \'$num; echo p\'`
>  	local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false' | wc -l`
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -38,7 +38,7 @@ freecwmp_parse_formated_parameter "$parameter" "Device.Users.User.{i}.Username"
>  if [ $rc -eq 0 ]; then
>  	local sed_cmd=`echo -n \'$num; echo p\'`
>  	local val=`eval sed -n $sed_cmd /etc/passwd | awk -F ':' '{ print $1 }'`
> -	freecwmp_value_output "$parameter" "$val"
> +	ubus_freecwmp_output "$parameter" "$val"
>  	return
>  fi
>  
> @@ -48,15 +48,16 @@ if [ $rc -eq 0 ]; then
>  	#   local sed_cmd=`echo -n \'$num; echo p\'`
>  	#   local val=`eval sed -n $sed_cmd /etc/shadow | awk -F ':' '{ print $2 }'`
>  	#   freecwmp_value_output "$parameter" "$val"
> -	freecwmp_value_output "$parameter" ""
> +	ubus_freecwmp_output "$parameter" ""
>  	return
>  fi
>  
>  freecwmp_parse_formated_parameter "$parameter" "Device.Users.User.{i}.Language" "rc" "num"
>  if [ $rc -eq 0 ]; then
> -	freecwmp_value_output "$parameter" ""
> +	ubus_freecwmp_output "$parameter" ""
>  	return
>  fi
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  set_device_users() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:34:33 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:34:34 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:44145 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6817387Ab2LHKedaDTcs (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:34:33 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so695474eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:34:28 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=h7cZHDhGkdzRjN/XPcpGmqqUFPsbHaMWcv6QE82U/xY=;
        b=bHfgWWnG8nIatjYn2MunnGCkigBzVAM3spWG2aGItAL0oPYd4C6r1KQabSBrX3Y4iF
         sAkmDEeP3MPviAa/lPoB110vd+meQ1FB5pjiVA5ZfYpjb3+m9DJxt4sR8sns3m7xMx3m
         RF5Swf7XEspzqYXos/xYFf1DmQso5I/j//XnsZmT08QjteB0SSCf+oyk3e4CWhTUp5Ag
         uLD7VfmahheEI5BhaybBOtKajBiagXGyoBgfickU7ZziPwcYxoL+NjCQj153RuP7ZXGM
         kyx2Men2Q2WdEgnHiPnoy484Oe5VC5kqEHxnMgkPatcQP/b2AcG823PG8zcRK+Umm5JQ
         q3gw==
Received: by 10.14.216.70 with SMTP id f46mr27583063eep.12.1354962868182;
        Sat, 08 Dec 2012 02:34:28 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id 44sm28648811eek.0.2012.12.08.02.34.27
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:34:27 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:38:26 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     Mohamed <mohamed.kallel@pivasoftware.com>
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 08/27] Update lan_device script to support communicte
 data of get parameter values to the core via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208103826-10595@mutt-kz>
Mail-Followup-To: Mohamed <mohamed.kallel@pivasoftware.com>,
        freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-9-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-9-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQl/+yQk8/iCE2R5h+ypZOq8mnkd9oIkWsa5BOSzGokvb9S6UY5G78F1PIGY2b2I9ulkgPlM
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 124
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:33PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/lan_device |   13 +++++++++++--
>  1 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index 5ba513c..fa9dda4 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -3,6 +3,7 @@
>  
>  get_wlan_enable() {
>  local num="$1"
> +local type="xsd:boolean"
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
>  let num=$num+1
>  if [ "$val" = "1" ]; then
> @@ -10,7 +11,7 @@ if [ "$val" = "1" ]; then
>  else
>  	val="1"
>  fi
> -freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
>  }
>  
>  set_wlan_enable() {
> @@ -29,7 +30,7 @@ get_wlan_ssid() {
>  local num="$1"
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
>  let num=$num+1
> -freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
>  }
>  
>  set_wlan_ssid() {
> @@ -44,30 +45,38 @@ case "$1" in
>  	InternetGatewayDevice.)
>  	get_wlan_enable 0
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.)
>  	get_wlan_enable 0
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.)
>  	get_wlan_enable 0
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
>  	get_wlan_enable 0
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
>  	get_wlan_enable 0
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
>  	get_wlan_enable 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
>  	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  set_lan_device() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:35:23 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:35:24 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:41477 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKfXYSlpE (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:35:23 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so695703eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:35:18 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=LmemyWzEbW1UlIjjvuAPyKz1MpcVWkSkeewYGAeyYVI=;
        b=W8PhRqMXSznFjrYqJlIzF3x3WiPcGvPGCS2wRqQ30xfaszehsvB1aqvy4/0Uyw1/yf
         7v5v57tWO1r2/+ugSB0uYPa+jhhk6BWkFVxEUrD7kRIb1VQNtgnaLm0/EhoHFGCNtXQa
         aqkUczO0vd8XbKfBn0Dn4zlbxXDc6+XSTzq0irZ7hcjpqi5edI2BWrVrJ+874/GDLSb6
         vwdlaE5OHuf1BjqLtfiNIjfdekiAP/K3aDtW+5PKd8S6YDqSd65h+/LCIp7EFi2InD/G
         J9gbUmkyPRfhW/PpXMWi1Q3SxwgAKcY4bj+Pw2z+y32RVkzwMWove+JDiJxMeb7yTA50
         0w/Q==
Received: by 10.14.216.70 with SMTP id f46mr27589431eep.12.1354962918084;
        Sat, 08 Dec 2012 02:35:18 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id e2sm28632133eeo.8.2012.12.08.02.35.16
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:35:17 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:39:16 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 09/27] Update management_server script to support
 communicte data of get parameter values to the core via ubus Contributed by
 Inteno Broadband Technology AB
Message-ID: <20121208103916-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-10-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-10-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmz19TbzZALAaHnye4OEOQF8wymF3tU7d5SXGqBGCU//R15NkHglcySVn80xCvZ3N2pqHtK
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 125
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:34PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/management_server |   72 ++++++++++++++++++-----
>  1 files changed, 57 insertions(+), 15 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
> index 9d1447e..eca3a61 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -10,7 +10,7 @@ local port=`get_management_server_x_freecwmp_org__acs_port`
>  local path=`get_management_server_x_freecwmp_org__acs_path`
>  FLAGS_value=$tmp
>  local val=`echo $scheme://$hostname:$port$path`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
>  }
>  
>  set_management_server_url() {
> @@ -46,7 +46,7 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change
>  
>  get_management_server_username() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].username 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
>  }
>  
>  set_management_server_username() {
> @@ -55,7 +55,7 @@ set_management_server_username() {
>  
>  get_management_server_password() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].password 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
>  }
>  
>  set_management_server_password() {
> @@ -65,7 +65,7 @@ set_management_server_password() {
>  get_management_server_periodic_inform_enable() {
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
>  freecwmp_get_parameter_value "val" "$parm"
> -freecwmp_output "$parm" "$val"
> +ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
>  }
>  
>  set_management_server_periodic_inform_enable() {
> @@ -76,7 +76,7 @@ freecwmp_set_parameter_value "$parm" "$1"
>  get_management_server_periodic_inform_interval() {
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
>  freecwmp_get_parameter_value "val" "$parm"
> -freecwmp_output "$parm" "$val"
> +ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
>  }
>  
>  set_management_server_periodic_inform_interval() {
> @@ -100,12 +100,12 @@ else
>  	val=$default_management_server_connection_request_url
>  fi
>  
> -freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
>  }
>  
>  get_management_server_connection_request_username() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].username 2> /dev/null`
> -freecwmp_value_output "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
>  }
>  
>  set_management_server_connection_request_username() {
> @@ -114,7 +114,7 @@ set_management_server_connection_request_username() {
>  
>  get_management_server_connection_request_password() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].password 2> /dev/null`
> -freecwmp_value_output "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
>  }
>  
>  set_management_server_connection_request_password() {
> @@ -125,7 +125,12 @@ set_management_server_connection_request_password() {
>  
>  get_management_server_x_freecwmp_org__acs_scheme() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].scheme 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_scheme() {
> @@ -134,7 +139,12 @@ set_management_server_x_freecwmp_org__acs_scheme() {
>  
>  get_management_server_x_freecwmp_org__acs_hostname() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].hostname 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_hostname() {
> @@ -147,7 +157,12 @@ fi
>  
>  get_management_server_x_freecwmp_org__acs_port() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].port 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_port() {
> @@ -156,7 +171,12 @@ set_management_server_x_freecwmp_org__acs_port() {
>  
>  get_management_server_x_freecwmp_org__acs_path() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].path 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_path() {
> @@ -165,7 +185,12 @@ set_management_server_x_freecwmp_org__acs_path() {
>  
>  get_management_server_x_freecwmp_org__connection_request_port() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].port 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  set_management_server_x_freecwmp_org__connection_request_port() {
> @@ -188,6 +213,7 @@ case "$1" in
>  	get_management_server_x_freecwmp_org__acs_port
>  	get_management_server_x_freecwmp_org__acs_path
>  	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.)
>  	get_management_server_url
> @@ -203,47 +229,62 @@ case "$1" in
>  	get_management_server_x_freecwmp_org__acs_port
>  	get_management_server_x_freecwmp_org__acs_path
>  	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.URL)
>  	get_management_server_url
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.Username)
>  	get_management_server_username
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.Password)
>  	get_management_server_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
>  	get_management_server_periodic_inform_enable
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
>  	get_management_server_periodic_inform_interval
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
>  	get_management_server_connection_request_url
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
>  	get_management_server_connection_request_username
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
>  	get_management_server_connection_request_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
>  	get_management_server_x_freecwmp_org__acs_scheme
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
>  	get_management_server_x_freecwmp_org__acs_hostname
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
>  	get_management_server_x_freecwmp_org__acs_port
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
>  	get_management_server_x_freecwmp_org__acs_path
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
>  	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  set_management_server() {
> @@ -301,10 +342,11 @@ return 1
>  }
>  
>  get_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
>  
>  	freecwmp_get_parameter_value "val" "$1"
> -	freecwmp_value_output "$1" "$val"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
>  }
>  
>  set_management_server_generic() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:36:32 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:36:33 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:53456 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKgcmrT0F (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:36:32 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so463007eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:36:27 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=WOhY9Gjgtpx3QP4Ksa84LWhKI7utnP/5CwsgiAvfgnQ=;
        b=TzXAPa+w0mDyv2kSE6UR7+f7UD5ZUFbdCvJTh0qIV0k0YcgTxDmhwq2FKuxtGIa88M
         GtDC/iF6nKmvg5lxXiy9fNV523O17fgzIxsM3etOODyAxajIJvEGm0M6+gFYVknRr1Bx
         g9rWoHe2unJfkMoWxudKD/7PFxT285ASo+7rilMDjkb/568vnXpjQ8opbHCDEGP/1xTx
         qtp9UxFYPZufeH89JjUlm0hCEpKTADgFc3+k0zRdHKCrlcHR+a6imDEeqbX1oUiotpYQ
         ApsHBFX9Z7ELKxf+Abq041diPivh9rysq8FgEMMztWq+oGk3q8C9vbrg/rCWex/abYbp
         SujQ==
Received: by 10.14.3.195 with SMTP id 43mr27373900eeh.36.1354962987346;
        Sat, 08 Dec 2012 02:36:27 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id 43sm28633679eed.10.2012.12.08.02.36.26
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:36:26 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:40:25 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 10/27] Update misc script to support communicte data of
 get parameter values to the core via ubus Contributed by Inteno Broadband
 Technology AB
Message-ID: <20121208104025-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-11-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-11-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmN55+UKVYAsBP58cOWxbTF3gDuF6IqzrIdhPwTSUeix37u4GZlKzWMfJwEDptKZghph79U
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 126
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:35PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/misc |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/misc b/ext/openwrt/scripts/functions/misc
> index 2e0210c..13f2142 100644
> --- a/ext/openwrt/scripts/functions/misc
> +++ b/ext/openwrt/scripts/functions/misc
> @@ -3,21 +3,25 @@
>  
>  get_misc_cpu_usage() {
>  local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ print $1 }' | awk -F'.' '{ print $2 }'`
> -freecwmp_value_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
> +ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
>  }
>  
>  get_misc_process_number() {
>  local val=`ps | grep -v COMMAND | wc -l`
> -freecwmp_value_output "Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val"
> +local type="xsd:unsignedInt"
> +ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "$type"
>  }
>  
>  get_misc() {
>  case "$1" in
>  	Device.DeviceInfo.ProcessStatus.CPUUsage)
>  	get_misc_cpu_usage
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
>  	get_misc_process_number
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:37:27 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:37:27 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:35902 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKh06I8F5 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:37:26 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so696520eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:37:21 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=6OSi5hE6lK0QH3U/bezkMu1psSkAj6w6ZNXDYwjwH4M=;
        b=n0GE5O5Jh6awIkHGxNZ5DPgKAu7RWfiWs8QT1+dOflB7VqvoFY/g4zShjsTUnTD0Vt
         JmDRZyzxmQMyPY3vvvt+AFykxyMjS1cDaHbVtYc/3/sESSRTaCTAZNFTYCBma7TFjAS+
         CuzlTmxVNXyzZyu+PP4perlTHoY62I71TZQpWNST/HsLPFYUBkoEuhaJczJuV5fki7yy
         fW8aP8k1eV+QpJ/oTf+tr6cNt5Ik2GWQk82EI3QaQ0s1UZ2sCVWYm13zHskyZp7auyhM
         MVQDJbGxyEABHvWZcdd9mtaW+4RYIAWzhJ9G8VgQUo113pNlrE7jXpU1d/LNACVc+y3B
         IlCA==
Received: by 10.14.0.133 with SMTP id 5mr27132233eeb.29.1354963041605;
        Sat, 08 Dec 2012 02:37:21 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id f49sm28634153eep.12.2012.12.08.02.37.20
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:37:21 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:41:19 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 11/27] Update wan_device script to support communicte
 data of get parameter values to the core via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208104119-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-12-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-12-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkj+l8Kt6IziyM/++Rk3du7OaARROTvi1Tee65HmqESBp9tXC8x2swMq3ie3tap5kkJsrcI
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 127
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:36PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK. Look at comment from patch v4.

> ---
>  ext/openwrt/scripts/functions/wan_device |   39 +++++++++++++++++++++++++----
>  1 files changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
> index 77cb63f..a8b6361 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -4,26 +4,37 @@
>  get_wan_device_mng_status() {
>  # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; Disconneting ; Disconnected 
>  local val="Connected"
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val" "xsd:boolean"
>  }
>  
>  get_wan_device_mng_interface_ip() {
>  local val
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
>  if [ -z "$default_wan_device_mng_interface_ip" ]; then
>  	val=`network_get_ipaddr val mng`
>  else
>  	val=$default_wan_device_mng_interface_ip
>  fi
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress" "$val"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  get_wan_device_mng_interface_mac() {
> +local val=""
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
>  if [ -z "$default_wan_device_mng_interface_mac" ]; then
>  	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
>  else
>  	val=$default_wan_device_mng_interface_mac
>  fi
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress" "$val"
> +if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
> +	ubus_freecwmp_output "$parm" "$val"
> +else
> +	freecwmp_output "$parm" "$val"
> +fi
>  }
>  
>  get_wan_device_wan_ppp_enable() {
> @@ -31,7 +42,7 @@ local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto
>  if [ -z $val ]; then
>  	val="1"
>  fi
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val" "xsd:boolean"
>  }
>  
>  set_wan_device_wan_ppp_enable() {
> @@ -47,7 +58,7 @@ fi
>  
>  get_wan_device_wan_ppp_username() {
>  local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
> +ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
>  }
>  
>  set_wan_device_wan_ppp_username() {
> @@ -55,7 +66,9 @@ set_wan_device_wan_ppp_username() {
>  }
>  
>  get_wan_device_wan_ppp_password() {
> -freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" ""
> +local val=""
> +val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
> +ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" "$val"
>  }
>  
>  set_wan_device_wan_ppp_password() {
> @@ -71,6 +84,7 @@ case "$1" in
>  	get_wan_device_wan_ppp_enable
>  	get_wan_device_wan_ppp_username
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.)
>  	get_wan_device_mng_status
> @@ -79,6 +93,7 @@ case "$1" in
>  	get_wan_device_wan_ppp_enable
>  	get_wan_device_wan_ppp_username
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.)
>  	get_wan_device_mng_status
> @@ -87,6 +102,7 @@ case "$1" in
>  	get_wan_device_wan_ppp_enable
>  	get_wan_device_wan_ppp_username
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
>  	get_wan_device_mng_status
> @@ -95,6 +111,7 @@ case "$1" in
>  	get_wan_device_wan_ppp_enable
>  	get_wan_device_wan_ppp_username
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
>  	get_wan_device_mng_status
> @@ -103,36 +120,46 @@ case "$1" in
>  	get_wan_device_wan_ppp_enable
>  	get_wan_device_wan_ppp_username
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
>  	get_wan_device_mng_status
>  	get_wan_device_mng_interface_ip
>  	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
>  	get_wan_device_mng_status
>  	get_wan_device_mng_interface_ip
>  	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
>  	get_wan_device_mng_status
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
>  	get_wan_device_mng_interface_ip
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
>  	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
>  	get_wan_device_wan_ppp_enable
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
>  	get_wan_device_wan_ppp_username
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
>  	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  set_wan_device() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:39:15 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:39:15 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:47379 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKjPPgSR9 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:39:15 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so697142eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:39:10 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=1uUoItBVKcPjotDpgoayP77gIK0KOXQwiU+G3Ijd4TQ=;
        b=o4vl/zQ5l1kY7uIw2ZLrunPZlDq5uZA6LMbU5lnn1WJLe6F9+9gn+g2v6oeiZRmxJ0
         VFnaDl0C70AcTEmTXDcHHiDK5rRH/GxoSbj/v/12N9XyDi7NklcljdswcBMJqh9roLSi
         qEgLaEhM3IaFmU/yjHuzR6mEGWHJstQYGgtLpGDMT0aBXy0zLDk+jBVg6X5gFU6idoLp
         WqKYjXNpPxc+U3p2oo24X9XrqUyevoFULT3glbDTc+IMiBlPcvGlFKfFwVOu1Yrr4rdB
         TcrRq7RmTtvHV203KC7ClSqKJSVrzcUbHQ8UAwcvWZSEKoVKWQVlW33XqZlnhBDRnkFj
         Qshg==
Received: by 10.14.203.8 with SMTP id e8mr27746691eeo.2.1354963149947;
        Sat, 08 Dec 2012 02:39:09 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id 6sm16650041eea.3.2012.12.08.02.39.08
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:39:09 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:43:08 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 12/27] update inform in order to get parameters from ubus
 instead from pipe Contributed by PIVA SOFTWARE
Message-ID: <20121208104308-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-13-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-13-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQk5YJFLT9Q48R0Z1/iGI2sutL6FcaAii6gSsxj10eEw+XEdFZkdB8qtUp6qAU+cFOHCbyBJ
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 128
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:37PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  src/xml.c |   40 ++++++++++++++++++----------------------
>  1 files changed, 18 insertions(+), 22 deletions(-)
> 
> diff --git a/src/xml.c b/src/xml.c
> index 23b9ec7..612c0bb 100644
> --- a/src/xml.c
> +++ b/src/xml.c
> @@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
>  {
>  	mxml_node_t *tree, *b;
>  	char *c, *tmp;
> +	struct external_parameter *external_parameter;
>  
>  #ifdef DUMMY_MODE
>  	FILE *fp;
> @@ -337,37 +338,31 @@ int xml_prepare_inform_message(char **msg_out)
>  	if (mxmlGetType(b) != MXML_ELEMENT)
>  		goto error;
>  
> -	tmp = "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
> -	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
> -	if (!b) goto error;
> -
> -	b = b->parent->next->next;
> -	if (mxmlGetType(b) != MXML_ELEMENT)
> +	external_get_action_write("value", "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", NULL);
> +	external_get_action_write("value", "InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
> +	if (external_get_action_execute())
>  		goto error;
>  
> -	c = NULL;
> -	if (external_get_action("value", tmp, &c)) goto error;
> -	if (c) {
> -		b = mxmlNewText(b, 0, c);
> -		FREE(c);
> -		if (!b) goto error;
> -	}
> -
> -	tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
> -	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
> -	if (!b) goto error;
> +	while (external_list_parameter.next!=&external_list_parameter) {

Missing spaces.

> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
> +		b = mxmlFindElementText(tree, tree, external_parameter->name, MXML_DESCEND);
> +		if (!b) continue;
>  
>  	b = b->parent->next->next;
>  	if (mxmlGetType(b) != MXML_ELEMENT)
>  		goto error;
>  
> -	c = NULL;
> -	if (external_get_action("value", tmp, &c)) goto error;
> -	if (c) {
> -		b = mxmlNewText(b, 0, c);
> -		FREE(c);
> +		if (external_parameter->data) {
> +			b = mxmlNewText(b, 0, external_parameter->data);
>  		if (!b) goto error;
>  	}

This looks like incorect indenting.

> +		list_del(&external_parameter->list);
> +		free(external_parameter->name);
> +		free(external_parameter->data);
> +		free(external_parameter->type);
> +		free(external_parameter->fault_code);
> +		free(external_parameter);
> +	}
>  
>  	if (xml_prepare_notifications_inform(tree))
>  		goto error;
> @@ -378,6 +373,7 @@ int xml_prepare_inform_message(char **msg_out)
>  	return 0;
>  
>  error:
> +	external_free_list_parameter();
>  	mxmlDelete(tree);
>  	return -1;
>  }
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:41:08 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:41:08 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:46358 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKlIM-2KT (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:41:08 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so697685eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:41:03 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=70P9Bux1eUJamk+zzis0MEEfN9T61yIyeB5nTyk/Sbo=;
        b=HczIp7hSsSw7KgpEYLC48V2K1gMpOiRa7P+V/2OJecABda6rIxTFXHWbpVcB2WryYS
         1hrXxJ0lpLw5/NVJrkeAu0WjsWG6vKWW+U+bHMu6FiNRZP80mpHx6vmbFhk51bCfVeg+
         Bhhg1jG+KPsZZakk9zZj2jpYfS17Je2cY3meR1ZvOJYbwzZJHdvMVMsRdYZCDYNTYtgA
         8ixa53ThW1ZUpktE+k18Tyb8wPaEKDF2+clJ62BSGTQPU7cWkC/SZdKiAeVrVbr3pXRp
         YmUPnlhElrIG81RHGSdcugLewS3AzrL6vDFEuGb1p5xHYB5KRZvqoUdp3fjvrzr4is5P
         DtaQ==
Received: by 10.14.0.3 with SMTP id 3mr27487147eea.16.1354963262889;
        Sat, 08 Dec 2012 02:41:02 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id v46sm28684713eep.1.2012.12.08.02.41.01
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:41:02 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:45:01 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 13/27] Add 3rd argument in the ubus handler of
 notification. The 3rd argument is the type of the parameter This agument
 could be  used in the response of get parameter attribute Contributed by
 Inteno Broadband Technology AB
Message-ID: <20121208104501-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-14-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-14-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkzKyU19fc7fX3+3AyGCrkPd2q9Ht0tslEU8dUOltwyQC8e4u7Yxh8Qj2q63jMkSQA10jFe
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 129
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:38PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  src/cwmp.c |    2 +-
>  src/cwmp.h |    2 +-
>  src/ubus.c |    5 ++++-
>  3 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/cwmp.c b/src/cwmp.c
> index 1bf9b2a..b75c762 100644
> --- a/src/cwmp.c
> +++ b/src/cwmp.c
> @@ -245,7 +245,7 @@ void cwmp_clear_events(void)
>  	pthread_mutex_unlock(&event_lock);
>  }
>  
> -void cwmp_add_notification(char *parameter, char *value)
> +void cwmp_add_notification(char *parameter, char *value, char *type)
>  {
>  	char *c = NULL;
>  	external_get_action("notification", parameter, &c);
> diff --git a/src/cwmp.h b/src/cwmp.h
> index 5703db0..1d8afac 100644
> --- a/src/cwmp.h
> +++ b/src/cwmp.h
> @@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
>  void cwmp_remove_event(int code);
>  void cwmp_clear_events(void);
>  
> -void cwmp_add_notification(char *parameter, char *value);
> +void cwmp_add_notification(char *parameter, char *value, char *type);
>  void cwmp_clear_notifications(void);
>  
>  int cwmp_set_parameter_write_handler(char *name, char *value);
> diff --git a/src/ubus.c b/src/ubus.c
> index d5437f9..0fd1def 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct uloop_timeout *timeout)
>  static enum notify {
>  	NOTIFY_PARAM,
>  	NOTIFY_VALUE,
> +	NOTIFY_TYPE,
>  	__NOTIFY_MAX
>  };
>  
>  static const struct blobmsg_policy notify_policy[] = {
>  	[NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
>  	[NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
> +	[NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
>  };
>  
>  static int
> @@ -66,7 +68,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
>  			     "triggered ubus notification parameter %s\n",
>  			     blobmsg_data(tb[NOTIFY_PARAM]));
>  	cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
> -			      blobmsg_data(tb[NOTIFY_VALUE]));
> +			blobmsg_data(tb[NOTIFY_VALUE]),
> +			tb[NOTIFY_TYPE]? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);

Incorect indentation and missing spaces.

>  
>  	return 0;
>  }
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:43:23 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:43:24 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:58313 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKnX0wOBt (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:43:23 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so464548eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:43:18 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=sgVDAUaFxivnG+T5fHAA37w/EHoj8TVlHyEfO1RDSj0=;
        b=U6fLJuasq6DkFYxWGRKfYdesJWacmUsBDl+YDbMqd1cu7S7FLoXCvswxebeDRRs184
         AP4fiUW6M6WyS5wZdLCiC9mluN4M0exyiX6ylLGen8e5p3U9AhThOG1V0SyPa0b8D9cp
         S0rUYCXawd8F5aLfUcltdTwoOWJmE4JcHEhh2mtkMqMGVgw4Ro3km9WyUWJmx8rDLwG3
         h7r/gJQauyw1UF43RSs9ki28u8vKD/D7IHAgTXNq5uo3WpWG6YsDr+D2Yvk3kOEt7dfZ
         PogTZXC3xkrVsFr45v8gWMvZbggHhPGFnRnEHdbwdwTAJAG5pqrVFBs+GCIFofIj+wVP
         jwnQ==
Received: by 10.14.225.194 with SMTP id z42mr27615045eep.22.1354963398045;
        Sat, 08 Dec 2012 02:43:18 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id d3sm28665773eeo.13.2012.12.08.02.43.16
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:43:17 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:47:16 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 14/27] add xml message get_parameter_name handler.
 Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Message-ID: <20121208104716-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-15-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-15-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQmMfOOjWgqcq5gD+lRw2TjWTTVHyutRcMlM25fu1vk38C2e6iNUz1YZizHoK69t/szFSYTf
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 130
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:39PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  src/cwmp.c     |    2 +-
>  src/external.c |   70 +++++++++++++-----------------------
>  src/external.h |    3 +-
>  src/ubus.c     |   39 ++++++++++++++++++++
>  src/xml.c      |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  src/xml.h      |    4 ++
>  6 files changed, 181 insertions(+), 48 deletions(-)
> 
> diff --git a/src/cwmp.c b/src/cwmp.c
> index b75c762..7de19e3 100644
> --- a/src/cwmp.c
> +++ b/src/cwmp.c
> @@ -248,7 +248,7 @@ void cwmp_clear_events(void)
>  void cwmp_add_notification(char *parameter, char *value, char *type)
>  {
>  	char *c = NULL;
> -	external_get_action("notification", parameter, &c);
> +	external_get_action_data("notification", parameter, &c);
>  	if (!c) return;
>  
>  	struct notification *n = NULL;
> diff --git a/src/external.c b/src/external.c
> index 94ae9b8..4973d1a 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -60,14 +60,32 @@ void external_free_list_parameter()
>  	}
>  }
>  
> -int external_get_action(char *action, char *name, char **value)
> +int external_get_action_data(char *action, char *name, char **value)
> +{
> +	struct external_parameter *external_parameter;
> +	external_get_action(action, name, NULL);
> +	if (external_list_parameter.next!=&external_list_parameter) {
> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
> +		if (external_parameter->data)
> +			*value = external_parameter->data;
> +		list_del(&external_parameter->list);
> +		free(external_parameter->name);
> +		free(external_parameter->data);
> +		free(external_parameter->type);
> +		free(external_parameter->fault_code);
> +		free(external_parameter);
> +	}
> +	external_free_list_parameter();
> +	return 0;
> +}
> +
> +int external_get_action(char *action, char *name, char *arg /* arg is added for GetParameterNames NextLevel argument*/)

Comments don't go here.

>  {
>  	freecwmp_log_message(NAME, L_NOTICE,
>  			     "executing get %s '%s'\n", action, name);
>  
> -	int pfds[2];
> -	if (pipe(pfds) < 0)
> -		return -1;
> +
> +	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
>  
>  	if ((uproc.pid = fork()) == -1)
>  		goto error;
> @@ -79,66 +97,28 @@ int external_get_action(char *action, char *name, char **value)
>  		int i = 0;
>  		argv[i++] = "/bin/sh";
>  		argv[i++] = fc_script;
> -		argv[i++] = "--newline";
> -		argv[i++] = "--value";
>  		argv[i++] = "get";
>  		argv[i++] = action;
>  		argv[i++] = name;
> +		if(arg) argv[i++] = arg;

Missing space. And put a comment here and not inside the function above.

>  		argv[i++] = NULL;
>  
> -		close(pfds[0]);
> -		dup2(pfds[1], 1);
> -		close(pfds[1]);
> -
>  		execvp(argv[0], (char **) argv);
>  		exit(ESRCH);
>  
>  	} else if (uproc.pid < 0)
>  		goto error;
>  
> -	/* parent */
> -	close(pfds[1]);
> -
>  	int status;
>  	while (wait(&status) != uproc.pid) {
>  		DD("waiting for child to exit");
>  	}
> +	pthread_cancel(ubus_thread);
> +	pthread_join(ubus_thread,NULL);

Missing space.

>  
> -	char buffer[64];
> -	ssize_t rxed;
> -	char *c;
> -	int t;
> -
> -	*value = NULL;
> -	while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
> -		if (*value)
> -			t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
> -		else
> -			t = asprintf(&c, "%.*s", (int) rxed, buffer);
> -
> -		if (t == -1) goto error;
> -
> -		free(*value);
> -		*value = strdup(c);
> -		free(c);
> -	}
> -
> -	if (!strlen(*value)) {
> -		FREE(*value);
> -		goto done;
> -	}
> -
> -	if (rxed < 0)
> -		goto error;
> -
> -done:
> -	close(pfds[0]);
>  	return 0;
>  
>  error:
> -	FREE(*c);
> -	FREE(*value);
> -	close(pfds[0]);

If we don't do any cleaning up here there should entire error should be
removed.

>  	return -1;
>  }
>  
> diff --git a/src/external.h b/src/external.h
> index c6df2ea..8e82c39 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -27,7 +27,8 @@ struct external_parameter {
>  	char *fault_code;
>  };
>  
> -int external_get_action(char *action, char *name, char **value);
> +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);
> diff --git a/src/ubus.c b/src/ubus.c
> index 0fd1def..cbf94b0 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *
>  	return 0;
>  }
>  
> +static enum get_param_names {
> +	GET_PARAM_NAMES_PARAM,
> +	GET_PARAM_NAMES_WRITABLE,
> +	GET_PARAM_NAMES_FAULT,
> +	__GET_PARAM_NAMES_MAX
> +};
> +
> +static const struct blobmsg_policy get_param_names_policy[] = {
> +	[GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = BLOBMSG_TYPE_STRING },

I don't like this "writable" parameter as it is now. It should be
renamed to permissions or something like that. That way we could control
both read and write.

And why is this BLOBMSG_TYPE_STRING?

> +	[GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
> +};
> +
> +static int
> +freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *obj,
> +			struct ubus_request_data *req, const char *method,
> +			struct blob_attr *msg)
> +{
> +	struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
> +
> +	blobmsg_parse(get_param_names_policy, ARRAY_SIZE(get_param_names_policy), tb,
> +		      blob_data(msg), blob_len(msg));
> +
> +	if (!tb[GET_PARAM_NAMES_PARAM])
> +		return UBUS_STATUS_INVALID_ARGUMENT;
> +
> +	freecwmp_log_message(NAME, L_NOTICE,
> +			     "triggered ubus get_parameter_names for the parameter %s\n",
> +			     blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
> +
> +	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
> +			tb[GET_PARAM_NAMES_WRITABLE]? blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,

Missing spaces.

> +			NULL,
> +			tb[GET_PARAM_NAMES_FAULT]? blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);

Missing spaces.

> +
> +	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("get_parameter_names", freecwmpd_handle_get_param_names, get_param_names_policy),
>  };
>  
>  static struct ubus_object_type main_object_type =
> diff --git a/src/xml.c b/src/xml.c
> index 612c0bb..c735244 100644
> --- a/src/xml.c
> +++ b/src/xml.c
> @@ -51,6 +51,7 @@ static struct cwmp_namespaces
>  const struct rpc_method rpc_methods[] = {
>  	{ "SetParameterValues", xml_handle_set_parameter_values },
>  	{ "GetParameterValues", xml_handle_get_parameter_values },
> +	{ "GetParameterNames", xml_handle_get_parameter_names },
>  	{ "SetParameterAttributes", xml_handle_set_parameter_attributes },
>  	{ "Download", xml_handle_download },
>  	{ "FactoryReset", xml_handle_factory_reset },
> @@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  		free(external_parameter->fault_code);
>  		free(external_parameter);
>  	}
> -
>  #ifdef ACS_MULTI
>  	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
>  			    NULL, NULL, MXML_DESCEND);
> @@ -736,6 +736,115 @@ out:
>  	return -1;
>  }
>  
> +int xml_handle_get_parameter_names(mxml_node_t *body_in,
> +				    mxml_node_t *tree_in,
> +				    mxml_node_t *tree_out)
> +{
> +	mxml_node_t *n, *parameter_list, *b = body_in;
> +	struct external_parameter *external_parameter;
> +	char *parameter_name = NULL;
> +	char *NextLevel = NULL;

All variables must be loverspace separated with underscore. Rename this
one to next_level.

> +	char *c;

This variable is used only when ACS_MULTI is set. It should be defined
bellow just before it's used for the first time.

> +	int counter = 0;
> +
> +	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
> +			    NULL, NULL, MXML_DESCEND);
> +	if (!n) return -1;
> +
> +	n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
> +	if (!n) return -1;
> +
> +	n = mxmlNewElement(n, "ParameterList");
> +	if (!n) return -1;
> +
> +#ifdef ACS_MULTI
> +	mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
> +#endif
> +
> +	while (b) {
> +		if (b && b->type == MXML_TEXT &&
> +			b->value.text.string &&
> +			b->parent->type == MXML_ELEMENT &&
> +			!strcmp(b->parent->value.element.name, "ParameterPath")) {
> +			parameter_name = b->value.text.string;
> +		}
> +		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterNames with empty ParameterPath*/

Comments can't be here.

> +			!strcmp(b->value.element.name, "ParameterPath") &&
> +			!b->child) {
> +			parameter_name = "";
> +		}
> +		if (b && b->type == MXML_TEXT &&
> +			b->value.text.string &&
> +			b->parent->type == MXML_ELEMENT &&
> +			!strcmp(b->parent->value.element.name, "NextLevel")) {
> +			NextLevel = b->value.text.string;
> +		}
> +		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
> +	}

Add newline here.

> +	if (parameter_name && NextLevel) {
> +		if (!external_get_action("name", parameter_name, NextLevel)) {
> +			// got the parameter value via external script
> +		} else {
> +			// error occurred when getting parameter value
> +			goto out;
> +		}

This section needs some rework.

> +	}
> +
> +	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
> +	if (!parameter_list) goto out;
> +
> +	while (external_list_parameter.next!=&external_list_parameter) {

Missing space.

> +

Remove newline.

> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
> +
> +		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
> +			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code

Add braces and update comment.

> +
> +		n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
> +		if (!n) goto out;
> +
> +		n = mxmlNewElement(n, "Name");
> +		if (!n) goto out;
> +
> +		n = mxmlNewText(n, 0, external_parameter->name);
> +		if (!n) goto out;
> +
> +		n = n->parent->parent;
> +		n = mxmlNewElement(n, "Writable");
> +		if (!n) goto out;
> +
> +		n = mxmlNewText(n, 0, external_parameter->data);
> +		if (!n) goto out;
> +
> +		counter++;
> +
> +		list_del(&external_parameter->list);
> +		free(external_parameter->name);
> +		free(external_parameter->data);
> +		free(external_parameter->type);
> +		free(external_parameter->fault_code);
> +		free(external_parameter);

This I have seen in several places already. This should go into a function then.

> +	}
> +
> +#ifdef ACS_MULTI
> +	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
> +			    NULL, NULL, MXML_DESCEND);
> +	if (!b) goto out;
> +
> +	if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
> +		goto out;
> +
> +	mxmlElementSetAttr(b, "soap_enc:arrayType", c);
> +	FREE(c);
> +#endif
> +
> +	return 0;
> +
> +out:
> +	external_free_list_parameter();
> +	return -1;
> +}
> +
>  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>  					       mxml_node_t *tree_in,
>  					       mxml_node_t *tree_out) {
> diff --git a/src/xml.h b/src/xml.h
> index 8f63192..a9191eb 100644
> --- a/src/xml.h
> +++ b/src/xml.h
> @@ -26,6 +26,10 @@ static int xml_handle_get_parameter_values(mxml_node_t *body_in,
>  					   mxml_node_t *tree_in,
>  					   mxml_node_t *tree_out);
>  
> +static int xml_handle_get_parameter_names(mxml_node_t *body_in,
> +					   mxml_node_t *tree_in,
> +					   mxml_node_t *tree_out);
> +
>  static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>  					       mxml_node_t *tree_in,
>  					       mxml_node_t *tree_out);
> -- 
> 1.7.4.1

Luka

From freecwmp@lukaperkov.net Sat Dec  8 11:45:47 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:45:48 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:50003 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKproCnfz (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:45:47 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so464977eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:45:42 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=rP9t76vovWF07GWsUMLpSNaUX5UsL5Qb+S1CXNDWyVg=;
        b=XGjshxAYNGAI874MGcqN3qPFLvuV6uCV5yiFXu0qSjpo5fWG+10lIb3R6x3tbMnzeE
         Oj5Ex88NTv01hBod6ARRdpXJXVKfVV6+v//cWX6WLmY6o40QlVpaAOAqK21wpgicgGAD
         k75f5q5tzpKA8pHu4DDAtbAk+swIVS9Zz17ZKmPOU756gx517O5nV+6pWIubwA24uWfK
         f8Awg6Tg1siaMWD+5R7LRvn08fEp4QMdzF7FxlcMXEIvM6RvTUVX4Hw0TCQzHh3WqzmI
         nszQD042wptDq17MrewUbWvPNdwhN9Cpbi6RgxgXc81iZTdeeDweSVzub5gA6uuHpumy
         oOyw==
Received: by 10.14.177.1 with SMTP id c1mr27582102eem.8.1354963542401;
        Sat, 08 Dec 2012 02:45:42 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id v46sm28710646eep.1.2012.12.08.02.45.41
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:45:41 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:49:40 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [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
Message-ID: <20121208104940-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-16-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-16-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnIGyIei9RrGizxfd9zSmbLC1IVwEugoi8VcQkILUm6brRln2Y1GeKWSgPt5Wd+kZB5swZr
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 131
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:40PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

We are using tabs and not spaces. This must be changed in the entire patch.

Also, I don't see that you have updated help output.

> ---
>  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]'`

Please explain what are you trying to do here. Why do we need __arg2?

> +            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

I don't like that you are changing here __arxX variables. This needs to be
reworked.

> +        fi
> +        if [ "$fault_code" = "0" ]; then
> +            if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" = "" \) ]; then

Do we really need "\(" ?

> +                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

Use multiple lines here. Also, no_fault error checking can be optimized here.

> +        fi
> +    fi
> +    if [ "$fault_code" != "0" ]; then
> +        let fault_code=$fault_code+9000

Please explain the logic behind this. We should use 9000 when defining the
variables.

> +        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
> +	;;

It's not good idea to use the same $value variable for two use cases.
This needs to be changed. Look at my comments in the next patch.

> + 

Remove this newline.

>  esac
>  }
>  freecwmp_value_output() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:47:19 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:47:20 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:61614 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6820513Ab2LHKrTMyM3E (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:47:19 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so699347eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:47:14 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=p9uXHRewllN+yJtgD7OxPO5d/jfKHUP4YAUcLiStj+g=;
        b=CPMhCmcz2y7quGadGx2IAUJw3hA8hlFLrZzDMY75ptKApD3k60hGWmxyMk4F5n9JZI
         ctDDIcNDz2ZqLh8ojlSXmBOhLPxXN1PGwt4SFN/qlyXy1AZZKmj2pKIlJR01Z6risDUE
         QAGJj0QpJSu+uAxO16GnGYaLaSmf3OWw9VCUx+SFV8pUU4uLwEUD7lisDtXPNLiH1Kv4
         t1eX+4uTFPj7Lf/4VjrC3SuHy9RbtSIwoiArBcv8BTNK6M+G1eoGaZL7dtlzh9+YodU/
         rCe/wO1MDGmf0K87RwhsK+8dtuINUiLAaMAd/wJB6gxKZ1DEKesecHr/cgaoTACZq7U2
         xtFg==
Received: by 10.14.206.197 with SMTP id l45mr27689375eeo.17.1354963633891;
        Sat, 08 Dec 2012 02:47:13 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id b2sm28695897eep.9.2012.12.08.02.47.12
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:47:13 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:51:12 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 16/27] update the script device_info in order to output
 parameters with ubus Contributed by Inteno Broadband Technology AB
Message-ID: <20121208105112-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-17-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-17-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkGiV5h5gdawSPL6xGEiFam02OU6SYOMC9t/OcmDQ9tBnuDMIVwY3s+qIp5W33y/iWehNhJ
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 132
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:41PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  ext/openwrt/scripts/functions/device_info |  199 +++++++++++++++++++++++++++--
>  1 files changed, 187 insertions(+), 12 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
> index 86ff5c9..c3c6c33 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -2,7 +2,15 @@
>  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
>  
>  get_device_info_manufacturer() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;

I don't like this... Tell us what why you use val? Why is it 0? What does that
mean? Generally all this information must go in commit message.

> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"

We should have something like:

freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val" "$permissions" "$type" "$fault_code"

Same goes for all other changes.

>  }
>  
> @@ -11,7 +19,15 @@ set_device_info_manufacturer() {
>  }
>  
>  get_device_info_oui() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
>  }
>  
> @@ -20,7 +36,15 @@ set_device_info_oui() {
>  }
>  
>  get_device_info_product_class() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
>  }
>  
> @@ -29,7 +53,15 @@ set_device_info_product_class() {
>  }
>  
>  get_device_info_serial_number() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
> +	;;
> +	get_name)
> +	local val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
>  }
>  
> @@ -38,7 +70,15 @@ set_device_info_serial_number() {
>  }
>  
>  get_device_info_hardware_version() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
>  }
>  
> @@ -47,7 +87,15 @@ set_device_info_hardware_version() {
>  }
>  
>  get_device_info_software_version() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
>  }
>  
> @@ -56,17 +104,32 @@ set_device_info_software_version() {
>  }
>  
>  get_device_info_uptime() {
> -local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
>  }
>  
>  get_device_info_device_log() {
>  local val=""
> -if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
> -	val=`dmesg | tail -n1`
> -else
> -	val=`dmesg | tail -n10`
> -fi
> +case "$action" in
> +	get_value)
> +	if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
> +		val=`dmesg | tail -n1`
> +	else
> +		val=`dmesg | tail -n10`
> +	fi
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
>  }
>  
> @@ -130,6 +193,94 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_device_info_name() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
> +	if [ "$2" = "0" ]; then
> +		get_device_info_manufacturer
> +		get_device_info_oui
> +		get_device_info_product_class
> +		get_device_info_serial_number
> +		get_device_info_hardware_version
> +		get_device_info_software_version
> +		get_device_info_uptime
> +		get_device_info_device_log
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.)
> +	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
> +	get_device_info_manufacturer
> +	get_device_info_oui
> +	get_device_info_product_class
> +	get_device_info_serial_number
> +	get_device_info_hardware_version
> +	get_device_info_software_version
> +	get_device_info_uptime
> +	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.Manufacturer)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_manufacturer
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_oui
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ProductClass)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_product_class
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SerialNumber)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_serial_number
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.HardwareVersion)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_hardware_version
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_software_version
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.UpTime)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_uptime
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.DeviceLog)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_device_info() {
>  case "$1" in
>  	InternetGatewayDevice.DeviceInfo.Manufacturer)
> @@ -179,6 +330,30 @@ get_device_info_generic() {
>  	return $FAULT_CPE_NO_FAULT
>  }
>  
> +get_device_info_generic_name() {
> +	local val=""
> +	case "$1" in
> +	InternetGatewayDevice.DeviceInfo.ModelName|\
> +	InternetGatewayDevice.DeviceInfo.Description|\
> +	InternetGatewayDevice.DeviceInfo.ModemFirmwareVersion|\
> +	InternetGatewayDevice.DeviceInfo.EnabledOptions|\
> +	InternetGatewayDevice.DeviceInfo.AdditionalHardwareVersion|\
> +	InternetGatewayDevice.DeviceInfo.AdditionalSoftwareVersion|\
> +	InternetGatewayDevice.DeviceInfo.SpecVersion|\
> +	InternetGatewayDevice.DeviceInfo.FirstUseDate)
> +	val="0"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ProvisioningCode)
> +	val="1"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_device_info_generic() {
>  	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
>  
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:48:20 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:48:21 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:45937 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823005Ab2LHKsUFXKJd (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:48:20 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so699618eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:48:14 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=nP40zJOSdlXmX1sqCoGFfIy5zNjS3Ip7Y9Sx/uYYZ5Q=;
        b=Js7pTJRpZW1Uexxxdfefm+p+zHZzIjPGXT/ZGUrH+DoUSoMdQyG1KrzVADIF+Vq6Hn
         4M2LeVHfI0KlMkxXskbSQHakv47XU+XJHIJbG+5uHT8gjtNjZNyvxeKgPht5FGQDQS7c
         yMGtNrQF7bZHa/oHWmAS80UTaFrRLNIvUoQKKMRD9ZgQE1XJIt8MkUhB1Jcr06ZLGgMc
         tdevJ+5lnGOkZmVlVNBHeZaYe7dQ1bJ6tah3CNxaXdJPKmFSJzfoWjaCqWsLPuaTPEFd
         iaN7QOO5TeXMpb2l0Eg1nElif2VEr+mhCAJDB4rK8ApA/cbFNBQFvdN3Q2WdkzQz7pPT
         hLBA==
Received: by 10.14.221.65 with SMTP id q41mr27464227eep.30.1354963694707;
        Sat, 08 Dec 2012 02:48:14 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id r1sm28722584eeo.2.2012.12.08.02.48.13
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:48:14 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:52:13 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 17/27] update the script lan_device in order to output
 parameters with ubus Contributed by Inteno Broadband Technology AB
Message-ID: <20121208105213-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-18-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-18-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQlidrnjWAZ5P7J5sQISUTKEmND/nIf2sek+zLdh2wotEqDVwknCvviivfN2Cg75SotYDWqF
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 133
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:42PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK, at least for now. Look at the comments in patch 16.

> ---
>  ext/openwrt/scripts/functions/lan_device |   98 ++++++++++++++++++++++++++++-
>  1 files changed, 94 insertions(+), 4 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index fa9dda4..712b5e8 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -4,7 +4,10 @@
>  get_wlan_enable() {
>  local num="$1"
>  local type="xsd:boolean"
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
>  let num=$num+1
>  if [ "$val" = "1" ]; then
>  	val="0"
> @@ -12,6 +15,13 @@ else
>  	val="1"
>  fi
>  ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
> +	;;
> +	get_name)
> +	val="1"
> +	let num=$num+1
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
> +	;;
> +esac
>  }
>  
>  set_wlan_enable() {
> @@ -28,9 +38,20 @@ delay_command "wifi" "wifi" "45"
>  
>  get_wlan_ssid() {
>  local num="$1"
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
> -let num=$num+1
> -ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
> +local val=""
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-iface[$num].ssid 2> /dev/null`
> +	let num=$num+1
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
> +	;;
> +	get_name)
> +	val="1"
> +	let num=$num+1
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
> +	;;
> +esac
> +
>  }
>  
>  set_wlan_ssid() {
> @@ -79,6 +100,75 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_lan_device_name() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
> +	if [ "$2" = "0" ]; then
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
> +		get_wlan_enable 0
> +		get_wlan_ssid 0
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
> +	if [ "$2" = "0" ]; then
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
> +		get_wlan_enable 0
> +		get_wlan_ssid 0
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.)
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
> +	if [ "$2" = "0" ]; then
> +		ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
> +		get_wlan_enable 0
> +		get_wlan_ssid 0
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wlan_enable 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_lan_device() {
>  case "$1" in
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:49:54 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:49:56 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:34909 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823005Ab2LHKtyo6vzW (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:49:54 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so700139eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:49:49 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=eanvpaH/F2lz7OAJ7NdikErtOXn6y1cvQmjn2XVlcns=;
        b=c59otUcYIf7ne2Zpyi/eC9XPMIGGQhNcCz1YpOwOI1GAZJgMRxjVHRvf/yqmp7Jjx4
         QnnaSpLrc2hrg7v+FGX49ngefb+1+2sF13NF+6rWlmBr9iCh0YxkyycsBFOOstaNrwc/
         GJOLzpIXENEs8deM8uoML9GtxSSfYROvdptsuEnHGRPyiroFf6j2uzbgKnjYM/IMqJg1
         f5/0c5j5OZ8JnML8+tEH7HftKTqPsqJniV9YxwsYCmsUfJ8NhHAxuOdqiPnYzt5dMvzC
         KNY+mOaQmeoA0ZFkijCDsUNkKtY76buOhFDMzuBS5mTNKymdOLZwHdHw34rlMZcsqbic
         89SA==
Received: by 10.14.203.8 with SMTP id e8mr27824253eeo.2.1354963789402;
        Sat, 08 Dec 2012 02:49:49 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id w3sm28708965eel.17.2012.12.08.02.49.48
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:49:48 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:53:47 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 18/27] update the script management_server in order to
 output parameters with ubus Contributed by Inteno Broadband Technology AB
Message-ID: <20121208105347-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-19-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-19-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnimXJhvmjOdDC42BP7O6heRybIDhnDJLRicawJeAL+SQE1Th6EvFhNClPx5DjWvJhJWdsj
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 134
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Thu, Dec 06, 2012 at 04:54:43PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

NACK, at least for now. Look at the comments in patch 16.

There are also some othe comments bellow.

> ---
>  ext/openwrt/config/freecwmp                     |   12 +-
>  ext/openwrt/scripts/functions/lan_device        |   22 +-
>  ext/openwrt/scripts/functions/management_server |  323 ++++++++++++++++++++---
>  3 files changed, 307 insertions(+), 50 deletions(-)
> 
> diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
> index 3b2b4c3..1379afd 100644
> --- a/ext/openwrt/config/freecwmp
> +++ b/ext/openwrt/config/freecwmp
> @@ -29,25 +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 get_name_function get_device_info_name

This should be fixed in the patch where spaces were introduced. Same goes for
all other space/tabs fixes.

>  	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 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 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 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 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 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/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index 712b5e8..64910e2 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -8,13 +8,13 @@ local val=""
>  case "$action" in
>  	get_value)
>  	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get wireless.@wifi-device[$num].disabled 2> /dev/null`
> -let num=$num+1
> -if [ "$val" = "1" ]; then
> -	val="0"
> -else
> -	val="1"
> -fi
> -ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
> +	let num=$num+1
> +	if [ "$val" = "1" ]; then
> +		val="0"
> +	else
> +		val="1"
> +	fi
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$type"
>  	;;
>  	get_name)
>  	val="1"
> @@ -138,16 +138,16 @@ case "$1" in
>  	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
>  	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
>  	if [ "$2" = "0" ]; then
> -	get_wlan_enable 0
> -	get_wlan_ssid 0
> +		get_wlan_enable 0
> +		get_wlan_ssid 0
>  	fi
>  	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
>  	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
>  	if [ "$2" = "0" ]; then
> -	get_wlan_enable 0
> -	get_wlan_ssid 0
> +		get_wlan_enable 0
> +		get_wlan_ssid 0
>  	fi
>  	return $FAULT_CPE_NO_FAULT
>  	;;
> diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
> index eca3a61..eed16d1 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -9,8 +9,16 @@ local hostname=`get_management_server_x_freecwmp_org__acs_hostname`
>  local port=`get_management_server_x_freecwmp_org__acs_port`
>  local path=`get_management_server_x_freecwmp_org__acs_path`
>  FLAGS_value=$tmp
> -local val=`echo $scheme://$hostname:$port$path`
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
> +local parm="InternetGatewayDevice.ManagementServer.URL"
> +case "$action" in
> +	get_value)
> +	val=`echo $scheme://$hostname:$port$path`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_url() {
> @@ -45,8 +53,17 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change
>  }
>  
>  get_management_server_username() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].username 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
> +local val=""
> +local parm="InternetGatewayDevice.ManagementServer.Username"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].username 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_username() {
> @@ -54,8 +71,17 @@ set_management_server_username() {
>  }
>  
>  get_management_server_password() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].password 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
> +local val=""
> +local parm="InternetGatewayDevice.ManagementServer.Password"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].password 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_password() {
> @@ -63,9 +89,18 @@ set_management_server_password() {
>  }
>  
>  get_management_server_periodic_inform_enable() {
> +local val=""
> +local type="xsd:boolean"
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
> -freecwmp_get_parameter_value "val" "$parm"
> -ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
> +case "$action" in
> +	get_value)
> +	freecwmp_get_parameter_value "val" "$parm"
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  set_management_server_periodic_inform_enable() {
> @@ -74,9 +109,18 @@ freecwmp_set_parameter_value "$parm" "$1"
>  }
>  
>  get_management_server_periodic_inform_interval() {
> +local val=""
> +local type="xsd:unsignedInt"
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
> -freecwmp_get_parameter_value "val" "$parm"
> -ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
> +case "$action" in
> +	get_value)
> +	freecwmp_get_parameter_value "val" "$parm"
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  set_management_server_periodic_inform_interval() {
> @@ -86,26 +130,42 @@ freecwmp_set_parameter_value "$parm" "$1"
>  
>  get_management_server_connection_request_url() {
>  local val
> -if [ -z "$default_management_server_connection_request_url" ]; then
> -	local tmp=${FLAGS_value}
> -	FLAGS_value=${FLAGS_TRUE}
> -	local ip=`get_wan_device_mng_interface_ip`
> -	local port=`get_management_server_x_freecwmp_org__connection_request_port`
> -	FLAGS_value=$tmp
> -
> -	if [ -n "$ip" -a -n "$port" ]; then
> -		val="http://$ip:$port/"
> +local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestURL"
> +case "$action" in
> +	get_value)
> +	if [ -z "$default_management_server_connection_request_url" ]; then
> +		local tmp=${FLAGS_value}
> +		FLAGS_value=${FLAGS_TRUE}
> +		local ip=`get_wan_device_mng_interface_ip`
> +		local port=`get_management_server_x_freecwmp_org__connection_request_port`
> +		FLAGS_value=$tmp
> +	
> +		if [ -n "$ip" -a -n "$port" ]; then
> +			val="http://$ip:$port/"
> +		fi
> +	else
> +		val=$default_management_server_connection_request_url
>  	fi
> -else
> -	val=$default_management_server_connection_request_url
> -fi
> -
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  get_management_server_connection_request_username() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].username 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
> +local val=""
> +local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].username 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_connection_request_username() {
> @@ -113,8 +173,17 @@ set_management_server_connection_request_username() {
>  }
>  
>  get_management_server_connection_request_password() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].password 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
> +local val=""
> +local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].password 2> /dev/null`
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_connection_request_password() {
> @@ -124,8 +193,16 @@ set_management_server_connection_request_password() {
>  # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
>  
>  get_management_server_x_freecwmp_org__acs_scheme() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].scheme 2> /dev/null`
> +local val=""
>  local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].scheme 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -138,8 +215,16 @@ set_management_server_x_freecwmp_org__acs_scheme() {
>  }
>  
>  get_management_server_x_freecwmp_org__acs_hostname() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].hostname 2> /dev/null`
> +local val=""
>  local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].hostname 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -156,8 +241,16 @@ fi
>  }
>  
>  get_management_server_x_freecwmp_org__acs_port() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].port 2> /dev/null`
> +local val=""
>  local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].port 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -170,8 +263,16 @@ set_management_server_x_freecwmp_org__acs_port() {
>  }
>  
>  get_management_server_x_freecwmp_org__acs_path() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].path 2> /dev/null`
> +local val=""
>  local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@acs[0].path 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -184,8 +285,16 @@ set_management_server_x_freecwmp_org__acs_path() {
>  }
>  
>  get_management_server_x_freecwmp_org__connection_request_port() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].port 2> /dev/null`
> +local val=""
>  local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@local[0].port 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -287,6 +396,146 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_management_server_name() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
> +	if [ "$2" = "0" ]; then
> +		get_management_server_url
> +		get_management_server_username
> +		get_management_server_password
> +		get_management_server_periodic_inform_enable
> +		get_management_server_periodic_inform_interval
> +		get_management_server_connection_request_url
> +		get_management_server_connection_request_username
> +		get_management_server_connection_request_password
> +		get_management_server_x_freecwmp_org__acs_scheme
> +		get_management_server_x_freecwmp_org__acs_hostname
> +		get_management_server_x_freecwmp_org__acs_port
> +		get_management_server_x_freecwmp_org__acs_path
> +		get_management_server_x_freecwmp_org__connection_request_port
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.)
> +	ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
> +	get_management_server_url
> +	get_management_server_username
> +	get_management_server_password
> +	get_management_server_periodic_inform_enable
> +	get_management_server_periodic_inform_interval
> +	get_management_server_connection_request_url
> +	get_management_server_connection_request_username
> +	get_management_server_connection_request_password
> +	get_management_server_x_freecwmp_org__acs_scheme
> +	get_management_server_x_freecwmp_org__acs_hostname
> +	get_management_server_x_freecwmp_org__acs_port
> +	get_management_server_x_freecwmp_org__acs_path
> +	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.URL)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_url
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Username)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Password)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_periodic_inform_enable
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_periodic_inform_interval
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_connection_request_url
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_connection_request_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_connection_request_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_x_freecwmp_org__acs_scheme
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_x_freecwmp_org__acs_hostname
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_x_freecwmp_org__acs_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_x_freecwmp_org__acs_path
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ParameterKey)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_management_server_parameter_key
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_management_server() {
>  case "$1" in
>  	InternetGatewayDevice.ManagementServer.URL)
> @@ -349,6 +598,14 @@ get_management_server_generic() {
>  	return $FAULT_CPE_NO_FAULT
>  }
>  
> +get_management_server_generic_name() {
> +	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +
> +	local val="1"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
> +}
> +
>  set_management_server_generic() {
>  	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
>  
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:52:03 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:52:05 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:58836 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823005Ab2LHKwDlwEMN (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:52:03 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so466467eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:51:58 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=lsJcXKq0/vutGfYLNgUMHDXEeDUMahnoUOTH1GX/1oY=;
        b=djDVJpVhe1HE7224d1KPgFPaSieD3DoGKDYrdW93nGnMmJsYMAfsleqex7C4x4lM47
         kuK1UIekW0FU5g16L/J7bm6Dqse0ZNEYnTEqbq6gALdfAFUAvMgw7c4g2Fb9My3Y+qXc
         rjv4Wk7tfWdQkranK7enqTqdDHaV9kFXEvmFG3zh6EI3LixyieTy31TRH6BlL8/86sMo
         fVgrcc/vx6uteUAZGAElXmZy9cjQlpeG1LVVa9Wlk57xDVNHPdyg0jJwTcLvmxwINHgn
         tgsHuMCDEEwRkq0jpWyf09YRCWFvzQurIUxdwTB0oTaeKQ3oBlMSnJsOikj0J0+u/L/m
         tWTw==
Received: by 10.14.177.1 with SMTP id c1mr27625440eem.8.1354963918328;
        Sat, 08 Dec 2012 02:51:58 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id f6sm6942269eeo.7.2012.12.08.02.51.56
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:51:57 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:55:56 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 19/27] update the script wan_device in order to output
 parameters with ubus Contributed by Inteno Broadband Technology AB
Message-ID: <20121208105556-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-20-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-20-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQlhqQKoxsvDE6E6WlAgUCuxJA7YwecHu8nt5Z11UjiQUb0GAVzP82VqT7o/TgcxVbIN1wbH
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 135
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:44PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  ext/openwrt/scripts/freecwmp.sh          |  127 +++++++++---------
>  ext/openwrt/scripts/functions/wan_device |  223 +++++++++++++++++++++++++++---
>  src/freecwmp.c                           |    2 +-
>  3 files changed, 267 insertions(+), 85 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
> index c5a0d53..a2f2bc1 100644
> --- a/ext/openwrt/scripts/freecwmp.sh
> +++ b/ext/openwrt/scripts/freecwmp.sh
> @@ -1,5 +1,6 @@
>  #!/bin/sh
>  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
> +# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>  
>  . /lib/functions.sh
>  . /usr/share/libubox/jshn.sh
> @@ -68,10 +69,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" = "name" ]; then
> +			__arg1="$3"
> +			__arg2=`echo $4| tr '[A-Z]' '[a-z]'`
> +			action="get_name"

Again space/tabs fixes must be changed when they are introduced...

>  		elif [ "$2" = "all" ]; then
>  			__arg1="$3"
>  			action="get_all"
> @@ -111,7 +112,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 get_name_functions "$section" "get_name_function"

Same here.

>  	config_get set_value_functions "$section" "set_value_function"
>  }
>  
> @@ -142,16 +143,57 @@ FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
>  FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
>  
>  if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
> -    no_fault="0"
> -    freecwmp_check_fault "$__arg1"
> -    fault_code="$?"
> -    if [ "$fault_code" = "0" ]; then
> -        if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1" = "" \) ]; then
> -            __arg1="InternetGatewayDevice."
> +	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 $get_value_functions
> +		do
> +			$function_name "$__arg1"
> +			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
> -	for function_name in $get_value_functions
> -	do
> -		$function_name "$__arg1"
> +	if [ "$fault_code" != "0" ]; then
> +		let fault_code=$fault_code+9000
> +		ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
> +	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"
> @@ -159,55 +201,14 @@ if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
>  				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
> -        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
> -    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

Am I missing something here? Why are you removing code that was added in one of
the previous patches?

> +			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
> diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
> index a8b6361..9c7cd14 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -1,20 +1,38 @@
>  #!/bin/sh
>  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
> +# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>  
>  get_wan_device_mng_status() {
>  # TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ; Disconneting ; Disconnected 
> -local val="Connected"
> -ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus" "$val" "xsd:boolean"
> +local val=""
> +local type="xsd:boolean"
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
> +case "$action" in
> +	get_value)
> +	val="Connected"
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  get_wan_device_mng_interface_ip() {
> -local val
> +local val=""
>  local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
> -if [ -z "$default_wan_device_mng_interface_ip" ]; then
> -	val=`network_get_ipaddr val mng`
> -else
> -	val=$default_wan_device_mng_interface_ip
> -fi
> +case "$action" in
> +	get_value)
> +	if [ -z "$default_wan_device_mng_interface_ip" ]; then
> +		val=`network_get_ipaddr val mng`
> +	else
> +		val=$default_wan_device_mng_interface_ip
> +	fi
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -25,11 +43,18 @@ fi
>  get_wan_device_mng_interface_mac() {
>  local val=""
>  local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
> -if [ -z "$default_wan_device_mng_interface_mac" ]; then
> -	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
> -else
> -	val=$default_wan_device_mng_interface_mac
> -fi
> +case "$action" in
> +	get_value)
> +	if [ -z "$default_wan_device_mng_interface_mac" ]; then
> +		val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.mng.macaddr`
> +	else
> +		val=$default_wan_device_mng_interface_mac
> +	fi
> +	;;
> +	get_name)
> +	val="0"
> +	;;
> +esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
>  else
> @@ -38,11 +63,21 @@ fi
>  }
>  
>  get_wan_device_wan_ppp_enable() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto 2> /dev/null`
> -if [ -z $val ]; then
> +local val=""
> +local type="xsd:boolean"
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.auto 2> /dev/null`
> +	if [ -z $val ]; then
> +		val="1"
> +	fi
> +	;;
> +	get_name)
>  	val="1"
> -fi
> -ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable" "$val" "xsd:boolean"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  set_wan_device_wan_ppp_enable() {
> @@ -57,8 +92,17 @@ fi
>  }
>  
>  get_wan_device_wan_ppp_username() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username" "$val"
> +local val=""
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.username 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_wan_device_wan_ppp_username() {
> @@ -67,8 +111,16 @@ set_wan_device_wan_ppp_username() {
>  
>  get_wan_device_wan_ppp_password() {
>  local val=""
> -val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
> -ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password" "$val"
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
> +case "$action" in
> +	get_value)
> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get network.wan.password 2> /dev/null`
> +	;;
> +	get_name)
> +	val="1"
> +	;;
> +esac
> +ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_wan_device_wan_ppp_password() {
> @@ -162,6 +214,135 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_wan_device_name() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
> +	if [ "$2" = "0" ]; then
> +		get_wan_device_mng_status
> +		get_wan_device_mng_interface_ip
> +		get_wan_device_mng_interface_mac
> +		get_wan_device_wan_ppp_enable
> +		get_wan_device_wan_ppp_username
> +		get_wan_device_wan_ppp_password
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection." "1"
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." "1"
> +	if [ "$2" = "0" ]; then
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	fi
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
> +	ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1." "1"
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_mng_status
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_mng_interface_ip
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_wan_ppp_enable
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_wan_ppp_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
> +	if [ "$2" = "1" ]; then
> +		return $FAULT_CPE_INVALID_ARGUMENTS
> +	fi
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_wan_device() {
>  case "$1" in
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> diff --git a/src/freecwmp.c b/src/freecwmp.c
> index f4c9cb1..eb2783c 100644
> --- a/src/freecwmp.c
> +++ b/src/freecwmp.c
> @@ -197,7 +197,7 @@ netlink_init(void)
>  
>  void signal_kill_all_handler(int sig)
>  {
> -     pthread_exit(NULL);
> +	pthread_exit(NULL);
>  }
>  
>  
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:54:13 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:54:14 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:60592 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823005Ab2LHKyNUSicA (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:54:13 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so701485eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:54:08 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=Q0z8RAq8N3MCG2+g9oAgdhPTZjKzg5N4PS8GKJ7O1cE=;
        b=fd+oPWmuRuTKNjWzdT9uiJbTnwLfY5lt1o/NQv1OO0w0ASp5CFWDlfqhXhC5cRM4bA
         jH8s2qvUMv+4OzYGN4v9lonyMfsimCyOG760VSrX5pGLjnKnizXZo9FT+3OQ3RKACLiS
         Ek7zUxbDl5DpNZgiWrmijB/nZyWy1uOEE8ZFE4wBLlbtikbiI73A8dIWW/hWomPUb0eC
         I+yV9w8fKQ7zATHM4IZAh1UqFBxBuvPtPGG6pX3MT+e8ldQhvznHAjhYEGEGwdGGvERP
         FPlTKU4wSoxHMnWcQ3/3j9AJcFpOgsFWQZGlC8Umi/cqhRD/YYBoYDBv1ZLjvvZOnM6Q
         jm1Q==
Received: by 10.14.223.135 with SMTP id v7mr27531409eep.41.1354964047988;
        Sat, 08 Dec 2012 02:54:07 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id v46sm28757551eep.1.2012.12.08.02.54.06
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:54:07 -0800 (PST)
Date:   Sat, 8 Dec 2012 11:58:06 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 20/27] update the get notification in order to put the
 returned data via ubus instead of pipe TODO: develop the xml handle message
 to perform send of GetParameterAttributeResponse Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208105806-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-21-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-21-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQlduS5jovjlPy/3y1ddZc8ilePPxHiOZuO1oXUZjBTHYqrMVtI8jwiIJ5AROscmYx0GwCY2
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 136
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:45PM +0100, Mohamed wrote:
> 
> 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      |   27 +++++++++++++++++++-
>  ext/openwrt/scripts/functions/common |   21 +++++++++++++++-
>  src/ubus.c                           |   43 ++++++++++++++++++++++++++++++++++
>  4 files changed, 94 insertions(+), 3 deletions(-)
> 
> diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
> index 1379afd..1f72c27 100644
> --- a/ext/openwrt/config/freecwmp
> +++ b/ext/openwrt/config/freecwmp
> @@ -30,24 +30,30 @@ config scripts
>  	list location /usr/share/freecwmp/functions/device_info
>  	list get_value_function get_device_info
>  	list get_name_function get_device_info_name
> +	list get_notification_function get_device_info_notification
>  	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 get_notification_function get_device_info_generic_notification
>  	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 get_notification_function get_lan_device_notification
>  	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 get_notification_function get_management_server_notification
>  	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 get_notification_function get_management_server_generic_notification
>  	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 get_notification_function get_wan_device_notification
>  	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 a2f2bc1..02a923e 100644
> --- a/ext/openwrt/scripts/freecwmp.sh
> +++ b/ext/openwrt/scripts/freecwmp.sh
> @@ -113,6 +113,7 @@ handle_scripts() {
>  	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 get_notification_functions "$section" "get_notification_function"
>  	config_get set_value_functions "$section" "set_value_function"
>  }
>  
> @@ -219,8 +220,30 @@ if [ "$action" = "set_value" ]; then
>  fi
>  
>  if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
> -	freecwmp_get_parameter_notification "x_notification" "$__arg1"
> -	freecwmp_notification_output "$__arg1" "$x_notification"
> +	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 $get_notification_functions
> +		do
> +			$function_name "$__arg1"
> +			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
> +		ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
> +	fi
>  fi
>  
>  if [ "$action" = "set_notification" ]; then
> diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
> index abba220..fd98a01 100644
> --- a/ext/openwrt/scripts/functions/common
> +++ b/ext/openwrt/scripts/functions/common
> @@ -51,7 +51,9 @@ case "$action" in
>  	get_name)
>  	ubus call tr069 get_parameter_names '{"parameter": "'$parameter'", "writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
>  	;;
> - 
> +	get_notification)
> +	ubus call tr069 get_parameter_attributes '{"parameter": "'$parameter'", "notification": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
> +	;;
>  esac
>  }
>  freecwmp_value_output() {
> @@ -151,6 +153,9 @@ freecwmp_config_notifications() {
>  		if [ "$item" = "$3" ]; then
>  			eval "export -- \"$4=2\""
>  			return 0
> +		elif [ "`echo $3|grep $item`" = "$3" ]; then
> +			eval "export -- \"$4=2\""
> +			return 0
>  		fi
>  	done
>  	for item in $__passive
> @@ -158,6 +163,9 @@ freecwmp_config_notifications() {
>  		if [ "$item" = "$3" ]; then
>  			eval "export -- \"$4=1\""
>  			return 0
> +		elif [ "`echo $3|grep $item`" = "$3" ]; then
> +			eval "export -- \"$4=1\""
> +			return 0
>  		fi
>  	done
>  }
> @@ -193,7 +201,18 @@ freecwmp_get_parameter_notification() {
>  	local _dest="$1"
>  	local _parm="$2"
>  	local _val
> +	local _parent
>  	config_foreach freecwmp_config_notifications "notifications" "get" "$_parm" "_val"
> +	if [ "$_val" = "" ]; then
> +		if [ "`echo $_parm|grep '\.$'`" = "" ]; then
> +			_parent="${_parm%.*}."
> +			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
> +		else
> +			_parent="${_parm%.*.}."
> +			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
> +		fi
> +	fi
> +	if [ "$_val" = "" ];then _val="0" ;fi
>  	eval "export -- \"$_dest=$_val\""
>  }
>  
> diff --git a/src/ubus.c b/src/ubus.c
> index cbf94b0..072b2a1 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -5,6 +5,7 @@
>   *	(at your option) any later version.
>   *
>   *	Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
> + *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
>   */
>  
>  #include <unistd.h>
> @@ -239,12 +240,54 @@ freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *o
>  	return 0;
>  }
>  
> +static enum get_param_attributes {
> +	GET_PARAM_ATTRIBUTES_PARAM,
> +	GET_PARAM_ATTRIBUTES_NOTIF,
> +	GET_PARAM_ATTRIBUTES_FAULT,
> +	__GET_PARAM_ATTRIBUTES_MAX
> +};
> +
> +static const struct blobmsg_policy get_param_attributes_policy[] = {
> +	[GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type = BLOBMSG_TYPE_STRING },
> +	[GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
> +};
> +
> +static int
> +freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct ubus_object *obj,
> +			struct ubus_request_data *req, const char *method,
> +			struct blob_attr *msg)
> +{
> +	struct blob_attr *tb[__GET_PARAM_ATTRIBUTES_MAX];
> +
> +	blobmsg_parse(get_param_attributes_policy, ARRAY_SIZE(get_param_attributes_policy), tb,
> +		      blob_data(msg), blob_len(msg));
> +
> +	if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
> +		return UBUS_STATUS_INVALID_ARGUMENT;
> +
> +	if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
> +		return UBUS_STATUS_INVALID_ARGUMENT;
> +
> +	freecwmp_log_message(NAME, L_NOTICE,
> +			     "triggered ubus get_parameter_attributes for the parameter %s\n",
> +			     blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
> +
> +	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
> +				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
> +				      NULL,
> +				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
> +
> +	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("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),
>  };
>  
>  static struct ubus_object_type main_object_type =
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 11:57:29 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 11:57:30 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:62805 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823021Ab2LHK53CEmjy (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 11:57:29 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so467953eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 02:57:23 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=gSp3zu+lbGCB0tSAjZwT61hvLcmQxIwiT5ctmVRcGkQ=;
        b=Py5MDJS1zQVDc44TeMKP19CidOak4iHrx3ar78jFQYvLyHksZk11Lk+IoN0GMUgveo
         BykoiDEIl0v87SGx9rQ/B50ThcVVc7hCAq5+HLw/ZT2iZya/xhergjw1y6kUvy1wgdY0
         yRyuN6TlMWjmLmScG460OOSS1FkqWTD7bA+mMecLGofViLW2hS+kHIrxS0FYmU/qLkbw
         BTAp88mp3je5/D8+F3PRFQv6sYAf1vqTf04YeIvjnoinK8OJLP3/Mq1YTy+/ujMJrJfM
         AUVuhn3bQ3Gf/XMjB7yilMV2xCGWZgQXlErJlzJeUJACkD9WE9Xv6Ei7KX8BO40lnf6O
         pFfw==
Received: by 10.14.173.69 with SMTP id u45mr27710600eel.21.1354964243640;
        Sat, 08 Dec 2012 02:57:23 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id v46sm28775752eep.1.2012.12.08.02.57.22
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 02:57:23 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:01:21 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 21/27] update the data model parameter scripts in order
 to output parameter and notification values via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208110121-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-22-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-22-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnatuqSrkaCjjPHKOoCmFCfQNwLf4L4wPJFkJMupRtprXdQv6RNK4gRyFRits+e0koUvoab
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 137
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:46PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  ext/openwrt/scripts/functions/device_info       |   94 +++++++++++++++
>  ext/openwrt/scripts/functions/lan_device        |   50 ++++++++
>  ext/openwrt/scripts/functions/management_server |  143 +++++++++++++++++++++++
>  ext/openwrt/scripts/functions/wan_device        |  105 +++++++++++++++++
>  4 files changed, 392 insertions(+), 0 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
> index c3c6c33..2be20b5 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -1,5 +1,6 @@
>  #!/bin/sh
>  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
> +# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

It's not 2013 yet. Is there a reason why you don't use "Zribi"?

>  
>  get_device_info_manufacturer() {
>  local val=""
> @@ -10,6 +11,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.Manufacturer"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
>  }
> @@ -27,6 +31,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
>  }
> @@ -44,6 +51,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ProductClass"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
>  }
> @@ -61,6 +71,9 @@ case "$action" in
>  	get_name)
>  	local val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SerialNumber"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
>  }
> @@ -78,6 +91,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.HardwareVersion"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
>  }
> @@ -95,6 +111,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
>  }
> @@ -112,6 +131,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.UpTime"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
>  }
> @@ -129,6 +151,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.DeviceLog"
> +	;;
>  esac
>  ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
>  }
> @@ -281,6 +306,66 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_device_info_notification() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	get_device_info_manufacturer
> +	get_device_info_oui
> +	get_device_info_product_class
> +	get_device_info_serial_number
> +	get_device_info_hardware_version
> +	get_device_info_software_version
> +	get_device_info_uptime
> +	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.)
> +	get_device_info_manufacturer
> +	get_device_info_oui
> +	get_device_info_product_class
> +	get_device_info_serial_number
> +	get_device_info_hardware_version
> +	get_device_info_software_version
> +	get_device_info_uptime
> +	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.Manufacturer)
> +	get_device_info_manufacturer
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
> +	get_device_info_oui
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ProductClass)
> +	get_device_info_product_class
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SerialNumber)
> +	get_device_info_serial_number
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.HardwareVersion)
> +	get_device_info_hardware_version
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
> +	get_device_info_software_version
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.UpTime)
> +	get_device_info_uptime
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.DeviceLog)
> +	get_device_info_device_log
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_device_info() {
>  case "$1" in
>  	InternetGatewayDevice.DeviceInfo.Manufacturer)
> @@ -354,6 +439,15 @@ get_device_info_generic_name() {
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_device_info_generic_notification() {
> +	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +
> +	local val
> +	freecwmp_get_parameter_notification "val" "$1"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
> +}
> +
>  set_device_info_generic() {
>  	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
>  
> diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index 64910e2..949f11c 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -1,5 +1,6 @@
>  #!/bin/sh
>  # Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
> +# Copyright (C) 2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>  
>  get_wlan_enable() {
>  local num="$1"
> @@ -21,6 +22,11 @@ case "$action" in
>  	let num=$num+1
>  	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
>  	;;
> +	get_notification)
> +	let num=$num+1
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
> +	;;
>  esac
>  }
>  
> @@ -50,6 +56,11 @@ case "$action" in
>  	let num=$num+1
>  	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
>  	;;
> +	get_notification)
> +	let num=$num+1
> +	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
> +	ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
> +	;;
>  esac
>  
>  }
> @@ -169,6 +180,45 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_lan_device_notification() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.)
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.)
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
> +	get_wlan_enable 0
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> +	get_wlan_enable 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
> +	get_wlan_ssid 0
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_lan_device() {
>  case "$1" in
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
> index eed16d1..b1e759d 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -1,5 +1,6 @@
>  #!/bin/sh
>  # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
> +# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>  
>  get_management_server_url() {
>  local tmp=${FLAGS_value}
> @@ -17,6 +18,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -62,6 +66,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -80,6 +87,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -99,6 +109,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val" "$type"
>  }
> @@ -119,6 +132,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val" "$type"
>  }
> @@ -150,6 +166,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -164,6 +183,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -182,6 +204,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -202,6 +227,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -224,6 +252,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -250,6 +281,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -272,6 +306,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -294,6 +331,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -536,6 +576,100 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_management_server_notification() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	get_management_server_url
> +	get_management_server_username
> +	get_management_server_password
> +	get_management_server_periodic_inform_enable
> +	get_management_server_periodic_inform_interval
> +	get_management_server_connection_request_url
> +	get_management_server_connection_request_username
> +	get_management_server_connection_request_password
> +	get_management_server_x_freecwmp_org__acs_scheme
> +	get_management_server_x_freecwmp_org__acs_hostname
> +	get_management_server_x_freecwmp_org__acs_port
> +	get_management_server_x_freecwmp_org__acs_path
> +	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.)
> +	get_management_server_url
> +	get_management_server_username
> +	get_management_server_password
> +	get_management_server_periodic_inform_enable
> +	get_management_server_periodic_inform_interval
> +	get_management_server_connection_request_url
> +	get_management_server_connection_request_username
> +	get_management_server_connection_request_password
> +	get_management_server_x_freecwmp_org__acs_scheme
> +	get_management_server_x_freecwmp_org__acs_hostname
> +	get_management_server_x_freecwmp_org__acs_port
> +	get_management_server_x_freecwmp_org__acs_path
> +	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.URL)
> +	get_management_server_url
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Username)
> +	get_management_server_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Password)
> +	get_management_server_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
> +	get_management_server_periodic_inform_enable
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
> +	get_management_server_periodic_inform_interval
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
> +	get_management_server_connection_request_url
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
> +	get_management_server_connection_request_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
> +	get_management_server_connection_request_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
> +	get_management_server_x_freecwmp_org__acs_scheme
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
> +	get_management_server_x_freecwmp_org__acs_hostname
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
> +	get_management_server_x_freecwmp_org__acs_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
> +	get_management_server_x_freecwmp_org__acs_path
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
> +	get_management_server_x_freecwmp_org__connection_request_port
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ParameterKey)
> +	get_management_server_parameter_key
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_management_server() {
>  case "$1" in
>  	InternetGatewayDevice.ManagementServer.URL)
> @@ -606,6 +740,15 @@ get_management_server_generic_name() {
>  	return $FAULT_CPE_NO_FAULT
>  }
>  
> +get_management_server_generic_notification() {
> +	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +	
> +	local val
> +	freecwmp_get_parameter_notification "val" "$1"
> +	ubus_freecwmp_output "$1" "$val"
> +	return $FAULT_CPE_NO_FAULT
> +}
> +
>  set_management_server_generic() {
>  	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
>  
> diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
> index 9c7cd14..02ba365 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -14,6 +14,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val" "$type"
>  }
> @@ -32,6 +35,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -54,6 +60,9 @@ case "$action" in
>  	get_name)
>  	val="0"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
>  	ubus_freecwmp_output "$parm" "$val"
> @@ -76,6 +85,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val" "$type"
>  }
> @@ -101,6 +113,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -119,6 +134,9 @@ case "$action" in
>  	get_name)
>  	val="1"
>  	;;
> +	get_notification)
> +	freecwmp_get_parameter_notification "val" "$parm"
> +	;;
>  esac
>  ubus_freecwmp_output "$parm" "$val"
>  }
> @@ -343,6 +361,93 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +get_wan_device_notification() {
> +case "$1" in
> +	InternetGatewayDevice.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	get_wan_device_wan_ppp_enable
> +	get_wan_device_wan_ppp_username
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
> +	get_wan_device_mng_status
> +	get_wan_device_mng_interface_ip
> +	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
> +	get_wan_device_mng_status
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
> +	get_wan_device_mng_interface_ip
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
> +	get_wan_device_mng_interface_mac
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> +	get_wan_device_wan_ppp_enable
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
> +	get_wan_device_wan_ppp_username
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
> +	get_wan_device_wan_ppp_password
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  set_wan_device() {
>  case "$1" in
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:02:46 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:02:47 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:52864 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816383Ab2LHLCqCUq3m (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:02:46 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so704237eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:02:40 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=MPMyGe2yXWm1vFz9I3fJpvDHWa6Ed4sTqOfAikFWztY=;
        b=gAJQCti7LGgkoKLH2DM6BwBhhVp1Mtm+ouxb+1km8h5MnQRs/yYxby7f/JEt26Z7za
         SmWV7NCltQG3rG3rMPYEOpa41SBTr+gfbExDboW+O0R3vZ0oVYnS3M5S7G0+Oo45YiVe
         0kB38fOdrPl6bi+V6WZ6o5Rwx7gGQCDMb29rnnxAwjtVqyiv3xYrcV3UB5goUl4MsXP9
         bUtB6thGctbVwPKCaNkkYrG3x09enU22/Hgm0o11yIAtR0pVk45JVeJY31tkkoQGtvRu
         3XkARxPfbZwSfaW0cu0MuynlgwSkKMNxUnM+cs2yqdFiuK5P3xL3Cva2DdtGuiNAZFk/
         mfRQ==
Received: by 10.14.218.69 with SMTP id j45mr27585997eep.35.1354964560657;
        Sat, 08 Dec 2012 03:02:40 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id z8sm28777400eeo.11.2012.12.08.03.02.39
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:02:40 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:06:38 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 22/27] update xml handler set parameter values in order
 to execute external command and get response via ubus Contributed by Inteno
 Broadband Technology AB
Message-ID: <20121208110638-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-23-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-23-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQlO20NvJDQZAlsCcAjhRMy2X6eIfPE/RMBPj1UWCTg37lqN+IPrkrTOcT0wu0FSZ7g8TvZX
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 138
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:47PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> ---
>  src/external.c |   36 ++++++++++++++++++++++++++-
>  src/external.h |    5 +++-
>  src/ubus.c     |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/xml.c      |   25 +++++++++++++-----
>  4 files changed, 130 insertions(+), 9 deletions(-)
> 
> diff --git a/src/external.c b/src/external.c
> index 4973d1a..7eec751 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -5,6 +5,7 @@
>   *	(at your option) any later version.
>   *
>   *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
> + *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
>   */
>  
>  #include <errno.h>
> @@ -27,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)
>  {
> @@ -60,6 +63,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;
> @@ -229,9 +244,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)
>  {
>  	freecwmp_log_message(NAME, L_NOTICE, "executing set script\n");
> +	FILE *fp;
> +
> +	if (access(fc_script_set_actions, R_OK | W_OK | F_OK) == -1)
> +		return -1;
> +
> +	fp = fopen(fc_script_set_actions, "a");
> +	if (!fp) return -1;
> +
> +#ifdef DUMMY_MODE
> +	fprintf(fp, "/bin/sh `pwd`/%s apply %s\n", fc_script, action);
> +#else
> +	fprintf(fp, "/bin/sh %s 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;
> @@ -258,6 +289,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_set_actions) != 0)
> diff --git a/src/external.h b/src/external.h
> index 8e82c39..77165ee 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -5,6 +5,7 @@
>   *	(at your option) any later version.
>   *
>   *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
> + *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
>   */
>  
>  #ifndef _FREECWMP_EXTERNAL_H__
> @@ -27,12 +28,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 072b2a1..e852ed4 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -281,11 +281,84 @@ 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;
> +
> +
> +	freecwmp_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;
> +
> +
> +	freecwmp_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 c735244..a8f82c7 100644
> --- a/src/xml.c
> +++ b/src/xml.c
> @@ -578,6 +578,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 &&
> @@ -602,25 +603,35 @@ 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 KMD add here check for fault return from ubus

What does KMD mean?

> +
> +	external_fetch_set_param_val_resp_status(&status);
> +	if(!status) return -1; //TODO KMD return a fault message here

Fix comment.

> +
>  	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,
> @@ -899,7 +910,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

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:04:28 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:04:29 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:46976 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816383Ab2LHLE2MywuE (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:04:28 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so704719eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:04:23 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=fBtPrtza1yCcpJ8VVFHeqhHSC32yoXo4cpXjUOWE+mk=;
        b=CZ571I+8rMG0J85hacOr3wEBX89DyaFqjxdNKFS771atyHRAlaotA8RcY2wZAfAOJV
         V3+Ohua2A73jrGmDC5dp0aDizpwKnf55ImvVAkY2Wu+M5jWaSrLUX1NhmGgqcMuv0d1K
         sLoPZAZuaZQY7Xe3MS8lqW4WAD6bI3rJN/fk41d2ipjvIATC4NlYoJQLqq1AY6kg5BU8
         //AI7EfabFH5fJfYDtmgCmQJD0qPYb/hmkEKcqBx1p6f/sC146a7sUwuYZO2krjqVkHj
         xG5hFZk/XtnIoCNH3kDEiN266STLU3cuiSRG86NhQNW28f5NVlTpBtvv0HzTG8wH6pRB
         KVkA==
Received: by 10.14.184.131 with SMTP id s3mr27445802eem.38.1354964662878;
        Sat, 08 Dec 2012 03:04:22 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id k4sm22383761eep.15.2012.12.08.03.04.21
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:04:22 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:08:21 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 23/27] update common script and freecwmp.sh script in
 order to have the functions for set parameter values working with ubus
 Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Message-ID: <20121208110821-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-24-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-24-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkW4gSh4G51wMMc9wP4GgVBsrJ02V4Vyo5BgFwFyc0zAk7f9UKou1PnKF46lgAHEeRrnJRm
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 139
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:48PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  ext/openwrt/scripts/freecwmp.sh      |   58 +++++++++++++++++++++++++++++++--
>  ext/openwrt/scripts/functions/common |   20 ++++++++++++
>  2 files changed, 74 insertions(+), 4 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
> index 02a923e..54c0924 100644
> --- a/ext/openwrt/scripts/freecwmp.sh
> +++ b/ext/openwrt/scripts/freecwmp.sh
> @@ -90,6 +90,15 @@ case "$1" in
>  	reboot)
>  		action="reboot"
>  		;;
> +	apply)
> +		if [ "$2" = "notification" ]; then
> +			action="apply_notification"
> +		elif [ "$2" = "value" ]; then
> +			action="apply_value"
> +		else
> +			action="apply_value"
> +		fi
> +		;;
>  esac
>  
>  if [ -z "$action" ]; then
> @@ -213,10 +222,30 @@ 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
> +	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_value_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_notification" -o "$action" = "get_all" ]; then
> @@ -295,6 +324,27 @@ if [ "$action" = "reboot" ]; then
>  	fi
>  fi
>  
> +if [ \( "$action" = "apply_notification" \) -o \( "$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 call tr069 set_parameter_values_status '{"status": "0"}'; fi
> +	else
> +		let n=$__fault_count-1
> +		for i in `seq 0 $n`
> +		do
> +			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"
> +		done
> +		rm -rf /var/state/freecwmp 2> /dev/null
> +		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert freecwmp
> +	fi
> +fi
> +
> +

Too many newlines.

>  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 fd98a01..f701eb9 100644
> --- a/ext/openwrt/scripts/functions/common
> +++ b/ext/openwrt/scripts/functions/common
> @@ -56,6 +56,16 @@ case "$action" in
>  	;;
>  esac
>  }
> + 
> +ubus_freecwmp_fault_output() {
> +local parameter="$1"
> +local fault_code="$2"
> +case "$action" in
> +	apply_value)
> +	ubus call tr069 set_parameter_values_fault '{"parameter": "'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null

Fix spacing here.

> +	;;
> +esac
> +}
>  freecwmp_value_output() {
>  	freecwmp_output "$1" "$2" "V"
>  }
> @@ -295,3 +305,13 @@ if [ "$1" = "." ]; then
>  fi
>  return $FAULT_CPE_NO_FAULT
>  }
> +
> +freecwmp_set_parameter_fault() {
> +	local _parm="$1"
> +	local _fault="$2"
> +		/sbin/uci -P /var/state batch << EOF 2>&1 >/dev/null

When using uci *always* use it with ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} like
in existing freecwmp script code.

> +			add freecwmp fault
> +			set freecwmp.@fault[-1].parameter="$_parm"
> +			set freecwmp.@fault[-1].fault_code="$_fault"
> +EOF
> +}
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:06:54 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:06:56 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:52565 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816383Ab2LHLGyk-2u7 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:06:54 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so470071eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:06:49 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=UApzSJulljOLyK2VjCjTOog2pSFeIZWw9snmzJ9a3kE=;
        b=eI1ewZnQcS8LzbD+CVg0IyUTlWSHbYoY7HZKDBXRLFhodK63fRJRy8OjT9Bgho8yoi
         24BkA7Aiq3zJzVbn37jJgxppCAj04o8+0/Z3wlYDGlcjzZFsRJ7MDV5NsbIUh/0lW69x
         5wQvoJE4VvHeJFxuyFJrjo1neh6tiom8FAe1gkXft8yiQUoH39OXNmW4L0efusbuoxwN
         YKSBoGyH2kckOMn/ITW4kA/o17hTJ4NlN77KMQwo5Trfgubp8Ktd5BhcHQAQ21R6c+k/
         tGWahQ+v1nNt2VvUntg/+zmaNI7r99P+ITjQdx/AZrZGCJGhlI94tGOQY+gTzONrNulj
         NjZQ==
Received: by 10.14.194.195 with SMTP id m43mr27624753een.44.1354964809278;
        Sat, 08 Dec 2012 03:06:49 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id z8sm28800988eeo.11.2012.12.08.03.06.47
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:06:48 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:10:47 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 24/27] update dm script to send the output of set
 parameter function to the ubus Contributed by Inteno Broadband Technology AB
Message-ID: <20121208111047-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-25-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-25-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkj9nf6P9IXLBTpAhDwWnGN63Yqkq/7X5tEcTLlrbFJIEFb+YE1Dt11W7YEw6Vzws0RtYfb
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 140
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:49PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  ext/openwrt/scripts/functions/device_info       |   62 +++++++-
>  ext/openwrt/scripts/functions/lan_device        |   33 +++--
>  ext/openwrt/scripts/functions/management_server |  178 +++++++++++++++++------
>  ext/openwrt/scripts/functions/wan_device        |   41 ++++--
>  4 files changed, 238 insertions(+), 76 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
> index 2be20b5..5fe2823 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -19,7 +19,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
>  }
>  
>  set_device_info_manufacturer() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].manufacturer="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.Manufacturer"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].manufacturer="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_oui() {
> @@ -39,7 +45,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
>  }
>  
>  set_device_info_oui() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].oui="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.ManufacturerOUI"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].oui="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_product_class() {
> @@ -59,7 +71,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
>  }
>  
>  set_device_info_product_class() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].product_class="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.ProductClass"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].product_class="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_serial_number() {
> @@ -79,7 +97,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
>  }
>  
>  set_device_info_serial_number() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].serial_number="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.SerialNumber"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].serial_number="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_hardware_version() {
> @@ -99,7 +123,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
>  }
>  
>  set_device_info_hardware_version() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].hardware_version="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.HardwareVersion"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].hardware_version="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_software_version() {
> @@ -119,7 +149,13 @@ ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
>  }
>  
>  set_device_info_software_version() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].software_version="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.DeviceInfo.SoftwareVersion"

This variable is not used, remove it.

> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].software_version="$val"
> +	;;
> +esac
>  }
>  
>  get_device_info_uptime() {
> @@ -370,24 +406,31 @@ set_device_info() {
>  case "$1" in
>  	InternetGatewayDevice.DeviceInfo.Manufacturer)
>  	set_device_info_manufacturer "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
>  	set_device_info_oui "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.ProductClass)
>  	set_device_info_product_class "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.SerialNumber)
>  	set_device_info_serial_number "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.HardwareVersion)
>  	set_device_info_hardware_version "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
>  	set_device_info_software_version "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
>  
>  check_parameter_device_info_generic() {
> @@ -449,8 +492,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
>  
>  	freecwmp_set_parameter_value "$1" "$2"
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	return $FAULT_CPE_NO_FAULT
>  }
> diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index 949f11c..db90021 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -33,13 +33,18 @@ esac
>  set_wlan_enable() {
>  local num="$1"
>  local val="$2"
> -if [ "$val" = "1" ]; then
> -	val="0"
> -else
> -	val="1"
> -fi
> -delay_command "wifi" "wifi" "45"
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
> +local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"

This variable is not used, remove it.

> +case $action in
> +	set_value)
> +	if [ "$val" = "1" ]; then
> +		val="0"
> +	else
> +		val="1"
> +	fi
> +	delay_command "wifi" "wifi" "45"
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
> +	;;
> +esac
>  }
>  
>  get_wlan_ssid() {
> @@ -68,8 +73,13 @@ esac
>  set_wlan_ssid() {
>  local num="$1"
>  local val="$2"
> -delay_command "wifi" "wifi" "45"
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
> +local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"

This variable is not used, remove it.

> +case $action in
> +	set_value)
> +	delay_command "wifi" "wifi" "45"
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
> +	;;
> +esac
>  }
>  
>  get_lan_device() {
> @@ -223,10 +233,13 @@ set_lan_device() {
>  case "$1" in
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
>  	set_wlan_enable 0 "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
>  	set_wlan_ssid 0 "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
> diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
> index b1e759d..37b1cb0 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -26,34 +26,39 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_url() {
> -local url=$1
> -local scheme
> -local hostname
> -local path
> -local port
> -
> -scheme=`echo $url | awk -F "://" '{ print $1 }'`
> -hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
> -port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F '/' '{ print $1 }'`
> -
> -if [ -z "$port" ]; then
> -	port=80
> -	path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
> -	echo 123 $path
> -else
> -	path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
> -fi
> -
> -if [ -z "$path" ]; then
> -	path="/"
> -fi
> -
> -set_management_server_x_freecwmp_org__acs_scheme $scheme
> -set_management_server_x_freecwmp_org__acs_hostname $hostname
> -set_management_server_x_freecwmp_org__acs_port $port
> -set_management_server_x_freecwmp_org__acs_path $path
> -
> -ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
> +local parm="InternetGatewayDevice.ManagementServer.URL"
> +case "$action" in
> +	set_value)
> +	local url=$1
> +	local scheme
> +	local hostname
> +	local path
> +	local port
> +	
> +	scheme=`echo $url | awk -F "://" '{ print $1 }'`
> +	hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
> +	port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F '/' '{ print $1 }'`
> +	
> +	if [ -z "$port" ]; then
> +		port=80
> +		path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
> +		echo 123 $path
> +	else
> +		path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
> +	fi
> +	
> +	if [ -z "$path" ]; then
> +		path="/"
> +	fi
> +	
> +	set_management_server_x_freecwmp_org__acs_scheme $scheme
> +	set_management_server_x_freecwmp_org__acs_hostname $hostname
> +	set_management_server_x_freecwmp_org__acs_port $port
> +	set_management_server_x_freecwmp_org__acs_path $path
> +	
> +	ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
> +	;;
> +esac
>  }
>  
>  get_management_server_username() {
> @@ -74,7 +79,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_username() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].username="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.Username"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].username="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_password() {
> @@ -95,7 +106,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_password() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].password="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.Password"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].password="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_periodic_inform_enable() {
> @@ -117,8 +134,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  set_management_server_periodic_inform_enable() {
> +local val=$1
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
> -freecwmp_set_parameter_value "$parm" "$1"
> +case "$action" in
> +	set_value)
> +	freecwmp_set_parameter_value "$parm" "$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_periodic_inform_interval() {
> @@ -140,8 +162,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
>  }
>  
>  set_management_server_periodic_inform_interval() {
> +local val=$1
>  local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
> -freecwmp_set_parameter_value "$parm" "$1"
> +case "$action" in
> +	set_value)
> +	freecwmp_set_parameter_value "$parm" "$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_connection_request_url() {
> @@ -191,7 +218,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_connection_request_username() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].username="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].username="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_connection_request_password() {
> @@ -212,7 +245,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_management_server_connection_request_password() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].password="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].password="$val"
> +	;;
> +esac
>  }
>  
>  # TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
> @@ -239,7 +278,13 @@ fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_scheme() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].scheme="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].scheme="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_x_freecwmp_org__acs_hostname() {
> @@ -264,11 +309,17 @@ fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_hostname() {
> -if [ -z "$default_management_server_acs_hostname" ]; then
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$1"
> -else
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
> -fi
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
> +case "$action" in
> +	set_value)
> +	if [ -z "$default_management_server_acs_hostname" ]; then
> +			/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$val"
> +	else
> +		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
> +	fi
> +	;;
> +esac
>  }
>  
>  get_management_server_x_freecwmp_org__acs_port() {
> @@ -293,7 +344,13 @@ fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_port() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].port="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].port="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_x_freecwmp_org__acs_path() {
> @@ -318,7 +375,13 @@ fi
>  }
>  
>  set_management_server_x_freecwmp_org__acs_path() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].path="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].path="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server_x_freecwmp_org__connection_request_port() {
> @@ -343,7 +406,13 @@ fi
>  }
>  
>  set_management_server_x_freecwmp_org__connection_request_port() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].port="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
> +case "$action" in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].port="$val"
> +	;;
> +esac
>  }
>  
>  get_management_server() {
> @@ -674,45 +743,59 @@ set_management_server() {
>  case "$1" in
>  	InternetGatewayDevice.ManagementServer.URL)
>  	set_management_server_url "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.Username)
>  	set_management_server_username "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.Password)
>  	set_management_server_password "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
>  	set_management_server_periodic_inform_enable "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
>  	set_management_server_periodic_inform_interval "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
>  	set_management_server_connection_request_url "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
>  	set_management_server_connection_request_username "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
>  	set_management_server_connection_request_password "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
>  	set_management_server_x_freecwmp_org__acs_scheme "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	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 $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
>  	set_management_server_x_freecwmp_org__acs_port "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
>  	set_management_server_x_freecwmp_org__acs_path "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
>  	set_management_server_x_freecwmp_org__connection_request_port "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
>  check_parameter_management_server_generic() {
> @@ -750,8 +833,9 @@ 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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
>  
>  	freecwmp_set_parameter_value "$1" "$2"
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	return $FAULT_CPE_NO_FAULT
>  }
> diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
> index 02ba365..c8f1887 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -94,13 +94,18 @@ ubus_freecwmp_output "$parm" "$val" "$type"
>  
>  set_wan_device_wan_ppp_enable() {
>  local val=$1
> -if [ "$val" -eq 0 ]; then
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
> -	ifdown wan &
> -elif [ "$val" -eq 1 ]; then
> -	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
> -	ifup wan &
> -fi
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
> +case $action in
> +	set_value)
> +	if [ "$val" -eq 0 ]; then
> +		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
> +		ifdown wan &
> +	elif [ "$val" -eq 1 ]; then
> +		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
> +		ifup wan &
> +	fi
> +	;;
> +esac
>  }
>  
>  get_wan_device_wan_ppp_username() {
> @@ -121,7 +126,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_wan_device_wan_ppp_username() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.username="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
> +case $action in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.username="$val"
> +	;;
> +esac
>  }
>  
>  get_wan_device_wan_ppp_password() {
> @@ -142,7 +153,13 @@ ubus_freecwmp_output "$parm" "$val"
>  }
>  
>  set_wan_device_wan_ppp_password() {
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.password="$1"
> +local val=$1
> +local parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
> +case $action in
> +	set_value)
> +	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.password="$1"
> +	;;
> +esac
>  }
>  
>  get_wan_device() {
> @@ -452,13 +469,17 @@ set_wan_device() {
>  case "$1" in
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
>  	set_wan_device_wan_ppp_enable "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
>  	set_wan_device_wan_ppp_username "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
>  	set_wan_device_wan_ppp_password "$2"
> +	return $FAULT_CPE_NO_FAULT
>  	;;
>  esac
> -/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit

NACK. Either remove it or don't.

> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:08:48 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:08:49 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:61257 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816383Ab2LHLIsK3dtH (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:08:48 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so706217eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:08:42 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=g74MUrB4JRTmVpfB4GqjAPMPPfoLUDEz+zivNqvAcRY=;
        b=QWWMfhGwDcoFuw4o4Ili8kkgCm1l1S+tF5/ub0H1sjlv8nlet2qh4x+/nqy5htHuqM
         pvMP+1gcrQ+rvQB6MbTj0cQL8/SaS84pZjybqTckMWtWOJ67X7Hv6PCeir/HNjRKelIB
         ohzrxYgQ1AWdGRFtuQULKvxogtMDj+h6W2X0eoE+9DRWCmLQjcWIW6BffWV29fOGobX1
         y7oQoH3K//zF3CXU7U1byp/2vE6jYVTHpNOvp0jiSuRXeYJFtShryoFGohEhM75Z7igr
         JExd9YhSBMv+MUIkwbV1Jncz9Ojc7qqUkgQXtIQCH1Wjq/+7y+5j7OS4nKynNowYrwzf
         BKoQ==
Received: by 10.14.3.195 with SMTP id 43mr27614539eeh.36.1354964922841;
        Sat, 08 Dec 2012 03:08:42 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id w3sm28814540eel.17.2012.12.08.03.08.41
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:08:42 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:12:41 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 25/27] add ubus listner for set parameter attribute
 Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Message-ID: <20121208111241-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-26-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-26-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkNLjaCpVl2tzcV8crpSIOeaV2p/mW5HXpG9/PugCLQYpL8AcR+vPHKeRcQXD2JUMZLq08J
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 141
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:50PM +0100, Mohamed wrote:
> 
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
>  src/external.c |   16 ++++++++++++++++
>  src/external.h |    2 ++
>  src/ubus.c     |   31 +++++++++++++++++++++++++++++++
>  src/xml.c      |   20 +++++++++++++++++---
>  4 files changed, 66 insertions(+), 3 deletions(-)
> 
> diff --git a/src/external.c b/src/external.c
> index 7eec751..a033781 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -75,6 +75,22 @@ void external_fetch_set_param_val_resp_status(char **status)
>  	external_method_status = NULL;
>  }
>  
> +void external_set_param_attr_resp (char *status, char *fault)
> +{
> +	free(external_method_status);
> +	external_method_status = status ? strdup(status) : NULL;
> +	free(external_method_fault);
> +	external_method_fault = fault ? strdup(fault) : NULL;
> +}
> +
> +void external_fetch_set_param_attr_resp (char **status, char **fault)
> +{
> +	*status = external_method_status;
> +	external_method_status = NULL;
> +	*fault = external_method_fault;
> +	external_method_fault = NULL;
> +}
> +
>  int external_get_action_data(char *action, char *name, char **value)
>  {
>  	struct external_parameter *external_parameter;
> diff --git a/src/external.h b/src/external.h
> index 77165ee..489d215 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -30,6 +30,8 @@ struct external_parameter {
>  
>  void external_set_param_val_resp_status (char *status);
>  void external_fetch_set_param_val_resp_status (char **status);
> +void external_set_param_attr_resp (char *status, char *fault);
> +void external_fetch_set_param_attr_resp (char **status, char **fault);
>  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);
> diff --git a/src/ubus.c b/src/ubus.c
> index e852ed4..8502805 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -281,6 +281,36 @@ freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct ubus_obje
>  	return 0;
>  }
>  
> +static enum set_param_attributes {
> +	SET_PARAM_ATTRIBUTES_SUCCESS,
> +	SET_PARAM_ATTRIBUTES_FAULT,
> +	__SET_PARAM_ATTRIBUTES_MAX
> +};
> +
> +static const struct blobmsg_policy set_param_attributes_policy[] = {
> +		[SET_PARAM_ATTRIBUTES_SUCCESS] = { .name = "success", .type = BLOBMSG_TYPE_STRING },

Too many tabs.

> +	[SET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
> +};
> +
> +static int
> +freecwmpd_handle_set_param_attributes(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_ATTRIBUTES_MAX];
> +
> +	blobmsg_parse(set_param_attributes_policy, ARRAY_SIZE(set_param_attributes_policy), tb,
> +		      blob_data(msg), blob_len(msg));
> +
> +	freecwmp_log_message(NAME, L_NOTICE,
> +			     "triggered ubus set_parameter_attributes\n");
> +
> +	external_set_param_attr_resp(tb[SET_PARAM_ATTRIBUTES_SUCCESS] ? blobmsg_data(tb[SET_PARAM_ATTRIBUTES_SUCCESS]) : NULL,
> +			tb[SET_PARAM_ATTRIBUTES_FAULT] ? blobmsg_data(tb[SET_PARAM_ATTRIBUTES_FAULT]) : NULL);
> +
> +	return 0;
> +}
> +
>  static enum set_param_values_fault {
>  	SET_PARAM_VALUES_FAULT_PARAM,
>  	SET_PARAM_VALUES_FAULT__FAULT,
> @@ -361,6 +391,7 @@ static const struct ubus_method freecwmp_methods[] = {
>  	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),
> +	UBUS_METHOD("set_parameter_attributes", freecwmpd_handle_set_param_attributes, set_param_attributes_policy),
>  };
>  
>  static struct ubus_object_type main_object_type =
> diff --git a/src/xml.c b/src/xml.c
> index a8f82c7..e46c50c 100644
> --- a/src/xml.c
> +++ b/src/xml.c
> @@ -6,6 +6,7 @@
>   *
>   *	Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
>   *	Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
> + *  Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>

Tabs not spaces.

>   */
>  
>  #include <stdbool.h>
> @@ -861,7 +862,7 @@ static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>  					       mxml_node_t *tree_out) {
>  
>  	mxml_node_t *n, *b = body_in;
> -	char *c, *parameter_name, *parameter_notification;
> +	char *c, *parameter_name, *parameter_notification, *success=NULL, *fault=NULL;
>  	uint8_t attr_notification_update;
>  
>  	/* handle cwmp:SetParameterAttributes */
> @@ -913,15 +914,28 @@ static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>  	if (external_set_action_execute("notification"))
>  		return -1;
>  
> +	external_fetch_set_param_attr_resp(&success, &fault);
> +
> +	if (fault && fault[0]=='9') goto error; //TODO KMD return a fault message here with fault indicated in the fault string

Fix spaces and comment.

> +
> +	if(!success) goto error; //TODO KMD return a fault message here

Fix comment.

> +
>  	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:SetParameterAttributesResponse");
> -	if (!b) return -1;
> +	if (!b) goto error;
>  
>  	config_load();
>  
> +	free(success);
> +	free(fault);
>  	return 0;
> +
> +error:
> +	free(success);
> +	free(fault);
> +	return -1;
>  }
>  
>  static int xml_handle_download(mxml_node_t *body_in,
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:09:56 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:09:56 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:57999 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823005Ab2LHLJz5R4PS (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:09:55 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so470736eaa.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:09:50 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=PeHD8G9QoFoD3J7DvZYFq5GZI7nb54PmMgrKurGegEE=;
        b=Oce4vzFKJSQA2aRhzAGZUhiOT+/xxakQ34wrVFuYALEww7wBTKkifGZcoZCJnC6mNq
         u0WTh6oIF6gRV4MSp8Q4CSMH28oqTCmN7/ctuXK3tXTV9ewg3cOFHPOEie071piePHEt
         9mt7n5gVxelhz9FdYkuvSOQ0xWk4/TVtWIrpPciGQ9LXcr0p0PQWqWH+I7oNxsbHQOij
         BxykbSFAT3MUgVSkvrH4gboPXWjk3vSt6HeszE5sqTSagTICdOjXq1lb4XPJJ9iY3rkN
         guh8lw3GsxQPRT8LvRJPK5HF33e3YFNSWIRM9WRXb/nJhaCWP8CyAtzc2fk7Z561HOwG
         p4QQ==
Received: by 10.14.178.196 with SMTP id f44mr27837093eem.14.1354964990585;
        Sat, 08 Dec 2012 03:09:50 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id 6sm16821188eea.3.2012.12.08.03.09.49
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:09:50 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:13:48 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [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
Message-ID: <20121208111348-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-27-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-27-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQklmdZl+PzKJeuPxuk7MP3xhBnHCplg33wgMbVDazuoTwaeIArHoB2yDaV4Nonuto5LD+Cb
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 142
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:51PM +0100, Mohamed wrote:
> 
> 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

This is simmilar to the code in one of the previous patches so I won't comment
it again here.

>  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

Missing spaces.

> +	;;
>  esac
>  }
>  freecwmp_value_output() {
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Sat Dec  8 12:13:30 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Sat, 08 Dec 2012 12:13:31 +0100 (CET)
Received: from mail-ee0-f49.google.com ([74.125.83.49]:36681 "EHLO
        mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6816383Ab2LHLNaCPEBZ (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Sat, 8 Dec 2012 12:13:30 +0100
Received: by mail-ee0-f49.google.com with SMTP id c4so707962eek.36
        for <freecwmp@linux-mips.org>; Sat, 08 Dec 2012 03:13:24 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=KSzmsIm+JxgmmZN2HfmUqlE1hXQCXYgb8d5XLb9mgqQ=;
        b=KfMJ11HWUcd4j9pOX4iRC0K6pC0dZDO7vDNQzsoCyev54xJREie4QwQ8qZdSJ5c3gk
         49VzZtIJMESY3loJ4D/xRmprrjyzFQ6ZUaoNFPgp6v0c5YL9fhQo4carChPgS/YXJzAf
         yZfpD4LpvugrwJOiVWH8MsQWFQ5sH/LLJGzODQVZEmFwAfjU28gIoyG9nbHEQA2noCGo
         TY/TnQXJwBFOZGii09p0XQvnyuIctL+mGFLQvllICJaYTFolyzeIk6Twrc3OuwTad4Wn
         fIXhMs7cVTOgcNtIrP3K4f4PEWXSQUgXkeG8fMG6KvPDS5vWsZrWVypEaYJP/2H0W77U
         DpOQ==
Received: by 10.14.173.65 with SMTP id u41mr27762588eel.13.1354965204625;
        Sat, 08 Dec 2012 03:13:24 -0800 (PST)
Received: from w500.lan (213-191-157-120.dhcp.iskon.hr. [213.191.157.120])
        by mx.google.com with ESMTPS id b49sm28835424eem.16.2012.12.08.03.13.23
        (version=SSLv3 cipher=OTHER);
        Sat, 08 Dec 2012 03:13:24 -0800 (PST)
Date:   Sat, 8 Dec 2012 12:17:22 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     mohamed.kallel@pivasoftware.com
Cc:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        freecwmp@lukaperkov.net, jogo@openwrt.org
Subject: Re: [PATCH 27/27] update the dm script function to communicate the
 output of set parameter attribute with ubus Contributed by Inteno Broadband
 Technology AB
Message-ID: <20121208111722-10595@mutt-kz>
Mail-Followup-To: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        ahmed.zribi@pivasoftware.com, jogo@openwrt.org
References: <mohamed.kallel@pivasoftware.com>
 <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
 <1354809292-2467-28-git-send-email-mohamed.kallel@pivasoftware.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1354809292-2467-28-git-send-email-mohamed.kallel@pivasoftware.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQkcr+TV34BVpLZOKEKm8s32nzyGN4l+x8rvNECLbITqpTGlL+l4Tyb5PhDdISakkPIDnrEl
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 143
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:52PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

Why should we add support for notifications on parameters that should not be
changed in real life?

For example "InternetGatewayDevice.DeviceInfo.Manufacturer".

> ---
>  ext/openwrt/scripts/functions/device_info       |   61 +++++++++++++
>  ext/openwrt/scripts/functions/lan_device        |   30 ++++++
>  ext/openwrt/scripts/functions/management_server |  108 +++++++++++++++++++++++
>  ext/openwrt/scripts/functions/wan_device        |   37 ++++++++
>  4 files changed, 236 insertions(+), 0 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
> index 5fe2823..08255de 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -25,6 +25,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].manufacturer="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;

I think there is a better way to do this then it is proposed in this
patch. I'll look into this.

>  esac
>  }
>  
> @@ -51,6 +54,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].oui="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -77,6 +83,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].product_class="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -103,6 +112,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].serial_number="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -129,6 +141,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].hardware_version="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -155,6 +170,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@device[0].software_version="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -433,6 +451,41 @@ return $FAULT_CPE_INVALID_PARAMETER_NAME
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
>  
> +set_device_info_notification() {
> +case "$1" in
> +	InternetGatewayDevice.DeviceInfo.)
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.Manufacturer)
> +	set_device_info_manufacturer "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
> +	set_device_info_oui "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.ProductClass)
> +	set_device_info_product_class "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SerialNumber)
> +	set_device_info_serial_number "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.HardwareVersion)
> +	set_device_info_hardware_version "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
> +	set_device_info_software_version "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +}
> +
>  check_parameter_device_info_generic() {
>  case "$1" in
>  	InternetGatewayDevice.DeviceInfo.ModelName|\
> @@ -498,3 +551,11 @@ set_device_info_generic() {
>  	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  	return $FAULT_CPE_NO_FAULT
>  }
> +
> +set_device_info_generic_notification() {
> +	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	return $FAULT_CPE_NO_FAULT
> +}
> diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
> index db90021..a8a94e5 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -44,6 +44,10 @@ case $action in
>  	delay_command "wifi" "wifi" "45"
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
>  	;;
> +	set_notification)
> +	let num=$num+1
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -79,6 +83,10 @@ case $action in
>  	delay_command "wifi" "wifi" "45"
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
>  	;;
> +	set_notification)
> +	let num=$num+1
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -243,3 +251,25 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
> +
> +set_lan_device_notification() {
> +case "$1" in
> +	InternetGatewayDevice.LANDevice.|\
> +	InternetGatewayDevice.LANDevice.1.|\
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.|\
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> +	set_wlan_enable 0 "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
> +	set_wlan_ssid 0 "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +}
> diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
> index 37b1cb0..532addd 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -58,6 +58,10 @@ case "$action" in
>  	
>  	ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
>  	;;
> +	set_notification)
> +	local val=$1
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -85,6 +89,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].username="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -112,6 +119,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].password="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -140,6 +150,9 @@ case "$action" in
>  	set_value)
>  	freecwmp_set_parameter_value "$parm" "$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -168,6 +181,9 @@ case "$action" in
>  	set_value)
>  	freecwmp_set_parameter_value "$parm" "$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -224,6 +240,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].username="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -251,6 +270,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].password="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -284,6 +306,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].scheme="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -319,6 +344,9 @@ case "$action" in
>  		/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
>  	fi
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -350,6 +378,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].port="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -381,6 +412,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@acs[0].path="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -412,6 +446,9 @@ case "$action" in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set freecwmp.@local[0].port="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -798,6 +835,69 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +set_management_server_notification() {
> +case "$1" in
> +	InternetGatewayDevice.ManagementServer.)
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.URL)
> +	set_management_server_url "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Username)
> +	set_management_server_username "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.Password)
> +	set_management_server_password "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
> +	set_management_server_periodic_inform_enable "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
> +	set_management_server_periodic_inform_interval "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
> +	set_management_server_connection_request_url "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
> +	set_management_server_connection_request_username "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
> +	set_management_server_connection_request_password "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
> +	set_management_server_x_freecwmp_org__acs_scheme "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
> +	set_management_server_x_freecwmp_org__acs_hostname "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
> +	set_management_server_x_freecwmp_org__acs_port "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
> +	set_management_server_x_freecwmp_org__acs_path "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
> +	set_management_server_x_freecwmp_org__connection_request_port "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  check_parameter_management_server_generic() {
>  case "$1" in
>  	InternetGatewayDevice.ManagementServer.UpgradesManaged)
> @@ -839,3 +939,11 @@ set_management_server_generic() {
>  	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  	return $FAULT_CPE_NO_FAULT
>  }
> +
> +set_management_server_generic_notification() {
> +	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +	return $FAULT_CPE_NO_FAULT
> +}
> diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
> index c8f1887..7a12eb5 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -105,6 +105,9 @@ case $action in
>  		ifup wan &
>  	fi
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -132,6 +135,9 @@ case $action in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.username="$val"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -159,6 +165,9 @@ case $action in
>  	set_value)
>  	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.password="$1"
>  	;;
> +	set_notification)
> +	freecwmp_set_parameter_notification "$parm" "$val"
> +	;;
>  esac
>  }
>  
> @@ -483,3 +492,31 @@ esac
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> +
> +set_wan_device_notification() {
> +case "$1" in
> +	InternetGatewayDevice.WANDevice.|\
> +	InternetGatewayDevice.WANDevice.1.|\
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.|\
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.|\
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.|\
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
> +	freecwmp_set_parameter_notification "$1" "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> +	set_wan_device_wan_ppp_enable "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
> +	set_wan_device_wan_ppp_username "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
> +	set_wan_device_wan_ppp_password "$2"
> +	return $FAULT_CPE_NO_FAULT
> +	;;
> +esac
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> -- 
> 1.7.4.1

Luka 

From freecwmp@lukaperkov.net Mon Dec 10 01:52:18 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Mon, 10 Dec 2012 01:52:19 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:61953 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6825906Ab2LJAwSBg14y (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Mon, 10 Dec 2012 01:52:18 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so882148eaa.36
        for <freecwmp@linux-mips.org>; Sun, 09 Dec 2012 16:52:11 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version
         :content-type:content-disposition:user-agent:x-gm-message-state;
        bh=0BPPm/9xapw5uuoAtk6WodF6cPscqIDBNgMiXcV8uBI=;
        b=AVvq/3jAlOTpZVH8VxmHL2vOSU/E74XPrdxpTIb8ZdxHPOOtuook+P5GPpgxTcPwYN
         n8b7fj66jf8pJ5+ytf+OqRZguzmK4dLqNiETA2ZpRqd9C57V0TiNFDUYGBzLgNQ1zXPj
         uwxM5VIVw+658qfXfE7+IVJU78BuPbAbJ/tJku2vDii1LjGynwMCle5K96bG8vsYG2Qh
         Q37Q4Md8rC/bNpCLollzGm729u+qxGGYLwDirPHuQRFoa7+JjOU9qUzFf5Syl2ZJ9ZHU
         S4knJ+NFbNH9p4ytdltxwsMnsV9+LL7wvCbqG0nIFc8iF0r0QlxS2UZV89PSdHdcgOsK
         NP3A==
Received: by 10.14.207.6 with SMTP id m6mr43447113eeo.10.1355100731674;
        Sun, 09 Dec 2012 16:52:11 -0800 (PST)
Received: from w500.lan ([141.138.0.195])
        by mx.google.com with ESMTPS id 43sm40244754eed.10.2012.12.09.16.52.10
        (version=SSLv3 cipher=OTHER);
        Sun, 09 Dec 2012 16:52:11 -0800 (PST)
Date:   Mon, 10 Dec 2012 01:56:10 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     freecwmp@linux-mips.org
Cc:     jogo@openwrt.org
Subject: [PATCH] simplify function configuration
Message-ID: <20121210005610-21211@mutt-kz>
Mail-Followup-To: freecwmp@linux-mips.org, jogo@openwrt.org
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQlMFQLrGal1G/RjHeVGXnvuXIbZda2IiOS+yxehjBIzmTPWh9chGZqecM2m4DxwxIuOwokq
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 144
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

simplify function configuration

Support for get_ and set_ function prototypes only (for now).

Signed-off-by: Luka Perkov <freecwmp@lukaperkov.net>
---
 ext/openwrt/config/freecwmp                  | 29 +++++++++++-----------------
 ext/openwrt/scripts/freecwmp.sh              | 13 +++++++++----
 ext/openwrt/scripts/functions/device_hosts   |  2 ++
 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/misc           |  2 ++
 7 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index ba6fbda..a64ee63 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -28,30 +28,23 @@ config scripts
 	list location /usr/share/freecwmp/functions/common
 	# freecwmp specific functions
 	list location /usr/share/freecwmp/functions/device_info
-	list get_value_function get_device_info
-	list set_value_function set_device_info
-	list get_value_function get_device_info_generic
-	list set_value_function set_device_info_generic
+	list function device_info
+	list function device_info_generic
 	list location /usr/share/freecwmp/functions/lan_device
-	list get_value_function get_lan_device
-	list set_value_function set_lan_device
+	list function lan_device
 	list location /usr/share/freecwmp/functions/management_server
-	list get_value_function get_management_server
-	list set_value_function set_management_server
-	list get_value_function get_management_server_generic
-	list set_value_function set_management_server_generic
+	list function management_server
+	list function management_server_generic
 	list location /usr/share/freecwmp/functions/wan_device
-	list get_value_function get_wan_device
-	list set_value_function set_wan_device
+	list function wan_device
 	list location /usr/share/freecwmp/functions/misc
-	list get_value_function get_misc
+	list function misc
 	list location /usr/share/freecwmp/functions/device_users
-	list get_value_function get_device_users
-	list set_value_function set_device_users
+	list function device_users
 	list location /usr/share/freecwmp/functions/device_hosts
-	list get_value_function get_device_hosts
+	list function device_hosts
 	list location /usr/share/freecwmp/functions/device_routing
-	list get_value_function get_device_routing
+	list function device_routing
 	list location /usr/share/freecwmp/functions/device_ip
-	list get_value_function get_device_ip
+	list function device_ip
 
diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..3d16c4b 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -96,18 +96,23 @@ if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
 	echo "[debug] started at \"`date`\""
 fi
 
+get_value_functions=""
+set_value_functions=""
+
 load_script() {
 	. $1 
 }
 
-get_value_functions=""
-set_value_functions=""
+load_function() {
+	get_value_functions="$get_value_functions get_$1"
+	set_value_functions="$set_value_functions set_$1"
+}
+
 handle_scripts() {
 	local section="$1"
 	config_get prefix "$section" "prefix"
 	config_list_foreach "$section" 'location' load_script
-	config_get get_value_functions "$section" "get_value_function"
-	config_get set_value_functions "$section" "set_value_function"
+	config_list_foreach "$section" 'function' load_function
 }
 
 config_load freecwmp
diff --git a/ext/openwrt/scripts/functions/device_hosts b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..542e6e7 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -189,3 +189,5 @@ fi
 # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 support yet)
 
 }
+
+set_device_hosts() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_ip b/ext/openwrt/scripts/functions/device_ip
index 5915012..af9033f 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -121,3 +121,5 @@ fi
 # TODO: Device.IP.Interface.{i}.Stats.
 
 }
+
+set_device_ip() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_routing b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..70246fd 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -351,3 +351,5 @@ if [ $rc -eq 0 ]; then
 fi
 
 }
+
+set_device_routing() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_users b/ext/openwrt/scripts/functions/device_users
index 0d377f7..e4949bd 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -124,3 +124,5 @@ fi
 
 # TODO: Device.Users.User.{i}.Language (why? look at the get value function for this parameter)
 }
+
+set_device_users() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/misc b/ext/openwrt/scripts/functions/misc
index 2e0210c..a4df841 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -21,3 +21,5 @@ case "$1" in
 	;;
 esac
 }
+
+set_misc() { echo -n > /dev/null; }

From freecwmp@lukaperkov.net Mon Dec 10 07:48:03 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Mon, 10 Dec 2012 07:48:04 +0100 (CET)
Received: from mail-ea0-f177.google.com ([209.85.215.177]:58437 "EHLO
        mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823091Ab2LJGsDH6dHN (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Mon, 10 Dec 2012 07:48:03 +0100
Received: by mail-ea0-f177.google.com with SMTP id c10so943078eaa.36
        for <freecwmp@linux-mips.org>; Sun, 09 Dec 2012 22:47:57 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=date:from:to:cc:subject:message-id:mail-followup-to:references
         :mime-version:content-type:content-disposition:in-reply-to
         :user-agent:x-gm-message-state;
        bh=KKwMWlOSvxhzu77y6tN98QsaWqdUI/Z6+IwgGvVECFw=;
        b=J5Z7DA8FhSCOUbAtPVZzRWaD2As8yYL1YR0uMtjcIrmv8WuROhp/5cH06hW9MIYndc
         v6/FUz0dbwq1uf2lSsgnTZWptr1+5dGUeX6o8U51FfvuYAZaHeU8JngAW9dCRXGokLed
         M0MMNVlXt39S9DLnAlXDaphwa/8vs/VdB7PyxiMcR3lc6y9cnixKHdHcHjbV6nHnkz2T
         xoeOAJNiSuCap/UtxAA6i3Bs/LRumqdBQv/c3KH3ZD4hTuznlDYTHRjgIRGLjYKr+TSx
         MX1gRzkVjOANZSn9jyaakEk1N6nGrNDsRp5HA3HiE892AjxVCXsD1GlxuS2GBeP9WQV5
         l5BQ==
Received: by 10.14.225.72 with SMTP id y48mr45876849eep.46.1355122077327;
        Sun, 09 Dec 2012 22:47:57 -0800 (PST)
Received: from w500 ([141.138.0.195])
        by mx.google.com with ESMTPS id f6sm19936363eeo.7.2012.12.09.22.47.55
        (version=SSLv3 cipher=OTHER);
        Sun, 09 Dec 2012 22:47:56 -0800 (PST)
Date:   Mon, 10 Dec 2012 07:51:56 +0100
From:   Luka Perkov <freecwmp@lukaperkov.net>
To:     freecwmp@linux-mips.org
Cc:     jogo@openwrt.org
Subject: Re: [PATCH] simplify function configuration
Message-ID: <20121210065140-27356@mutt-kz>
Mail-Followup-To: freecwmp@linux-mips.org, jogo@openwrt.org
References: <20121210005610-21211@mutt-kz>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20121210005610-21211@mutt-kz>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQnqILkgwSqKezPVWSgIissxfmfIYjreepZYzEE2+RP/vYke3rNicIYyY+hqsfz6d44rnKB/
Return-Path: <freecwmp@lukaperkov.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 145
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: freecwmp@lukaperkov.net
Precedence: bulk
X-list: freecwmp

On Mon, Dec 10, 2012 at 01:56:10AM +0100, Luka Perkov wrote:
> simplify function configuration
> 
> Support for get_ and set_ function prototypes only (for now).
> 
> Signed-off-by: Luka Perkov <freecwmp@lukaperkov.net>
> ---
> --- a/ext/openwrt/scripts/functions/device_hosts
> +++ b/ext/openwrt/scripts/functions/device_hosts
> @@ -189,3 +189,5 @@ fi
>  # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 support yet)
>  
>  }
> +
> +set_device_hosts() { echo -n > /dev/null; }

I was tired last night... return; will do a job just fine:

set_device_hosts() { return; }

Luka

From mohamed.kallel@pivasoftware.com Mon Dec 24 15:54:27 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Mon, 24 Dec 2012 15:54:29 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:55797 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823006Ab2LXOy11Iu9l (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Mon, 24 Dec 2012 15:54:27 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis)
        id 0LkUcJ-1TCi4Y2qmh-00bkIQ; Mon, 24 Dec 2012 15:54:10 +0100
Message-ID: <50D86C90.8070100@pivasoftware.com>
Date:   Mon, 24 Dec 2012 15:54:08 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        jogo@openwrt.org
Subject: Re: [PATCH 02/27] get_parameter values handler from xml is supporting
 many parameters from external ubus output Contributed by Inteno Broadband
 Technology AB && PIVA SOFTWARE
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com> <1354809292-2467-3-git-send-email-mohamed.kallel@pivasoftware.com> <20121208103011-10595@mutt-kz>
In-Reply-To: <20121208103011-10595@mutt-kz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Provags-ID: V02:K0:6JaexD7QqPcW4JDTe/UYHErflBwk9WrbSjGTtAKhbOJ
 q2XyXgfkv8SGFclWSfK8LlS8EqyfnWO1rvnolAqLQQrxI+tmzW
 dv6JKEPwoTE54qq/3RvaJY0lQb82EuHMuSB1ARfeKQ3m4lJyxk
 Y7jWR7syiTnK10kluzJmJYhWcT1VIwaEKGdXj7rfXDaCKOrM7N
 PY+Eybia7tGMlI2SMW1KUW5Vzl4sNywJwiNrPy5aPQGjalsxGa
 EjTFV8V6YaqxOqjz+ZFcpPsu5zROyR5hGI8sYZDM5FMqPwAdpD
 01RwexBgKPi3oCJ/OvMcIll3iCNLqzkv0iJ18nlqDbt3Tf5sCi
 Yu1j7DwqF6ZEbAl8LPHyVsd/zlvfr1pNXi3Ks2cKP
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 146
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Answers and remarks

Le 08/12/2012 11:30, Luka Perkov a écrit :
> Missing commit message. Contributed by must go in commit message and not
> in subject.
>
> On Thu, Dec 06, 2012 at 04:54:27PM +0100, Mohamed wrote:
>> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
>> ---
>>   bin/Makefile.am |    3 +-
>>   configure.ac    |    3 ++
>>   src/external.c  |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   src/external.h  |    6 +++-
>>   src/freecwmp.c  |   17 ++++++++++
>>   src/xml.c       |   66 +++++++++++++++++++++++--------------
>>   6 files changed, 163 insertions(+), 27 deletions(-)
>>
>> diff --git a/bin/Makefile.am b/bin/Makefile.am
>> index 78cb111..ac96905 100644
>> --- a/bin/Makefile.am
>> +++ b/bin/Makefile.am
>> @@ -48,5 +48,6 @@ freecwmpd_LDADD =		\
>>   	$(LIBUBUS_LIBS)		\
>>   	$(MICROXML_LIBS)	\
>>   	$(LIBCURL_LIBS)		\
>> -	$(LIBZSTREAM_LIBS)
>> +	$(LIBZSTREAM_LIBS)	\
>> +	$(LIBPTHREAD_LIBS)
>>   
>> diff --git a/configure.ac b/configure.ac
>> index c646c3a..38d3df4 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
>>   LIBUBUS_LIBS='-lubus'
>>   AC_SUBST([LIBUBUS_LIBS])
>>   
>> +LIBPTHREAD_LIBS='-lpthread'
>> +AC_SUBST([LIBPTHREAD_LIBS])
>> +
> This should go after line 30 and not here:
>
>   30 # checks for libraries
>
>>   AM_COND_IF([HTTP_CURL], [
>>    AC_DEFINE(HTTP_CURL)
>>    PKG_CHECK_MODULES(LIBCURL, [libcurl])
>> diff --git a/src/external.c b/src/external.c
>> index c9c768f..94ae9b8 100644
>> --- a/src/external.c
>> +++ b/src/external.c
>> @@ -25,8 +25,15 @@
>>   #include "freecwmp.h"
>>   
>>   static struct uloop_process uproc;
>> +pthread_t ubus_thread;
>>   LIST_HEAD(external_list_parameter);
>>   
>> +void *thread_uloop_run (void *v)
> No space here "thread_uloop_run(".
>
>> +{
>> +	uloop_run();
>> +	return NULL;
>> +}
>> +
>>   void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
>>   {
>>   	struct external_parameter *external_parameter;
>> @@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name, char *param_data, char *par
>>   	if (fault_code) external_parameter->fault_code = strdup(fault_code);
>>   }
>>   
>> +void external_free_list_parameter()
>> +{
>> +	struct external_parameter *external_parameter;
>> +	while (external_list_parameter.next!=&external_list_parameter) {
> Missing space "next != &external".
>
>> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
>> +		list_del(&external_parameter->list);
>> +		free(external_parameter->name);
>> +		free(external_parameter->data);
>> +		free(external_parameter->type);
>> +		free(external_parameter->fault_code);
>> +		free(external_parameter);
>> +	}
>> +}
>> +
>>   int external_get_action(char *action, char *name, char **value)
>>   {
>>   	freecwmp_log_message(NAME, L_NOTICE,
>> @@ -121,6 +142,80 @@ error:
>>   	return -1;
>>   }
>>   
>> +int external_get_action_write(char *action, char *name, char *arg)
>> +{
>> +	freecwmp_log_message(NAME, L_NOTICE,
>> +		"adding to get %s script '%s'\n", action, name);
>> +
>> +	FILE *fp;
>> +
>> +	if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
>> +		fp = fopen(fc_script_get_actions, "a");
>> +		if (!fp) return -1;
>> +	} else {
>> +		fp = fopen(fc_script_get_actions, "w");
>> +		if (!fp) return -1;
>> +
>> +		fprintf(fp, "#!/bin/sh\n");
>> +
>> +		if (chmod(fc_script_get_actions,
>> +			strtol("0700", 0, 8)) < 0) {
>> +			return -1;
>> +	}
> Wrong indentation.
>
>> +	}
>> +
>> +#ifdef DUMMY_MODE
>> +	fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action, name, arg?arg:"");
>> +#else
>> +	fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name, arg?arg:"");
>> +#endif
> Reformat like in the existing code:
>
> #ifdef DUMMY_MODE
>          fprintf(fp, "/bin/sh `pwd`/%s get %s %s '%s'\n", fc_script, action, name, arg ? arg : "");
> #else
>          fprintf(fp, "/bin/sh %s get %s %s '%s'\n", fc_script, action, name, arg ? arg : "");
> #endif
The arg should not be set under '%s', This is not set parameter it's get 
parameter.
>
>> +
>> +	fclose(fp);
>> +
>> +	return 0;
>> +}
>> +
>> +int external_get_action_execute()
>> +{
>> +	freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
>> +
>> +	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
>> +
>> +	if ((uproc.pid = fork()) == -1) {
>> +		return -1;
>> +	}
>> +
>> +	if (uproc.pid == 0) {
>> +		/* child */
>> +
>> +		const char *argv[3];
>> +		int i = 0;
>> +		argv[i++] = "/bin/sh";
>> +		argv[i++] = fc_script_get_actions;
>> +		argv[i++] = NULL;
>> +
>> +		execvp(argv[0], (char **) argv);
>> +		exit(ESRCH);
>> +
>> +	} else if (uproc.pid < 0)
>> +	return -1;
>> +
>> +	/* parent */
>> +	int status;
>> +	while (wait(&status) != uproc.pid) {
>> +		DD("waiting for child to exit");
>> +	}
>> +
>> +	pthread_cancel(ubus_thread);
>> +	pthread_join(ubus_thread,NULL);
> Missing space.
>
>> +
>> +	// TODO: add some kind of checks
>> +
>> +	remove(fc_script_get_actions);
>> +
>> +	return 0;
>> +}
>> +
>>   int external_set_action_write(char *action, char *name, char *value)
>>   {
>>   	freecwmp_log_message(NAME, L_NOTICE,
>> diff --git a/src/external.h b/src/external.h
>> index 64b4c6b..c6df2ea 100644
>> --- a/src/external.h
>> +++ b/src/external.h
>> @@ -16,7 +16,8 @@ static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
>>   #else
>>   static char *fc_script = "/usr/sbin/freecwmp";
>>   #endif
>> -static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
>> +static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
>> +static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";
> Do we really need both? Why not use just "/tmp/freecwmp_actions.sh"?
>
>>   
>>   struct external_parameter {
>>   	struct list_head list;
>> @@ -27,11 +28,14 @@ struct external_parameter {
>>   };
>>   
>>   int external_get_action(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_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);
>> +void external_free_list_parameter();
>>   
>>   #endif
>>   
>> diff --git a/src/freecwmp.c b/src/freecwmp.c
>> index 4ef8395..f4c9cb1 100644
>> --- a/src/freecwmp.c
>> +++ b/src/freecwmp.c
>> @@ -18,6 +18,7 @@
>>   #include <arpa/inet.h>
>>   #include <linux/netlink.h>
>>   #include <linux/rtnetlink.h>
>> +#include <signal.h>
>>   
>>   #include <libfreecwmp.h>
>>   #include <libubox/uloop.h>
>> @@ -194,11 +195,27 @@ netlink_init(void)
>>   	return 0;
>>   }
>>   
>> +void signal_kill_all_handler(int sig)
>> +{
>> +     pthread_exit(NULL);
> Use tabs and not spaces.
>
>> +}
>> +
>> +
>> +
> Too many new lines.
>
>>   int main (int argc, char **argv)
>>   {
>>   	freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");
>>   
>>   	bool foreground = false;
>> +	struct sigaction sigint_action;
>> +
>> +	sigint_action.sa_handler = &signal_kill_all_handler;
>> +	sigemptyset (&sigint_action.sa_mask);
> No space here.
>
>> +	/* reset handler in case when pthread_cancel didn't stop
>> +	   threads for some reason */
> Use u-boot coding style for multiline comments:
>
> 	/*
> 	 * reset handler in case when pthread_cancel didn't stop
> 	 * threads for some reason
> 	 */
>
>> +	sigint_action.sa_flags = SA_RESETHAND;
>> +	sigaction(SIGTERM, &sigint_action, NULL);
>> +
> Too many new lines.
>
>>   
>>   	setlocale(LC_CTYPE, "");
>>   	umask(0037);
>> diff --git a/src/xml.c b/src/xml.c
>> index 9fa036b..23b9ec7 100644
>> --- a/src/xml.c
>> +++ b/src/xml.c
>> @@ -21,6 +21,8 @@
>>   #include "messages.h"
>>   #include "time.h"
>>   
>> +extern struct list_head external_list_parameter;
>> +
>>   struct rpc_method {
>>   	const char *name;
>>   	int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
>> @@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   				    mxml_node_t *tree_in,
>>   				    mxml_node_t *tree_out)
>>   {
>> -	mxml_node_t *n, *b = body_in;
>> +	mxml_node_t *n, *parameter_list, *b = body_in;
>> +	struct external_parameter *external_parameter;
>>   	char *parameter_name = NULL;
>>   	char *parameter_value = NULL;
>> -	char *c;
>> +	char *c=NULL;
> Missing space. And we don't need to set it to NULL.
>
>>   	int counter = 0;
>>   
>>   	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
>> @@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   		    !strcmp(b->parent->value.element.name, "string")) {
>>   			parameter_name = b->value.text.string;
>>   		}
>> -
> Don't remove newline.
>
>> +		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterValues with empty string*/
> Use multiline comment above if.
>
>> +			!strcmp(b->value.element.name, "string") &&
>> +			!b->child) {
>> +			parameter_name = "";
> Set it to NULL.
in the code we added we make difference between NULL an empty message"". 
For us it's not the same. empty means that we have to return all 
parameter in the data model
>
>> +		}
> Add newline.
>
>>   		if (parameter_name) {
>>   			if (!config_get_cwmp(parameter_name, &parameter_value)) {
>> +				external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);
> Missing spaces.
>
>> +				FREE(parameter_value);
>>   				// got the parameter value using libuci
>> -			} else if (!external_get_action("value",
>> -					parameter_name, &parameter_value)) {
>> +			} else if (!external_get_action_write("value",parameter_name, NULL)) {
> Missing spaces.
>
>>   				// got the parameter value via external script
>>   			} else {
>>   				// error occurred when getting parameter value
>>   				goto out;
>>   			}
>> -			counter++;
>> +		}
>> +		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
>> +		parameter_name = NULL;
>> +	}
>>   
>> -			n = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
>> -			if (!n) goto out;
>> +	if (external_get_action_execute())
>> +		goto out;
>> +
>> +	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
>> +	if (!parameter_list) goto out;
>> +
>> +	while (external_list_parameter.next!=&external_list_parameter) {
> Missing spaces.
>
>> +
>> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
>>   
>> -			n = mxmlNewElement(n, "ParameterValueStruct");
>> +		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
>> +			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code
> Use braces and multiline comment. Make comment more readable.
>
>> +
>> +		n = mxmlNewElement(parameter_list, "ParameterValueStruct");
>>   			if (!n) goto out;
>>   
>>   			n = mxmlNewElement(n, "Name");
>>   			if (!n) goto out;
>>   
>> -			n = mxmlNewText(n, 0, parameter_name);
>> +		n = mxmlNewText(n, 0, external_parameter->name);
> Wrong indentation.
>
>>   			if (!n) goto out;
>>   
>>   			n = n->parent->parent;
>> @@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   			if (!n) goto out;
>>   
>>   #ifdef ACS_MULTI
>> -			mxmlElementSetAttr(n, "xsi:type", "xsd:string");
>> +		mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
> Wrong indentation.
>
>>   #endif
>> -			n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
>> +		n = mxmlNewText(n, 0, external_parameter->data? external_parameter->data : "");
> Wrong indentation. Missing spaces.
>
>>   			if (!n) goto out;
>>   
>> -			/*
>> -			 * three day's work to finally find memory leak if we
>> -			 * free parameter_name;
>> -			 * it points to: b->value.text.string
>> -			 *
>> -			 * also, parameter_value can be NULL so we don't do checks
>> -			 */
>> -			parameter_name = NULL;
>> -		}
>> +		counter++;
>>   		
>> -		FREE(parameter_value);
>> -		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
>> +		list_del(&external_parameter->list);
>> +		free(external_parameter->name);
>> +		free(external_parameter->data);
>> +		free(external_parameter->type);
>> +		free(external_parameter->fault_code);
>> +		free(external_parameter);
>>   	}
>>   
>>   #ifdef ACS_MULTI
>> @@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   	FREE(c);
>>   #endif
>>   
>> -	FREE(parameter_value);
>>   	return 0;
>>   
>>   out:
>> -	FREE(parameter_value);
>> +	external_free_list_parameter();
>>   	return -1;
>>   }
>>   
>> -- 
>> 1.7.4.1
> Luka
>


From mohamed.kallel@pivasoftware.com Mon Dec 24 18:20:45 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Mon, 24 Dec 2012 18:20:47 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:61278 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6822998Ab2LXRUpnhd14 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Mon, 24 Dec 2012 18:20:45 +0100
Received: from [127.0.0.1] ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis)
        id 0MDPjh-1Tqnnd2hht-00GoYZ; Mon, 24 Dec 2012 18:20:39 +0100
Message-ID: <50D88EE4.9020204@pivasoftware.com>
Date:   Mon, 24 Dec 2012 18:20:36 +0100
From:   KALLEL Mohamed <mohamed.kallel@pivasoftware.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com,
        jogo@openwrt.org
Subject: Re: [PATCH 14/27] add xml message get_parameter_name handler. Contributed
 by Inteno Broadband Technology AB & PIVA SOFTWARE
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com> <1354809292-2467-15-git-send-email-mohamed.kallel@pivasoftware.com> <20121208104716-10595@mutt-kz>
In-Reply-To: <20121208104716-10595@mutt-kz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Provags-ID: V02:K0:2/EjTnhMsBgfN5U2VJV7+O6iK8W2JMtFMbrVPIl+26I
 twA+ihiB4c4B8o6QpdNzID1CY+AROyfmtCcDVVETcGEtScZIHk
 k8WiZNFtlG2h5GJ42o5wIo3cVjyeQa9/JzXQboyF80Qzi3G5XJ
 z9Rc5kd0jkz5stKYmAn+Ttw9Sj79jR2fSWZ12u8Cm/jCKZRJfm
 HdWkgNVjhFmX4+eUMCr7bR8R0LWDYpiA4xBDAFEl6tDLs0Ye6O
 +n2jyJ5hQ/TEp2S7mYYjp0yXECbgNvqMidAdHaFqxHpAQecVtY
 7LzfT7f87/U3W71G3GzmgVwjexPdWZPljPLyKjO6duRwwTxhUs
 crQxO1+/tPMyThOWa97N+ft0LelBRGLZWRx1jrz6A
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 147
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Le 08/12/2012 11:47, Luka Perkov a écrit :
> Missing commit message. Contributed by must go in commit message and not
> in subject.
>
> On Thu, Dec 06, 2012 at 04:54:39PM +0100, Mohamed wrote:
>> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
>> ---
>>   src/cwmp.c     |    2 +-
>>   src/external.c |   70 +++++++++++++-----------------------
>>   src/external.h |    3 +-
>>   src/ubus.c     |   39 ++++++++++++++++++++
>>   src/xml.c      |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>   src/xml.h      |    4 ++
>>   6 files changed, 181 insertions(+), 48 deletions(-)
>>
>> diff --git a/src/cwmp.c b/src/cwmp.c
>> index b75c762..7de19e3 100644
>> --- a/src/cwmp.c
>> +++ b/src/cwmp.c
>> @@ -248,7 +248,7 @@ void cwmp_clear_events(void)
>>   void cwmp_add_notification(char *parameter, char *value, char *type)
>>   {
>>   	char *c = NULL;
>> -	external_get_action("notification", parameter, &c);
>> +	external_get_action_data("notification", parameter, &c);
>>   	if (!c) return;
>>   
>>   	struct notification *n = NULL;
>> diff --git a/src/external.c b/src/external.c
>> index 94ae9b8..4973d1a 100644
>> --- a/src/external.c
>> +++ b/src/external.c
>> @@ -60,14 +60,32 @@ void external_free_list_parameter()
>>   	}
>>   }
>>   
>> -int external_get_action(char *action, char *name, char **value)
>> +int external_get_action_data(char *action, char *name, char **value)
>> +{
>> +	struct external_parameter *external_parameter;
>> +	external_get_action(action, name, NULL);
>> +	if (external_list_parameter.next!=&external_list_parameter) {
>> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
>> +		if (external_parameter->data)
>> +			*value = external_parameter->data;
>> +		list_del(&external_parameter->list);
>> +		free(external_parameter->name);
>> +		free(external_parameter->data);
>> +		free(external_parameter->type);
>> +		free(external_parameter->fault_code);
>> +		free(external_parameter);
>> +	}
>> +	external_free_list_parameter();
>> +	return 0;
>> +}
>> +
>> +int external_get_action(char *action, char *name, char *arg /* arg is added for GetParameterNames NextLevel argument*/)
> Comments don't go here.
>
>>   {
>>   	freecwmp_log_message(NAME, L_NOTICE,
>>   			     "executing get %s '%s'\n", action, name);
>>   
>> -	int pfds[2];
>> -	if (pipe(pfds) < 0)
>> -		return -1;
>> +
>> +	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
>>   
>>   	if ((uproc.pid = fork()) == -1)
>>   		goto error;
>> @@ -79,66 +97,28 @@ int external_get_action(char *action, char *name, char **value)
>>   		int i = 0;
>>   		argv[i++] = "/bin/sh";
>>   		argv[i++] = fc_script;
>> -		argv[i++] = "--newline";
>> -		argv[i++] = "--value";
>>   		argv[i++] = "get";
>>   		argv[i++] = action;
>>   		argv[i++] = name;
>> +		if(arg) argv[i++] = arg;
> Missing space. And put a comment here and not inside the function above.
>
>>   		argv[i++] = NULL;
>>   
>> -		close(pfds[0]);
>> -		dup2(pfds[1], 1);
>> -		close(pfds[1]);
>> -
>>   		execvp(argv[0], (char **) argv);
>>   		exit(ESRCH);
>>   
>>   	} else if (uproc.pid < 0)
>>   		goto error;
>>   
>> -	/* parent */
>> -	close(pfds[1]);
>> -
>>   	int status;
>>   	while (wait(&status) != uproc.pid) {
>>   		DD("waiting for child to exit");
>>   	}
>> +	pthread_cancel(ubus_thread);
>> +	pthread_join(ubus_thread,NULL);
> Missing space.
>
>>   
>> -	char buffer[64];
>> -	ssize_t rxed;
>> -	char *c;
>> -	int t;
>> -
>> -	*value = NULL;
>> -	while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
>> -		if (*value)
>> -			t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
>> -		else
>> -			t = asprintf(&c, "%.*s", (int) rxed, buffer);
>> -
>> -		if (t == -1) goto error;
>> -
>> -		free(*value);
>> -		*value = strdup(c);
>> -		free(c);
>> -	}
>> -
>> -	if (!strlen(*value)) {
>> -		FREE(*value);
>> -		goto done;
>> -	}
>> -
>> -	if (rxed < 0)
>> -		goto error;
>> -
>> -done:
>> -	close(pfds[0]);
>>   	return 0;
>>   
>>   error:
>> -	FREE(*c);
>> -	FREE(*value);
>> -	close(pfds[0]);
> If we don't do any cleaning up here there should entire error should be
> removed.
The above element c, value, pfds are not exist any more in the function, 
there is nothing to cleanup here in this function
>
>>   	return -1;
>>   }
>>   
>> diff --git a/src/external.h b/src/external.h
>> index c6df2ea..8e82c39 100644
>> --- a/src/external.h
>> +++ b/src/external.h
>> @@ -27,7 +27,8 @@ struct external_parameter {
>>   	char *fault_code;
>>   };
>>   
>> -int external_get_action(char *action, char *name, char **value);
>> +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);
>> diff --git a/src/ubus.c b/src/ubus.c
>> index 0fd1def..cbf94b0 100644
>> --- a/src/ubus.c
>> +++ b/src/ubus.c
>> @@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *
>>   	return 0;
>>   }
>>   
>> +static enum get_param_names {
>> +	GET_PARAM_NAMES_PARAM,
>> +	GET_PARAM_NAMES_WRITABLE,
>> +	GET_PARAM_NAMES_FAULT,
>> +	__GET_PARAM_NAMES_MAX
>> +};
>> +
>> +static const struct blobmsg_policy get_param_names_policy[] = {
>> +	[GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
>> +	[GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = BLOBMSG_TYPE_STRING },
> I don't like this "writable" parameter as it is now. It should be
> renamed to permissions or something like that. That way we could control
> both read and write.
>
> And why is this BLOBMSG_TYPE_STRING?
The writable is the keyword used in the standard of TR069 So I prefer to 
keep it as defined in the standard. if writabe = 1 (true) that means the 
parameter is writable. And if writable is 0 (false) that means the 
parameter is non writable as mentioned in the standard (Annex A).

And it's a BLOBMSG_TYPE_STRING, because I will set it as string in the 
xml message. and even if there is a check I can make check on the string 
and I do not to convert to int (loose time). the Same thing for similar 
variables
>> +	[GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
>> +};
>> +
>> +static int
>> +freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *obj,
>> +			struct ubus_request_data *req, const char *method,
>> +			struct blob_attr *msg)
>> +{
>> +	struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
>> +
>> +	blobmsg_parse(get_param_names_policy, ARRAY_SIZE(get_param_names_policy), tb,
>> +		      blob_data(msg), blob_len(msg));
>> +
>> +	if (!tb[GET_PARAM_NAMES_PARAM])
>> +		return UBUS_STATUS_INVALID_ARGUMENT;
>> +
>> +	freecwmp_log_message(NAME, L_NOTICE,
>> +			     "triggered ubus get_parameter_names for the parameter %s\n",
>> +			     blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
>> +
>> +	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
>> +			tb[GET_PARAM_NAMES_WRITABLE]? blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
> Missing spaces.
>
>> +			NULL,
>> +			tb[GET_PARAM_NAMES_FAULT]? blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
> Missing spaces.
>
>> +
>> +	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("get_parameter_names", freecwmpd_handle_get_param_names, get_param_names_policy),
>>   };
>>   
>>   static struct ubus_object_type main_object_type =
>> diff --git a/src/xml.c b/src/xml.c
>> index 612c0bb..c735244 100644
>> --- a/src/xml.c
>> +++ b/src/xml.c
>> @@ -51,6 +51,7 @@ static struct cwmp_namespaces
>>   const struct rpc_method rpc_methods[] = {
>>   	{ "SetParameterValues", xml_handle_set_parameter_values },
>>   	{ "GetParameterValues", xml_handle_get_parameter_values },
>> +	{ "GetParameterNames", xml_handle_get_parameter_names },
>>   	{ "SetParameterAttributes", xml_handle_set_parameter_attributes },
>>   	{ "Download", xml_handle_download },
>>   	{ "FactoryReset", xml_handle_factory_reset },
>> @@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   		free(external_parameter->fault_code);
>>   		free(external_parameter);
>>   	}
>> -
>>   #ifdef ACS_MULTI
>>   	b = mxmlFindElement(tree_out, tree_out, "ParameterList",
>>   			    NULL, NULL, MXML_DESCEND);
>> @@ -736,6 +736,115 @@ out:
>>   	return -1;
>>   }
>>   
>> +int xml_handle_get_parameter_names(mxml_node_t *body_in,
>> +				    mxml_node_t *tree_in,
>> +				    mxml_node_t *tree_out)
>> +{
>> +	mxml_node_t *n, *parameter_list, *b = body_in;
>> +	struct external_parameter *external_parameter;
>> +	char *parameter_name = NULL;
>> +	char *NextLevel = NULL;
> All variables must be loverspace separated with underscore. Rename this
> one to next_level.
>
>> +	char *c;
> This variable is used only when ACS_MULTI is set. It should be defined
> bellow just before it's used for the first time.
>
>> +	int counter = 0;
>> +
>> +	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
>> +			    NULL, NULL, MXML_DESCEND);
>> +	if (!n) return -1;
>> +
>> +	n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
>> +	if (!n) return -1;
>> +
>> +	n = mxmlNewElement(n, "ParameterList");
>> +	if (!n) return -1;
>> +
>> +#ifdef ACS_MULTI
>> +	mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
>> +#endif
>> +
>> +	while (b) {
>> +		if (b && b->type == MXML_TEXT &&
>> +			b->value.text.string &&
>> +			b->parent->type == MXML_ELEMENT &&
>> +			!strcmp(b->parent->value.element.name, "ParameterPath")) {
>> +			parameter_name = b->value.text.string;
>> +		}
>> +		if (b && b->type == MXML_ELEMENT && /* added in order to support GetParameterNames with empty ParameterPath*/
> Comments can't be here.
>
>> +			!strcmp(b->value.element.name, "ParameterPath") &&
>> +			!b->child) {
>> +			parameter_name = "";
>> +		}
>> +		if (b && b->type == MXML_TEXT &&
>> +			b->value.text.string &&
>> +			b->parent->type == MXML_ELEMENT &&
>> +			!strcmp(b->parent->value.element.name, "NextLevel")) {
>> +			NextLevel = b->value.text.string;
>> +		}
>> +		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
>> +	}
> Add newline here.
>
>> +	if (parameter_name && NextLevel) {
>> +		if (!external_get_action("name", parameter_name, NextLevel)) {
>> +			// got the parameter value via external script
>> +		} else {
>> +			// error occurred when getting parameter value
>> +			goto out;
>> +		}
> This section needs some rework.
>
>> +	}
>> +
>> +	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
>> +	if (!parameter_list) goto out;
>> +
>> +	while (external_list_parameter.next!=&external_list_parameter) {
> Missing space.
>
>> +
> Remove newline.
>
>> +		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
>> +
>> +		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9')
>> +			goto out; // KMD TODO return FAULT message the fault code is in ->fault_code
> Add braces and update comment.
>
>> +
>> +		n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
>> +		if (!n) goto out;
>> +
>> +		n = mxmlNewElement(n, "Name");
>> +		if (!n) goto out;
>> +
>> +		n = mxmlNewText(n, 0, external_parameter->name);
>> +		if (!n) goto out;
>> +
>> +		n = n->parent->parent;
>> +		n = mxmlNewElement(n, "Writable");
>> +		if (!n) goto out;
>> +
>> +		n = mxmlNewText(n, 0, external_parameter->data);
>> +		if (!n) goto out;
>> +
>> +		counter++;
>> +
>> +		list_del(&external_parameter->list);
>> +		free(external_parameter->name);
>> +		free(external_parameter->data);
>> +		free(external_parameter->type);
>> +		free(external_parameter->fault_code);
>> +		free(external_parameter);
> This I have seen in several places already. This should go into a function then.
>
>> +	}
>> +
>> +#ifdef ACS_MULTI
>> +	b = mxmlFindElement(tree_out, tree_out, "ParameterList",
>> +			    NULL, NULL, MXML_DESCEND);
>> +	if (!b) goto out;
>> +
>> +	if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
>> +		goto out;
>> +
>> +	mxmlElementSetAttr(b, "soap_enc:arrayType", c);
>> +	FREE(c);
>> +#endif
>> +
>> +	return 0;
>> +
>> +out:
>> +	external_free_list_parameter();
>> +	return -1;
>> +}
>> +
>>   static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>>   					       mxml_node_t *tree_in,
>>   					       mxml_node_t *tree_out) {
>> diff --git a/src/xml.h b/src/xml.h
>> index 8f63192..a9191eb 100644
>> --- a/src/xml.h
>> +++ b/src/xml.h
>> @@ -26,6 +26,10 @@ static int xml_handle_get_parameter_values(mxml_node_t *body_in,
>>   					   mxml_node_t *tree_in,
>>   					   mxml_node_t *tree_out);
>>   
>> +static int xml_handle_get_parameter_names(mxml_node_t *body_in,
>> +					   mxml_node_t *tree_in,
>> +					   mxml_node_t *tree_out);
>> +
>>   static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
>>   					       mxml_node_t *tree_in,
>>   					       mxml_node_t *tree_out);
>> -- 
>> 1.7.4.1
> Luka
>


From ahmed.zribi@pivasoftware.com Tue Dec 25 11:48:41 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Tue, 25 Dec 2012 11:48:46 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.9]:60025 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823018Ab2LYKsle64We convert rfc822-to-8bit
        (ORCPT <rfc822;freecwmp@linux-mips.org>);
        Tue, 25 Dec 2012 11:48:41 +0100
Received: from [127.0.0.1] ([41.230.29.57])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MCk6A-1Twpyf00sE-009Ppv; Tue, 25 Dec 2012 11:48:35 +0100
Message-ID: <50D9847C.3090601@pivasoftware.com>
Date:   Tue, 25 Dec 2012 11:48:28 +0100
From:   Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Reply-To: ahmed.zribi@pivasoftware.com
Organization: PIVA Software
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        jogo@openwrt.org
Subject: Re: [PATCH 03/27] add in the scripts the functions needed to communicate
 data to ubus handler for the get_parameter_values ubus handler Contributed
 by Inteno Broadband Technology AB
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com> <1354809292-2467-4-git-send-email-mohamed.kallel@pivasoftware.com> <20121208103240-10595@mutt-kz>
In-Reply-To: <20121208103240-10595@mutt-kz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
X-Provags-ID: V02:K0:vYq7uiJstn/FpLXWuowwM/43VsLqeyZ4nxHhnr9t7Jo
 YhnnA73YaI2J1JVbShcl/0uhmYnOrp6ZJUAf9Mn1FeD9ID5POc
 sYRkqCRlJGvbHKqm95QQbd0ysGDtAyF828Te2RxmCNT8N7yA6U
 J2DB5x8cP6NX4JHNTH6gmjBD/qfT0YFNGtCYzaPNNlaFG7tGOC
 N/+xlwYfP8f5yEU5c87zhjgFfqD88jDuDNJk+VxC1NkqwTwqYM
 50Wp0RJWSp/hPyfK+8/U6jOYBzXZvfhPcJAl002CsoY/UMSExk
 /odsiMhv8ji8TVq9CmUvJz08fOwXc2Yz0k0YTuS1gZGz4yeisO
 or6lwJqk6b/vhf1avaL+lgCvE0prfSr2lPohRldTK
Return-Path: <ahmed.zribi@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 148
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: ahmed.zribi@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Le 08/12/2012 11:32, Luka Perkov a écrit :
> Missing commit message. Contributed by must go in commit message and not
> in subject.
>
> On Thu, Dec 06, 2012 at 04:54:28PM +0100, Mohamed wrote:
>> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
>> ---
>>   ext/openwrt/scripts/freecwmp.sh      |   51 ++++++++++++++++++++++++++++------
>>   ext/openwrt/scripts/functions/common |   23 +++++++++++++++
>>   2 files changed, 65 insertions(+), 9 deletions(-)
>>
>> diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
>> index ccab19f..f2bebc8 100644
>> --- a/ext/openwrt/scripts/freecwmp.sh
>> +++ b/ext/openwrt/scripts/freecwmp.sh
>> @@ -113,21 +113,54 @@ handle_scripts() {
>>   config_load freecwmp
>>   config_foreach handle_scripts "scripts"
>>   
>> +# Fault code
> Rename to "Fault codes".
>
>> +
>> +FAULT_CPE_NO_FAULT="0"
> We don't need this one. Use 0 when you need it.
>
>> +FAULT_CPE_REQUEST_DENIED="1"
>> +FAULT_CPE_INTERNAL_ERROR="2"
>> +FAULT_CPE_INVALID_ARGUMENTS="3"
>> +FAULT_CPE_RESOURCES_EXCEEDED="4"
>> +FAULT_CPE_INVALID_PARAMETER_NAME="5"
>> +FAULT_CPE_INVALID_PARAMETER_TYPE="6"
>> +FAULT_CPE_INVALID_PARAMETER_VALUE="7"
>> +FAULT_CPE_NON_WRITABLE_PARAMETER="8"
>> +FAULT_CPE_NOTIFICATION_REJECTED="9"
>> +FAULT_CPE_DOWNLOAD_FAILURE="10"
>> +FAULT_CPE_UPLOAD_FAILURE="11"
>> +FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
>> +FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
>> +FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
>> +FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
>> +FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
>> +FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
>> +FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
>> +FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
> Rename it from "FAULT_CPE_" to "E_". Also, why didn't you use error codes from
> the standard?
On OpenWrt, return values are interpreted as modulo 256. Since 9003 mod 256 is 43, and 9005 mod 256 equals 45, you get these return values, respectively.
>
> Error codes should also be added in libfreecwmp. I saw that you are using them
> in freecwmp core too.
We will add error codes in next patches
>> +
>>   if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
>> -	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
> NACK. You don't need to remove this.
>
>> +    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 $get_value_functions
>>   	do
>>   		$function_name "$__arg1"
>> +				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
>> +        ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
>> +    fi
>>   fi
>>   
>>   if [ "$action" = "set_value" ]; then
>> diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
>> index 7e3000a..082e067 100644
>> --- a/ext/openwrt/scripts/functions/common
>> +++ b/ext/openwrt/scripts/functions/common
>> @@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE} ]; then
>>   fi
>>   }
>>   
>> +ubus_freecwmp_output() {
> Rename to freecwmp_ubus_output. Also, this needs to be integrated with
> freecwmp_output function. More about that in other comments.
>
>> +local parameter="$1"
>> +local value="$2"
>> +local type="$3"
>> +local fault_code="$4"
>> +
>> +if [ "$type" = "" ]; then
>> +	type="xsd:string"
>> +fi
>> +
>> +case "$action" in
>> +	get_value)
>> +	ubus call tr069 get_parameter_values '{"parameter": "'$parameter'", "value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}' 2> /dev/null
> This needs to be used like the uci command:
>
> /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}
>
> You need to pass optional parameter to ubus command where the socket is
> located.
>
>> +	;;
>> +esac
>> +}
> Missing newline.
>
>>   freecwmp_value_output() {
>>   	freecwmp_output "$1" "$2" "V"
>>   }
>> @@ -249,3 +265,10 @@ EOF
>>   	sh "$lock" &
>>   fi
>>   }
>> +
>> +freecwmp_check_fault() {
>> +if [ "$1" = "." ]; then
>> +	return $FAULT_CPE_INVALID_PARAMETER_NAME
>> +fi
>> +return $FAULT_CPE_NO_FAULT
>> +}
>> -- 
>> 1.7.4.1
> Luka
>



From ahmed.zribi@pivasoftware.com Tue Dec 25 17:51:43 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Tue, 25 Dec 2012 17:51:47 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.8]:65214 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823018Ab2LYQvnPNdkC convert rfc822-to-8bit
        (ORCPT <rfc822;freecwmp@linux-mips.org>);
        Tue, 25 Dec 2012 17:51:43 +0100
Received: from [127.0.0.1] ([41.230.29.57])
        by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis)
        id 0M2puc-1SyCDz1EZS-00sWZr; Tue, 25 Dec 2012 17:51:37 +0100
Message-ID: <50D9D98D.90601@pivasoftware.com>
Date:   Tue, 25 Dec 2012 17:51:25 +0100
From:   Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
Reply-To: ahmed.zribi@pivasoftware.com
Organization: PIVA Software
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To:     freecwmp@lukaperkov.net
CC:     mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org,
        jogo@openwrt.org
Subject: Re: [PATCH 16/27] update the script device_info in order to output
 parameters with ubus Contributed by Inteno Broadband Technology AB
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com> <1354809292-2467-17-git-send-email-mohamed.kallel@pivasoftware.com> <20121208105112-10595@mutt-kz>
In-Reply-To: <20121208105112-10595@mutt-kz>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
X-Provags-ID: V02:K0:PagQFXLUrmKKe8P8qVVc6Lk8wt7SAml71NfE8rJW96E
 T0/JDKnCGVL5Oku13x0NuS94N5aA+m9GWMtRIqWmtki8dAKe9N
 TMQwU03vxadPtS3RD20XNLeKB+0haMNiMcZBE/7MV6tT/cVbPA
 x2M4HgErDkhSL1I+t1tWBRxYlNRgpuXm0pysuLuxRCgVqYtICL
 A0dr5EVcN4Y9cE1eZvArhW/kElsX5hVa933fNBuTfijanzkVJJ
 do/2I0GW+mjKA4hxmBOA6P6h3mg43K3aI5dmb3yn6smjiuWwtz
 GTmINH5bNrzbfWpruit06M7bN8SfFQfPNn43N30TzeY8ZtE2kW
 TDpWc5e13p92mitFQEHI=
Return-Path: <ahmed.zribi@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 149
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: ahmed.zribi@pivasoftware.com
Precedence: bulk
X-list: freecwmp


Le 08/12/2012 11:51, Luka Perkov a écrit :
> Missing commit message. Contributed by must go in commit message and not
> in subject.
>
> On Thu, Dec 06, 2012 at 04:54:41PM +0100, Mohamed wrote:
>> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
>> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
>> ---
>>   ext/openwrt/scripts/functions/device_info |  199 +++++++++++++++++++++++++++--
>>   1 files changed, 187 insertions(+), 12 deletions(-)
>>
>> diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
>> index 86ff5c9..c3c6c33 100644
>> --- a/ext/openwrt/scripts/functions/device_info
>> +++ b/ext/openwrt/scripts/functions/device_info
>> @@ -2,7 +2,15 @@
>>   # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
>>   
>>   get_device_info_manufacturer() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].manufacturer 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
> I don't like this... Tell us what why you use val? Why is it 0? What does that
> mean? Generally all this information must go in commit message.
GetParameterNamesResponse must contain the parameter name and the permission ("writable" tag in soap message), in the cwmp standard "0" means the parameter is not writable; "1" means the parameter is 
writable.
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
> We should have something like:
>
> freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val" "$permissions" "$type" "$fault_code"
>
> Same goes for all other changes.
>
>>   }
>>   
>> @@ -11,7 +19,15 @@ set_device_info_manufacturer() {
>>   }
>>   
>>   get_device_info_oui() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].oui 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
>>   }
>>   
>> @@ -20,7 +36,15 @@ set_device_info_oui() {
>>   }
>>   
>>   get_device_info_product_class() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].product_class 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"	
>>   }
>>   
>> @@ -29,7 +53,15 @@ set_device_info_product_class() {
>>   }
>>   
>>   get_device_info_serial_number() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].serial_number 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	local val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
>>   }
>>   
>> @@ -38,7 +70,15 @@ set_device_info_serial_number() {
>>   }
>>   
>>   get_device_info_hardware_version() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].hardware_version 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
>>   }
>>   
>> @@ -47,7 +87,15 @@ set_device_info_hardware_version() {
>>   }
>>   
>>   get_device_info_software_version() {
>> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get freecwmp.@device[0].software_version 2> /dev/null`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
>>   }
>>   
>> @@ -56,17 +104,32 @@ set_device_info_software_version() {
>>   }
>>   
>>   get_device_info_uptime() {
>> -local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
>> +local val=""
>> +case "$action" in
>> +	get_value)
>> +	val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
>>   }
>>   
>>   get_device_info_device_log() {
>>   local val=""
>> -if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
>> -	val=`dmesg | tail -n1`
>> -else
>> -	val=`dmesg | tail -n10`
>> -fi
>> +case "$action" in
>> +	get_value)
>> +	if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
>> +		val=`dmesg | tail -n1`
>> +	else
>> +		val=`dmesg | tail -n10`
>> +	fi
>> +	;;
>> +	get_name)
>> +	val="0"
>> +	;;
>> +esac
>>   ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
>>   }
>>   
>> @@ -130,6 +193,94 @@ esac
>>   return $FAULT_CPE_INVALID_PARAMETER_NAME
>>   }
>>   
>> +get_device_info_name() {
>> +case "$1" in
>> +	InternetGatewayDevice.)
>> +	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
>> +	if [ "$2" = "0" ]; then
>> +		get_device_info_manufacturer
>> +		get_device_info_oui
>> +		get_device_info_product_class
>> +		get_device_info_serial_number
>> +		get_device_info_hardware_version
>> +		get_device_info_software_version
>> +		get_device_info_uptime
>> +		get_device_info_device_log
>> +	fi
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.)
>> +	ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
>> +	get_device_info_manufacturer
>> +	get_device_info_oui
>> +	get_device_info_product_class
>> +	get_device_info_serial_number
>> +	get_device_info_hardware_version
>> +	get_device_info_software_version
>> +	get_device_info_uptime
>> +	get_device_info_device_log
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.Manufacturer)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_manufacturer
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_oui
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.ProductClass)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_product_class
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.SerialNumber)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_serial_number
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.HardwareVersion)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_hardware_version
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_software_version
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.UpTime)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_uptime
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.DeviceLog)
>> +	if [ "$2" = "1" ]; then
>> +		return $FAULT_CPE_INVALID_ARGUMENTS
>> +	fi
>> +	get_device_info_device_log
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +esac
>> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>> +}
>> +
>>   set_device_info() {
>>   case "$1" in
>>   	InternetGatewayDevice.DeviceInfo.Manufacturer)
>> @@ -179,6 +330,30 @@ get_device_info_generic() {
>>   	return $FAULT_CPE_NO_FAULT
>>   }
>>   
>> +get_device_info_generic_name() {
>> +	local val=""
>> +	case "$1" in
>> +	InternetGatewayDevice.DeviceInfo.ModelName|\
>> +	InternetGatewayDevice.DeviceInfo.Description|\
>> +	InternetGatewayDevice.DeviceInfo.ModemFirmwareVersion|\
>> +	InternetGatewayDevice.DeviceInfo.EnabledOptions|\
>> +	InternetGatewayDevice.DeviceInfo.AdditionalHardwareVersion|\
>> +	InternetGatewayDevice.DeviceInfo.AdditionalSoftwareVersion|\
>> +	InternetGatewayDevice.DeviceInfo.SpecVersion|\
>> +	InternetGatewayDevice.DeviceInfo.FirstUseDate)
>> +	val="0"
>> +	ubus_freecwmp_output "$1" "$val"
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	InternetGatewayDevice.DeviceInfo.ProvisioningCode)
>> +	val="1"
>> +	ubus_freecwmp_output "$1" "$val"
>> +	return $FAULT_CPE_NO_FAULT
>> +	;;
>> +	esac
>> +return $FAULT_CPE_INVALID_PARAMETER_NAME
>> +}
>> +
>>   set_device_info_generic() {
>>   	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
>>   
>> -- 
>> 1.7.4.1
> Luka
>



From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:40 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:02:44 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:58523 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823072Ab2L1QCkJzhqn (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:40 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0Lj8u3-1TCGlb3TTj-00dTne; Fri, 28 Dec 2012 17:02:33 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 01/10] Add ubus listner get_parameter_values.
Date:   Fri, 28 Dec 2012 16:59:38 +0100
Message-Id: <1356710387-3043-2-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:zB4y9QFDZ2Uy8Aahy6kY2wdzr2knhz/d/UEXberrXJX
 chn1ISvtGGjsmEEZDumebaYVDV+/V1VBeN37d7FRYFJffXHO3Y
 v6xwP94ms7u7g3t11cNbrMxb3nTKTIIO8maS+YTKRXgCNjNXW/
 JrMtwbaY2VEhfJy901fAw/bfAWtoLs2DqCK/xdeKa5vlBujANd
 903nor2ruE4Fcippe7Nuyso9rIz3Dz6KRCrFiwXM0NqRQj2UnG
 sCX9pmxGCQ757+proFpnLaQ4b2L+/6IB6+2qoNlsdMsD/9ZzJb
 Wmw2qCnpg8v6iGtJjFFP3DqK9hmvuT1VYhk7zhHfB3J4uJauH8
 0m4Y4EyiO0uvb2QgacGRPuTzLNMUx1RF6rq31O5DbQ1MfkKt5g
 840763Sf9HhPMCfA8HLxPMOcCQdo/0gO9l3PEfTFGqKPPm4Zf0
 4w85q
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 150
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

The  ubus listner get_parameter_values  allows to get the freecwmp output from extenal command.
Contributed by Inteno Broadband Technology AB/

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 src/external.c |   32 ++++++++++++++++++++++++++++++++
 src/external.h |   16 ++++++++++++++++
 src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/src/external.c b/src/external.c
index 2abed40..46a4931 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,6 +25,38 @@
 #include "freecwmp.h"
 
 static struct uloop_process uproc;
+LIST_HEAD(external_list_parameter);
+
+void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
+{
+	struct external_parameter *external_parameter;
+	struct list_head *ilist; int i =0;
+	external_parameter = calloc(1, sizeof(struct external_parameter));
+	list_add_tail(&external_parameter->list, &external_list_parameter);
+	if (param_name) external_parameter->name = strdup(param_name);
+	if (param_data) external_parameter->data = strdup(param_data);
+	if (param_type) external_parameter->type = strdup(param_type);
+	if (fault_code) external_parameter->fault_code = strdup(fault_code);
+}
+
+void external_parameter_delete(struct external_parameter *external_parameter)
+{
+	list_del(&external_parameter->list);
+	free(external_parameter->name);
+	free(external_parameter->data);
+	free(external_parameter->type);
+	free(external_parameter->fault_code);
+	free(external_parameter);
+}
+
+void external_free_list_parameter()
+{
+	struct external_parameter *external_parameter;
+	while (external_list_parameter.next != &external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		external_parameter_delete(external_parameter);
+	}
+}
 
 int external_get_action(char *action, char *name, char **value)
 {
diff --git a/src/external.h b/src/external.h
index 8606266..0e09415 100644
--- a/src/external.h
+++ b/src/external.h
@@ -9,6 +9,7 @@
 
 #ifndef _FREECWMP_EXTERNAL_H__
 #define _FREECWMP_EXTERNAL_H__
+#include <libubox/list.h>
 
 #ifdef DUMMY_MODE
 static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
@@ -17,11 +18,26 @@ static char *fc_script = "/usr/sbin/freecwmp";
 #endif
 static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
 
+/*
+ * external_parameter structure is used to get data from external command when a parameter method is triggered
+ * The (*data) is used as notification for GetParameterAttribute; as writable for GetParameterNames; as value for GetParameterValues
+ */
+struct external_parameter {
+	struct list_head list;
+	char *name;
+	char *data;
+	char *type;
+	char *fault_code;
+};
+
 int external_get_action(char *action, char *name, char **value);
 int external_set_action_write(char *action, char *name, char *value);
 int external_set_action_execute();
 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);
+void external_free_list_parameter();
+void external_parameter_delete(struct external_parameter *external_parameter);
 
 #endif
 
diff --git a/src/ubus.c b/src/ubus.c
index 13f0a54..3cc3c69 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -16,6 +16,7 @@
 #include "config.h"
 #include "cwmp.h"
 #include "freecwmp.h"
+#include "external.h"
 
 static struct ubus_context *ctx = NULL;
 static struct ubus_object main_object;
@@ -155,10 +156,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
 	return 0;
 }
 
+static enum get_param_values {
+	GET_PARAM_VALUES_PARAM,
+	GET_PARAM_VALUES_VALUE,
+	GET_PARAM_VALUES_TYPE,
+	GET_PARAM_VALUES_FAULT,
+	__GET_PARAM_VALUES_MAX
+};
+
+static const struct blobmsg_policy get_param_values_policy[] = {
+	[GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_VALUES_MAX];
+
+	blobmsg_parse(get_param_values_policy, ARRAY_SIZE(get_param_values_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_VALUES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	lfc_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_values for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
+			tb[GET_PARAM_VALUES_VALUE] ? blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,
+			tb[GET_PARAM_VALUES_TYPE] ? blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",
+			tb[GET_PARAM_VALUES_FAULT] ? blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);
+
+	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),
 };
 
 static struct ubus_object_type main_object_type =
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:45 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:02:48 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:65486 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823080Ab2L1QCkKZ7At (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:40 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MbX2O-1TVr5H45UC-00InDl; Fri, 28 Dec 2012 17:02:32 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Subject: [PATCH v2 00/10] Data model with ubus and add get parameter names method
Date:   Fri, 28 Dec 2012 16:59:37 +0100
Message-Id: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
X-Provags-ID: V02:K0:l1iknzBdC7ZYMD4TKCQiO5rlEaf20J3ZlYs4fDL1RcE
 rL+ix8SOxdmMCvnHi67GUUGRB3LfudWFbT8/KUFzra1DCuKHxf
 agqs8xJkPHP8bapaNr2/x+DMGHL7MRT9ls78+TthB77Op/fWMa
 ShsPv1X7c8ByaXqnQOnKf9nN2wsHtx+f54TUDBGDDxoEWIW4g+
 K9x1k/iP2+PJEVQUqJdANtuTl95nJhagszzwTrq5eiOE0JtK7p
 50uTWlyJq69Ut2W0cKUV++zuwRICC7ZacCmrDvVFOXw31JqiBd
 yWUAwZxRZtmN8ZlRAH4br3J7nxg0j88pN3hURBnnDf/9B1l9x5
 soSH1+KWh7gmMJaoMZbmsZtBvDuvEGbhxF0K8eoJ7vKIMzY2Et
 Ix4YDEtAM/PuF/QL/ZT7Z5kBCmVBJ+pdgm7mmMXc7OmLziHzF/
 74e5a
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 151
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

Hi Luka

Please, find here after the patches updated with your remarks.
Note that I have reduced the number of patches to 10 instead of 27

Just to remeber you, As summary, The following patches contains:
  communication from script to the core via ubus
  GetParameterValues method supporting many parameters
  GetParameterNames method added

Regards
Mohamed Kallel

Mohamed (10):
  Add ubus listner get_parameter_values.
  get_parameter_values method support many parameter names
  Update scripts in order to send data from external script to the core
    via ubus
  Update inform in order to get parameters from ubus
  Add 3rd argument in the ubus handler of notification.
  Add xml_get_parameter_name handler.
  Adapt the scripts in order to support get parameter names
  Use ubus for get notification
  Use ubus for set parameter values
  Use ubus for set parameter attribute

 bin/Makefile.am                                 |    3 +-
 configure.ac                                    |    3 +
 ext/openwrt/scripts/freecwmp.sh                 |  215 ++++++-
 ext/openwrt/scripts/functions/common            |  162 +++++-
 ext/openwrt/scripts/functions/device_hosts      |   12 +-
 ext/openwrt/scripts/functions/device_info       |  356 ++++++++++-
 ext/openwrt/scripts/functions/device_ip         |   11 +-
 ext/openwrt/scripts/functions/device_routing    |   11 +-
 ext/openwrt/scripts/functions/device_users      |   10 +-
 ext/openwrt/scripts/functions/lan_device        |  233 ++++++-
 ext/openwrt/scripts/functions/management_server |  805 ++++++++++++++++++++---
 ext/openwrt/scripts/functions/misc              |   17 +-
 ext/openwrt/scripts/functions/wan_device        |  433 +++++++++++-
 src/cwmp.c                                      |    4 +-
 src/cwmp.h                                      |    2 +-
 src/external.c                                  |  238 ++++++--
 src/external.h                                  |   30 +-
 src/freecwmp.c                                  |   17 +
 src/ubus.c                                      |  234 +++++++-
 src/xml.c                                       |  285 ++++++--
 src/xml.h                                       |    4 +
 21 files changed, 2759 insertions(+), 326 deletions(-)

-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:50 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:02:51 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:59031 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823083Ab2L1QCnYSx5Y (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:43 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0LnYkN-1T7t2s48Ex-00hrWM; Fri, 28 Dec 2012 17:02:34 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 02/10]  get_parameter_values method support many parameter names
Date:   Fri, 28 Dec 2012 16:59:39 +0100
Message-Id: <1356710387-3043-3-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:YiqXGezkkGHwQvF5E8I06sbyIiD7MJYIjc/SEXTTQXE
 APzoJ5KcG7mdQRt3bsQV2GMWv9uDXg9QhNhpSg+mL58+RXMnUf
 Q12DrZHu/Ls6kDB3F4fdlzi4aeI0Tpo67RXGQtixPqf1kpobjz
 hsUFksFoa1JJgH+FtJ774ZbCHz6sTCUgVOqfYnpqZGu+60Rg/4
 oSQBJnHU1ZwPhO5IpG+9/3Cipj8/NS+IHkbLZTscUuwtIjU3ce
 l8dYr7lvkVan/elbBjDxFaM+jZYJL/VW3VXoaLTnNgQaiDTx/L
 4nlwVCi0h6sJn5G8qK+VPGhRH33CtkGSfzMWrQg8QMb2TpXs55
 84eS2qGc+woBaynipmpHBSLqaEaQMJB1O3tNERfrs3vD4wBNDL
 FNkP4Bh0zGmNV0dGjlgWs+k7ajLP+BuUqbbu7ZIVZRoY1/J9ho
 YqMnq
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 152
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

The xml get_parameter_values handler is ready to get the value from external ubus output now. and  is supporting many parameters
Contributed by Inteno Broadband Technology AB && PIVA SOFTWARE

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 bin/Makefile.am |    3 +-
 configure.ac    |    3 ++
 src/external.c  |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 src/external.h  |    5 ++-
 src/freecwmp.c  |   17 ++++++++++
 src/xml.c       |   81 +++++++++++++++++++++++++++++------------------
 6 files changed, 164 insertions(+), 39 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 75b9bda..9078ab3 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,5 +48,6 @@ freecwmpd_LDADD =		\
 	$(LIBUBUS_LIBS)		\
 	$(MICROXML_LIBS)	\
 	$(LIBCURL_LIBS)		\
-	$(LIBZSTREAM_LIBS)
+	$(LIBZSTREAM_LIBS)	\
+	$(LIBPTHREAD_LIBS)
 
diff --git a/configure.ac b/configure.ac
index 5ae95c4..765bfe0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,9 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 
 # checks for libraries
+LIBPTHREAD_LIBS='-lpthread'
+AC_SUBST([LIBPTHREAD_LIBS])
+
 AC_ARG_WITH([libfreecwmp-include-path],
   [AS_HELP_STRING([--with-libfreecwmp-include-path],
     [location of the libfreecwmp library headers])],
diff --git a/src/external.c b/src/external.c
index 46a4931..44be0b6 100644
--- a/src/external.c
+++ b/src/external.c
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <errno.h>
@@ -25,8 +26,15 @@
 #include "freecwmp.h"
 
 static struct uloop_process uproc;
+pthread_t ubus_thread;
 LIST_HEAD(external_list_parameter);
 
+void *thread_uloop_run(void *v)
+{
+	uloop_run();
+	return NULL;
+}
+
 void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code)
 {
 	struct external_parameter *external_parameter;
@@ -140,6 +148,80 @@ error:
 	return -1;
 }
 
+int external_get_action_write(char *action, char *name, char *arg)
+{
+	lfc_log_message(NAME, L_NOTICE, "adding to get %s script '%s'\n",
+			action, name);
+
+	FILE *fp;
+
+	if (access(fc_script_actions, R_OK | W_OK | X_OK) != -1) {
+		fp = fopen(fc_script_actions, "a");
+		if (!fp) return -1;
+	} else {
+		fp = fopen(fc_script_actions, "w");
+		if (!fp) return -1;
+
+		fprintf(fp, "#!/bin/sh\n");
+
+		if (chmod(fc_script_actions,
+			strtol("0700", 0, 8)) < 0) {
+			return -1;
+		}
+	}
+
+#ifdef DUMMY_MODE
+	fprintf(fp, "/bin/sh `pwd`/%s --ubus get %s %s %s\n", fc_script, action, name, arg ? arg : "");
+#else
+	fprintf(fp, "/bin/sh %s --ubus get %s %s %s\n", fc_script, action, name, arg ? arg : "");
+#endif
+
+	fclose(fp);
+
+	return 0;
+}
+
+int external_get_action_execute()
+{
+	lfc_log_message(NAME, L_NOTICE, "executing get script\n");
+
+	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
+
+	if ((uproc.pid = fork()) == -1) {
+		return -1;
+	}
+
+	if (uproc.pid == 0) {
+		/* child */
+
+		const char *argv[3];
+		int i = 0;
+		argv[i++] = "/bin/sh";
+		argv[i++] = fc_script_actions;
+		argv[i++] = NULL;
+
+		execvp(argv[0], (char **) argv);
+		exit(ESRCH);
+
+	} else if (uproc.pid < 0)
+	return -1;
+
+	/* parent */
+	int status;
+	while (wait(&status) != uproc.pid) {
+		DD("waiting for child to exit");
+	}
+
+	pthread_cancel(ubus_thread);
+	pthread_join(ubus_thread, NULL);
+
+	// TODO: add some kind of checks
+
+	remove(fc_script_actions);
+
+	return 0;
+}
+
 int external_set_action_write(char *action, char *name, char *value)
 {
 	lfc_log_message(NAME, L_NOTICE, "adding to set %s script '%s'\n",
@@ -147,16 +229,16 @@ int external_set_action_write(char *action, char *name, char *value)
 
 	FILE *fp;
 
-	if (access(fc_script_set_actions, R_OK | W_OK | X_OK) != -1) {
-		fp = fopen(fc_script_set_actions, "a");
+	if (access(fc_script_actions, R_OK | W_OK | X_OK) != -1) {
+		fp = fopen(fc_script_actions, "a");
 		if (!fp) return -1;
 	} else {
-		fp = fopen(fc_script_set_actions, "w");
+		fp = fopen(fc_script_actions, "w");
 		if (!fp) return -1;
 
 		fprintf(fp, "#!/bin/sh\n");
 
-		if (chmod(fc_script_set_actions,
+		if (chmod(fc_script_actions,
 			strtol("0700", 0, 8)) < 0) {
 			return -1;
 		}
@@ -187,7 +269,7 @@ int external_set_action_execute()
 		const char *argv[3];
 		int i = 0;
 		argv[i++] = "/bin/sh";
-		argv[i++] = fc_script_set_actions;
+		argv[i++] = fc_script_actions;
 		argv[i++] = NULL;
 
 		execvp(argv[0], (char **) argv);
@@ -204,7 +286,7 @@ int external_set_action_execute()
 
 	// TODO: add some kind of checks
 
-	if (remove(fc_script_set_actions) != 0)
+	if (remove(fc_script_actions) != 0)
 		return -1;
 
 	return 0;
diff --git a/src/external.h b/src/external.h
index 0e09415..f69fb34 100644
--- a/src/external.h
+++ b/src/external.h
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #ifndef _FREECWMP_EXTERNAL_H__
@@ -16,7 +17,7 @@ static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
 #else
 static char *fc_script = "/usr/sbin/freecwmp";
 #endif
-static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
+static char *fc_script_actions = "/tmp/freecwmp_actions.sh";
 
 /*
  * external_parameter structure is used to get data from external command when a parameter method is triggered
@@ -31,6 +32,8 @@ struct external_parameter {
 };
 
 int external_get_action(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_simple(char *arg);
diff --git a/src/freecwmp.c b/src/freecwmp.c
index d311cf4..0ad0e94 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -18,6 +18,7 @@
 #include <arpa/inet.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
+#include <signal.h>
 
 #include <libfreecwmp.h>
 #include <libubox/uloop.h>
@@ -194,11 +195,27 @@ netlink_init(void)
 	return 0;
 }
 
+void signal_kill_all_handler(int sig)
+{
+	pthread_exit(NULL);
+}
+
 int main (int argc, char **argv)
 {
 	lfc_log_message(NAME, L_NOTICE, "daemon started\n");
 
 	bool foreground = false;
+	struct sigaction sigint_action;
+
+	sigint_action.sa_handler = &signal_kill_all_handler;
+	sigemptyset(&sigint_action.sa_mask);
+
+	/*
+	 * reset handler in case when pthread_cancel didn't stop
+	 * threads for some reason
+	 */
+	sigint_action.sa_flags = SA_RESETHAND;
+	sigaction(SIGTERM, &sigint_action, NULL);
 
 	setlocale(LC_CTYPE, "");
 	umask(0037);
diff --git a/src/xml.c b/src/xml.c
index 0aa4f35..f89fd3c 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -21,6 +21,8 @@
 #include "messages.h"
 #include "time.h"
 
+extern struct list_head external_list_parameter;
+
 struct rpc_method {
 	const char *name;
 	int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
@@ -628,7 +630,8 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 				    mxml_node_t *tree_in,
 				    mxml_node_t *tree_out)
 {
-	mxml_node_t *n, *b = body_in;
+	mxml_node_t *n, *parameter_list, *b = body_in;
+	struct external_parameter *external_parameter;
 	char *parameter_name = NULL;
 	char *parameter_value = NULL;
 	char *c;
@@ -656,54 +659,71 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 			parameter_name = b->value.text.string;
 		}
 
+		/*
+		 * If the string node from GetParameterValues does not contain child node (txt node)
+		 * Then the parameter name is empty string which means get all parameters from the data model
+		 */
+		if (b && b->type == MXML_ELEMENT &&
+			!strcmp(b->value.element.name, "string") &&
+			!b->child) {
+			parameter_name = "";
+		}
+
 		if (parameter_name) {
 			if (!config_get_cwmp(parameter_name, &parameter_value)) {
+				external_add_list_paramameter(parameter_name,parameter_value, "xsd:string", NULL);
+				FREE(parameter_value);
 				// got the parameter value using libuci
-			} else if (!external_get_action("value",
-					parameter_name, &parameter_value)) {
+			} else if (!external_get_action_write("value", parameter_name, NULL)) {
 				// got the parameter value via external script
 			} else {
 				// error occurred when getting parameter value
 				goto out;
 			}
-			counter++;
+		}
 
-			n = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
-			if (!n) goto out;
+		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+		parameter_name = NULL;
+	}
 
-			n = mxmlNewElement(n, "ParameterValueStruct");
-			if (!n) goto out;
+	if (external_get_action_execute())
+		goto out;
 
-			n = mxmlNewElement(n, "Name");
-			if (!n) goto out;
+	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
+	if (!parameter_list) goto out;
 
-			n = mxmlNewText(n, 0, parameter_name);
-			if (!n) goto out;
+	while (external_list_parameter.next != &external_list_parameter) {
+
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+
+		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9') {
+			// TODO return FAULT message the fault code is saved in external_parameter->fault_code
+			goto out;
+		}
 
-			n = n->parent->parent;
-			n = mxmlNewElement(n, "Value");
+		n = mxmlNewElement(parameter_list, "ParameterValueStruct");
 			if (!n) goto out;
 
+		n = mxmlNewElement(n, "Name");
+		if (!n) goto out;
+
+		n = mxmlNewText(n, 0, external_parameter->name);
+		if (!n) goto out;
+
+		n = n->parent->parent;
+		n = mxmlNewElement(n, "Value");
+		if (!n) goto out;
+
 #ifdef ACS_MULTI
-			mxmlElementSetAttr(n, "xsi:type", "xsd:string");
+		mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
 #endif
-			n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
-			if (!n) goto out;
+		n = mxmlNewText(n, 0, external_parameter->data ? external_parameter->data : "");
+		if (!n) goto out;
 
-			/*
-			 * three day's work to finally find memory leak if we
-			 * free parameter_name;
-			 * it points to: b->value.text.string
-			 *
-			 * also, parameter_value can be NULL so we don't do checks
-			 */
-			parameter_name = NULL;
-		}
+		counter++;
 		
-		FREE(parameter_value);
-		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+		external_parameter_delete(external_parameter);
 	}
-
 #ifdef ACS_MULTI
 	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
 			    NULL, NULL, MXML_DESCEND);
@@ -716,11 +736,10 @@ int xml_handle_get_parameter_values(mxml_node_t *body_in,
 	FREE(c);
 #endif
 
-	FREE(parameter_value);
 	return 0;
 
 out:
-	FREE(parameter_value);
+	external_free_list_parameter();
 	return -1;
 }
 
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:52 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:02:56 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:58881 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823088Ab2L1QCoG03F3 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:44 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MQCLn-1TkVeY2fhL-005Ez8; Fri, 28 Dec 2012 17:02:38 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 05/10] Add 3rd argument in the ubus handler of notification.
Date:   Fri, 28 Dec 2012 16:59:42 +0100
Message-Id: <1356710387-3043-6-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:qpYXhdUO/64TXjo9FmXOZ7/4/fP5Z/mZ3qDDmu03/V4
 vSRcEFhx72D0LpTIjhpzt9SIejYnrP/5DP3/g22/tOj0urVcgE
 9Ob+bXxKbRNky73yVpLLBl9QenR6Dxi9+4XZ7psvGmscdcOULT
 fHkdqc63i0t3fglUJOmR3hCTGyzA09+IZUV6sUd00UalbH7lH1
 1rxN8L/V8UG/19F0K8cz/H9voULb4lZxYKVsAQ2hExtitRYa9a
 6h3Na6weC9H93d48KS+gFoOcpWjqkrgd3TzRbSI8mNPJUA+RYX
 0/4L4EqGcjkXUME9CkLlVZjCnm+35Cme/76C8MMrGs3O3X6cVX
 jmpZT88/YYKsWqo4RGd+S07wb4hDdnolcYDRWbJ0SYHhiN/c7k
 uG7ezMZJdY5fMJRPGe/Li9bQYAPNJz1g29czcVpq+6WADX+aIw
 YmPwK
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 153
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

Add 3rd argument in the ubus handler of notification. The 3rd argument is the type of the parameter This agument could be used in the response of get parameter attribute
Contributed by Inteno Broadband Technology AB

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 src/cwmp.c |    2 +-
 src/cwmp.h |    2 +-
 src/ubus.c |    5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index 6b2031b..f1f5e9f 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -245,7 +245,7 @@ void cwmp_clear_events(void)
 	pthread_mutex_unlock(&event_lock);
 }
 
-void cwmp_add_notification(char *parameter, char *value)
+void cwmp_add_notification(char *parameter, char *value, char *type)
 {
 	char *c = NULL;
 	external_get_action("notification", parameter, &c);
diff --git a/src/cwmp.h b/src/cwmp.h
index 5703db0..1d8afac 100644
--- a/src/cwmp.h
+++ b/src/cwmp.h
@@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
 void cwmp_remove_event(int code);
 void cwmp_clear_events(void);
 
-void cwmp_add_notification(char *parameter, char *value);
+void cwmp_add_notification(char *parameter, char *value, char *type);
 void cwmp_clear_notifications(void);
 
 int cwmp_set_parameter_write_handler(char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index 3cc3c69..719a848 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct uloop_timeout *timeout)
 static enum notify {
 	NOTIFY_PARAM,
 	NOTIFY_VALUE,
+	NOTIFY_TYPE,
 	__NOTIFY_MAX
 };
 
 static const struct blobmsg_policy notify_policy[] = {
 	[NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
 	[NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+	[NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
 };
 
 static int
@@ -65,7 +67,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
 	lfc_log_message(NAME, L_NOTICE, "triggered ubus notification parameter %s\n",
 			blobmsg_data(tb[NOTIFY_PARAM]));
 	cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
-			      blobmsg_data(tb[NOTIFY_VALUE]));
+			blobmsg_data(tb[NOTIFY_VALUE]),
+			tb[NOTIFY_TYPE] ? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);
 
 	return 0;
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:57 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:02:58 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:54627 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823089Ab2L1QCos1xgr (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:44 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MXjQA-1Tar282cze-00WYsV; Fri, 28 Dec 2012 17:02:39 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 06/10] Add xml_get_parameter_name handler.
Date:   Fri, 28 Dec 2012 16:59:43 +0100
Message-Id: <1356710387-3043-7-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:uxS6mjgn0wVy9t8MofBluer3iUQ3yqBatPzsrWrbBPL
 0/KhInYQCcpIY/a5CW3GijXJczLyA7WtAin1nfva8FL23wmHjc
 vl+SLvhQsQulPchLuDwnSjFg1deIFgfrYTWwdvt1FiE0C8xbo6
 0AIonIZwjok7WiAl95Efi/L+HJHRWwtIfPDSqfria8F7PNrzPt
 kVcBPLGg8FbHLBl13Cf1/lSaBqoB+AACNZXkiBeDHZSXiy2y0n
 q1dKo1v1DMaWybRXmOkLwSwgafUHcrxtLIfrhmVpEtSFPFBwDy
 H2h4slWYJhqpegb9WVhXJLjrOAO+5MWgkJ8rnptXIDOFf74BUq
 bvl8wXKVkCiokFvtD6TeUXU+Q4o163ZaYarpGR8X9nlSlBr9fg
 zIDEoF+Xp6+jpT0iuR9ILQy+HX9PHSIvlifgJatnse/wQ9Tdb9
 sX1xE
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 154
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

Add in the core (only C) the get_parameter_name handler, and add also the ubus related function in order to get from scripts the parameter names
Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 src/cwmp.c     |    2 +-
 src/external.c |   73 ++++++++++++++-----------------------
 src/external.h |    3 +-
 src/ubus.c     |   40 ++++++++++++++++++++
 src/xml.c      |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/xml.h      |    4 ++
 6 files changed, 185 insertions(+), 47 deletions(-)

diff --git a/src/cwmp.c b/src/cwmp.c
index f1f5e9f..18c8ff4 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -248,7 +248,7 @@ void cwmp_clear_events(void)
 void cwmp_add_notification(char *parameter, char *value, char *type)
 {
 	char *c = NULL;
-	external_get_action("notification", parameter, &c);
+	external_get_action_data("notification", parameter, &c);
 	if (!c) return;
 
 	struct notification *n = NULL;
diff --git a/src/external.c b/src/external.c
index 44be0b6..80c8108 100644
--- a/src/external.c
+++ b/src/external.c
@@ -66,14 +66,34 @@ void external_free_list_parameter()
 	}
 }
 
-int external_get_action(char *action, char *name, char **value)
+int external_get_action_data(char *action, char *name, char **value)
+{
+	struct external_parameter *external_parameter;
+	external_get_action(action, name, NULL);
+	if (external_list_parameter.next!=&external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		if (external_parameter->data)
+			*value = strdup(external_parameter->data);
+		external_parameter_delete(external_parameter);
+	}
+	external_free_list_parameter();
+	return 0;
+}
+
+/*
+ * external_get_action allow to execute external commands related to get methods:
+ * GetParameterNames, GetParameterValues, GetParameterAttributes
+ * Input:
+ * - action: external action to execute: get value, or get name, or get notification
+ * - name: the parameter name
+ * - arg: is used only in case of GetParameterNames to indicate the NextLevel argument
+ */
+int external_get_action(char *action, char *name, char *arg)
 {
 	lfc_log_message(NAME, L_NOTICE, "executing get %s '%s'\n",
 			action, name);
 
-	int pfds[2];
-	if (pipe(pfds) < 0)
-		return -1;
+	pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
 
 	if ((uproc.pid = fork()) == -1)
 		goto error;
@@ -85,66 +105,29 @@ int external_get_action(char *action, char *name, char **value)
 		int i = 0;
 		argv[i++] = "/bin/sh";
 		argv[i++] = fc_script;
-		argv[i++] = "--newline";
-		argv[i++] = "--value";
+		argv[i++] = "--ubus";
 		argv[i++] = "get";
 		argv[i++] = action;
 		argv[i++] = name;
+		if (arg) argv[i++] = arg;
 		argv[i++] = NULL;
 
-		close(pfds[0]);
-		dup2(pfds[1], 1);
-		close(pfds[1]);
-
 		execvp(argv[0], (char **) argv);
 		exit(ESRCH);
 
 	} else if (uproc.pid < 0)
 		goto error;
 
-	/* parent */
-	close(pfds[1]);
-
 	int status;
 	while (wait(&status) != uproc.pid) {
 		DD("waiting for child to exit");
 	}
+	pthread_cancel(ubus_thread);
+	pthread_join(ubus_thread, NULL);
 
-	char buffer[64];
-	ssize_t rxed;
-	char *c;
-	int t;
-
-	*value = NULL;
-	while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
-		if (*value)
-			t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
-		else
-			t = asprintf(&c, "%.*s", (int) rxed, buffer);
-
-		if (t == -1) goto error;
-
-		free(*value);
-		*value = strdup(c);
-		free(c);
-	}
-
-	if (!strlen(*value)) {
-		FREE(*value);
-		goto done;
-	}
-
-	if (rxed < 0)
-		goto error;
-
-done:
-	close(pfds[0]);
 	return 0;
 
 error:
-	FREE(*c);
-	FREE(*value);
-	close(pfds[0]);
 	return -1;
 }
 
diff --git a/src/external.h b/src/external.h
index f69fb34..4e64a99 100644
--- a/src/external.h
+++ b/src/external.h
@@ -31,7 +31,8 @@ struct external_parameter {
 	char *fault_code;
 };
 
-int external_get_action(char *action, char *name, char **value);
+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);
diff --git a/src/ubus.c b/src/ubus.c
index 719a848..4c741a5 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -5,6 +5,7 @@
  *	(at your option) any later version.
  *
  *	Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <unistd.h>
@@ -199,11 +200,50 @@ freecwmpd_handle_get_param_values(struct ubus_context *ctx, struct ubus_object *
 	return 0;
 }
 
+static enum get_param_names {
+	GET_PARAM_NAMES_PARAM,
+	GET_PARAM_NAMES_WRITABLE,
+	GET_PARAM_NAMES_FAULT,
+	__GET_PARAM_NAMES_MAX
+};
+
+static const struct blobmsg_policy get_param_names_policy[] = {
+	[GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_NAMES_MAX];
+
+	blobmsg_parse(get_param_names_policy, ARRAY_SIZE(get_param_names_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_NAMES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	lfc_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_names for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
+			tb[GET_PARAM_NAMES_WRITABLE] ? blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
+			NULL,
+			tb[GET_PARAM_NAMES_FAULT] ? blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
+
+	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("get_parameter_names", freecwmpd_handle_get_param_names, get_param_names_policy),
 };
 
 static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index d1d1ed9..92fc046 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -6,6 +6,7 @@
  *
  *	Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
  *	Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
+ *	Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
  */
 
 #include <stdbool.h>
@@ -51,6 +52,7 @@ static struct cwmp_namespaces
 const struct rpc_method rpc_methods[] = {
 	{ "SetParameterValues", xml_handle_set_parameter_values },
 	{ "GetParameterValues", xml_handle_get_parameter_values },
+	{ "GetParameterNames", xml_handle_get_parameter_names },
 	{ "SetParameterAttributes", xml_handle_set_parameter_attributes },
 	{ "Download", xml_handle_download },
 	{ "FactoryReset", xml_handle_factory_reset },
@@ -734,6 +736,114 @@ out:
 	return -1;
 }
 
+int xml_handle_get_parameter_names(mxml_node_t *body_in,
+				    mxml_node_t *tree_in,
+				    mxml_node_t *tree_out)
+{
+	mxml_node_t *n, *parameter_list, *b = body_in;
+	struct external_parameter *external_parameter;
+	char *parameter_name = NULL;
+	char *next_level = NULL;
+	int counter = 0;
+
+	n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
+			    NULL, NULL, MXML_DESCEND);
+	if (!n) return -1;
+
+	n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
+	if (!n) return -1;
+
+	n = mxmlNewElement(n, "ParameterList");
+	if (!n) return -1;
+
+#ifdef ACS_MULTI
+	mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
+#endif
+
+	while (b) {
+		if (b && b->type == MXML_TEXT &&
+			b->value.text.string &&
+			b->parent->type == MXML_ELEMENT &&
+			!strcmp(b->parent->value.element.name, "ParameterPath")) {
+			parameter_name = b->value.text.string;
+		}
+
+		/*
+		 * If the ParameterPath node from GetParameterNames does not contain child node (txt node)
+		 * Then the parameter name is an empty string which means get all parameters from the data model
+		 */
+		if (b && b->type == MXML_ELEMENT &&
+			!strcmp(b->value.element.name, "ParameterPath") &&
+			!b->child) {
+			parameter_name = "";
+		}
+
+		if (b && b->type == MXML_TEXT &&
+			b->value.text.string &&
+			b->parent->type == MXML_ELEMENT &&
+			!strcmp(b->parent->value.element.name, "NextLevel")) {
+			next_level = b->value.text.string;
+		}
+		b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+	}
+
+	if (parameter_name && next_level) {
+		if (external_get_action("name", parameter_name, next_level))
+			goto out;
+	}
+
+	parameter_list = mxmlFindElement(tree_out, tree_out, "ParameterList", NULL, NULL, MXML_DESCEND);
+	if (!parameter_list) goto out;
+
+	while (external_list_parameter.next != &external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+
+		if (external_parameter->fault_code && external_parameter->fault_code[0]=='9') {
+			goto out;
+			//TODO return FAULT message the fault code is in external_parameter->fault_cod
+		}
+
+		n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
+		if (!n) goto out;
+
+		n = mxmlNewElement(n, "Name");
+		if (!n) goto out;
+
+		n = mxmlNewText(n, 0, external_parameter->name);
+		if (!n) goto out;
+
+		n = n->parent->parent;
+		n = mxmlNewElement(n, "Writable");
+		if (!n) goto out;
+
+		n = mxmlNewText(n, 0, external_parameter->data);
+		if (!n) goto out;
+
+		counter++;
+
+		external_parameter_delete(external_parameter);
+	}
+
+#ifdef ACS_MULTI
+	char *c;
+	b = mxmlFindElement(tree_out, tree_out, "ParameterList", 
+			    NULL, NULL, MXML_DESCEND);
+	if (!b) goto out;
+
+	if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
+		goto out;
+
+	mxmlElementSetAttr(b, "soap_enc:arrayType", c);
+	FREE(c);
+#endif
+
+	return 0;
+
+out:
+	external_free_list_parameter();
+	return -1;
+}
+
 static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 					       mxml_node_t *tree_in,
 					       mxml_node_t *tree_out) {
diff --git a/src/xml.h b/src/xml.h
index 8f63192..a9191eb 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -26,6 +26,10 @@ static int xml_handle_get_parameter_values(mxml_node_t *body_in,
 					   mxml_node_t *tree_in,
 					   mxml_node_t *tree_out);
 
+static int xml_handle_get_parameter_names(mxml_node_t *body_in,
+					   mxml_node_t *tree_in,
+					   mxml_node_t *tree_out);
+
 static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
 					       mxml_node_t *tree_in,
 					       mxml_node_t *tree_out);
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:02:59 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:03:03 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.186]:52946 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823091Ab2L1QCpFOMMK (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:45 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MLEXd-1ToLPR2gcr-000J24; Fri, 28 Dec 2012 17:02:37 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 04/10] Update inform in order to get parameters from ubus
Date:   Fri, 28 Dec 2012 16:59:41 +0100
Message-Id: <1356710387-3043-5-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:B9+LEosdil5DqBbeYRGly/1FqcwC6+3ZEQoupAsGJjQ
 Sgmwvv/BMg5HHQD2i2D1xm8bbl+dI3euLvhKn33l8+N4P63fs7
 3KMf/tc4xHht7Puwxmm+J8OYrwDRaNVd+WxwcJK03wkHrYY839
 FsBan9IFSJ4wLPavpDHPK8+EqqiktyJWdiNrB/BSxagRvG59G1
 lC2msKYaGSIwnvyV7iyNSKybX2+FBtgDzKbAOAycGFWF9anOUQ
 So55ud1n72CMQxnlDhFSYyiUzjMExu2nlRvgVX0Gkyr8dM8bLs
 kiZXpNwxmW/Zt5CxCgv5HPgb5D9U156gv1trbsx0b69ng41fUN
 6gNWe/9hv5Vq7LZ557H+QitZaKRR2ZFxgyTZPqQybU8eMKda0D
 2BTu4RnXZXJy4hZd2d5m5GIE0gQ7N9tTd77oHDxqRx7BQK6EYE
 jWlxn
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 155
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

Update inform in order to get parameters from ubus instead from pipe
Contributed by PIVA SOFTWARE

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 src/xml.c |   43 +++++++++++++++++--------------------------
 1 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/src/xml.c b/src/xml.c
index f89fd3c..d1d1ed9 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
 {
 	mxml_node_t *tree, *b;
 	char *c, *tmp;
+	struct external_parameter *external_parameter;
 
 #ifdef DUMMY_MODE
 	FILE *fp;
@@ -337,36 +338,25 @@ int xml_prepare_inform_message(char **msg_out)
 	if (mxmlGetType(b) != MXML_ELEMENT)
 		goto error;
 
-	tmp = "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
-	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-	if (!b) goto error;
-
-	b = b->parent->next->next;
-	if (mxmlGetType(b) != MXML_ELEMENT)
+	external_get_action_write("value", "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", NULL);
+	external_get_action_write("value", "InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
+	if (external_get_action_execute())
 		goto error;
 
-	c = NULL;
-	if (external_get_action("value", tmp, &c)) goto error;
-	if (c) {
-		b = mxmlNewText(b, 0, c);
-		FREE(c);
-		if (!b) goto error;
-	}
-
-	tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
-	b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
-	if (!b) goto error;
+	while (external_list_parameter.next != &external_list_parameter) {
+		external_parameter = list_entry(external_list_parameter.next, struct external_parameter, list);
+		b = mxmlFindElementText(tree, tree, external_parameter->name, MXML_DESCEND);
+		if (!b) continue;
 
-	b = b->parent->next->next;
-	if (mxmlGetType(b) != MXML_ELEMENT)
-		goto error;
+		b = b->parent->next->next;
+		if (mxmlGetType(b) != MXML_ELEMENT)
+			goto error;
 
-	c = NULL;
-	if (external_get_action("value", tmp, &c)) goto error;
-	if (c) {
-		b = mxmlNewText(b, 0, c);
-		FREE(c);
-		if (!b) goto error;
+		if (external_parameter->data) {
+			b = mxmlNewText(b, 0, external_parameter->data);
+			if (!b) goto error;
+		}
+		external_parameter_delete(external_parameter);
 	}
 
 	if (xml_prepare_notifications_inform(tree))
@@ -378,6 +368,7 @@ int xml_prepare_inform_message(char **msg_out)
 	return 0;
 
 error:
+	external_free_list_parameter();
 	mxmlDelete(tree);
 	return -1;
 }
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:03:07 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:03:09 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.17.10]:63624 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823110Ab2L1QCrbvjmw (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:47 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0MIkdY-1TmQXJ0AG0-002Dm1; Fri, 28 Dec 2012 17:02:42 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 08/10] Use ubus for get notification
Date:   Fri, 28 Dec 2012 16:59:45 +0100
Message-Id: <1356710387-3043-9-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:sWVaox0SYO9T0YfQ6/ndEwsZ5Eehlf1elNUOSbjp1fE
 EX0UB3B8YVDVKfexNNp9nVXipod9ByBCthMPXAJKqdfbOaZBeJ
 DRXT1W9PyPibNYMcQd+Te0J8/jCNoMkSLUjXt9aS35IRY2JFzo
 l0Kxlnf/iDuhrQg4U98npHP1kKfPoCU3l8bGDO9EgPOSBjN/97
 byRQNej9OhiX4YF+HEx23crH31DQQ90MuRlGId1ea92WK1gaGA
 hxE6yiJwvgO/RJUTJI+yAcGGbXKIa8+HbAmGtOgRZbrdrz82kG
 DIDfwJUObexlWPlcpE1K0zQJIx+P+xo/SiFlEb4ZwPKMCgAcqH
 obinlaVCXTW9ZPsGVE20nUU/ZMipTJ79Oby016xT+P504rchkN
 1Tb/v92RLbFc2AcDUfzcwvfUIGkGycz39dxuvRwka8v/i8hmA0
 3WYnP
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 156
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

update the get notification in order to put the returned data via ubus instead of pipe TODO: develop the xml handle message to perform send of GetParameterAttributeResponse
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                 |   31 +++++-
 ext/openwrt/scripts/functions/common            |   20 +++
 ext/openwrt/scripts/functions/device_hosts      |    2 +
 ext/openwrt/scripts/functions/device_info       |   93 +++++++++++++++
 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        |   49 ++++++++
 ext/openwrt/scripts/functions/management_server |  142 +++++++++++++++++++++++
 ext/openwrt/scripts/functions/misc              |    2 +
 ext/openwrt/scripts/functions/wan_device        |  102 ++++++++++++++++
 src/ubus.c                                      |   42 +++++++
 12 files changed, 487 insertions(+), 2 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index b2a2e40..efc4cc0 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -105,6 +105,7 @@ fi
 get_value_functions=""
 set_value_functions=""
 get_name_functions=""
+get_notification_functions=""
 
 load_script() {
 	. $1 
@@ -114,6 +115,7 @@ load_function() {
 	get_value_functions="$get_value_functions get_$1"
 	set_value_functions="$set_value_functions set_$1"
 	get_name_functions="$get_name_functions get_$1_name"
+	get_notification_functions="$get_notification_functions get_$1_notification"
 }
 
 handle_scripts() {
@@ -225,8 +227,33 @@ if [ "$action" = "set_value" ]; then
 fi
 
 if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
-	freecwmp_get_parameter_notification "x_notification" "$__arg1"
-	freecwmp_notification_output "$__arg1" "$x_notification"
+	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 and accepting empty string
+		if [  ${#__arg1} -lt ${#__tmp_arg} -a ${#__arg1} -ne 0 ]; then
+			echo "CWMP parameters usualy begin with 'InternetGatewayDevice.' or 'Device.' or ''     "
+			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
+		# TODO: don't return only 'InternetGatewayDevice.' when getting an empty string; but we should both
+		#       parameters with prefix 'InternetGatewayDevice.' and 'Device.'
+		if [ "$__arg1" = "InternetGatewayDevice." -a "$__arg1" = "" ]; then
+			__param="InternetGatewayDevice."
+		else
+			__param="$__arg1"
+		fi
+		freecwmp_execute_functions "$get_notification_functions" "$__param"
+		fault_code="$?"
+	fi
+	if [ "$fault_code" != "0" ]; then
+		let fault_code=$fault_code+9000
+		freecwmp_output "$__arg1" "" "" "" "$fault_code"
+	fi
 fi
 
 if [ "$action" = "set_notification" ]; then
diff --git a/ext/openwrt/scripts/functions/common b/ext/openwrt/scripts/functions/common
index 5cd02b3..2bfba9a 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -64,6 +64,9 @@ freecwmp_ubus_output() {
 		get_name)
 		ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET}  call tr069 get_parameter_names '{ "parameter": "'$parameter'", "writable": "'$permissions'", "fault_code": "'$fault_code'" }' 2> /dev/null
 		;;
+		get_notification)
+		ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET}  call tr069 get_parameter_attributes '{ "parameter": "'$parameter'", "notification": "'$value'", "fault_code": "'$fault_code'" }' 2> /dev/null
+		;;
 	esac
 }
 freecwmp_value_output() {
@@ -195,6 +198,9 @@ freecwmp_config_notifications() {
 		if [ "$item" = "$3" ]; then
 			eval "export -- \"$4=2\""
 			return 0
+		elif [ "`echo $3|grep $item`" = "$3" ]; then
+			eval "export -- \"$4=2\""
+			return 0
 		fi
 	done
 	for item in $__passive
@@ -202,6 +208,9 @@ freecwmp_config_notifications() {
 		if [ "$item" = "$3" ]; then
 			eval "export -- \"$4=1\""
 			return 0
+		elif [ "`echo $3|grep $item`" = "$3" ]; then
+			eval "export -- \"$4=1\""
+			return 0
 		fi
 	done
 }
@@ -237,7 +246,18 @@ freecwmp_get_parameter_notification() {
 	local _dest="$1"
 	local _parm="$2"
 	local _val
+	local _parent
 	config_foreach freecwmp_config_notifications "notifications" "get" "$_parm" "_val"
+	if [ "$_val" = "" ]; then
+		if [ "`echo $_parm|grep '\.$'`" = "" ]; then
+			_parent="${_parm%.*}."
+			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
+		else
+			_parent="${_parm%.*.}."
+			config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val"
+		fi
+	fi
+	if [ "$_val" = "" ];then _val="0" ;fi
 	eval "export -- \"$_dest=$_val\""
 }
 
diff --git a/ext/openwrt/scripts/functions/device_hosts b/ext/openwrt/scripts/functions/device_hosts
index 5f63c38..2365c88 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -192,4 +192,6 @@ return $E_INVALID_PARAMETER_NAME
 
 get_device_hosts_name() { return $E_INVALID_PARAMETER_NAME; }
 
+get_device_hosts_notification() { return $E_INVALID_PARAMETER_NAME; }
+
 set_device_hosts() { return; }
diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
index 3509d9d..e9de6d2 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -12,6 +12,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.Manufacturer"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val" "$permissions"
 }
@@ -30,6 +33,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val" "$permissions"
 }
@@ -47,6 +53,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ProductClass"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val" "$permissions"
 }
@@ -65,6 +74,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SerialNumber"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val" "$permissions"
 }
@@ -83,6 +95,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.HardwareVersion"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val" "$permissions"
 }
@@ -101,6 +116,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val" "$permissions"
 }
@@ -119,6 +137,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.UpTime"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val" "$permissions"
 }
@@ -137,6 +158,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.DeviceLog"
+	;;
 esac
 freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val" "$permissions"
 }
@@ -289,6 +313,66 @@ esac
 return $E_INVALID_PARAMETER_NAME
 }
 
+get_device_info_notification() {
+case "$1" in
+	InternetGatewayDevice.)
+	get_device_info_manufacturer
+	get_device_info_oui
+	get_device_info_product_class
+	get_device_info_serial_number
+	get_device_info_hardware_version
+	get_device_info_software_version
+	get_device_info_uptime
+	get_device_info_device_log
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.)
+	get_device_info_manufacturer
+	get_device_info_oui
+	get_device_info_product_class
+	get_device_info_serial_number
+	get_device_info_hardware_version
+	get_device_info_software_version
+	get_device_info_uptime
+	get_device_info_device_log
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.Manufacturer)
+	get_device_info_manufacturer
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+	get_device_info_oui
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.ProductClass)
+	get_device_info_product_class
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.SerialNumber)
+	get_device_info_serial_number
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.HardwareVersion)
+	get_device_info_hardware_version
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+	get_device_info_software_version
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.UpTime)
+	get_device_info_uptime
+	return 0
+	;;
+	InternetGatewayDevice.DeviceInfo.DeviceLog)
+	get_device_info_device_log
+	return 0
+	;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
 set_device_info() {
 case "$1" in
 	InternetGatewayDevice.DeviceInfo.Manufacturer)
@@ -363,6 +447,15 @@ get_device_info_generic_name() {
 return $E_INVALID_PARAMETER_NAME
 }
 
+get_device_info_generic_notification() {
+	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $E_INVALID_PARAMETER_NAME; fi
+
+	local val
+	freecwmp_get_parameter_notification "val" "$1"
+	freecwmp_output "$1" "$val"
+	return 0
+}
+
 set_device_info_generic() {
 	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
 
diff --git a/ext/openwrt/scripts/functions/device_ip b/ext/openwrt/scripts/functions/device_ip
index c4fbab6..0be4860 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -125,4 +125,6 @@ return $E_INVALID_PARAMETER_NAME;
 
 get_device_ip_name() { return $E_INVALID_PARAMETER_NAME; }
 
+get_device_ip_notification() { return $E_INVALID_PARAMETER_NAME; }
+
 set_device_ip() { return; }
diff --git a/ext/openwrt/scripts/functions/device_routing b/ext/openwrt/scripts/functions/device_routing
index 7e76be3..f3b186c 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -355,4 +355,6 @@ return $E_INVALID_PARAMETER_NAME
 
 get_device_routing_name() { return $E_INVALID_PARAMETER_NAME; }
 
+get_device_routing_notification() { return $E_INVALID_PARAMETER_NAME; }
+
 set_device_routing() { return; }
diff --git a/ext/openwrt/scripts/functions/device_users b/ext/openwrt/scripts/functions/device_users
index 1926208..7988df5 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -129,4 +129,6 @@ fi
 
 get_device_users_name() { return $E_INVALID_PARAMETER_NAME; }
 
+get_device_users_notification() { return $E_INVALID_PARAMETER_NAME; }
+
 set_device_users() { return; }
diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index 1d00558..8fdf12b 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -23,6 +23,11 @@ case "$action" in
 	let num=$num+1
 	freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val" "$permissions"
 	;;
+	get_notification)
+	let num=$num+1
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+	freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+	;;
 esac
 }
 
@@ -53,6 +58,11 @@ case "$action" in
 	let num=$num+1
 	freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val" "$permissions"
 	;;
+	get_notification)
+	let num=$num+1
+	freecwmp_get_parameter_notification "val" "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+	freecwmp_output "InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+	;;
 esac
 }
 
@@ -171,6 +181,45 @@ esac
 return $E_INVALID_PARAMETER_NAME
 }
 
+get_lan_device_notification() {
+case "$1" in
+	InternetGatewayDevice.)
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.)
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.1.)
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+	get_wlan_enable 0
+	get_wlan_ssid 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+	get_wlan_enable 0
+	return 0
+	;;
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+	get_wlan_ssid 0
+	return 0
+	;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
 set_lan_device() {
 case "$1" in
 	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
index 0ecdf26..e40758c 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -23,6 +23,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -68,6 +71,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -87,6 +93,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -107,6 +116,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions" "$type"
 }
@@ -128,6 +140,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions" "$type"
 }
@@ -163,6 +178,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -178,6 +196,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -197,6 +218,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -217,6 +241,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -236,6 +263,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -259,6 +289,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -278,6 +311,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -297,6 +333,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -535,6 +574,100 @@ esac
 return $E_INVALID_PARAMETER_NAME
 }
 
+get_management_server_notification() {
+case "$1" in
+	InternetGatewayDevice.)
+	get_management_server_url
+	get_management_server_username
+	get_management_server_password
+	get_management_server_periodic_inform_enable
+	get_management_server_periodic_inform_interval
+	get_management_server_connection_request_url
+	get_management_server_connection_request_username
+	get_management_server_connection_request_password
+	get_management_server_x_freecwmp_org__acs_scheme
+	get_management_server_x_freecwmp_org__acs_hostname
+	get_management_server_x_freecwmp_org__acs_port
+	get_management_server_x_freecwmp_org__acs_path
+	get_management_server_x_freecwmp_org__connection_request_port
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.)
+	get_management_server_url
+	get_management_server_username
+	get_management_server_password
+	get_management_server_periodic_inform_enable
+	get_management_server_periodic_inform_interval
+	get_management_server_connection_request_url
+	get_management_server_connection_request_username
+	get_management_server_connection_request_password
+	get_management_server_x_freecwmp_org__acs_scheme
+	get_management_server_x_freecwmp_org__acs_hostname
+	get_management_server_x_freecwmp_org__acs_port
+	get_management_server_x_freecwmp_org__acs_path
+	get_management_server_x_freecwmp_org__connection_request_port
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.URL)
+	get_management_server_url
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.Username)
+	get_management_server_username
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.Password)
+	get_management_server_password
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+	get_management_server_periodic_inform_enable
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+	get_management_server_periodic_inform_interval
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+	get_management_server_connection_request_url
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+	get_management_server_connection_request_username
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+	get_management_server_connection_request_password
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+	get_management_server_x_freecwmp_org__acs_scheme
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+	get_management_server_x_freecwmp_org__acs_hostname
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+	get_management_server_x_freecwmp_org__acs_port
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+	get_management_server_x_freecwmp_org__acs_path
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+	get_management_server_x_freecwmp_org__connection_request_port
+	return 0
+	;;
+	InternetGatewayDevice.ManagementServer.ParameterKey)
+	get_management_server_parameter_key
+	return 0
+	;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
 set_management_server() {
 case "$1" in
 	InternetGatewayDevice.ManagementServer.URL)
@@ -605,6 +738,15 @@ get_management_server_generic_name() {
 	return 0
 }
 
+get_management_server_generic_notification() {
+	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $E_INVALID_PARAMETER_NAME; fi
+	
+	local val
+	freecwmp_get_parameter_notification "val" "$1"
+	freecwmp_output "$1" "$val"
+	return 0
+}
+
 set_management_server_generic() {
 	check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return 0; fi
 
diff --git a/ext/openwrt/scripts/functions/misc b/ext/openwrt/scripts/functions/misc
index bf48308..fe0686f 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -29,4 +29,6 @@ return $E_INVALID_PARAMETER_NAME
 
 get_misc_name () { return $E_INVALID_PARAMETER_NAME; }
 
+get_misc_notification () { return $E_INVALID_PARAMETER_NAME; }
+
 set_misc() { return; }
diff --git a/ext/openwrt/scripts/functions/wan_device b/ext/openwrt/scripts/functions/wan_device
index b3b456b..0944bca 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -15,6 +15,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions" "$type"
 }
@@ -34,6 +37,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -53,6 +59,9 @@ case "$action" in
 	get_name)
 	permissions="0"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -101,6 +110,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -120,6 +132,9 @@ case "$action" in
 	get_name)
 	permissions="1"
 	;;
+	get_notification)
+	freecwmp_get_parameter_notification "val" "$parm"
+	;;
 esac
 freecwmp_output "$parm" "$val" "$permissions"
 }
@@ -344,6 +359,93 @@ esac
 return $E_INVALID_PARAMETER_NAME
 }
 
+get_wan_device_notification() {
+case "$1" in
+	InternetGatewayDevice.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	get_wan_device_wan_ppp_enable
+	get_wan_device_wan_ppp_username
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+	get_wan_device_mng_status
+	get_wan_device_mng_interface_ip
+	get_wan_device_mng_interface_mac
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+	get_wan_device_mng_status
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+	get_wan_device_mng_interface_ip
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+	get_wan_device_mng_interface_mac
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+	get_wan_device_wan_ppp_enable
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+	get_wan_device_wan_ppp_username
+	return 0
+	;;
+	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+	get_wan_device_wan_ppp_password
+	return 0
+	;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
 set_wan_device() {
 case "$1" in
 	InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
diff --git a/src/ubus.c b/src/ubus.c
index 4c741a5..4825b5f 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -238,12 +238,54 @@ freecwmpd_handle_get_param_names(struct ubus_context *ctx, struct ubus_object *o
 	return 0;
 }
 
+static enum get_param_attributes {
+	GET_PARAM_ATTRIBUTES_PARAM,
+	GET_PARAM_ATTRIBUTES_NOTIF,
+	GET_PARAM_ATTRIBUTES_FAULT,
+	__GET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy get_param_attributes_policy[] = {
+	[GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type = BLOBMSG_TYPE_STRING },
+	[GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type = BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct ubus_object *obj,
+			struct ubus_request_data *req, const char *method,
+			struct blob_attr *msg)
+{
+	struct blob_attr *tb[__GET_PARAM_ATTRIBUTES_MAX];
+
+	blobmsg_parse(get_param_attributes_policy, ARRAY_SIZE(get_param_attributes_policy), tb,
+		      blob_data(msg), blob_len(msg));
+
+	if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
+	lfc_log_message(NAME, L_NOTICE,
+			     "triggered ubus get_parameter_attributes for the parameter %s\n",
+			     blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
+
+	external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
+				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
+				      NULL,
+				      blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
+
+	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("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),
 };
 
 static struct ubus_object_type main_object_type =
-- 
1.7.4.1


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:03:10 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:03:11 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.171]:52241 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823080Ab2L1QCtIUn0X (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:49 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0LbCQQ-1TMTN21sr4-00kwSd; Fri, 28 Dec 2012 17:02:43 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 09/10] Use ubus for set parameter values
Date:   Fri, 28 Dec 2012 16:59:46 +0100
Message-Id: <1356710387-3043-10-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:fxBTPXwCTvjDRHIkEwqXEO3ZdlyMJSlJ47xiw4Cqnq5
 bdwefJZDjtHq7RddJh8gji9LJ50TWBiuz7XaskQg5WnhcMLxFK
 vgsm8s/O4IuHn490B3FF2zFg3HVWuH5dxidQlIrdYXDJg5GjjK
 A9XqlJUc4YjGu9nb2KjOARByI9Y06LHs1hbDmvjcHtXUYfwg2k
 TKD0Fu7EWbxRuxLGmUIIBXjOUAWNCQlaiRKTyxilaTaYUbzfG6
 c2klFFzGCLSi9udJTS4kfTbQCW007+T7u43srT8UYDCdJctA6u
 t3R/Wbm6s27aBSKPi9HBuIzvnbVvXQD7ZSsUEfi+WYtBgpfEwm
 yWHMFF/i2+1hA7HGYEB3aInp+nco7zY8brA0txJICax3VoG+q5
 NKPIMTDmT67RtA7NKBlDzW9J3vVx4QgPIbHr2lre8NoO9YwB+L
 d4/Y37ky+NFNhkRug6taWTF6vow==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 157
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

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


From mohamed.kallel@pivasoftware.com Fri Dec 28 17:03:12 2012
Received: with ECARTIS (v1.0.0; list freecwmp); Fri, 28 Dec 2012 17:03:14 +0100 (CET)
Received: from moutng.kundenserver.de ([212.227.126.187]:60760 "EHLO
        moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK)
        by eddie.linux-mips.org with ESMTP id S6823121Ab2L1QCu670h1 (ORCPT
        <rfc822;freecwmp@linux-mips.org>); Fri, 28 Dec 2012 17:02:50 +0100
Received: from localhost.localdomain ([41.224.250.29])
        by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis)
        id 0LmRkt-1TFYYa3OoV-00aC10; Fri, 28 Dec 2012 17:02:44 +0100
From:   Mohamed Kallel <mohamed.kallel@pivasoftware.com>
To:     freecwmp@linux-mips.org
Cc:     freecwmp@lukaperkov.net, jogo@openwrt.org,
        Mohamed <mohamed.kallel@pivasoftware.com>,
        Ahmed Zribi <ahmed.zribi@pivasoftware.com>
Subject: [PATCH v2 10/10] Use ubus for set parameter attribute
Date:   Fri, 28 Dec 2012 16:59:47 +0100
Message-Id: <1356710387-3043-11-git-send-email-mohamed.kallel@pivasoftware.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
X-Provags-ID: V02:K0:7PK9CoMGJp8WalpxtDzGGwPBmyassK2aJJbml7boVo4
 Z+MpDaGoFuvqOPBdYIJ3cB3fjRchvcfn/Ha+zjrsAyy3spyDtX
 FHaqikqGHllmYM6/HuSYjANHNoK7QEirMXpuUG/yCvkZSGwkQ4
 6yA4sAMpdwtr3sKEoHx2bUih3jLvL9TGo5OGmf8yRclCbvPGQx
 IocEEZc+pMVbyhuWnRSuGrloSBsnaYFipHVz6yXNAZzBOSFLKc
 KBA63wHv11cbd2H5MvcXB9Os0bfODNJrjoxrh18R6By6lOy9j9
 vffy+GX6u3Pcyl0ATND9CrGIVbc6fNskElZNmG20AEOvDeHyQZ
 zzsx5jRUngsMVV4uGAGfOiXsaBSpeOcMuLd+25SDYyuA32a2yU
 8kdOrajJirQmbmVckIARq7Jd0zM3NESvEr6TWJUSLazCoNxgYU
 ohjlLyu5nQtXl2TMUf7Z6nd/7sA==
Return-Path: <mohamed.kallel@pivasoftware.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s freecwmp"> (uid 0)
X-Orcpt: rfc822;freecwmp@linux-mips.org
Original-Recipient: rfc822;freecwmp@linux-mips.org
X-archive-position: 158
X-ecartis-version: Ecartis v1.0.0
Sender: freecwmp-bounce@linux-mips.org
Errors-to: freecwmp-bounce@linux-mips.org
X-original-sender: mohamed.kallel@pivasoftware.com
Precedence: bulk
X-list: freecwmp

From: Mohamed <mohamed.kallel@pivasoftware.com>

Update set parameter attribute in order to get external command output from Ubus
Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
 ext/openwrt/scripts/freecwmp.sh                 |   42 +++-
 ext/openwrt/scripts/functions/common            |    3 +
 ext/openwrt/scripts/functions/device_hosts      |    2 +
 ext/openwrt/scripts/functions/device_info       |   11 +
 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        |   57 +++++-
 ext/openwrt/scripts/functions/management_server |  259 +++++++++++++++++++----
 ext/openwrt/scripts/functions/misc              |    2 +
 ext/openwrt/scripts/functions/wan_device        |   71 ++++++-
 src/external.c                                  |   16 ++
 src/external.h                                  |    2 +
 src/ubus.c                                      |   31 +++
 src/xml.c                                       |   25 ++-
 15 files changed, 458 insertions(+), 69 deletions(-)

diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index 294f2f0..22e524a 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -24,7 +24,7 @@ USAGE: $0 [flags] command [parameter] [values]
 command:
   get [value|notification|tags|name|all]
   set [value|notification|tag]
-  apply [value]
+  apply [value|notification]
   download
   factory_reset
   reboot
@@ -93,7 +93,13 @@ case "$1" in
 		action="reboot"
 		;;
 	apply)
-		action="apply_value"
+		if [ "$2" = "notification" ]; then
+			action="apply_notification"
+		elif [ "$2" = "value" ]; then
+			action="apply_value"
+		else
+			action="apply_value"
+		fi
 		;;
 esac
 
@@ -110,7 +116,8 @@ get_value_functions=""
 set_value_functions=""
 get_name_functions=""
 get_notification_functions=""
-
+set_notification_functions=""
+	
 load_script() {
 	. $1 
 }
@@ -120,6 +127,7 @@ load_function() {
 	set_value_functions="$set_value_functions set_$1"
 	get_name_functions="$get_name_functions get_$1_name"
 	get_notification_functions="$get_notification_functions get_$1_notification"
+	set_notification_functions="$set_notification_functions set_$1_notification"
 }
 
 handle_scripts() {
@@ -277,8 +285,26 @@ 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
+	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_notification_functions" "$__parm" "$__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_tags" -o "$action" = "get_all" ]; then
@@ -325,7 +351,7 @@ if [ "$action" = "reboot" ]; then
 	fi
 fi
 
-if [ "$action" = "apply_value" ]; then
+if [ "$action" = "apply_notification" -o "$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
@@ -334,6 +360,9 @@ if [ "$action" = "apply_value" ]; then
 		if [ "$action" = "apply_value" ]; then 
 			ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 set_parameter_values_status '{ "status": "0" }' 2> /dev/null
 		fi
+		if [ "$action" = "apply_notification" ]; then 
+			freecwmp_fault_output "" "" "0"
+		fi
 	else
 		let n=$__fault_count-1
 		for i in `seq 0 $n`
@@ -341,6 +370,7 @@ if [ "$action" = "apply_value" ]; then
 			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"
+			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 f6a3e8b..bb883fc 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -78,6 +78,9 @@ 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
 	;;
+	apply_notification)
+	ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET}  call tr069 set_parameter_attributes '{ "success": "'$success'", "fault_code": "'$fault_code'" }' 2> /dev/null
+	;;
 esac
 }
 
diff --git a/ext/openwrt/scripts/functions/device_hosts b/ext/openwrt/scripts/functions/device_hosts
index 330125a..1450135 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -195,3 +195,5 @@ get_device_hosts_name() { return $E_INVALID_PARAMETER_NAME; }
 get_device_hosts_notification() { return $E_INVALID_PARAMETER_NAME; }
 
 set_device_hosts() { return $E_INVALID_PARAMETER_NAME; }
+
+set_device_hosts_notification() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_info b/ext/openwrt/scripts/functions/device_info
index 37b930e..74f5e11 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -403,6 +403,10 @@ esac
 return $E_INVALID_PARAMETER_NAME
 }
 
+set_device_info_notification() {
+return $E_INVALID_PARAMETER_NAME
+}
+
 check_parameter_device_info_generic() {
 case "$1" in
 	InternetGatewayDevice.DeviceInfo.ModelName|\
@@ -468,3 +472,10 @@ set_device_info_generic() {
 	freecwmp_set_parameter_value "$1" "$2"
 	return 0
 }
+
+set_device_info_generic_notification() {
+	check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $E_INVALID_PARAMETER_NAME; fi
+
+	freecwmp_set_parameter_notification "$1" "$2"
+	return 0
+}
diff --git a/ext/openwrt/scripts/functions/device_ip b/ext/openwrt/scripts/functions/device_ip
index dc2147d..e5a4ea9 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -128,3 +128,5 @@ get_device_ip_name() { return $E_INVALID_PARAMETER_NAME; }
 get_device_ip_notification() { return $E_INVALID_PARAMETER_NAME; }
 
 set_device_ip() { return $E_INVALID_PARAMETER_NAME; }
+
+set_device_ip_notification() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_routing b/ext/openwrt/scripts/functions/device_routing
index dff6f4d..0f40592 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -358,3 +358,5 @@ get_device_routing_name() { return $E_INVALID_PARAMETER_NAME; }
 get_device_routing_notification() { return $E_INVALID_PARAMETER_NAME; }
 
 set_device_routing() { return $E_INVALID_PARAMETER_NAME; }
+
+set_device_routing_notification() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/device_users b/ext/openwrt/scripts/functions/device_users
index f8264e0..22c9309 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -132,3 +132,5 @@ get_device_users_name() { return $E_INVALID_PARAMETER_NAME; }
 get_device_users_notification() { return $E_INVALID_PARAMETER_NAME; }
 
 set_device_users() { return $E_INVALID_PARAMETER_NAME; }
+
+set_device_users_notification() { return $E_INVALID_PARAMETER_NAME; }
diff --git a/ext/openwrt/scripts/functions/lan_device b/ext/openwrt/scripts/functions/lan_device
index 5d5c84f..f7b91c1 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -34,13 +34,22 @@ esac
 set_wlan_enable() {
 local num="$1"
 local val="$2"
-if [ "$val" = "1" ]; then
-	val="0"
-else
-	val="1"
-fi
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+case $action in
+	set_value)
+	if [ "$val" = "1" ]; then
+		val="0"
+	else
+		val="1"
+	fi
+	delay_command "wifi" "wifi" "45"
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-device[$num].disabled="$val"
+	;;
+	set_notification)
+	let num=$num+1
+	freecwmp_set_parameter_notification "$parm" "$val"
+	;;
+esac
 }
 
 get_wlan_ssid() {
@@ -69,8 +78,17 @@ esac
 set_wlan_ssid() {
 local num="$1"
 local val="$2"
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+case $action in
+	set_value)
+	delay_command "wifi" "wifi" "45"
+	/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set wireless.@wifi-iface[$num].ssid="$val"
+	;;
+	set_notification)
+	let num=$num+1
+	freecwmp_set_parameter_notification "$parm" "$val"
+	;;
+esac
 }
 
 get_lan_device() {
@@ -233,3 +251,24 @@ case "$1" in
 esac
 return $E_INVALID_PARAMETER_NAME
 }
+
+set_lan_device_notification() {
+case "$1" in
+	InternetGatewayDevice.LANDevice.|\
+	InternetGatewayDevice.LANDevice.1.|\
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.|\
+	InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+	freecwmp_set_parameter_notification "$1" "$2"
+	return 0
+	;;
+	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
+return $E_INVALID_PARAMETER_NAME
+}
diff --git a/ext/openwrt/scripts/functions/management_server b/ext/openwrt/scripts/functions/management_server
index 1dd69e1..f58447b 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -31,33 +31,42 @@ freecwmp_output "$parm" "$val" "$permissions"
 }
 
 set_management_server_url() {
-local url=$1
-local scheme
-local hostname
-local path
-local port
-
-scheme=`echo $url | awk -F "://" '{ print $1 }'`
-hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":" '{ print $1 }' | awk -F "/