freecwmp
[Top] [All Lists]

ubus data model patch [12/27]

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

  ubus data model patch [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



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