[netcf-devel] [PATCH 4/4] Remove newly deprecated code.
Laine Stump
laine at laine.org
Thu Oct 22 17:38:42 UTC 2009
From: root <root at vlap.laine.org>
This patch removes add_ipv4_state_to_xml_doc() and the utility
functions it calls (which use ioctl(SIOCGIFADDR)). Their
functionality was replaced in the previous commit with the new
add_state_to_xml_doc() (which uses the netlink socket).
---
src/dutil.c | 133 -----------------------------------------------------------
src/dutil.h | 14 ------
2 files changed, 0 insertions(+), 147 deletions(-)
diff --git a/src/dutil.c b/src/dutil.c
index 271d9a1..24c422d 100644
--- a/src/dutil.c
+++ b/src/dutil.c
@@ -509,60 +509,6 @@ int if_is_active(struct netcf *ncf, const char *intf) {
return ((ifr.ifr_flags & IFF_UP) == IFF_UP);
}
-unsigned int if_ipv4_address(struct netcf *ncf, const char *intf) {
- struct ifreq ifr;
-
- if (!if_is_active(ncf, intf)) {
- /* SIOCGIFADDR fails on a device that is down */
- return 0;
- }
- MEMZERO(&ifr, 1);
- strncpy(ifr.ifr_name, intf, sizeof(ifr.ifr_name));
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
- if (ioctl(ncf->driver->ioctl_fd, SIOCGIFADDR, &ifr)) {
- if (errno != EADDRNOTAVAIL) {
- report_error(ncf, NETCF_EIOCTL, "Failed to get ipv4 address for %s - %s",
- intf, strerror(errno));
- }
- return 0;
- }
-
- return (((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
-}
-
-unsigned int if_ipv4_netmask(struct netcf *ncf, const char *intf) {
- struct ifreq ifr;
-
- if (!if_is_active(ncf, intf)) {
- /* SIOCGIFNETMASK fails on a device that is down */
- return 0;
- }
- MEMZERO(&ifr, 1);
- strncpy(ifr.ifr_name, intf, sizeof(ifr.ifr_name));
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
- if (ioctl(ncf->driver->ioctl_fd, SIOCGIFNETMASK, &ifr)) {
- if (errno != EADDRNOTAVAIL) {
- report_error(ncf, NETCF_EIOCTL, "Failed to get ipv4 netmask for %s - %s",
- intf, strerror(errno));
- }
- return 0;
- }
-
- return (((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr);
-}
-
-int if_ipv4_prefix(struct netcf *ncf, const char *intf) {
- unsigned int nmv4 = if_ipv4_netmask(ncf, intf);
- int prefix = 0;
-
- nmv4 = ntohl(nmv4);
- while ((nmv4 & 0xFFFFFFFF) != 0) {
- nmv4 <<= 1;
- prefix++;
- }
- return prefix;
-}
-
const char *if_type(struct netcf *ncf, const char *intf) {
char *path;
struct stat stats;
@@ -656,85 +602,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..93dae1a 100644
--- a/src/dutil.h
+++ b/src/dutil.h
@@ -122,17 +122,6 @@ int netlink_close(struct netcf *ncf);
/* Check if the interface INTF is up using an ioctl call */
int if_is_active(struct netcf *ncf, const char *intf);
-/* Get the current IPv4 address of INTF as an unsigned int using an ioctl call */
-unsigned int if_ipv4_address(struct netcf *ncf, const char *intf);
-
-/* get the current IPv4 netmask of INTF as an unsigned int using an ioctl call */
-unsigned int if_ipv4_netmask(struct netcf *ncf, const char *intf);
-
-/* get the current IPv4 prefix (#bits of netmask) of INTF as an
- * int using an ioctl call */
-
-int if_ipv4_prefix(struct netcf *ncf, const char *intf);
-
/* return the type of the interface - "ethernet" (physical device),
* "bridge", "bond", or "vlan"
*/
@@ -147,9 +136,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