Deleted Added
full compact
main.c (202060) main.c (204202)
1/*-
2 * Copyright (c) 1983, 1988, 1993
3 * 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

--- 30 unchanged lines hidden (view full) ---

39
40#if 0
41#ifndef lint
42static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94";
43#endif /* not lint */
44#endif
45
46#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1983, 1988, 1993
3 * 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

--- 30 unchanged lines hidden (view full) ---

39
40#if 0
41#ifndef lint
42static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94";
43#endif /* not lint */
44#endif
45
46#include <sys/cdefs.h>
47__FBSDID("$FreeBSD: head/usr.bin/netstat/main.c 202060 2010-01-11 03:00:17Z delphij $");
47__FBSDID("$FreeBSD: head/usr.bin/netstat/main.c 204202 2010-02-22 15:57:36Z rwatson $");
48
49#include <sys/param.h>
50#include <sys/file.h>
51#include <sys/protosw.h>
52#include <sys/socket.h>
53#include <sys/socketvar.h>
54
55#include <netinet/in.h>

--- 277 unchanged lines hidden (view full) ---

333int hflag; /* show counters in human readable format */
334int iflag; /* show interfaces */
335int Lflag; /* show size of listen queues */
336int mflag; /* show memory stats */
337int noutputs = 0; /* how much outputs before we exit */
338int numeric_addr; /* show addresses numerically */
339int numeric_port; /* show ports numerically */
340static int pflag; /* show given protocol */
48
49#include <sys/param.h>
50#include <sys/file.h>
51#include <sys/protosw.h>
52#include <sys/socket.h>
53#include <sys/socketvar.h>
54
55#include <netinet/in.h>

--- 277 unchanged lines hidden (view full) ---

333int hflag; /* show counters in human readable format */
334int iflag; /* show interfaces */
335int Lflag; /* show size of listen queues */
336int mflag; /* show memory stats */
337int noutputs = 0; /* how much outputs before we exit */
338int numeric_addr; /* show addresses numerically */
339int numeric_port; /* show ports numerically */
340static int pflag; /* show given protocol */
341int Qflag; /* show netisr information */
341int rflag; /* show routing tables (or routing stats) */
342int sflag; /* show protocol statistics */
343int Wflag; /* wide display */
344int xflag; /* extra information, includes all socket buffer info */
345int zflag; /* zero stats */
346
347int interval; /* repeat interval for i/f stats */
348

--- 6 unchanged lines hidden (view full) ---

355int
356main(int argc, char *argv[])
357{
358 struct protox *tp = NULL; /* for printing cblocks & stats */
359 int ch;
360
361 af = AF_UNSPEC;
362
342int rflag; /* show routing tables (or routing stats) */
343int sflag; /* show protocol statistics */
344int Wflag; /* wide display */
345int xflag; /* extra information, includes all socket buffer info */
346int zflag; /* zero stats */
347
348int interval; /* repeat interval for i/f stats */
349

--- 6 unchanged lines hidden (view full) ---

356int
357main(int argc, char *argv[])
358{
359 struct protox *tp = NULL; /* for printing cblocks & stats */
360 int ch;
361
362 af = AF_UNSPEC;
363
363 while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSsuWw:xz")) != -1)
364 while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:Qq:rSsuWw:xz"))
365 != -1)
364 switch(ch) {
365 case 'A':
366 Aflag = 1;
367 break;
368 case 'a':
369 aflag = 1;
370 break;
371 case 'B':

--- 69 unchanged lines hidden (view full) ---

441 case 'p':
442 if ((tp = name2protox(optarg)) == NULL) {
443 errx(1,
444 "%s: unknown or uninstrumented protocol",
445 optarg);
446 }
447 pflag = 1;
448 break;
366 switch(ch) {
367 case 'A':
368 Aflag = 1;
369 break;
370 case 'a':
371 aflag = 1;
372 break;
373 case 'B':

--- 69 unchanged lines hidden (view full) ---

443 case 'p':
444 if ((tp = name2protox(optarg)) == NULL) {
445 errx(1,
446 "%s: unknown or uninstrumented protocol",
447 optarg);
448 }
449 pflag = 1;
450 break;
451 case 'Q':
452 Qflag = 1;
453 break;
449 case 'q':
450 noutputs = atoi(optarg);
451 if (noutputs != 0)
452 noutputs++;
453 break;
454 case 'r':
455 rflag = 1;
456 break;

--- 62 unchanged lines hidden (view full) ---

519 if (mflag) {
520 if (!live) {
521 if (kread(0, NULL, 0) == 0)
522 mbpr(kvmd, nl[N_MBSTAT].n_value);
523 } else
524 mbpr(NULL, 0);
525 exit(0);
526 }
454 case 'q':
455 noutputs = atoi(optarg);
456 if (noutputs != 0)
457 noutputs++;
458 break;
459 case 'r':
460 rflag = 1;
461 break;

--- 62 unchanged lines hidden (view full) ---

524 if (mflag) {
525 if (!live) {
526 if (kread(0, NULL, 0) == 0)
527 mbpr(kvmd, nl[N_MBSTAT].n_value);
528 } else
529 mbpr(NULL, 0);
530 exit(0);
531 }
532 if (Qflag) {
533 if (!live)
534 usage();
535 netisr_stats();
536 exit(0);
537 }
527#if 0
528 /*
529 * Keep file descriptors open to avoid overhead
530 * of open/close on each call to get* routines.
531 */
532 sethostent(1);
533 setnetent(1);
534#else

--- 240 unchanged lines hidden (view full) ---

775 }
776 endprotoent();
777 return (NULL);
778}
779
780static void
781usage(void)
782{
538#if 0
539 /*
540 * Keep file descriptors open to avoid overhead
541 * of open/close on each call to get* routines.
542 */
543 sethostent(1);
544 setnetent(1);
545#else

--- 240 unchanged lines hidden (view full) ---

786 }
787 endprotoent();
788 return (NULL);
789}
790
791static void
792usage(void)
793{
783 (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
794 (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
784"usage: netstat [-AaLnSWx] [-f protocol_family | -p protocol]\n"
785" [-M core] [-N system]",
786" netstat -i | -I interface [-abdhnW] [-f address_family]\n"
787" [-M core] [-N system]",
788" netstat -w wait [-I interface] [-d] [-M core] [-N system] [-q howmany]",
789" netstat -s [-s] [-z] [-f protocol_family | -p protocol]\n"
790" [-M core] [-N system]",
791" netstat -i | -I interface -s [-f protocol_family | -p protocol]\n"
792" [-M core] [-N system]",
793" netstat -m [-M core] [-N system]",
794" netstat -B [-I interface]",
795" netstat -r [-AanW] [-f address_family] [-M core] [-N system]",
796" netstat -rs [-s] [-M core] [-N system]",
797" netstat -g [-W] [-f address_family] [-M core] [-N system]",
795"usage: netstat [-AaLnSWx] [-f protocol_family | -p protocol]\n"
796" [-M core] [-N system]",
797" netstat -i | -I interface [-abdhnW] [-f address_family]\n"
798" [-M core] [-N system]",
799" netstat -w wait [-I interface] [-d] [-M core] [-N system] [-q howmany]",
800" netstat -s [-s] [-z] [-f protocol_family | -p protocol]\n"
801" [-M core] [-N system]",
802" netstat -i | -I interface -s [-f protocol_family | -p protocol]\n"
803" [-M core] [-N system]",
804" netstat -m [-M core] [-N system]",
805" netstat -B [-I interface]",
806" netstat -r [-AanW] [-f address_family] [-M core] [-N system]",
807" netstat -rs [-s] [-M core] [-N system]",
808" netstat -g [-W] [-f address_family] [-M core] [-N system]",
798" netstat -gs [-s] [-f address_family] [-M core] [-N system]");
809" netstat -gs [-s] [-f address_family] [-M core] [-N system]",
810" netstat -Q");
799 exit(1);
800}
811 exit(1);
812}