main.c (127398) | main.c (129906) |
---|---|
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 --- 28 unchanged lines hidden (view full) --- 37 Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94"; 43#endif 44static const char rcsid[] = | 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 --- 28 unchanged lines hidden (view full) --- 37 Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/usr.bin/netstat/main.c 127398 2004-03-25 08:51:14Z bms $"; | 45 "$FreeBSD: head/usr.bin/netstat/main.c 129906 2004-05-31 21:46:06Z bmilekic $"; |
46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/file.h> 50#include <sys/protosw.h> 51#include <sys/socket.h> 52 53#include <netinet/in.h> --- 197 unchanged lines hidden (view full) --- 251static struct protox *knownname (char *); 252 253static kvm_t *kvmd; 254static char *nlistf = NULL, *memf = NULL; 255 256int Aflag; /* show addresses of protocol control block */ 257int aflag; /* show all sockets (including servers) */ 258int bflag; /* show i/f total bytes in/out */ | 46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/file.h> 50#include <sys/protosw.h> 51#include <sys/socket.h> 52 53#include <netinet/in.h> --- 197 unchanged lines hidden (view full) --- 251static struct protox *knownname (char *); 252 253static kvm_t *kvmd; 254static char *nlistf = NULL, *memf = NULL; 255 256int Aflag; /* show addresses of protocol control block */ 257int aflag; /* show all sockets (including servers) */ 258int bflag; /* show i/f total bytes in/out */ |
259int cflag; /* show mbuf cache information */ | |
260int dflag; /* show i/f dropped packets */ 261int gflag; /* show group (multicast) routing or stats */ 262int iflag; /* show interfaces */ 263int Lflag; /* show size of listen queues */ 264int mflag; /* show memory stats */ 265int numeric_addr; /* show addresses numerically */ 266int numeric_port; /* show ports numerically */ 267static int pflag; /* show given protocol */ --- 24 unchanged lines hidden (view full) --- 292 Aflag = 1; 293 break; 294 case 'a': 295 aflag = 1; 296 break; 297 case 'b': 298 bflag = 1; 299 break; | 259int dflag; /* show i/f dropped packets */ 260int gflag; /* show group (multicast) routing or stats */ 261int iflag; /* show interfaces */ 262int Lflag; /* show size of listen queues */ 263int mflag; /* show memory stats */ 264int numeric_addr; /* show addresses numerically */ 265int numeric_port; /* show ports numerically */ 266static int pflag; /* show given protocol */ --- 24 unchanged lines hidden (view full) --- 291 Aflag = 1; 292 break; 293 case 'a': 294 aflag = 1; 295 break; 296 case 'b': 297 bflag = 1; 298 break; |
300 case 'c': 301 cflag = 1; 302 break; | |
303 case 'd': 304 dflag = 1; 305 break; 306 case 'f': 307 if (strcmp(optarg, "ipx") == 0) 308 af = AF_IPX; 309 else if (strcmp(optarg, "inet") == 0) 310 af = AF_INET; --- 109 unchanged lines hidden (view full) --- 420 421 /* 422 * Discard setgid privileges if not the running kernel so that bad 423 * guys can't print interesting stuff from kernel memory. 424 */ 425 if (nlistf != NULL || memf != NULL) 426 setgid(getgid()); 427 | 299 case 'd': 300 dflag = 1; 301 break; 302 case 'f': 303 if (strcmp(optarg, "ipx") == 0) 304 af = AF_IPX; 305 else if (strcmp(optarg, "inet") == 0) 306 af = AF_INET; --- 109 unchanged lines hidden (view full) --- 416 417 /* 418 * Discard setgid privileges if not the running kernel so that bad 419 * guys can't print interesting stuff from kernel memory. 420 */ 421 if (nlistf != NULL || memf != NULL) 422 setgid(getgid()); 423 |
428 if (cflag && !mflag) { 429 (void)fprintf(stderr, "-c only valid with -m\n"); 430 usage(); 431 } | |
432 if (mflag) { 433 if (memf != NULL) { 434 if (kread(0, 0, 0) == 0) 435 mbpr(nl[N_MBSTAT].n_value, 436 nl[N_MBTYPES].n_value, 437 nl[N_NMBCLUSTERS].n_value, 438 nl[N_NMBUFS].n_value, 439 nl[N_MBHI].n_value, --- 265 unchanged lines hidden --- | 424 if (mflag) { 425 if (memf != NULL) { 426 if (kread(0, 0, 0) == 0) 427 mbpr(nl[N_MBSTAT].n_value, 428 nl[N_MBTYPES].n_value, 429 nl[N_NMBCLUSTERS].n_value, 430 nl[N_NMBUFS].n_value, 431 nl[N_MBHI].n_value, --- 265 unchanged lines hidden --- |