summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rtsold
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2003-08-08 16:52:31 +0000
committerume <ume@FreeBSD.org>2003-08-08 16:52:31 +0000
commit0820e437dc59b5da388bb504e58d1f00bd256862 (patch)
tree50cba84d10e6505e3662a05163062e1145b9737d /usr.sbin/rtsold
parentbf86284d6ca930a2f0cbe53ce120be3cda8ada70 (diff)
downloadFreeBSD-src-0820e437dc59b5da388bb504e58d1f00bd256862.zip
FreeBSD-src-0820e437dc59b5da388bb504e58d1f00bd256862.tar.gz
drop the code for the environment where getifaddrs(3) is not
supported. Obtained from: KAME MFC after: 1 week
Diffstat (limited to 'usr.sbin/rtsold')
-rw-r--r--usr.sbin/rtsold/Makefile2
-rw-r--r--usr.sbin/rtsold/if.c86
-rw-r--r--usr.sbin/rtsold/rtsold.c4
3 files changed, 1 insertions, 91 deletions
diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile
index bc0f4be..510e2dd 100644
--- a/usr.sbin/rtsold/Makefile
+++ b/usr.sbin/rtsold/Makefile
@@ -19,7 +19,7 @@ MAN= rtsold.8
MLINKS= rtsold.8 rtsol.8
SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
-CFLAGS+= -DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM
+CFLAGS+= -DINET6 -DHAVE_ARC4RANDOM
DPADD= ${LIBKVM}
LDADD= -lkvm
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index 27690ca..b1f9fd6 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -68,9 +68,7 @@
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
-#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
-#endif
#include "rtsold.h"
@@ -78,9 +76,6 @@ extern int rssock;
static int ifsock;
static int get_llflag __P((const char *name));
-#ifndef HAVE_GETIFADDRS
-static unsigned int if_maxindex __P((void));
-#endif
static void get_rtaddrs __P((int addrs, struct sockaddr *sa,
struct sockaddr **rti_info));
@@ -326,7 +321,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;
@@ -370,88 +364,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));
- strcpy(ifr6.ifr_name, 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 55b1942..ca2044a 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -751,9 +751,6 @@ warnmsg(priority, func, msg, va_alist)
static char **
autoifprobe()
{
-#ifndef HAVE_GETIFADDRS
- errx(1, "-a is not available with the configuration");
-#else
static char ifname[IFNAMSIZ + 1];
static char *argv[2];
struct ifaddrs *ifap, *ifa, *target;
@@ -804,5 +801,4 @@ autoifprobe()
return argv;
else
return (char **)NULL;
-#endif
}
OpenPOWER on IntegriCloud