mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Optimize get of namespaces
This commit is contained in:
parent
9f20db9d6d
commit
06278ffdca
1 changed files with 21 additions and 9 deletions
30
src/xml.c
30
src/xml.c
|
|
@ -922,16 +922,18 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
||||||
int i;
|
int i;
|
||||||
mxml_node_t *b = tree;
|
mxml_node_t *b = tree;
|
||||||
|
|
||||||
|
FREE(ns.soap_env);
|
||||||
|
FREE(ns.soap_enc);
|
||||||
|
FREE(ns.xsd);
|
||||||
|
FREE(ns.xsi);
|
||||||
|
FREE(ns.cwmp);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char *c;
|
char *c;
|
||||||
FREE(ns.soap_env);
|
|
||||||
FREE(ns.soap_enc);
|
|
||||||
FREE(ns.xsd);
|
|
||||||
FREE(ns.xsi);
|
|
||||||
FREE(ns.cwmp);
|
|
||||||
|
|
||||||
c = (char *)xml__get_attribute_name_by_value(b, soap_env_url);
|
c = (char *)xml__get_attribute_name_by_value(b, soap_env_url);
|
||||||
if (c && *(c + 5) == ':') {
|
if (c && *(c + 5) == ':') {
|
||||||
|
FREE(ns.soap_env);
|
||||||
ns.soap_env = strdup((c + 6));
|
ns.soap_env = strdup((c + 6));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -939,6 +941,7 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
||||||
|
|
||||||
c = (char *)xml__get_attribute_name_by_value(b, soap_enc_url);
|
c = (char *)xml__get_attribute_name_by_value(b, soap_enc_url);
|
||||||
if (c && *(c + 5) == ':') {
|
if (c && *(c + 5) == ':') {
|
||||||
|
FREE(ns.soap_enc);
|
||||||
ns.soap_enc = strdup((c + 6));
|
ns.soap_enc = strdup((c + 6));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -946,6 +949,7 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
||||||
|
|
||||||
c = (char *)xml__get_attribute_name_by_value(b, xsd_url);
|
c = (char *)xml__get_attribute_name_by_value(b, xsd_url);
|
||||||
if (c && *(c + 5) == ':') {
|
if (c && *(c + 5) == ':') {
|
||||||
|
FREE(ns.xsd);
|
||||||
ns.xsd = strdup((c + 6));
|
ns.xsd = strdup((c + 6));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -953,6 +957,7 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
||||||
|
|
||||||
c = (char *)xml__get_attribute_name_by_value(b, xsi_url);
|
c = (char *)xml__get_attribute_name_by_value(b, xsi_url);
|
||||||
if (c && *(c + 5) == ':') {
|
if (c && *(c + 5) == ':') {
|
||||||
|
FREE(ns.xsi);
|
||||||
ns.xsi = strdup((c + 6));
|
ns.xsi = strdup((c + 6));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -962,15 +967,17 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
||||||
cwmp_urn = cwmp_urls[i];
|
cwmp_urn = cwmp_urls[i];
|
||||||
c = (char *)xml__get_attribute_name_by_value(b, cwmp_urn);
|
c = (char *)xml__get_attribute_name_by_value(b, cwmp_urn);
|
||||||
if (c && *(c + 5) == ':') {
|
if (c && *(c + 5) == ':') {
|
||||||
|
FREE(ns.cwmp);
|
||||||
ns.cwmp = strdup((c + 6));
|
ns.cwmp = strdup((c + 6));
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ns.cwmp)
|
if (ns.cwmp && ns.soap_env && ns.xsd && ns.soap_enc && ns.xsi)
|
||||||
continue;
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
} while ((b = mxmlWalkNext(b, tree, MXML_DESCEND)));
|
} while ((b = mxmlWalkNext(b, tree, MXML_DESCEND)));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1039,7 +1046,12 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
||||||
session->tree_in = mxmlLoadString(NULL, msg_in, MXML_OPAQUE_CALLBACK);
|
session->tree_in = mxmlLoadString(NULL, msg_in, MXML_OPAQUE_CALLBACK);
|
||||||
if (!session->tree_in)
|
if (!session->tree_in)
|
||||||
goto error;
|
goto error;
|
||||||
xml_recreate_namespace(session->tree_in);
|
|
||||||
|
if (xml_recreate_namespace(session->tree_in) == -1) {
|
||||||
|
CWMP_LOG(ERROR, "Failed to get ns parameters");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* get NoMoreRequests or HolRequest*/
|
/* get NoMoreRequests or HolRequest*/
|
||||||
session->hold_request = false;
|
session->hold_request = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue