freecwmp
[Top] [All Lists]

[PATCH v2 04/10] Update inform in order to get parameters from ubus

To: freecwmp@linux-mips.org
Subject: [PATCH v2 04/10] Update inform in order to get parameters from ubus
From: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Date: Fri, 28 Dec 2012 16:59:41 +0100
Cc: freecwmp@lukaperkov.net, jogo@openwrt.org, Mohamed <mohamed.kallel@pivasoftware.com>, Ahmed Zribi <ahmed.zribi@pivasoftware.com>
In-reply-to: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <1356710387-3043-1-git-send-email-mohamed.kallel@pivasoftware.com>
Sender: freecwmp-bounce@linux-mips.org
From: Mohamed <mohamed.kallel@pivasoftware.com>

Update 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


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