if.c (78309) | if.c (78314) |
---|---|
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 78309 2001-06-15 23:07:59Z assar $"; | 39 "$FreeBSD: head/usr.bin/netstat/if.c 78314 2001-06-15 23:35:13Z assar $"; |
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 --- 23 unchanged lines hidden (view full) --- 71#include <string.h> 72#include <unistd.h> 73 74#include "netstat.h" 75 76#define YES 1 77#define NO 0 78 | 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 --- 23 unchanged lines hidden (view full) --- 71#include <string.h> 72#include <unistd.h> 73 74#include "netstat.h" 75 76#define YES 1 77#define NO 0 78 |
79static void sidewaysintpr __P((u_int, u_long)); 80static void catchalarm __P((int)); | 79static void sidewaysintpr (u_int, u_long); 80static void catchalarm (int); |
81 82#ifdef INET6 | 81 82#ifdef INET6 |
83char *netname6 __P((struct sockaddr_in6 *, struct in6_addr *)); | 83char *netname6 (struct sockaddr_in6 *, struct in6_addr *); |
84static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */ 85static int bdg_done; 86#endif 87 88void 89bdg_stats(u_long dummy, char *name) /* print bridge statistics */ 90{ 91 int i; --- 34 unchanged lines hidden (view full) --- 126} 127 128 129 130 131/* 132 * Display a formatted value, or a '-' in the same space. 133 */ | 84static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */ 85static int bdg_done; 86#endif 87 88void 89bdg_stats(u_long dummy, char *name) /* print bridge statistics */ 90{ 91 int i; --- 34 unchanged lines hidden (view full) --- 126} 127 128 129 130 131/* 132 * Display a formatted value, or a '-' in the same space. 133 */ |
134void 135show_stat(fmt, width, value, showvalue) 136 char *fmt; 137 int width; 138 u_long value; 139 short showvalue; | 134static void 135show_stat(char *fmt, int width, u_long value, short showvalue) |
140{ 141 char newfmt[32]; 142 143 /* Construct the format string */ 144 if (showvalue) { 145 sprintf(newfmt, "%%%d%s", width, fmt); 146 printf(newfmt, value); 147 } else { 148 sprintf(newfmt, "%%%ds", width); 149 printf(newfmt, "-"); 150 } 151} 152 153 154 155/* 156 * Print a description of the network interfaces. 157 */ 158void | 136{ 137 char newfmt[32]; 138 139 /* Construct the format string */ 140 if (showvalue) { 141 sprintf(newfmt, "%%%d%s", width, fmt); 142 printf(newfmt, value); 143 } else { 144 sprintf(newfmt, "%%%ds", width); 145 printf(newfmt, "-"); 146 } 147} 148 149 150 151/* 152 * Print a description of the network interfaces. 153 */ 154void |
159intpr(interval, ifnetaddr, pfunc) 160 int interval; 161 u_long ifnetaddr; 162 void (*pfunc)(char *); | 155intpr(int interval, u_long ifnetaddr, void (*pfunc)(char *)) |
163{ 164 struct ifnet ifnet; 165 struct ifnethead ifnethead; 166 union { 167 struct ifaddr ifa; 168 struct in_ifaddr in; 169#ifdef INET6 170 struct in6_ifaddr in6; --- 338 unchanged lines hidden (view full) --- 509/* 510 * Print a running summary of interface statistics. 511 * Repeat display every interval seconds, showing statistics 512 * collected over that interval. Assumes that interval is non-zero. 513 * First line printed at top of screen is always cumulative. 514 * XXX - should be rewritten to use ifmib(4). 515 */ 516static void | 156{ 157 struct ifnet ifnet; 158 struct ifnethead ifnethead; 159 union { 160 struct ifaddr ifa; 161 struct in_ifaddr in; 162#ifdef INET6 163 struct in6_ifaddr in6; --- 338 unchanged lines hidden (view full) --- 502/* 503 * Print a running summary of interface statistics. 504 * Repeat display every interval seconds, showing statistics 505 * collected over that interval. Assumes that interval is non-zero. 506 * First line printed at top of screen is always cumulative. 507 * XXX - should be rewritten to use ifmib(4). 508 */ 509static void |
517sidewaysintpr(interval, off) 518 unsigned interval; 519 u_long off; | 510sidewaysintpr(unsigned interval, u_long off) |
520{ 521 struct ifnet ifnet; 522 u_long firstifnet; 523 struct ifnethead ifnethead; 524 struct iftot *iftot, *ip, *ipn, *total, *sum, *interesting; 525 register int line; 526 int oldmask, first; 527 u_long interesting_off; --- 146 unchanged lines hidden (view full) --- 674 /*NOTREACHED*/ 675} 676 677/* 678 * Called if an interval expires before sidewaysintpr has completed a loop. 679 * Sets a flag to not wait for the alarm. 680 */ 681static void | 511{ 512 struct ifnet ifnet; 513 u_long firstifnet; 514 struct ifnethead ifnethead; 515 struct iftot *iftot, *ip, *ipn, *total, *sum, *interesting; 516 register int line; 517 int oldmask, first; 518 u_long interesting_off; --- 146 unchanged lines hidden (view full) --- 665 /*NOTREACHED*/ 666} 667 668/* 669 * Called if an interval expires before sidewaysintpr has completed a loop. 670 * Sets a flag to not wait for the alarm. 671 */ 672static void |
682catchalarm(signo) 683 int signo; | 673catchalarm(int signo) |
684{ 685 signalled = YES; 686} | 674{ 675 signalled = YES; 676} |