Commit Graph

118 Commits

Author SHA1 Message Date
Bruce Evans
b6c86f4b1e Fixed some style bugs (whitespace lossage for removal of __P(()), and
lots of naming and typing errors involving `interval').
2007-02-27 05:10:36 +00:00
Bruce Evans
93547b07b9 Use a periodic itimer instead of repeated calls to alarm() in
sidewaysintpr().  This increases the accuracy of the per-interval
counts when they are interpreted as rates.  Repeated calls to alarm(n)
give an average interval that is about 2 ticks larger than n and has
a large variance.  Periodic itimers normally get the average almost
right but have similarly large variance (due to scheduling delays).

Statistics utilities should use clock_gettime() to determine the
actual interval, but it is still useful to maximize the accuracy of
the interval, especially for cases like netstat -w where counts are
displayed so the program cannot hide the inaccuracy in a rate
conversion.
2007-02-27 04:54:33 +00:00
Bruce Evans
1f575ce8f9 Don't always print a space character in show_stat(), since a space
shouldn't be printed after the last column.  This restores the
formatting to 79 columns.
2006-11-08 15:15:05 +00:00
Yaroslav Tykhiy
7b95a1ebbd Achieve WARNS=2 by using uintmax_t to pass around 64-bit quantities,
including to printf().  Using uintmax_t is also robust to further
extensions in both the C language and the bitwidth of kernel counters.

Tested on:	i386 amd64 ia64
2006-07-28 16:09:19 +00:00
Ruslan Ermilov
b5f6749117 Align output. 2005-11-09 15:12:57 +00:00
Max Laier
b6de9e91bd Remove bridge(4) from the tree. if_bridge(4) is a full functional
replacement and has additional features which make it superior.

Discussed on:	-arch
Reviewed by:	thompsa
X-MFC-after:	never (RELENG_6 as transition period)
2005-09-27 18:10:43 +00:00
Gleb Smirnoff
7c23a867f7 - Print space character in show_stat(). Remove a lot of priuntf(" ").
- Utilize show_stat() in sidewaysintpr() loop. This makes periodic
  statistics to honor -h flag.
2005-09-27 10:42:02 +00:00
Ruslan Ermilov
c6358a5e6f Bail if interface is misspelled instead of falling out into the
"all interfaces" mode.  (Only works with -w, but still better
than nothing.)
2005-08-20 08:34:21 +00:00
Gleb Smirnoff
c2dfd19ff0 Add a new switch -h for interface stats mode, which prints all interface
statistics in human readable form.

In collaboration with:	vsevolod
Reviewed by:		cperciva
2005-08-18 21:04:12 +00:00
Max Laier
2e37c5a333 Print newly exported pfsync statistics with netstat(8).
Requested by:	glebius
MFC after:	1 week
2005-07-14 22:42:35 +00:00
Philippe Charnier
6cc6f12231 Add __FBSDID. Replace local variable sin by sockin to not conflict with sin(3).
Use warnx() instead of warn() when error message is not of any interest. Add
prototypes.
2004-07-26 20:18:11 +00:00
Ruslan Ermilov
e16552014d Show link-level multicast packet counters with the -a option. 2004-04-12 15:00:48 +00:00
Ruslan Ermilov
bce2e7c8bb Fixed alignment of multicast addresses when printing that got
broken in previous revision.
2004-04-12 09:44:42 +00:00
Bruce M Simpson
25d295e1ed Fix some minor nits in netstat whereby large interface names would be
truncated. In environments where many tunnel or vlan interfaces are created,
interface names have high numbers which overflow the field width.

PRs:		bin/52349, bin/35838
Submitted by:	Mike Tancsa, Scot W. Hetzel
Approved by:	re (rwatson)
2003-11-28 17:34:23 +00:00
Brooks Davis
9bf40ede4a 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)
2003-10-31 18:32:15 +00:00
Peter Wemm
ab54ea99de Kill #ifdef NS and some leftover #ifdef ISO code. Re-pack the nlist[]
array, it isn't likely to find any ARPAnet IMP drivers in FreeBSD.
2003-03-05 19:20:29 +00:00
Robert Drehmel
ec3b72e932 - Determine the size of buffers with sizeof() instead of using
plain magic numbers - one of them was apparently wrong but unharmful.
 - Remove empty line.
2003-02-10 16:58:47 +00:00
David Malone
a01e3379df Warns cleanups for netstat:
1) Include arpa/inet.h for ntohs.
2) Constness fixes.
3) Fix shadowing except for "sin" which shouldn't be in scope.
4) Remove register keyword.
5) Add missing initialsers to user defined structs.
5) Make prototype of netname6 globally visable.
6) Use right macros for printing syncache stats (even though entrie isn't
   a word).
2002-09-05 17:06:51 +00:00
Mark Murray
e65dd7bc2f fix warnings; change variable/argument names that mask global names. 2002-04-28 12:15:40 +00:00
Matthew N. Dodd
6f9cdfce19 Print statistics for AF_IPX.
Note that the IPX code doesn't update these correctly yet, but should.
2001-10-19 00:40:51 +00:00
Ruslan Ermilov
acb60e59c1 The previous change also disaligned lines with AF_IPX and AF_NS
addresses.  Unshrink "Network" width to the previous value, and
make sure everything is aligned again.
2001-10-09 08:33:50 +00:00
Matthew N. Dodd
dd1f8b9bf4 Minor output formatting for 'netstat -i':
- Right align Mtu
- Print AF_INET family with correct field width.
2001-10-09 05:58:26 +00:00
Ruslan Ermilov
d44ddba96c Implement the ``-f address_family'' filter for -i.
Prodded by:	Igor Podlesny <poige@morning.ru>
2001-09-11 17:14:33 +00:00
Assar Westerlund
f964d60dd3 remove warnings
remove superfluous declarations
make things more consistent
2001-06-15 23:55:45 +00:00
Assar Westerlund
5e0517186d remove K&R support 2001-06-15 23:35:13 +00:00
Assar Westerlund
e9370a2e59 revert removal of warning and K&R support
Requested by: bde
2001-06-15 23:07:59 +00:00
Ruslan Ermilov
cf5e44f88e First round of netstat(1) cleanup.
Removed the ambiguity in -s, -f, -p and -i flags handling.
Basically, there are four displays (except others):

1.  PCB display.
2.  Protocol statistics display. (-s)
3.  Interface statistics display. (-i)
4.  Per-interface protocol statistics display. (-i -s)

All of the above except 3) can be limited to a particular
protocol family (-f) or a single protocol (-p).

Some examples:

1.  netstat -f inet    -- show PCBs of all INET protocols
2.  netstat -p udp     -- show PCB of UDP protocol only (NEW!)
3.  netstat -s         -- show protocol statistics for all families
4.  netstat -s -f inet -- show INET protocols statistics
5.  netstat -s -p icmp -- show ICMP protocol statistics

This is a work in progress.  Manpage has been fixed slightly,
but is still incomplete.
2001-06-15 18:25:38 +00:00
Assar Westerlund
af7a0a2d2b remove most of the warnings 2001-06-15 01:53:05 +00:00
Bill Fenner
b9d92bf53e Add missing break when printing IPv6 multicast addresses.
Use the sockaddr_dl sdl_type, not ifnet.if_type, to decide what type
 a multicast sockaddr_dl is.
2001-04-26 06:02:03 +00:00
Poul-Henning Kamp
0b23654bb3 Don't core dump when given "-i -a". Problem caused by a mistaken
dereference of a kernel-pointer in userland.

PR:		26168
Submitted by:	Peter Pentchev <roam@orbitel.bg>
2001-03-30 19:16:04 +00:00
Josef Karthauser
445f17bbee When displaying interface statistics with -i show a '-' for any
values that aren't updated for a particular network-layer address.
2001-03-04 22:25:05 +00:00
Poul-Henning Kamp
6817526d14 Convert if_multiaddrs from LIST to TAILQ so that it can be traversed
backwards in the three drivers which want to do that.

Reviewed by:    mikeh
2001-02-06 10:12:15 +00:00
Poul-Henning Kamp
4d51ef6343 Use macro API to <sys/queue.h>
Submitted by:	"Jason" <jsmethers@pdq.net>
Reviewed by:	phk
2000-12-30 21:22:54 +00:00
Guido van Rooij
591c194a92 Now that the amount of (pseudo) interfaces is growing with IPv6,
get rid of stupid upperbound on the amount of interfaces (was 8).
2000-10-30 11:53:19 +00:00
Josef Karthauser
5da9f8fa97 Augment the 'ifaddr' structure with a 'struct if_data' to keep
statistics on a per network address basis.

Teach the IPv4 and IPv6 input/output routines to log packets/bytes
against the network address connected to the flow.

Teach netstat to display the per-address stats for IP protocols
when 'netstat -i' is evoked, instead of displaying the per-interface
stats.
2000-10-19 23:15:54 +00:00
John Polstra
3cfac2c58d Fix bug: "netstat -si" prints interface information, but the header
line is missing.  This apparently was broken in revision 1.31 of
"if.c".

Submitted by:	Maxime Henrion <mhenrion@cybercable.fr>
2000-07-28 04:05:04 +00:00
Jordan K. Hubbard
e54ca68cb8 Print mac addresses in standard byte:byte format rather than
byte.byte.  This makes it consistent with our other utilities
like arp(8) and ifconfig(8).

Submitted by:	Paul Vixie <paul@vix.com>
2000-01-03 17:48:36 +00:00
Yoshinobu Inoue
cfa1ca9dfa udp IPv6 support, IPv6/IPv4 tunneling support in kernel,
packet divert at kernel for IPv6/IPv4 translater daemon

This includes queue related patch submitted by jburkhol@home.com.

Submitted by: queue related patch from jburkhol@home.com
Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
1999-12-07 17:39:16 +00:00
Doug Rabson
890bc2a54a Fix the output of 'netstat -I de0 1' for the alpha. Fix a bunch of
warnings while I'm here.
1999-11-09 22:22:36 +00:00
Matthew Dillon
f41f949d09 Cleanup missing includes, stale includes, and a few printf format
inconsistancies.
1999-10-23 17:45:11 +00:00
Julian Elischer
a97a99221a Cleanup towards -Wall 1999-10-21 07:08:56 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Luigi Rizzo
0024d1db07 Add support for printing bridging statistics with ``-p bdg '' .
If someone has a better flag to use I'll be glad to change it.
1999-04-26 16:11:50 +00:00
Bill Fumerola
9baac9f2e9 IPX address formatting nit.
PR:		bin/11179
Submitted by:	Dan Nelson <dnelson@emsphone.com>
1999-04-20 22:04:31 +00:00
Bruce Evans
22694ebad5 Fixed printf format errors. 1998-07-06 21:01:54 +00:00
Peter Wemm
c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Garrett Wollman
75fb877061 Print out the interface's multicast addresses using the new
structures.
1997-01-13 21:27:46 +00:00
Garrett Wollman
8766942543 Update to match changes in <net/if.h> and <netinet/ip_mroute.h>. 1997-01-03 20:16:31 +00:00
Garrett Wollman
15244cd5c2 Learn to follow the new interface address lists. 1996-12-13 21:29:59 +00:00
Garrett Wollman
0e27dc0563 Understand queue-ized ifnet structures. 1996-12-11 20:39:43 +00:00
Garrett Wollman
628d2ac1b0 Fix up programs which expect <net/if.h> to include <sys/time.h> to instead
do it themselves.  (Some of these programs actually depended on this
beyond compiling the definition of struct ifinfo!)  Also fix up some
other #include messes while we're at it.
1996-12-10 17:11:53 +00:00
Bill Fenner
f6719675d2 Display multicast addresses if the "a" flag is used in combination
with "-i".  This was already in the man page but was not implemented.

Obtained from:	Multicast release 3.5
1996-12-02 06:38:30 +00:00
Julian Elischer
a8d3784533 fix printing of netranges in the i and r displays for netatalk 1996-08-31 07:43:01 +00:00
Julian Elischer
3a67d2bc37 Submitted by: archie@whistle.com
appletalk cleanups
1996-07-23 01:18:47 +00:00
Julian Elischer
6ffcfd6c9e appletalk cleanups
e.g.
Active ATALK connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
ddp        0      0  [69.230]130            [*.*]*
ddp        0      0  [69.230]128            [*.*]*
ddp        0      0  [69.230]1              [*.*]*

etc..
1996-07-09 02:55:47 +00:00
Alexander Langer
7d56c0ee6b Code cleanup: remove unused variables, use correct *printf format
specifiers (some unsigned values were printed as signed, some longs
were printed as ints), and place parentheses around assignments in
if statements.
1996-06-02 23:19:12 +00:00
David Greenman
0b87c9157d Make the -w option actually useful to people. Instead of it creating a
messy 130 column collage, output the system totals -or- info for a
specific interface if -I is given. Also wait for <interval> before
outputting the first sample so that it represents meaningful data (as
opposed to the total since the system was booted - most busy systems
wrap around many times during their operation, so these numbers are
only misleading).
1996-02-29 07:44:37 +00:00
Garrett Wollman
cbc17e711e XNS sort-of-support is no more. 1996-02-13 17:30:37 +00:00
Garrett Wollman
0761cb293e Remove support for OSI networking in user-land (#ifdef OSI aor CCITT)
in preparation for its removal from the kernel source tree.  NB: because
a function was deleted, libc is now at version 3.0 (was 2.2 previously).
1996-02-06 20:36:15 +00:00
Peter Wemm
05ddff6e30 Merge in Lite-2 changes. 1996-01-14 23:33:13 +00:00
Stefan Eßer
09a67ffa0e Increase width of Network column from 11 to 13 for the AF_INET case.
This seems to have been missed, when the recent IPX changes went in ...
1995-11-22 22:21:04 +00:00
Julian Elischer
cc6a66f20e Reviewed by: julian and jhay@mikom.csir.co.za
Submitted by:	Mike Mitchell, supervisor@alb.asctmd.com

This is a bulk mport of Mike's IPX/SPX protocol stacks and all the
related gunf that goes with it..
it is not guaranteed to work 100% correctly at this time
but as we had several people trying to work on it
I figured it would be better to get it checked in so
they could all get teh same thing to work on..

Mikes been using it for a year or so
but on 2.0

more changes and stuff will be merged in from other developers now that this is in.

Mike Mitchell, Network Engineer
AMTECH Systems Corporation, Technology and Manufacturing
8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000
supervisor@alb.asctmd.com
1995-10-26 20:31:59 +00:00
David Greenman
1b72e71cc2 Fixed netstat to not bogusly mangle the argv[] command args by rewriting
the way it stores and handles "interface". The previous behavior resulted
in strange output from 'w' and 'ps' when an interface specification was
given to netstat.
1995-09-23 15:04:28 +00:00
David Greenman
3aa80b1d81 Output statistics as unsigned in the -w section.
Look at error return of kread() and stop on error.
Fix warning in kread() to not output "kvm_read:" twice.
Killed PCB cache misses stat as we no longer have it.
1995-07-29 22:34:15 +00:00
David Greenman
e1e293a5dc Added '-b' option to display the number of in and out bytes on a given
interface (used with -i and -I flag).
1994-10-12 02:37:35 +00:00
David Greenman
541f256275 Changed output formatting to 0 pad hex bytes if necessary. This makes
the output consistent with traditional representations of ethernet
addresses. I still don't like the spacing in netstat -i, however.
1994-08-05 12:38:06 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00