[netcf-devel] [PATCH 3/3] Remove newly deprecated code.

Laine Stump laine at laine.org
Thu Oct 22 13:43:24 UTC 2009


This patch removes add_ipv4_state_to_xml_doc() (which uses
ioctl(SIOCGIFADDR)), whose functionality was replaced in the previous
commit with the new add_state_to_xml_doc() (which uses the netlink
socket).
---
 src/dutil.c |   79 -----------------------------------------------------------
 src/dutil.h |    3 --
 2 files changed, 0 insertions(+), 82 deletions(-)

diff --git a/src/dutil.c b/src/dutil.c
index d12d656..3adc6f8 100644
--- a/src/dutil.c
+++ b/src/dutil.c
@@ -656,85 +656,6 @@ int dutil_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
     return result;
 }
 
-/* Given an xml document that follows interface.rng, add the IP
- * address and prefix under protocol/ip
- */
-void add_ipv4_state_to_xml_doc(xmlDocPtr doc, struct netcf *ncf ATTRIBUTE_UNUSED,
-                          unsigned int ipv4, int prefix) {
-
-    xmlNodePtr root = NULL, proto = NULL, ip = NULL, cur;
-    xmlAttrPtr prop = NULL;
-    char ip_str[48], prefix_str[16];
-
-
-    root = xmlDocGetRootElement(doc);
-    ERR_THROW((root == NULL), ncf, EINTERNAL,
-              "failed to get document root element");
-
-    ERR_THROW(!xmlStrEqual(root->name, BAD_CAST "interface"),
-              ncf, EINTERNAL, "root document is not an interface");
-
-    for (cur = root->children; cur != NULL; cur = cur->next) {
-        if ((cur->type == XML_ELEMENT_NODE) &&
-            xmlStrEqual(cur->name, BAD_CAST "protocol")) {
-            xmlChar *family = xmlGetProp(cur, BAD_CAST "family");
-            if (family != NULL) {
-                if (xmlStrEqual(family, BAD_CAST "ipv4"))
-                    proto = cur;
-                xmlFree(family);
-                if (proto != NULL) {
-                    break;
-                }
-            }
-        }
-    }
-
-    if ((ipv4 != 0) && (proto == NULL)) {
-        proto = xmlNewDocNode(doc, NULL, BAD_CAST "protocol", NULL);
-        ERR_NOMEM(proto == NULL, ncf);
-
-        cur = xmlAddChild(root, proto);
-        ERR_NOMEM(cur == NULL, ncf);
-        prop = xmlSetProp(proto, BAD_CAST "family", BAD_CAST "ipv4");
-        ERR_NOMEM(prop == NULL, ncf);
-
-    }
-
-    if (proto == NULL)
-        return;
-
-    /* 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"))) {
-            xmlUnlinkNode(cur);
-            xmlFreeNode(cur);
-        }
-        cur = next;
-    }
-
-    if (ipv4 != 0) {
-        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);
-        ERR_NOMEM((prop == NULL), ncf);
-        snprintf(prefix_str, sizeof(prefix_str), "%d", prefix);
-        prop = xmlSetProp(ip, BAD_CAST "prefix", BAD_CAST prefix_str);
-        ERR_NOMEM((prop == NULL), ncf);
-    }
-
-error:
-    return;
-}
-
 /* Data that needs to be preserved between calls to the libnl iterator
  * callback.
  */
diff --git a/src/dutil.h b/src/dutil.h
index f664a05..4f87f5b 100644
--- a/src/dutil.h
+++ b/src/dutil.h
@@ -147,9 +147,6 @@ int dutil_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml);
 /* Transform the Augeas XML AUG_XML into interface XML NCF_XML */
 int dutil_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml);
 
-/* add the given state (currently IP + netmask) to the interface's xml document */
-void add_ipv4_state_to_xml_doc(xmlDocPtr doc, struct netcf *ncf, unsigned int ipv4, int prefix);
-
 /* Add the state of the interface (currently all addresses + netmasks)
  * to its xml document.
  */
-- 
1.6.5.15.gc274d



More information about the netcf-devel mailing list