aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat/if.c
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
committerBrooks Davis <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
commit9bf40ede4a299f315bc4b0ae5329631b8c7dc271 (patch)
tree4d9e6671d486576767506230a4240131526fea49 /usr.bin/netstat/if.c
parentdc6279b887bf4473d77b898631f74466b5f7a094 (diff)
downloadsrc-9bf40ede4a299f315bc4b0ae5329631b8c7dc271.tar.gz
src-9bf40ede4a299f315bc4b0ae5329631b8c7dc271.zip
Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface and if_dname/unit are the driver name and instance. This change paves the way for interface renaming and enhanced pseudo device creation and configuration symantics. Approved By: re (in principle) Reviewed By: njl, imp Tested On: i386, amd64, sparc64 Obtained From: NetBSD (if_xname)
Notes
Notes: svn path=/head/; revision=121816
Diffstat (limited to 'usr.bin/netstat/if.c')
-rw-r--r--usr.bin/netstat/if.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index e5639077f3d7..b2527cdfa155 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -169,7 +169,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
short timer;
int drops;
struct sockaddr *sa = NULL;
- char name[32], tname[16];
+ char name[IFNAMSIZ];
short network_layer;
short link_layer;
@@ -216,13 +216,10 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
if (ifaddraddr == 0) {
ifnetfound = ifnetaddr;
- if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet) ||
- kread((u_long)ifnet.if_name, tname, 16))
+ if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet))
return;
- tname[sizeof(tname) - 1] = '\0';
+ strlcpy(name, ifnet.if_xname, sizeof(name));
ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link);
- snprintf(name, sizeof(name), "%s%d", tname,
- ifnet.if_unit);
if (interface != 0 && (strcmp(name, interface) != 0))
continue;
cp = index(name, '\0');
@@ -464,7 +461,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
struct iftot {
SLIST_ENTRY(iftot) chain;
- char ift_name[16]; /* interface name */
+ char ift_name[IFNAMSIZ]; /* interface name */
u_long ift_ip; /* input packets */
u_long ift_ie; /* input errors */
u_long ift_op; /* output packets */
@@ -508,14 +505,11 @@ sidewaysintpr(unsigned interval1, u_long off)
interesting = NULL;
interesting_off = 0;
for (off = firstifnet, ip = iftot; off;) {
- char name[16], tname[16];
+ char name[IFNAMSIZ];
if (kread(off, (char *)&ifnet, sizeof ifnet))
break;
- if (kread((u_long)ifnet.if_name, tname, sizeof(tname)))
- break;
- tname[sizeof(tname) - 1] = '\0';
- snprintf(name, sizeof(name), "%s%d", tname, ifnet.if_unit);
+ strlcpy(name, ifnet.if_xname, sizeof(name));
if (interface && strcmp(name, interface) == 0) {
interesting = ip;
interesting_off = off;