freecwmp
[Top] [All Lists]

[PATCH 12/27] update inform in order to get parameters from ubus instead

To: freecwmp@linux-mips.org
Subject: [PATCH 12/27] update inform in order to get parameters from ubus instead from pipe Contributed by PIVA SOFTWARE
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Thu, 6 Dec 2012 16:54:37 +0100
Cc: freecwmp@lukaperkov.net, Mohamed <mohamed.kallel@pivasoftware.com>, Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
In-reply-to: <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com>
Sender: freecwmp-bounce@linux-mips.org
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


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