summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-05-15 14:40:54 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-05-15 14:40:54 +0000
commit4704f778169b60302f0b776a10c48eada74ddf92 (patch)
tree0cf037f32081bd9db9dff9e8f11229cc102d34b4
parent4496bc8d4facd72b6870c01ab4071de6264054fc (diff)
make getifaddrs(3) a default, as all BSD has it by now
-rw-r--r--sbin/rtsol/Makefile4
-rw-r--r--usr.sbin/rtsold/Makefile4
-rw-r--r--usr.sbin/rtsold/if.c86
-rw-r--r--usr.sbin/rtsold/rtsold.c6
4 files changed, 6 insertions, 94 deletions
diff --git a/sbin/rtsol/Makefile b/sbin/rtsol/Makefile
index 09ad6d1677e..e1bf581e77b 100644
--- a/sbin/rtsol/Makefile
+++ b/sbin/rtsol/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.5 2002/10/26 20:23:20 itojun Exp $
+# $OpenBSD: Makefile,v 1.6 2003/05/15 14:40:53 itojun Exp $
PROG= rtsol
SRCS= rtsold.c rtsol.c if.c probe.c dump.c
-CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_GETIFADDRS -DHAVE_POLL_H
+CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_POLL_H
#MAN= rtsold.8
NOMAN= yes
diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile
index 143d5d493d6..a80a7929ade 100644
--- a/usr.sbin/rtsold/Makefile
+++ b/usr.sbin/rtsold/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.5 2002/10/26 20:23:20 itojun Exp $
+# $OpenBSD: Makefile,v 1.6 2003/05/15 14:40:53 itojun Exp $
PROG= rtsold
SRCS= rtsold.c rtsol.c if.c probe.c dump.c
-CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_GETIFADDRS -DHAVE_POLL_H
+CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_POLL_H
MAN= rtsold.8
MLINKS= rtsold.8 rtsol.8
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index ff0f297bc46..6b864a02995 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.15 2003/04/02 23:39:20 jason Exp $ */
+/* $OpenBSD: if.c,v 1.16 2003/05/15 14:40:53 itojun Exp $ */
/* $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $ */
/*
@@ -56,9 +56,7 @@
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
-#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
-#endif
#include "rtsold.h"
@@ -66,9 +64,6 @@ extern int rssock;
static int ifsock;
static int get_llflag(const char *);
-#ifndef HAVE_GETIFADDRS
-static unsigned int if_maxindex(void);
-#endif
static void get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
int
@@ -310,7 +305,6 @@ getinet6sysctl(int code)
static int
get_llflag(const char *name)
{
-#ifdef HAVE_GETIFADDRS
struct ifaddrs *ifap, *ifa;
struct in6_ifreq ifr6;
struct sockaddr_in6 *sin6;
@@ -354,86 +348,8 @@ get_llflag(const char *name)
freeifaddrs(ifap);
close(s);
return -1;
-#else
- int s;
- unsigned int maxif;
- struct ifreq *iflist;
- struct ifconf ifconf;
- struct ifreq *ifr, *ifr_end;
- struct sockaddr_in6 *sin6;
- struct in6_ifreq ifr6;
-
- maxif = if_maxindex() + 1;
- iflist = (struct ifreq *)malloc(maxif * BUFSIZ); /* XXX */
- if (iflist == NULL) {
- warnmsg(LOG_ERR, __func__, "not enough core");
- exit(1);
- }
-
- if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) < 0) {
- warnmsg(LOG_ERR, __func__, "socket(SOCK_DGRAM): %s",
- strerror(errno));
- exit(1);
- }
- memset(&ifconf, 0, sizeof(ifconf));
- ifconf.ifc_req = iflist;
- ifconf.ifc_len = maxif * BUFSIZ; /* XXX */
- if (ioctl(s, SIOCGIFCONF, &ifconf) < 0) {
- warnmsg(LOG_ERR, __func__, "ioctl(SIOCGIFCONF): %s",
- strerror(errno));
- exit(1);
- }
-
- /* Look for this interface in the list */
- ifr_end = (struct ifreq *) (ifconf.ifc_buf + ifconf.ifc_len);
- for (ifr = ifconf.ifc_req; ifr < ifr_end;
- ifr = (struct ifreq *) ((char *) &ifr->ifr_addr
- + ifr->ifr_addr.sa_len)) {
- if (strlen(ifr->ifr_name) != strlen(name) ||
- strncmp(ifr->ifr_name, name, strlen(name)) != 0)
- continue;
- if (ifr->ifr_addr.sa_family != AF_INET6)
- continue;
- sin6 = (struct sockaddr_in6 *)&ifr->ifr_addr;
- if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
- continue;
-
- memset(&ifr6, 0, sizeof(ifr6));
- strncpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
- memcpy(&ifr6.ifr_ifru.ifru_addr, sin6, sin6->sin6_len);
- if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) < 0) {
- warnmsg(LOG_ERR, __func__,
- "ioctl(SIOCGIFAFLAG_IN6): %s", strerror(errno));
- exit(1);
- }
-
- free(iflist);
- close(s);
- return ifr6.ifr_ifru.ifru_flags6;
- }
-
- free(iflist);
- close(s);
- return -1;
-#endif
}
-#ifndef HAVE_GETIFADDRS
-static unsigned int
-if_maxindex()
-{
- struct if_nameindex *p, *p0;
- unsigned int max = 0;
-
- p0 = if_nameindex();
- for (p = p0; p && p->if_index && p->if_name; p++) {
- if (max < p->if_index)
- max = p->if_index;
- }
- if_freenameindex(p0);
- return max;
-}
-#endif
static void
get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c
index a961acc9107..87150bd6abc 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsold.c,v 1.28 2003/03/13 22:26:52 millert Exp $ */
+/* $OpenBSD: rtsold.c,v 1.29 2003/05/15 14:40:53 itojun Exp $ */
/* $KAME: rtsold.c,v 1.57 2002/09/20 21:59:55 itojun Exp $ */
/*
@@ -783,9 +783,6 @@ warnmsg(int priority, const char *func, const char *msg, ...)
char **
autoifprobe()
{
-#ifndef HAVE_GETIFADDRS
- errx(1, "-a is not available with the configuration");
-#else
static char **argv = NULL;
static int n = 0;
char **a;
@@ -856,5 +853,4 @@ autoifprobe()
}
freeifaddrs(ifap);
return argv;
-#endif
}