diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-08 16:11:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-08 16:11:12 +0000 |
commit | 0f6681e3c5494add35544b9250439a810bc045d6 (patch) | |
tree | 3cfa6609c5fdafcacf4a3eb1342d6db1c13ffa63 | |
parent | e13cc2d80520205675bd2af774ba409cbc0359e0 (diff) |
kill HAVE_GETIFADDRS
-rw-r--r-- | sbin/isakmpd/if.c | 93 | ||||
-rw-r--r-- | sbin/isakmpd/sysdep/openbsd/Makefile.sysdep | 4 |
2 files changed, 3 insertions, 94 deletions
diff --git a/sbin/isakmpd/if.c b/sbin/isakmpd/if.c index a54b60a4c77..ea9af7e9c16 100644 --- a/sbin/isakmpd/if.c +++ b/sbin/isakmpd/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.23 2005/04/04 19:31:11 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.24 2005/04/08 16:11:11 deraadt Exp $ */ /* $EOM: if.c,v 1.12 1999/10/01 13:45:20 niklas Exp $ */ /* @@ -35,9 +35,7 @@ #include <net/if.h> #include <stdlib.h> #include <unistd.h> -#ifdef HAVE_GETIFADDRS #include <ifaddrs.h> -#endif #include "sysdep.h" @@ -45,81 +43,11 @@ #include "monitor.h" #include "if.h" -#ifndef HAVE_GETIFADDRS -/* XXX Unsafe if either x or y has side-effects. */ -#ifndef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) -#endif - -/* Most boxes has less than 16 interfaces, so this might be a good guess. */ -#define INITIAL_IFREQ_COUNT 16 - -/* - * Get all network interface configurations. - * Return 0 if successful, -1 otherwise. - */ -int -siocgifconf(struct ifconf *ifcp) -{ - caddr_t buf, new_buf; - int s, len; - - /* Get a socket to ask for the network interface configurations. */ - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s == -1) { - log_error("siocgifconf: " - "socket (AF_INET, SOCK_DGRAM, 0) failed"); - return -1; - } - len = sizeof(struct ifreq) * INITIAL_IFREQ_COUNT; - buf = 0; - while (1) { - /* - * Allocate a larger buffer each time around the loop and get - * the network interfaces configurations into it. - */ - new_buf = realloc(buf, len); - if (!new_buf) { - log_error("siocgifconf: realloc (%p, %d) failed", buf, - len); - goto err; - } - ifcp->ifc_len = len; - ifcp->ifc_buf = buf = new_buf; - if (ioctl(s, SIOCGIFCONF, ifcp) == -1) { - log_error("siocgifconf: ioctl (%d, SIOCGIFCONF, ...) " - "failed", s); - goto err; - } - - /* - * If there is place for another ifreq we can be sure that the - * buffer was big enough, otherwise double the size and try - * again. - */ - if (len - ifcp->ifc_len >= sizeof(struct ifreq)) - break; - len *= 2; - } - close(s); - return 0; - -err: - if (buf) - free(buf); - ifcp->ifc_len = 0; - ifcp->ifc_buf = 0; - close(s); - return -1; -} -#endif - int if_map(int (*func)(char *, struct sockaddr *, void *), void *arg) { int err = 0; -#ifdef HAVE_GETIFADDRS struct ifaddrs *ifap, *ifa; if (getifaddrs(&ifap) < 0) @@ -129,24 +57,5 @@ if_map(int (*func)(char *, struct sockaddr *, void *), void *arg) if ((*func)(ifa->ifa_name, ifa->ifa_addr, arg) == -1) err = -1; freeifaddrs(ifap); -#else - struct ifconf ifc; - struct ifreq *ifrp; - caddr_t limit, p; - size_t len; - - if (siocgifconf(&ifc)) - return -1; - - limit = ifc.ifc_buf + ifc.ifc_len; - for (p = ifc.ifc_buf; p < limit; p += len) { - ifrp = (struct ifreq *)p; - if ((*func)(ifrp->ifr_name, &ifrp->ifr_addr, arg) == -1) - err = -1; - len = sizeof ifrp->ifr_name + - MAX(sysdep_sa_len(&ifrp->ifr_addr), sizeof ifrp->ifr_addr); - } - free(ifc.ifc_buf); -#endif return err; } diff --git a/sbin/isakmpd/sysdep/openbsd/Makefile.sysdep b/sbin/isakmpd/sysdep/openbsd/Makefile.sysdep index 2d72338483b..3e48a3cd60f 100644 --- a/sbin/isakmpd/sysdep/openbsd/Makefile.sysdep +++ b/sbin/isakmpd/sysdep/openbsd/Makefile.sysdep @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.sysdep,v 1.26 2005/04/08 16:09:25 deraadt Exp $ +# $OpenBSD: Makefile.sysdep,v 1.27 2005/04/08 16:11:11 deraadt Exp $ # $EOM: Makefile.sysdep,v 1.18 2001/01/26 10:55:22 niklas Exp $ # @@ -32,7 +32,7 @@ IPSEC_SRCS= pf_key_v2.c IPSEC_CFLAGS= -DUSE_PF_KEY_V2 -DUSE_DEFAULT_ROUTE -CFLAGS+= -DHAVE_GETIFADDRS -DHAVE_PCAP +CFLAGS+= -DHAVE_PCAP CFLAGS+= -DHAVE_CLOSEFROM .ifdef FEATURES |