aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/systat/netstat.c
Commit message (Collapse)AuthorAgeFilesLines
* Hide struct socket and struct unpcb from the userland.Gleb Smirnoff2017-10-021-0/+1
| | | | | | | | | | | | | | | | | | | Violators may define _WANT_SOCKET and _WANT_UNPCB respectively and are not guaranteed for stability of the structures. The violators list is the the usual one: libprocstat(3) and netstat(1) internally and lsof in ports. In struct xunpcb remove the inclusion of kernel structure and add a bunch of spare fields. The xsocket already has socket not included, but add there spares as well. Embed xsockbuf into xsocket. Sort declarations in sys/socketvar.h to separate kernel only from userland available ones. PR: 221820 (exp-run) Notes: svn path=/head/; revision=324227
* Hide struct inpcb, struct tcpcb from the userland.Gleb Smirnoff2017-03-211-32/+33
| | | | | | | | | | | | | | | | | | | | | | | This is a painful change, but it is needed. On the one hand, we avoid modifying them, and this slows down some ideas, on the other hand we still eventually modify them and tools like netstat(1) never work on next version of FreeBSD. We maintain a ton of spares in them, and we already got some ifdef hell at the end of tcpcb. Details: - Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO. - Make struct xinpcb, struct xtcpcb pure API structures, not including kernel structures inpcb and tcpcb inside. Export into these structures the fields from inpcb and tcpcb that are known to be used, and put there a ton of spare space. - Make kernel and userland utilities compilable after these changes. - Bump __FreeBSD_version. Reviewed by: rrs, gnn Differential Revision: D10018 Notes: svn path=/head/; revision=315662
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Use NULL instead of 0 for pointers.Marcelo Araujo2016-04-201-1/+1
| | | | | | | | | gethostbyname(3) will return NULL for error status. MFC after: 2 weeks. Notes: svn path=/head/; revision=298324
* Augment struct tcpstat with tcps_states[], which is used for book-keepingGleb Smirnoff2016-01-271-1/+1
| | | | | | | | | | the amount of TCP connections by state. Provides a cheap way to get connection count without traversing the whole pcb list. Sponsored by: Netflix Notes: svn path=/head/; revision=294869
* - Avoid accessing window properties directly, instead, use accessors.Xin LI2015-09-101-1/+1
| | | | | | | | | | | This should be no-op for now, but allows the code to work if we move to NCURSES_OPAQUE. - Use calloc() instead of malloc+bzero. MFC after: 2 weeks Notes: svn path=/head/; revision=287633
* Merge from projects/sendfile:Gleb Smirnoff2014-11-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Introduce a notion of "not ready" mbufs in socket buffers. These mbufs are now being populated by some I/O in background and are referenced outside. This forces following implications: - An mbuf which is "not ready" can't be taken out of the buffer. - An mbuf that is behind a "not ready" in the queue neither. - If sockbet buffer is flushed, then "not ready" mbufs shouln't be freed. o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc. The sb_ccc stands for ""claimed character count", or "committed character count". And the sb_acc is "available character count". Consumers of socket buffer API shouldn't already access them directly, but use sbused() and sbavail() respectively. o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones with M_BLOCKED. o New field sb_fnrdy points to the first not ready mbuf, to avoid linear search. o New function sbready() is provided to activate certain amount of mbufs in a socket buffer. A special note on SCTP: SCTP has its own sockbufs. Unfortunately, FreeBSD stack doesn't yet allow protocol specific sockbufs. Thus, SCTP does some hacks to make itself compatible with FreeBSD: it manages sockbufs on its own, but keeps sb_cc updated to inform the stack of amount of data in them. The new notion of "not ready" data isn't supported by SCTP. Instead, only a mechanical substitute is done: s/sb_cc/sb_ccc/. A proper solution would be to take away struct sockbuf from struct socket and allow protocols to implement their own socket buffers, like SCTP already does. This was discussed with rrs@. Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=275326
* Whitespace fixes.Ed Schouten2012-02-051-2/+0
| | | | | | | | | - Remove redundant empty lines. - Replace ^L by \014. This allows you to safely cat/grep/etc this file without causing confusion. Notes: svn path=/head/; revision=231011
* Replace index() and rindex() calls with strchr() and strrchr().Ed Schouten2012-01-031-2/+2
| | | | | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Notes: svn path=/head/; revision=229403
* Fix whitespace inconsistencies in systat(1).Ed Schouten2011-10-151-1/+1
| | | | | | | According to md5(1), the resulting binary is the same. Notes: svn path=/head/; revision=226396
* Remove duplicated header filesKevin Lo2011-06-241-1/+0
| | | | Notes: svn path=/head/; revision=223493
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-111-4/+0
| | | | | | | | | | | | is in accordance with the information provided at ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Also add $FreeBSD$ to a few files to keep svn happy. Discussed with: imp, rwatson Notes: svn path=/head/; revision=216370
* Revert most part of 200420 as requested, as more review and polish isXin LI2009-12-131-0/+1
| | | | | | | needed. Notes: svn path=/head/; revision=200462
* Remove unneeded header includes from usr.bin/ except contributed code.Xin LI2009-12-111-1/+0
| | | | | | | Tested with: make universe Notes: svn path=/head/; revision=200420
* Correct a number of evolved problems with inp_vflag and inp_flags:Robert Watson2009-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | certain flags that should have been in inp_flags ended up in inp_vflag, meaning that they were inconsistently locked, and in one case, interpreted. Move the following flags from inp_vflag to gaps in the inp_flags space (and clean up the inp_flags constants to make gaps more obvious to future takers): INP_TIMEWAIT INP_SOCKREF INP_ONESBCAST INP_DROPPED Some aspects of this change have no effect on kernel ABI at all, as these are UDP/TCP/IP-internal uses; however, netstat and sockstat detect INP_TIMEWAIT when listing TCP sockets, so any MFC will need to take this into account. MFC after: 1 week (or after dependencies are MFC'd) Reviewed by: bz Notes: svn path=/head/; revision=189848
* ANSIfy and remove register.Xin LI2008-01-161-30/+14
| | | | | | | Resulting binary verified with strip(1)+md5(1). Notes: svn path=/head/; revision=175387
* The logic of fetchnetstat_sysctl() isn't too complex: if idx is 0,Yaroslav Tykhiy2006-11-271-2/+2
| | | | | | | | | | | we set and use xtp; if idx is 1, we set and use xip; the other cases are impossible. However, GCC cannot see that xip and xtp are always initialized before use because they are initialized and used in different if/else blocks. So setting them to NULL at the very beginning won't hurt. Notes: svn path=/head/; revision=164680
* + WARNS=4 reminds that nlist.n_name isn't const.Yaroslav Tykhiy2006-11-271-3/+5
| | | | | | | | | + Use C99 initializers to be WARNS-clean. + The last element in a namelist should have its n_name set to NULL, not to an empty string. Notes: svn path=/head/; revision=164679
* Don't discard a const qualifier from constant strings.Yaroslav Tykhiy2006-11-271-1/+2
| | | | Notes: svn path=/head/; revision=164678
* Remove trailing whitespace.Bruce Evans2006-04-301-6/+6
| | | | | | | | Submitted by: Se=E1n Farley <sean-freebsd at farley dot org> PR: bin/81874 Notes: svn path=/head/; revision=158161
* Show the load average in the tcp display (it was already shown, perhapsBruce Evans2006-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | not very usefully, in all other displays). This was the original point of the PR. Move the load average up by 2 so that it starts in row 0 for all windows (2 lines above it were wasted for all other windows except vmstat). Move everything below it up by 2 or 3 (3 for icmp and icmp6 which had an extra blank line due from not compensating for the foot-shooting in note (3); only ip and ip6 compensated). Reduce the magic numbers related to this. Notes by the submitter: %%% 1. All the subwin() calls are identical using #define MAINWIN_ROW 3 (systat.h). 2. The load average is at the top of the window. 3. Each display starts on the fourth line. I made changes to those displays that shifted the start line (i.e., icmp). This entailed a lot of changes within the comments at the top of those displays. 4. For ip6, I shifted the "Input next-header histogram" column down one row to separate it from "IPv6 Output". I raised "bad scope packets" and "address selection failed" up one row to stay with "IPv6 Input" (valid?). They were down one row to probably line up at the bottom, but I think they should stick with their fellow items in a column. 5. I condensed ifstat a bit. It had a lot of empty rows. %%% Submitted by: Se=E1n Farley <sean-freebsd at farley dot org> PR: bin/81874 Notes: svn path=/head/; revision=158160
* simply ignore unknown address family.Hajimu UMEMOTO2005-02-191-3/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=142095
* teach IPv6 to `systat -netstat'.Hajimu UMEMOTO2005-02-191-29/+122
| | | | | | | | Tested by: kuriyama MFC after: 1 week Notes: svn path=/head/; revision=142093
* Make systat -net aware of compressed time_wait sockets.Mike Silbersack2003-12-241-3/+11
| | | | Notes: svn path=/head/; revision=123800
* Add ip6 and icmp6 displays to systat.David Malone2003-08-011-0/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=118318
* Widen struct sockbuf's sb_timeo member to int from short. WithJohn Polstra2002-07-241-4/+4
| | | | | | | | | | | | | | | | non-default but reasonable values of hz this member overflowed, breaking NFS over UDP. Also, as long as I'm plowing up struct sockbuf ... Change certain members from u_long/long to u_int/int in order to reduce wasted space on 64-bit machines. This change was requested by Andrew Gallatin. Netstat and systat need to be rebuilt. I am incrementing __FreeBSD_version in case any ports need to change. Notes: svn path=/head/; revision=100591
* remove __PWarner Losh2002-03-221-7/+7
| | | | Notes: svn path=/head/; revision=92922
* WARNS=2 fixes with NO_WERROR set, as there are some header issuesMark Murray2001-12-121-38/+39
| | | | | | | with namelists. use __FBSDID(). Notes: svn path=/head/; revision=87715
* Get rid of setgid kmem for systat, and while being there, fix some bugsThomas Moestl2001-03-231-23/+142
| | | | | | | | | | | | | | and compiler warnings. The data for network statistics are still obtained via the kvm interface if systat was started with the needed privileges, otherwise sysctls are used. The reason for this is that with really many open sockets, the sysctl method is probably slower, but it systat -netstat is probably not really usable in either mode under these conditions. Approved by: rwatson Notes: svn path=/head/; revision=74671
* My bad, committed the submitted patch rather than the fixed patch.Poul-Henning Kamp2000-12-301-2/+3
| | | | Notes: svn path=/head/; revision=70526
* Use macro API to <sys/queue.h>Poul-Henning Kamp2000-12-301-31/+16
| | | | | | | | Submitted by: "Jason" <jsmethers@pdq.net> Reviewed by: phk Notes: svn path=/head/; revision=70523
* systat is way too comfortable with curses internals...Peter Wemm1999-08-301-1/+1
| | | | Notes: svn path=/head/; revision=50635
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Quiet many compiler warnings.David E. O'Brien1998-10-081-2/+2
| | | | Notes: svn path=/head/; revision=40060
* #include <arpa/inet.h>Peter Wemm1998-06-121-1/+2
| | | | Notes: svn path=/head/; revision=36916
* o Use snprintf rather than sprintfWarner Losh1998-06-091-6/+8
| | | | | | | | | | | | | | o Add more checks for buffer overflows o Use snprintf rather than strcat/cpy and have better checks for max length exceeded. Most of these changes are not exploitable buffer overruns, but it never hurts to be safe. Inspired by and obtained from: OpenBSD Notes: svn path=/head/; revision=36789
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=23012
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=21673
* bin/1942 curses problem in systatPoul-Henning Kamp1996-11-021-2/+2
| | | | | | | | truncate if too long for field. 2.2 candidate. Notes: svn path=/head/; revision=19330
* Eliminate unnecessary include of <sys/mbuf.h>.Garrett Wollman1996-10-281-1/+4
| | | | Notes: svn path=/head/; revision=19234
* Move #include of queue.h before #include of socketvar.h in preparation forDavid Greenman1996-03-111-1/+1
| | | | | | | struct socket changes. Notes: svn path=/head/; revision=14543
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-4/+4
| | | | Notes: svn path=/head/; revision=8874
* Updated for 4.4BSD queue macros. (Oops, I forgot to commit this last night;David Greenman1995-04-091-11/+4
| | | | | | | sorry Jordan). Notes: svn path=/head/; revision=7715
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+470
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590