[PATCH 09/13] totemip: clean up headers a lot more

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

getifaddrs is always available if there is freeifaddr.

all BSD and openindiana have it defined in ifaddr.h.

drop a bunch of obsoleted headers.

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
:100644 100644 c2aa47b... 7ff8997... M	configure.ac
:100644 100644 e0c7317... a641feb... M	exec/totemip.c
 configure.ac   |    3 +-
 exec/totemip.c |  120 --------------------------------------------------------
 2 files changed, 1 insertions(+), 122 deletions(-)

diff --git a/configure.ac b/configure.ac
index c2aa47b..7ff8997 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,8 +94,7 @@ AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdint.h \
 		  stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h \
 		  sys/time.h syslog.h unistd.h sys/types.h getopt.h malloc.h \
-		  sys/sockio.h utmpx.h ifaddrs.h stddef.h sys/file.h \
-		  net/if_var.h netinet/in_var.h netinet/in.h])
+		  utmpx.h ifaddrs.h stddef.h sys/file.h])
 
 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
 		[AC_DEFINE_UNQUOTED([HAVE_SOCK_SIN_LEN], [1], [sockaddr_in needs sin_len])],
diff --git a/exec/totemip.c b/exec/totemip.c
index e0c7317..a641feb 100644
--- a/exec/totemip.c
+++ b/exec/totemip.c
@@ -50,21 +50,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
-#endif
-#ifdef HAVE_NET_IF_VAR_H
-#include <net/if_var.h>
-#endif
-#ifdef HAVE_NETINET_IN_VAR_H
-#include <netinet/in_var.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_IFADDRS_H
 #include <ifaddrs.h>
-#endif
 
 #include <corosync/totem/totemip.h>
 #include <corosync/swab.h>
@@ -333,7 +319,6 @@ int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
 	return ret;
 }
 
-#if defined(HAVE_GETIFADDRS)
 int totemip_getifaddrs(struct list_head *addrs)
 {
 	struct ifaddrs *ifap, *ifa;
@@ -396,111 +381,6 @@ error_free_ifaddrs:
 	freeifaddrs(ifap);
 	return (-1);
 }
-#elif defined(SOLARIS)
-/*
- * On Solaris, man if_tcp describes this method
- */
-int totemip_getifaddrs(struct list_head *addrs)
-{
-	int id_fd;
-	int numreqs;
-	int res;
-	struct lifconf lifconf;
-	struct lifreq *lifreq;
-	int i, j;
-	struct totem_ip_if_address *if_addr;
-	short family;
-
-	list_init(addrs);
-
-	for (family = 0; family < 2; family++) {
-		numreqs = 0;
-		res = -1;
-
-		lifconf.lifc_family = (family == 0 ? AF_INET : AF_INET6);
-		id_fd = socket (lifconf.lifc_family, SOCK_STREAM, 0);
-		lifconf.lifc_flags = 0;
-		lifconf.lifc_buf = NULL;
-		lifconf.lifc_len = 0;
-		do {
-			numreqs += 32;
-			lifconf.lifc_len = sizeof (struct lifreq) * numreqs;
-			lifconf.lifc_buf = (void *)realloc(lifconf.lifc_buf, lifconf.lifc_len);
-			res = ioctl (id_fd, SIOCGLIFCONF, &lifconf);
-			if (res < 0) {
-				close (id_fd);
-			}
-		} while (res >= 0 && lifconf.lifc_len == sizeof (struct lifconf) * numreqs);
-
-		if (res < 0)
-			continue ;
-
-		lifreq = (struct lifreq *)lifconf.lifc_buf;
-		for (i = 0; i < lifconf.lifc_len / sizeof (struct lifreq); i++) {
-			if (ioctl(id_fd, SIOCGLIFADDR, &lifreq[i]) < 0)
-				continue ;
-
-			if (lifreq[i].lifr_addr.ss_family != AF_INET && lifreq[i].lifr_addr.ss_family != AF_INET6)
-				continue ;
-
-			if_addr = malloc(sizeof(struct totem_ip_if_address));
-			if (if_addr == NULL) {
-				goto error_free_ifaddrs;
-			}
-
-			memset(if_addr, 0, sizeof(struct totem_ip_if_address));
-
-			if_addr->name = strdup(lifreq[i].lifr_name);
-			if (if_addr->name == NULL) {
-				goto error_free_addr;
-			}
-
-			if (totemip_sockaddr_to_totemip_convert(&lifreq[i].lifr_addr, &if_addr->ip_addr) == -1) {
-				goto error_free_addr_name;
-			}
-
-			if (ioctl(id_fd, SIOCGLIFSUBNET, &lifreq[i]) < 0)
-				continue ;
-
-			/*
-			 * lifreq doesn't contain mask address. But It length of prefix in bits,
-			 * so we can generate mask.
-			 */
-			memset(&if_addr->mask_addr, 0, sizeof(if_addr->mask_addr));
-			if_addr->mask_addr.family = if_addr->ip_addr.family;
-			for (j = 0; j < lifreq[i].lifr_addrlen; j++) {
-				if_addr->mask_addr.addr[j / 8] |= 1 << (7 - (j % 8));
-			}
-			if (ioctl(id_fd, SIOCGLIFFLAGS, &lifreq[i]) >= 0) {
-				if_addr->interface_up = lifreq[i].lifr_flags & IFF_UP;
-			}
-			if (ioctl(id_fd, SIOCGLIFINDEX, &lifreq[i]) >= 0) {
-				if_addr->interface_num = lifreq[i].lifr_index;
-			}
-
-			list_add_tail(&if_addr->list, addrs);
-		}
-
-		free (lifconf.lifc_buf);
-		close (id_fd);
-	}
-
-	return (0);
-
-error_free_addr_name:
-	free(if_addr->name);
-
-error_free_addr:
-	free(if_addr);
-
-error_free_ifaddrs:
-	totemip_freeifaddrs(addrs);
-	free (lifconf.lifc_buf);
-	close (id_fd);
-
-	return (-1);
-}
-#endif /* HAVE_GETIFADDRS */
 
 void totemip_freeifaddrs(struct list_head *addrs)
 {
-- 
1.7.7.6

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux