Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src assume presense of getifaddrs(3).
details: https://anonhg.NetBSD.org/src/rev/af60cf787213
branches: trunk
changeset: 547234:af60cf787213
user: itojun <itojun%NetBSD.org@localhost>
date: Thu May 15 14:44:57 2003 +0000
description:
assume presense of getifaddrs(3).
diffstat:
sbin/rtsol/Makefile | 4 +-
usr.sbin/rtsold/Makefile | 4 +-
usr.sbin/rtsold/if.c | 86 +-----------------------------------------------
usr.sbin/rtsold/rtsold.c | 6 +--
4 files changed, 6 insertions(+), 94 deletions(-)
diffs (182 lines):
diff -r c27ad04c558e -r af60cf787213 sbin/rtsol/Makefile
--- a/sbin/rtsol/Makefile Thu May 15 14:34:39 2003 +0000
+++ b/sbin/rtsol/Makefile Thu May 15 14:44:57 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2002/08/19 10:17:00 lukem Exp $
+# $NetBSD: Makefile,v 1.11 2003/05/15 14:44:58 itojun Exp $
NOMAN= # defined
@@ -7,7 +7,7 @@
PROG= rtsol
SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
-CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM -DUSE_RTSOCK
+CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DUSE_RTSOCK
#MAN= rtsold.8
diff -r c27ad04c558e -r af60cf787213 usr.sbin/rtsold/Makefile
--- a/usr.sbin/rtsold/Makefile Thu May 15 14:34:39 2003 +0000
+++ b/usr.sbin/rtsold/Makefile Thu May 15 14:44:57 2003 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.8 2002/05/31 22:10:18 itojun Exp $
+# $NetBSD: Makefile,v 1.9 2003/05/15 14:44:57 itojun Exp $
PROG= rtsold
SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
-CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM -DUSE_RTSOCK
+CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DUSE_RTSOCK
MAN= rtsold.8
MLINKS= rtsold.8 rtsol.8
diff -r c27ad04c558e -r af60cf787213 usr.sbin/rtsold/if.c
--- a/usr.sbin/rtsold/if.c Thu May 15 14:34:39 2003 +0000
+++ b/usr.sbin/rtsold/if.c Thu May 15 14:44:57 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.11 2003/04/02 23:29:29 itojun Exp $ */
+/* $NetBSD: if.c,v 1.12 2003/05/15 14:44:57 itojun Exp $ */
/* $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $ */
/*
@@ -55,9 +55,7 @@
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
-#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
-#endif
#include "rtsold.h"
@@ -65,9 +63,6 @@
static int ifsock;
static int get_llflag __P((const char *));
-#ifndef HAVE_GETIFADDRS
-static unsigned int if_maxindex __P((void));
-#endif
static void get_rtaddrs __P((int, struct sockaddr *, struct sockaddr **));
int
@@ -309,7 +304,6 @@
static int
get_llflag(const char *name)
{
-#ifdef HAVE_GETIFADDRS
struct ifaddrs *ifap, *ifa;
struct in6_ifreq ifr6;
struct sockaddr_in6 *sin6;
@@ -353,86 +347,8 @@
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, __FUNCTION__, "not enough core");
- exit(1);
- }
-
- if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) < 0) {
- warnmsg(LOG_ERR, __FUNCTION__, "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, __FUNCTION__, "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, __FUNCTION__,
- "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(void)
-{
- 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 -r c27ad04c558e -r af60cf787213 usr.sbin/rtsold/rtsold.c
--- a/usr.sbin/rtsold/rtsold.c Thu May 15 14:34:39 2003 +0000
+++ b/usr.sbin/rtsold/rtsold.c Thu May 15 14:44:57 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsold.c,v 1.22 2003/05/15 00:19:30 itojun Exp $ */
+/* $NetBSD: rtsold.c,v 1.23 2003/05/15 14:44:57 itojun Exp $ */
/* $KAME: rtsold.c,v 1.55 2002/09/08 01:26:03 itojun Exp $ */
/*
@@ -731,9 +731,6 @@
char **
autoifprobe(void)
{
-#ifndef HAVE_GETIFADDRS
- errx(1, "-a is not available with the configuration");
-#else
static char **argv = NULL;
static int n = 0;
char **a;
@@ -806,5 +803,4 @@
}
freeifaddrs(ifap);
return argv;
-#endif
}
Home |
Main Index |
Thread Index |
Old Index