diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-19 06:01:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-19 06:01:45 +0000 |
commit | 303c6c739533d05ca4a15490e82f1fe35ca9f162 (patch) | |
tree | 8f76d6b632c4da84e585030cd79792ec42a6569b /sbin/ifconfig | |
parent | e164f701cfa14d881c0938b09de162d79c5a656f (diff) |
handle more interfaces in -a mode
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index a2488e9235e..ada052118e6 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.4 1996/08/16 09:22:41 mickey Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.5 1996/09/19 06:01:44 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.22 1996/01/04 20:11:20 pk Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.4 1996/08/16 09:22:41 mickey Exp $"; +static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.5 1996/09/19 06:01:44 deraadt Exp $"; #endif #endif /* not lint */ @@ -350,18 +350,25 @@ getinfo(ifr) void printall() { - char inbuf[8192]; + char *inbuf = NULL; struct ifconf ifc; struct ifreq ifreq, *ifr; - int i; + int i, len = 8192; - 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"); + while (1) { + ifc.ifc_len = len; + ifc.ifc_buf = inbuf = realloc(inbuf, len); + if (inbuf == NULL) + err(1, "malloc"); + if (ioctl(s, SIOCGIFCONF, &ifc) < 0) + err(1, "SIOCGIFCONF"); + if (ifc.ifc_len + sizeof(ifreq) < len) + break; + len *= 2; + } ifr = ifc.ifc_req; ifreq.ifr_name[0] = '\0'; for (i = 0; i < ifc.ifc_len; ) { @@ -379,6 +386,7 @@ printall() continue; status(); } + free(inbuf); } #define RIDADDR 0 |