if.c (121816) | if.c (123030) |
---|---|
1/* 2 * Copyright (c) 1983, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35/* 36static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95"; 37*/ 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35/* 36static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95"; 37*/ 38static const char rcsid[] = |
39 "$FreeBSD: head/usr.bin/netstat/if.c 121816 2003-10-31 18:32:15Z brooks $"; | 39 "$FreeBSD: head/usr.bin/netstat/if.c 123030 2003-11-28 17:34:23Z bms $"; |
40#endif /* not lint */ 41 42#include <sys/types.h> 43#include <sys/protosw.h> 44#include <sys/socket.h> 45#include <sys/sysctl.h> 46#include <sys/time.h> 47 --- 135 unchanged lines hidden (view full) --- 183 } 184 if (kread(ifnetaddr, (char *)&ifnethead, sizeof ifnethead)) 185 return; 186 ifnetaddr = (u_long)TAILQ_FIRST(&ifnethead); 187 if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet)) 188 return; 189 190 if (!pfunc) { | 40#endif /* not lint */ 41 42#include <sys/types.h> 43#include <sys/protosw.h> 44#include <sys/socket.h> 45#include <sys/sysctl.h> 46#include <sys/time.h> 47 --- 135 unchanged lines hidden (view full) --- 183 } 184 if (kread(ifnetaddr, (char *)&ifnethead, sizeof ifnethead)) 185 return; 186 ifnetaddr = (u_long)TAILQ_FIRST(&ifnethead); 187 if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet)) 188 return; 189 190 if (!pfunc) { |
191 printf("%-5.5s %5.5s %-13.13s %-17.17s %8.8s %5.5s", 192 "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs"); | 191 if (Wflag) 192 printf("%-7.7s", "Name"); 193 else 194 printf("%-5.5s", "Name"); 195 printf(" %5.5s %-13.13s %-17.17s %8.8s %5.5s", 196 "Mtu", "Network", "Address", "Ipkts", "Ierrs"); |
193 if (bflag) 194 printf(" %10.10s","Ibytes"); 195 printf(" %8.8s %5.5s", "Opkts", "Oerrs"); 196 if (bflag) 197 printf(" %10.10s","Obytes"); 198 printf(" %5s", "Coll"); 199 if (tflag) 200 printf(" %s", "Time"); --- 45 unchanged lines hidden (view full) --- 246 ibytes = ifnet.if_ibytes; 247 oerrors = ifnet.if_oerrors; 248 ierrors = ifnet.if_ierrors; 249 collisions = ifnet.if_collisions; 250 timer = ifnet.if_timer; 251 drops = ifnet.if_snd.ifq_drops; 252 253 if (ifaddraddr == 0) { | 197 if (bflag) 198 printf(" %10.10s","Ibytes"); 199 printf(" %8.8s %5.5s", "Opkts", "Oerrs"); 200 if (bflag) 201 printf(" %10.10s","Obytes"); 202 printf(" %5s", "Coll"); 203 if (tflag) 204 printf(" %s", "Time"); --- 45 unchanged lines hidden (view full) --- 250 ibytes = ifnet.if_ibytes; 251 oerrors = ifnet.if_oerrors; 252 ierrors = ifnet.if_ierrors; 253 collisions = ifnet.if_collisions; 254 timer = ifnet.if_timer; 255 drops = ifnet.if_snd.ifq_drops; 256 257 if (ifaddraddr == 0) { |
254 printf("%-5.5s %5lu ", name, ifnet.if_mtu); | 258 if (Wflag) 259 printf("%-7.7s", name); 260 else 261 printf("%-5.5s", name); 262 printf(" %5lu ", ifnet.if_mtu); |
255 printf("%-13.13s ", "none"); 256 printf("%-17.17s ", "none"); 257 } else { 258 if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { 259 ifaddraddr = 0; 260 continue; 261 } 262#define CP(x) ((char *)(x)) 263 cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + 264 CP(&ifaddr); 265 sa = (struct sockaddr *)cp; 266 if (af != AF_UNSPEC && sa->sa_family != af) { 267 ifaddraddr = 268 (u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_link); 269 continue; 270 } | 263 printf("%-13.13s ", "none"); 264 printf("%-17.17s ", "none"); 265 } else { 266 if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { 267 ifaddraddr = 0; 268 continue; 269 } 270#define CP(x) ((char *)(x)) 271 cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + 272 CP(&ifaddr); 273 sa = (struct sockaddr *)cp; 274 if (af != AF_UNSPEC && sa->sa_family != af) { 275 ifaddraddr = 276 (u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_link); 277 continue; 278 } |
271 printf("%-5.5s %5lu ", name, ifnet.if_mtu); | 279 if (Wflag) 280 printf("%-7.7s", name); 281 else 282 printf("%-5.5s", name); 283 printf(" %5lu ", ifnet.if_mtu); |
272 switch (sa->sa_family) { 273 case AF_UNSPEC: 274 printf("%-13.13s ", "none"); 275 printf("%-15.15s ", "none"); 276 break; 277 case AF_INET: 278 sin = (struct sockaddr_in *)sa; 279#ifdef notdef --- 368 unchanged lines hidden --- | 284 switch (sa->sa_family) { 285 case AF_UNSPEC: 286 printf("%-13.13s ", "none"); 287 printf("%-15.15s ", "none"); 288 break; 289 case AF_INET: 290 sin = (struct sockaddr_in *)sa; 291#ifdef notdef --- 368 unchanged lines hidden --- |