From 525c9d6e37d1dea2b3b16cac7bb3a877323854c3 Mon Sep 17 00:00:00 2001 From: cgd Date: Tue, 4 Jun 1996 20:09:03 +0000 Subject: [PATCH] if doing 'netstat -I -w ', and netstat can't find an interface of the given name, print an error message and exit. This whole section of code needs to be re-thought, if interfaces can be dynamically added or removed. --- usr.bin/netstat/if.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 11884bd1eb85..051a83d48158 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.17 1996/06/04 20:09:03 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.17 1996/06/04 20:09:03 cgd Exp $"; #endif #endif /* not lint */ @@ -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);