Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig assume the presense of getifaddrs(3).
details: https://anonhg.NetBSD.org/src/rev/cd84cdfc1594
branches: trunk
changeset: 509155:cd84cdfc1594
user: itojun <itojun%NetBSD.org@localhost>
date: Sat Apr 28 00:00:06 2001 +0000
description:
assume the presense of getifaddrs(3).
diffstat:
sbin/ifconfig/Makefile | 3 +-
sbin/ifconfig/ifconfig.c | 159 +----------------------------------------------
2 files changed, 3 insertions(+), 159 deletions(-)
diffs (239 lines):
diff -r d18f505addf5 -r cd84cdfc1594 sbin/ifconfig/Makefile
--- a/sbin/ifconfig/Makefile Fri Apr 27 21:36:58 2001 +0000
+++ b/sbin/ifconfig/Makefile Sat Apr 28 00:00:06 2001 +0000
@@ -1,11 +1,10 @@
-# $NetBSD: Makefile,v 1.12 2000/04/13 07:39:57 itojun Exp $
+# $NetBSD: Makefile,v 1.13 2001/04/28 00:00:06 itojun Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= ifconfig
MAN= ifconfig.8
CPPFLAGS+=-DINET6
-CPPFLAGS+=-DHAVE_IFADDRS_H
# KAME scope id hack
CPPFLAGS+=-DKAME_SCOPEID
diff -r d18f505addf5 -r cd84cdfc1594 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c Fri Apr 27 21:36:58 2001 +0000
+++ b/sbin/ifconfig/ifconfig.c Sat Apr 28 00:00:06 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ifconfig.c,v 1.105 2001/04/27 09:10:04 itojun Exp $ */
+/* $NetBSD: ifconfig.c,v 1.106 2001/04/28 00:00:06 itojun Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-__RCSID("$NetBSD: ifconfig.c,v 1.105 2001/04/27 09:10:04 itojun Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.106 2001/04/28 00:00:06 itojun Exp $");
#endif
#endif /* not lint */
@@ -121,9 +121,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
-#endif
struct ifreq ifr, ridreq;
struct ifaliasreq addreq __attribute__((aligned(4)));
@@ -696,7 +694,6 @@
void
printall()
{
-#ifdef HAVE_IFADDRS_H
struct ifaddrs *ifap, *ifa;
struct ifreq ifr;
const struct sockaddr_dl *sdl = NULL;
@@ -755,80 +752,6 @@
if (lflag)
putchar('\n');
freeifaddrs(ifap);
-#else
- char inbuf[8192];
- const struct sockaddr_dl *sdl = NULL;
- struct ifconf ifc;
- struct ifreq ifreq, *ifr;
- int i, siz, idx;
- char ifrbuf[8192], *cp;
-
- ifc.ifc_len = sizeof(inbuf);
- ifc.ifc_buf = inbuf;
- getsock(af);
- if (s < 0)
- err(1, "socket");
- if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
- err(1, "SIOCGIFCONF");
- ifreq.ifr_name[0] = '\0';
- for (i = 0, idx = 0; i < ifc.ifc_len; ) {
- /* Copy the mininum ifreq into the buffer. */
- cp = ((caddr_t)ifc.ifc_req + i);
- memcpy(ifrbuf, cp, sizeof(*ifr));
-
- /* Now compute the actual size of the ifreq. */
- ifr = (struct ifreq *)ifrbuf;
- siz = ifr->ifr_addr.sa_len;
- if (siz < sizeof(ifr->ifr_addr))
- siz = sizeof(ifr->ifr_addr);
- siz += sizeof(ifr->ifr_name);
- i += siz;
-
- /* Now copy the whole thing. */
- if (sizeof(ifrbuf) < siz)
- errx(1, "ifr too big");
- memcpy(ifrbuf, cp, siz);
-
- if (ifr->ifr_addr.sa_family == AF_LINK)
- sdl = (const struct sockaddr_dl *) &ifr->ifr_addr;
- if (!strncmp(ifreq.ifr_name, ifr->ifr_name,
- sizeof(ifr->ifr_name)))
- continue;
- (void) strncpy(name, ifr->ifr_name, sizeof(ifr->ifr_name));
- ifreq = *ifr;
-
- if (getinfo(&ifreq) < 0)
- continue;
- if (bflag && (flags & (IFF_POINTOPOINT|IFF_LOOPBACK)))
- continue;
- if (dflag && (flags & IFF_UP) != 0)
- continue;
- if (uflag && (flags & IFF_UP) == 0)
- continue;
-
- if (sflag && carrier())
- continue;
- idx++;
- /*
- * Are we just listing the interfaces?
- */
- if (lflag) {
- if (idx > 1)
- putchar(' ');
- fputs(name, stdout);
- continue;
- }
-
- if (sdl == NULL) {
- status(NULL, 0);
- } else {
- status(LLADDR(sdl), sdl->sdl_alen);
- sdl = NULL;
- }
- }
- if (lflag)
- putchar('\n');
-#endif
}
void
@@ -2066,7 +1989,6 @@
in_status(force)
int force;
{
-#ifdef HAVE_IFADDRS_H
struct ifaddrs *ifap, *ifa;
struct ifreq ifr;
@@ -2086,44 +2008,6 @@
in_alias(&ifr);
}
freeifaddrs(ifap);
-#else
- char inbuf[8192];
- struct ifconf ifc;
- struct ifreq *ifr;
- int i, siz;
- char ifrbuf[8192], *cp;
-
- ifc.ifc_len = sizeof(inbuf);
- ifc.ifc_buf = inbuf;
- getsock(af);
- if (s < 0)
- err(1, "socket");
- if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
- err(1, "SIOCGIFCONF");
- for (i = 0; i < ifc.ifc_len; ) {
- /* Copy the mininum ifreq into the buffer. */
- cp = ((caddr_t)ifc.ifc_req + i);
- memcpy(ifrbuf, cp, sizeof(*ifr));
-
- /* Now compute the actual size of the ifreq. */
- ifr = (struct ifreq *)ifrbuf;
- siz = ifr->ifr_addr.sa_len;
- if (siz < sizeof(ifr->ifr_addr))
- siz = sizeof(ifr->ifr_addr);
- siz += sizeof(ifr->ifr_name);
- i += siz;
-
- /* Now copy the whole thing. */
- if (sizeof(ifrbuf) < siz)
- errx(1, "ifr too big");
- memcpy(ifrbuf, cp, siz);
-
- if (!strncmp(name, ifr->ifr_name, sizeof(ifr->ifr_name))) {
- if (ifr->ifr_addr.sa_family == AF_INET)
- in_alias(ifr);
- }
- }
-#endif
}
void
@@ -2271,7 +2155,6 @@
in6_status(force)
int force;
{
-#ifdef HAVE_IFADDRS_H
struct ifaddrs *ifap, *ifa;
struct in6_ifreq ifr;
@@ -2291,44 +2174,6 @@
in6_alias(&ifr);
}
freeifaddrs(ifap);
-#else
- char inbuf[8192];
- struct ifconf ifc;
- struct ifreq *ifr;
- int i, siz;
- char ifrbuf[8192], *cp;
-
- ifc.ifc_len = sizeof(inbuf);
- ifc.ifc_buf = inbuf;
- getsock(af);
- if (s < 0)
- err(1, "socket");
- if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
- err(1, "SIOCGIFCONF");
- for (i = 0; i < ifc.ifc_len; ) {
- /* Copy the mininum ifreq into the buffer. */
- cp = ((caddr_t)ifc.ifc_req + i);
- memcpy(ifrbuf, cp, sizeof(*ifr));
-
- /* Now compute the actual size of the ifreq. */
- ifr = (struct ifreq *)ifrbuf;
- siz = ifr->ifr_addr.sa_len;
- if (siz < sizeof(ifr->ifr_addr))
- siz = sizeof(ifr->ifr_addr);
- siz += sizeof(ifr->ifr_name);
- i += siz;
-
- /* Now copy the whole thing. */
- if (sizeof(ifrbuf) < siz)
- errx(1, "ifr too big");
- memcpy(ifrbuf, cp, siz);
-
- if (!strncmp(name, ifr->ifr_name, sizeof(ifr->ifr_name))) {
- if (ifr->ifr_addr.sa_family == AF_INET6)
- in6_alias((struct in6_ifreq *)ifr);
- }
- }
-#endif
}
#endif /*INET6*/
Home |
Main Index |
Thread Index |
Old Index