summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-10 07:48:32 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-10 07:48:32 +0000
commit38e9936a94dc4b2255c08c92d794c6bbda00bf19 (patch)
treefe7f276b0f3a60ccf86479fdbbd2507e354b29b5
parent3fb1d3fc24dae7c5506be7d6bae54ecc97348ba0 (diff)
handle up to 100 interfaces, nice message for non-existing interface
-rw-r--r--usr.bin/netstat/if.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 11884bd1eb8..879a7e9055b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.16 1996/05/07 05:30:45 thorpej Exp $ */
+/* $NetBSD: if.c,v 1.16.4.1 1996/06/04 20:27:06 cgd Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-static char *rcsid = "$NetBSD: if.c,v 1.16 1996/05/07 05:30:45 thorpej Exp $";
+static char *rcsid = "$NetBSD: if.c,v 1.16.4.1 1996/06/04 20:27:06 cgd Exp $";
#endif
#endif /* not lint */
@@ -239,7 +239,7 @@ intpr(interval, ifnetaddr)
}
}
-#define MAXIF 10
+#define MAXIF 100
struct iftot {
char ift_name[IFNAMSIZ]; /* interface name */
int ift_ip; /* input packets */
@@ -283,7 +283,7 @@ sidewaysintpr(interval, off)
lastif = iftot;
sum = iftot + MAXIF - 1;
total = sum - 1;
- interesting = iftot;
+ interesting = (interface == NULL) ? iftot : NULL;
for (off = firstifnet, ip = iftot; off;) {
if (kread(off, (char *)&ifnet, sizeof ifnet))
break;
@@ -298,6 +298,11 @@ sidewaysintpr(interval, off)
break;
off = (u_long)ifnet.if_list.tqe_next;
}
+ if (interesting == NULL) {
+ fprintf(stderr, "%s: %s: unknown interface\n",
+ __progname, interface);
+ exit(1);
+ }
lastif = ip;
(void)signal(SIGALRM, catchalarm);