[netcf-devel] [PATCH 1/3] Remove config-origined ip addrs from ncf_if_xml_state output.
Laine Stump
laine at laine.org
Tue Sep 29 18:39:03 UTC 2009
The output of ncf_if_xml_state will now contain only IP addresses
retrieved directly from the device.
---
src/dutil.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/dutil.c b/src/dutil.c
index e2d05b8..dd75768 100644
--- a/src/dutil.c
+++ b/src/dutil.c
@@ -586,20 +586,24 @@ void add_state_to_xml_doc(xmlDocPtr doc, struct netcf *ncf ATTRIBUTE_UNUSED,
}
- for (cur = proto->children; cur != NULL; cur = cur->next) {
+ /* remove all existing ip nodes from the protocol node - we only
+ * want addresses retrieved from the device in the output.
+ */
+ cur = proto->children;
+ while(cur != NULL) {
+ xmlNodePtr next = cur->next;
if ((cur->type == XML_ELEMENT_NODE) &&
(xmlStrEqual(cur->name, BAD_CAST "ip"))) {
- break;
+ xmlUnlinkNode(cur);
+ xmlFreeNode(cur);
}
+ cur = next;
}
- if (ip == NULL) {
- ip = xmlNewDocNode(doc, NULL, BAD_CAST "ip", NULL);
- ERR_NOMEM((ip == NULL), ncf);
-
- cur = xmlAddChild(proto, ip);
- ERR_NOMEM((cur == NULL), ncf);
- }
+ ip = xmlNewDocNode(doc, NULL, BAD_CAST "ip", NULL);
+ ERR_NOMEM((ip == NULL), ncf);
+ cur = xmlAddChild(proto, ip);
+ ERR_NOMEM((cur == NULL), ncf);
inet_ntop(AF_INET, (struct in_addr *)&ipv4, ip_str, sizeof(ip_str));
prop = xmlSetProp(ip, BAD_CAST "address", BAD_CAST ip_str);
--
1.6.2.5
More information about the netcf-devel
mailing list