freecwmp
[Top] [All Lists]

[PATCH 2/2] freecwmp: try multiple cwmp urn strings

To: freecwmp@linux-mips.org
Subject: [PATCH 2/2] freecwmp: try multiple cwmp urn strings
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Thu, 23 Feb 2012 16:01:25 +0100
Cc: Kaspar Schleiser <kaspar@schleiser.de>
In-reply-to: <1330009285-19692-1-git-send-email-kaspar@schleiser.de>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <1330009285-19692-1-git-send-email-kaspar@schleiser.de>
Sender: freecwmp-bounce@linux-mips.org
Hey,

servers send different cwmp urn strings depending on their version. 
freecwmp used to expect version 1.2 and hardcode the corresponding urn.

This patch makes freecwmp try multiple version strings.
Apply on top of "freecwmp: make constant url strings const char*".

Kaspar

Signed-off-by: Kaspar Schleiser <kaspar@schleiser.de>
---
 src/xml/xml.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/xml/xml.c b/src/xml/xml.c
index 2e4c07b..0a5a197 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -21,7 +21,12 @@ const static char *soap_env_url = 
"http://schemas.xmlsoap.org/soap/envelope/";;
 const static char *soap_enc_url = "http://schemas.xmlsoap.org/soap/encoding/";;
 const static char *xsd_url = "http://www.w3.org/2001/XMLSchema";;
 const static char *xsi_url = "http://www.w3.org/2001/XMLSchema-instance";;
-const static char *cwmp_url = "urn:dslforum-org:cwmp-1-2";
+
+const static char *cwmp_urls[] =  { 
+               "urn:dslforum-org:cwmp-1-2", 
+               "urn:dslforum-org:cwmp-1-0", 
+               NULL 
+       };
 
 static void
 xml_recreate_namespace(char *msg)
@@ -30,6 +35,8 @@ xml_recreate_namespace(char *msg)
 
        mxml_node_t *tree;
        char *c;
+       const char *cwmp_urn;
+       int i;
 
        if (ns.soap_env)
                free(ns.soap_env);
@@ -66,9 +73,13 @@ xml_recreate_namespace(char *msg)
                ns.xsi = strdup((c + 6));
        }
 
-       c = (char *) mxmlElementGetAttrName(tree, cwmp_url);
-       if (*(c + 5) == ':') {
-               ns.cwmp = strdup((c + 6));
+       for (i = 0; cwmp_urls[i] != NULL; i++) {
+               cwmp_urn = cwmp_urls[i];
+               c = (char *) mxmlElementGetAttrName(tree, cwmp_urn);
+               if (c && *(c + 5) == ':') {
+                       ns.cwmp = strdup((c + 6));
+                       break;
+               }
        }
 
 done:
-- 
1.7.9


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