]> git.proxmox.com Git - mirror_corosync.git/commitdiff
totemip: clean up headers a lot more
authorFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 30 Aug 2012 10:54:48 +0000 (12:54 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 30 Aug 2012 13:00:27 +0000 (15:00 +0200)
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@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
configure.ac
exec/totemip.c

index c2aa47bd1f52a0a5bec796f45bf7a6b00b9c5605..7ff899789344c2d393431e47e1a33da154deffac 100644 (file)
@@ -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])],
index e0c731749969cf881327c77670fb4971923150eb..a641febfce26121bff250bed318347d68d323af8 100644 (file)
 #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)
 {