tcpdump.c (173819) | tcpdump.c (190207) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 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: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 16 unchanged lines hidden (view full) --- 25 * Seth Webster <swebster@sst.ll.mit.edu> 26 */ 27 28#ifndef lint 29static const char copyright[] _U_ = 30 "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ 31The Regents of the University of California. All rights reserved.\n"; 32static const char rcsid[] _U_ = | 1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 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: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 16 unchanged lines hidden (view full) --- 25 * Seth Webster <swebster@sst.ll.mit.edu> 26 */ 27 28#ifndef lint 29static const char copyright[] _U_ = 30 "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ 31The Regents of the University of California. All rights reserved.\n"; 32static const char rcsid[] _U_ = |
33 "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.13 2007/09/12 19:48:51 guy Exp $ (LBL)"; | 33 "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.271.2.11 2008-09-25 21:50:04 guy Exp $ (LBL)"; |
34#endif 35 | 34#endif 35 |
36/* $FreeBSD: head/contrib/tcpdump/tcpdump.c 173819 2007-11-21 12:52:26Z mlaier $ */ | 36/* $FreeBSD: head/contrib/tcpdump/tcpdump.c 190207 2009-03-21 18:30:25Z rpaulo $ */ |
37 38/* 39 * tcpdump - monitor tcp/ip traffic on an ethernet. 40 * 41 * First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory. 42 * Mercilessly hacked and occasionally improved since then via the 43 * combined efforts of Van, Steve McCanne and Craig Leres of LBL. 44 */ --- 17 unchanged lines hidden (view full) --- 62#include <smi.h> 63#endif 64 65#include <pcap.h> 66#include <signal.h> 67#include <stdio.h> 68#include <stdlib.h> 69#include <string.h> | 37 38/* 39 * tcpdump - monitor tcp/ip traffic on an ethernet. 40 * 41 * First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory. 42 * Mercilessly hacked and occasionally improved since then via the 43 * combined efforts of Van, Steve McCanne and Craig Leres of LBL. 44 */ --- 17 unchanged lines hidden (view full) --- 62#include <smi.h> 63#endif 64 65#include <pcap.h> 66#include <signal.h> 67#include <stdio.h> 68#include <stdlib.h> 69#include <string.h> |
70#include <limits.h> |
|
70#ifndef WIN32 | 71#ifndef WIN32 |
72#include <sys/wait.h> 73#include <sys/resource.h> |
|
71#include <pwd.h> 72#include <grp.h> 73#include <errno.h> 74#endif /* WIN32 */ 75 | 74#include <pwd.h> 75#include <grp.h> 76#include <errno.h> 77#endif /* WIN32 */ 78 |
79 |
|
76#include "netdissect.h" 77#include "interface.h" 78#include "addrtoname.h" 79#include "machdep.h" 80#include "setsignal.h" 81#include "gmt2local.h" 82#include "pcap-missing.h" 83 | 80#include "netdissect.h" 81#include "interface.h" 82#include "addrtoname.h" 83#include "machdep.h" 84#include "setsignal.h" 85#include "gmt2local.h" 86#include "pcap-missing.h" 87 |
88#ifndef NAME_MAX 89#define NAME_MAX 255 90#endif 91 |
|
84netdissect_options Gndo; 85netdissect_options *gndo = &Gndo; 86 | 92netdissect_options Gndo; 93netdissect_options *gndo = &Gndo; 94 |
87/* 88 * Define the maximum number of files for the -C flag, and how many 89 * characters can be added to a filename for the -C flag (which 90 * should be enough to handle MAX_CFLAG - 1). 91 */ 92#define MAX_CFLAG 1000000 93#define MAX_CFLAG_CHARS 6 94 | |
95int dflag; /* print filter code */ 96int Lflag; /* list available data link types and exit */ | 95int dflag; /* print filter code */ 96int Lflag; /* list available data link types and exit */ |
97char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */ |
|
97 98static int infodelay; 99static int infoprint; 100 101char *program_name; 102 103int32_t thiszone; /* seconds offset from gmt to local time */ 104 105/* Forwards */ 106static RETSIGTYPE cleanup(int); | 98 99static int infodelay; 100static int infoprint; 101 102char *program_name; 103 104int32_t thiszone; /* seconds offset from gmt to local time */ 105 106/* Forwards */ 107static RETSIGTYPE cleanup(int); |
108static RETSIGTYPE child_cleanup(int); |
|
107static void usage(void) __attribute__((noreturn)); 108static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn)); 109 110static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *); 111static void ndo_default_print(netdissect_options *, const u_char *, u_int); 112static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *); 113static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *); 114static void droproot(const char *, const char *); --- 102 unchanged lines hidden (view full) --- 217 { enc_if_print, DLT_ENC }, 218#endif 219#ifdef DLT_SYMANTEC_FIREWALL 220 { symantec_if_print, DLT_SYMANTEC_FIREWALL }, 221#endif 222#ifdef DLT_APPLE_IP_OVER_IEEE1394 223 { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 }, 224#endif | 109static void usage(void) __attribute__((noreturn)); 110static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn)); 111 112static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *); 113static void ndo_default_print(netdissect_options *, const u_char *, u_int); 114static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *); 115static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *); 116static void droproot(const char *, const char *); --- 102 unchanged lines hidden (view full) --- 219 { enc_if_print, DLT_ENC }, 220#endif 221#ifdef DLT_SYMANTEC_FIREWALL 222 { symantec_if_print, DLT_SYMANTEC_FIREWALL }, 223#endif 224#ifdef DLT_APPLE_IP_OVER_IEEE1394 225 { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 }, 226#endif |
227#ifdef DLT_IEEE802_11_RADIO_AVS 228 { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS }, 229#endif |
|
225#ifdef DLT_JUNIPER_ATM1 226 { juniper_atm1_print, DLT_JUNIPER_ATM1 }, 227#endif 228#ifdef DLT_JUNIPER_ATM2 229 { juniper_atm2_print, DLT_JUNIPER_ATM2 }, 230#endif 231#ifdef DLT_JUNIPER_MFR 232 { juniper_mfr_print, DLT_JUNIPER_MFR }, --- 32 unchanged lines hidden (view full) --- 265 { juniper_frelay_print, DLT_JUNIPER_FRELAY }, 266#endif 267#ifdef DLT_JUNIPER_CHDLC 268 { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, 269#endif 270#ifdef DLT_MFR 271 { mfr_if_print, DLT_MFR }, 272#endif | 230#ifdef DLT_JUNIPER_ATM1 231 { juniper_atm1_print, DLT_JUNIPER_ATM1 }, 232#endif 233#ifdef DLT_JUNIPER_ATM2 234 { juniper_atm2_print, DLT_JUNIPER_ATM2 }, 235#endif 236#ifdef DLT_JUNIPER_MFR 237 { juniper_mfr_print, DLT_JUNIPER_MFR }, --- 32 unchanged lines hidden (view full) --- 270 { juniper_frelay_print, DLT_JUNIPER_FRELAY }, 271#endif 272#ifdef DLT_JUNIPER_CHDLC 273 { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, 274#endif 275#ifdef DLT_MFR 276 { mfr_if_print, DLT_MFR }, 277#endif |
278#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H) 279 { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, 280#endif |
|
273 { NULL, 0 }, 274}; 275 276static if_printer 277lookup_printer(int type) 278{ 279 struct printer *p; 280 --- 12 unchanged lines hidden (view full) --- 293extern char *optarg; 294 295struct print_info { 296 if_printer printer; 297}; 298 299struct dump_info { 300 char *WFileName; | 281 { NULL, 0 }, 282}; 283 284static if_printer 285lookup_printer(int type) 286{ 287 struct printer *p; 288 --- 12 unchanged lines hidden (view full) --- 301extern char *optarg; 302 303struct print_info { 304 if_printer printer; 305}; 306 307struct dump_info { 308 char *WFileName; |
309 char *CurrentFileName; |
|
301 pcap_t *pd; 302 pcap_dumper_t *p; 303}; 304 305static void 306show_dlts_and_exit(pcap_t *pd) 307{ 308 int n_dlts; --- 13 unchanged lines hidden (view full) --- 322 if (dlt_name != NULL) { 323 (void) fprintf(stderr, " %s (%s)", dlt_name, 324 pcap_datalink_val_to_description(dlts[n_dlts])); 325 326 /* 327 * OK, does tcpdump handle that type? 328 */ 329 if (lookup_printer(dlts[n_dlts]) == NULL) | 310 pcap_t *pd; 311 pcap_dumper_t *p; 312}; 313 314static void 315show_dlts_and_exit(pcap_t *pd) 316{ 317 int n_dlts; --- 13 unchanged lines hidden (view full) --- 331 if (dlt_name != NULL) { 332 (void) fprintf(stderr, " %s (%s)", dlt_name, 333 pcap_datalink_val_to_description(dlts[n_dlts])); 334 335 /* 336 * OK, does tcpdump handle that type? 337 */ 338 if (lookup_printer(dlts[n_dlts]) == NULL) |
330 (void) fprintf(stderr, " (not supported)"); | 339 (void) fprintf(stderr, " (printing not supported)"); |
331 putchar('\n'); 332 } else { | 340 putchar('\n'); 341 } else { |
333 (void) fprintf(stderr, " DLT %d (not supported)\n", | 342 (void) fprintf(stderr, " DLT %d (printing not supported)\n", |
334 dlts[n_dlts]); 335 } 336 } 337 free(dlts); 338 exit(0); 339} 340 341/* 342 * Set up flags that might or might not be supported depending on the 343 * version of libpcap we're using. 344 */ | 343 dlts[n_dlts]); 344 } 345 } 346 free(dlts); 347 exit(0); 348} 349 350/* 351 * Set up flags that might or might not be supported depending on the 352 * version of libpcap we're using. 353 */ |
345#ifdef WIN32 | 354#if defined(HAVE_PCAP_CREATE) || defined(WIN32) |
346#define B_FLAG "B:" 347#define B_FLAG_USAGE " [ -B size ]" | 355#define B_FLAG "B:" 356#define B_FLAG_USAGE " [ -B size ]" |
348#else /* WIN32 */ | 357#else /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ |
349#define B_FLAG 350#define B_FLAG_USAGE | 358#define B_FLAG 359#define B_FLAG_USAGE |
351#endif /* WIN32 */ | 360#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ |
352 | 361 |
362#ifdef HAVE_PCAP_CREATE 363#define I_FLAG "I" 364#else /* HAVE_PCAP_CREATE */ 365#define I_FLAG 366#endif /* HAVE_PCAP_CREATE */ 367 |
|
353#ifdef HAVE_PCAP_FINDALLDEVS 354#ifndef HAVE_PCAP_IF_T 355#undef HAVE_PCAP_FINDALLDEVS 356#endif 357#endif 358 359#ifdef HAVE_PCAP_FINDALLDEVS 360#define D_FLAG "D" --- 59 unchanged lines hidden (view full) --- 420 421 return c; 422} 423 424 425static void 426MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars) 427{ | 368#ifdef HAVE_PCAP_FINDALLDEVS 369#ifndef HAVE_PCAP_IF_T 370#undef HAVE_PCAP_FINDALLDEVS 371#endif 372#endif 373 374#ifdef HAVE_PCAP_FINDALLDEVS 375#define D_FLAG "D" --- 59 unchanged lines hidden (view full) --- 435 436 return c; 437} 438 439 440static void 441MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars) 442{ |
443 char *filename = malloc(NAME_MAX + 1); 444 445 /* Process with strftime if Gflag is set. */ 446 if (Gflag != 0) { 447 struct tm *local_tm; 448 449 /* Convert Gflag_time to a usable format */ 450 if ((local_tm = localtime(&Gflag_time)) == NULL) { 451 error("MakeTimedFilename: localtime"); 452 } 453 454 /* There's no good way to detect an error in strftime since a return 455 * value of 0 isn't necessarily failure. 456 */ 457 strftime(filename, NAME_MAX, orig_name, local_tm); 458 } else { 459 strncpy(filename, orig_name, NAME_MAX); 460 } 461 |
|
428 if (cnt == 0 && max_chars == 0) | 462 if (cnt == 0 && max_chars == 0) |
429 strcpy(buffer, orig_name); | 463 strncpy(buffer, filename, NAME_MAX + 1); |
430 else | 464 else |
431 sprintf(buffer, "%s%0*d", orig_name, max_chars, cnt); | 465 if (snprintf(buffer, NAME_MAX + 1, "%s%0*d", filename, max_chars, cnt) > NAME_MAX) 466 /* Report an error if the filename is too large */ 467 error("too many output files or filename is too long (> %d)", NAME_MAX); 468 free(filename); |
432} 433 434static int tcpdump_printf(netdissect_options *ndo _U_, 435 const char *fmt, ...) 436{ 437 438 va_list args; 439 int ret; --- 5 unchanged lines hidden (view full) --- 445 return ret; 446} 447 448int 449main(int argc, char **argv) 450{ 451 register int cnt, op, i; 452 bpf_u_int32 localnet, netmask; | 469} 470 471static int tcpdump_printf(netdissect_options *ndo _U_, 472 const char *fmt, ...) 473{ 474 475 va_list args; 476 int ret; --- 5 unchanged lines hidden (view full) --- 482 return ret; 483} 484 485int 486main(int argc, char **argv) 487{ 488 register int cnt, op, i; 489 bpf_u_int32 localnet, netmask; |
453 register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName, *WFileNameAlt; | 490 register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName; |
454 pcap_handler callback; 455 int type; 456 struct bpf_program fcode; 457#ifndef WIN32 458 RETSIGTYPE (*oldhandler)(int); 459#endif 460 struct print_info printinfo; 461 struct dump_info dumpinfo; 462 u_char *pcap_userdata; 463 char ebuf[PCAP_ERRBUF_SIZE]; 464 char *username = NULL; 465 char *chroot_dir = NULL; 466#ifdef HAVE_PCAP_FINDALLDEVS 467 pcap_if_t *devpointer; 468 int devnum; 469#endif 470 int status; 471#ifdef WIN32 | 491 pcap_handler callback; 492 int type; 493 struct bpf_program fcode; 494#ifndef WIN32 495 RETSIGTYPE (*oldhandler)(int); 496#endif 497 struct print_info printinfo; 498 struct dump_info dumpinfo; 499 u_char *pcap_userdata; 500 char ebuf[PCAP_ERRBUF_SIZE]; 501 char *username = NULL; 502 char *chroot_dir = NULL; 503#ifdef HAVE_PCAP_FINDALLDEVS 504 pcap_if_t *devpointer; 505 int devnum; 506#endif 507 int status; 508#ifdef WIN32 |
472 u_int UserBufferSize = 1000000; | |
473 if(wsockinit() != 0) return 1; 474#endif /* WIN32 */ 475 476 gndo->ndo_Oflag=1; 477 gndo->ndo_Rflag=1; 478 gndo->ndo_dlt=-1; 479 gndo->ndo_default_print=ndo_default_print; 480 gndo->ndo_printf=tcpdump_printf; --- 15 unchanged lines hidden (view full) --- 496 error("%s", ebuf); 497 498#ifdef LIBSMI 499 smiInit("tcpdump"); 500#endif 501 502 opterr = 0; 503 while ( | 509 if(wsockinit() != 0) return 1; 510#endif /* WIN32 */ 511 512 gndo->ndo_Oflag=1; 513 gndo->ndo_Rflag=1; 514 gndo->ndo_dlt=-1; 515 gndo->ndo_default_print=ndo_default_print; 516 gndo->ndo_printf=tcpdump_printf; --- 15 unchanged lines hidden (view full) --- 532 error("%s", ebuf); 533 534#ifdef LIBSMI 535 smiInit("tcpdump"); 536#endif 537 538 opterr = 0; 539 while ( |
504 (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1) | 540 (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) |
505 switch (op) { 506 507 case 'a': 508 /* compatibility for old -a */ 509 break; 510 511 case 'A': 512 ++Aflag; 513 break; 514 | 541 switch (op) { 542 543 case 'a': 544 /* compatibility for old -a */ 545 break; 546 547 case 'A': 548 ++Aflag; 549 break; 550 |
515#ifdef WIN32 | 551#if defined(HAVE_PCAP_CREATE) || defined(WIN32) |
516 case 'B': | 552 case 'B': |
517 UserBufferSize = atoi(optarg)*1024; 518 if (UserBufferSize < 0) | 553 Bflag = atoi(optarg)*1024; 554 if (Bflag <= 0) |
519 error("invalid packet buffer size %s", optarg); 520 break; | 555 error("invalid packet buffer size %s", optarg); 556 break; |
521#endif /* WIN32 */ | 557#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ |
522 523 case 'c': 524 cnt = atoi(optarg); 525 if (cnt <= 0) 526 error("invalid packet count %s", optarg); 527 break; 528 529 case 'C': --- 40 unchanged lines hidden (view full) --- 570 case 'f': 571 ++fflag; 572 break; 573 574 case 'F': 575 infile = optarg; 576 break; 577 | 558 559 case 'c': 560 cnt = atoi(optarg); 561 if (cnt <= 0) 562 error("invalid packet count %s", optarg); 563 break; 564 565 case 'C': --- 40 unchanged lines hidden (view full) --- 606 case 'f': 607 ++fflag; 608 break; 609 610 case 'F': 611 infile = optarg; 612 break; 613 |
614 case 'G': 615 Gflag = atoi(optarg); 616 if (Gflag < 0) 617 error("invalid number of seconds %s", optarg); 618 619 /* We will create one file initially. */ 620 Gflag_count = 0; 621 622 /* Grab the current time for rotation use. */ 623 if ((Gflag_time = time(NULL)) == (time_t)-1) { 624 error("main: can't get current time: %s", 625 pcap_strerror(errno)); 626 } 627 break; 628 |
|
578 case 'i': 579 if (optarg[0] == '0' && optarg[1] == 0) 580 error("Invalid adapter index"); 581 582#ifdef HAVE_PCAP_FINDALLDEVS 583 /* 584 * If the argument is a number, treat it as 585 * an index into the list of adapters, as --- 19 unchanged lines hidden (view full) --- 605 } 606 device = devpointer->name; 607 break; 608 } 609#endif /* HAVE_PCAP_FINDALLDEVS */ 610 device = optarg; 611 break; 612 | 629 case 'i': 630 if (optarg[0] == '0' && optarg[1] == 0) 631 error("Invalid adapter index"); 632 633#ifdef HAVE_PCAP_FINDALLDEVS 634 /* 635 * If the argument is a number, treat it as 636 * an index into the list of adapters, as --- 19 unchanged lines hidden (view full) --- 656 } 657 device = devpointer->name; 658 break; 659 } 660#endif /* HAVE_PCAP_FINDALLDEVS */ 661 device = optarg; 662 break; 663 |
664#ifdef HAVE_PCAP_CREATE 665 case 'I': 666 ++Iflag; 667 break; 668#endif /* HAVE_PCAP_CREATE */ 669 |
|
613 case 'l': 614#ifdef WIN32 615 /* 616 * _IOLBF is the same as _IOFBF in Microsoft's C 617 * libraries; the only alternative they offer 618 * is _IONBF. 619 * 620 * XXX - this should really be checking for MSVC++, --- 5 unchanged lines hidden (view full) --- 626#ifdef HAVE_SETLINEBUF 627 setlinebuf(stdout); 628#else 629 setvbuf(stdout, NULL, _IOLBF, 0); 630#endif 631#endif /* WIN32 */ 632 break; 633 | 670 case 'l': 671#ifdef WIN32 672 /* 673 * _IOLBF is the same as _IOFBF in Microsoft's C 674 * libraries; the only alternative they offer 675 * is _IONBF. 676 * 677 * XXX - this should really be checking for MSVC++, --- 5 unchanged lines hidden (view full) --- 683#ifdef HAVE_SETLINEBUF 684 setlinebuf(stdout); 685#else 686 setvbuf(stdout, NULL, _IOLBF, 0); 687#endif 688#endif /* WIN32 */ 689 break; 690 |
634 case 'n': 635 ++nflag; | 691 case 'K': 692 ++Kflag; |
636 break; 637 | 693 break; 694 |
638 case 'N': 639 ++Nflag; 640 break; 641 | |
642 case 'm': 643#ifdef LIBSMI | 695 case 'm': 696#ifdef LIBSMI |
644 if (smiLoadModule(optarg) == 0) { | 697 if (smiLoadModule(optarg) == 0) { |
645 error("could not load MIB module %s", optarg); | 698 error("could not load MIB module %s", optarg); |
646 } | 699 } |
647 sflag = 1; 648#else 649 (void)fprintf(stderr, "%s: ignoring option `-m %s' ", 650 program_name, optarg); 651 (void)fprintf(stderr, "(no libsmi support)\n"); 652#endif 653 break; 654 655 case 'M': 656 /* TCP-MD5 shared secret */ 657#ifndef HAVE_LIBCRYPTO 658 warning("crypto code not compiled in"); 659#endif 660 tcpmd5secret = optarg; 661 break; 662 | 700 sflag = 1; 701#else 702 (void)fprintf(stderr, "%s: ignoring option `-m %s' ", 703 program_name, optarg); 704 (void)fprintf(stderr, "(no libsmi support)\n"); 705#endif 706 break; 707 708 case 'M': 709 /* TCP-MD5 shared secret */ 710#ifndef HAVE_LIBCRYPTO 711 warning("crypto code not compiled in"); 712#endif 713 tcpmd5secret = optarg; 714 break; 715 |
716 case 'n': 717 ++nflag; 718 break; 719 720 case 'N': 721 ++Nflag; 722 break; 723 |
|
663 case 'O': 664 Oflag = 0; 665 break; 666 667 case 'p': 668 ++pflag; 669 break; 670 --- 105 unchanged lines hidden (view full) --- 776 pcap_debug = 1; 777#else 778 extern int yydebug; 779 yydebug = 1; 780#endif 781 } 782 break; 783#endif | 724 case 'O': 725 Oflag = 0; 726 break; 727 728 case 'p': 729 ++pflag; 730 break; 731 --- 105 unchanged lines hidden (view full) --- 837 pcap_debug = 1; 838#else 839 extern int yydebug; 840 yydebug = 1; 841#endif 842 } 843 break; 844#endif |
845 case 'z': 846 if (optarg) { 847 zflag = strdup(optarg); 848 } else { 849 usage(); 850 /* NOTREACHED */ 851 } 852 break; 853 |
|
784 case 'Z': 785 if (optarg) { 786 username = strdup(optarg); 787 } 788 else { 789 usage(); 790 /* NOTREACHED */ 791 } --- 9 unchanged lines hidden (view full) --- 801 case 0: /* Default */ 802 case 4: /* Default + Date*/ 803 thiszone = gmt2local(0); 804 break; 805 806 case 1: /* No time stamp */ 807 case 2: /* Unix timeval style */ 808 case 3: /* Microseconds since previous packet */ | 854 case 'Z': 855 if (optarg) { 856 username = strdup(optarg); 857 } 858 else { 859 usage(); 860 /* NOTREACHED */ 861 } --- 9 unchanged lines hidden (view full) --- 871 case 0: /* Default */ 872 case 4: /* Default + Date*/ 873 thiszone = gmt2local(0); 874 break; 875 876 case 1: /* No time stamp */ 877 case 2: /* Unix timeval style */ 878 case 3: /* Microseconds since previous packet */ |
879 case 5: /* Microseconds since first packet */ |
|
809 break; 810 811 default: /* Not supported */ | 880 break; 881 882 default: /* Not supported */ |
812 error("only -t, -tt, -ttt, and -tttt are supported"); | 883 error("only -t, -tt, -ttt, -tttt and -ttttt are supported"); |
813 break; 814 } 815 816#ifdef WITH_CHROOT 817 /* if run as root, prepare for chrooting */ 818 if (getuid() == 0 || geteuid() == 0) { 819 /* future extensibility for cmd-line arguments */ 820 if (!chroot_dir) --- 58 unchanged lines hidden (view full) --- 879 } 880 else 881 { 882 fprintf(stderr, "%s: listening on %s\n", program_name, device); 883 } 884 885 fflush(stderr); 886#endif /* WIN32 */ | 884 break; 885 } 886 887#ifdef WITH_CHROOT 888 /* if run as root, prepare for chrooting */ 889 if (getuid() == 0 || geteuid() == 0) { 890 /* future extensibility for cmd-line arguments */ 891 if (!chroot_dir) --- 58 unchanged lines hidden (view full) --- 950 } 951 else 952 { 953 fprintf(stderr, "%s: listening on %s\n", program_name, device); 954 } 955 956 fflush(stderr); 957#endif /* WIN32 */ |
958#ifdef HAVE_PCAP_CREATE 959 pd = pcap_create(device, ebuf); 960 if (pd == NULL) 961 error("%s", ebuf); 962 status = pcap_set_snaplen(pd, snaplen); 963 if (status != 0) 964 error("%s: pcap_set_snaplen failed: %s", 965 device, pcap_statustostr(status)); 966 status = pcap_set_promisc(pd, !pflag); 967 if (status != 0) 968 error("%s: pcap_set_promisc failed: %s", 969 device, pcap_statustostr(status)); 970 if (Iflag) { 971 status = pcap_set_rfmon(pd, 1); 972 if (status != 0) 973 error("%s: pcap_set_rfmon failed: %s", 974 device, pcap_statustostr(status)); 975 } 976 status = pcap_set_timeout(pd, 1000); 977 if (status != 0) 978 error("%s: pcap_set_timeout failed: %s", 979 device, pcap_statustostr(status)); 980 if (Bflag != 0) { 981 status = pcap_set_buffer_size(pd, Bflag); 982 if (status != 0) 983 error("%s: pcap_set_buffer_size failed: %s", 984 device, pcap_statustostr(status)); 985 } 986 status = pcap_activate(pd); 987 if (status < 0) { 988 /* 989 * pcap_activate() failed. 990 */ 991 cp = pcap_geterr(pd); 992 if (status == PCAP_ERROR) 993 error("%s", cp); 994 else if ((status == PCAP_ERROR_NO_SUCH_DEVICE || 995 status == PCAP_ERROR_PERM_DENIED) && 996 *cp != '\0') 997 error("%s: %s\n(%s)", device, 998 pcap_statustostr(status), cp); 999 else 1000 error("%s: %s", device, 1001 pcap_statustostr(status)); 1002 } else if (status > 0) { 1003 /* 1004 * pcap_activate() succeeded, but it's warning us 1005 * of a problem it had. 1006 */ 1007 cp = pcap_geterr(pd); 1008 if (status == PCAP_WARNING) 1009 warning("%s", cp); 1010 else if (status == PCAP_WARNING_PROMISC_NOTSUP && 1011 *cp != '\0') 1012 warning("%s: %s\n(%s)", device, 1013 pcap_statustostr(status), cp); 1014 else 1015 warning("%s: %s", device, 1016 pcap_statustostr(status)); 1017 } 1018#else |
|
887 *ebuf = '\0'; 888 pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf); 889 if (pd == NULL) 890 error("%s", ebuf); 891 else if (*ebuf) 892 warning("%s", ebuf); | 1019 *ebuf = '\0'; 1020 pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf); 1021 if (pd == NULL) 1022 error("%s", ebuf); 1023 else if (*ebuf) 1024 warning("%s", ebuf); |
1025#endif /* HAVE_PCAP_CREATE */ |
|
893 /* 894 * Let user own process after socket has been opened. 895 */ 896#ifndef WIN32 897 if (setgid(getgid()) != 0 || setuid(getuid()) != 0) 898 fprintf(stderr, "Warning: setgid/setuid failed !\n"); 899#endif /* WIN32 */ | 1026 /* 1027 * Let user own process after socket has been opened. 1028 */ 1029#ifndef WIN32 1030 if (setgid(getgid()) != 0 || setuid(getuid()) != 0) 1031 fprintf(stderr, "Warning: setgid/setuid failed !\n"); 1032#endif /* WIN32 */ |
900#ifdef WIN32 901 if(UserBufferSize != 1000000) 902 if(pcap_setbuff(pd, UserBufferSize)==-1){ | 1033#if !defined(HAVE_PCAP_CREATE) && defined(WIN32) 1034 if(Bflag != 0) 1035 if(pcap_setbuff(pd, Bflag)==-1){ |
903 error("%s", pcap_geterr(pd)); 904 } | 1036 error("%s", pcap_geterr(pd)); 1037 } |
905#endif /* WIN32 */ | 1038#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */ |
906 if (Lflag) 907 show_dlts_and_exit(pd); 908 if (gndo->ndo_dlt >= 0) { 909#ifdef HAVE_PCAP_SET_DATALINK 910 if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0) 911 error("%s", pcap_geterr(pd)); 912#else 913 /* 914 * We don't actually support changing the 915 * data link type, so we only let them 916 * set it to what it already is. 917 */ 918 if (gndo->ndo_dlt != pcap_datalink(pd)) { 919 error("%s is not one of the DLTs supported by this device\n", 920 gndo->ndo_dltname); 921 } 922#endif 923 (void)fprintf(stderr, "%s: data link type %s\n", | 1039 if (Lflag) 1040 show_dlts_and_exit(pd); 1041 if (gndo->ndo_dlt >= 0) { 1042#ifdef HAVE_PCAP_SET_DATALINK 1043 if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0) 1044 error("%s", pcap_geterr(pd)); 1045#else 1046 /* 1047 * We don't actually support changing the 1048 * data link type, so we only let them 1049 * set it to what it already is. 1050 */ 1051 if (gndo->ndo_dlt != pcap_datalink(pd)) { 1052 error("%s is not one of the DLTs supported by this device\n", 1053 gndo->ndo_dltname); 1054 } 1055#endif 1056 (void)fprintf(stderr, "%s: data link type %s\n", |
924 program_name, gndo->ndo_dltname); | 1057 program_name, gndo->ndo_dltname); |
925 (void)fflush(stderr); 926 } 927 i = pcap_snapshot(pd); 928 if (snaplen < i) { 929 warning("snaplen raised from %d to %d", snaplen, i); 930 snaplen = i; 931 } 932 if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { --- 10 unchanged lines hidden (view full) --- 943 if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) 944 error("%s", pcap_geterr(pd)); 945 if (dflag) { 946 bpf_dump(&fcode, dflag); 947 pcap_close(pd); 948 exit(0); 949 } 950 init_addrtoname(localnet, netmask); | 1058 (void)fflush(stderr); 1059 } 1060 i = pcap_snapshot(pd); 1061 if (snaplen < i) { 1062 warning("snaplen raised from %d to %d", snaplen, i); 1063 snaplen = i; 1064 } 1065 if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { --- 10 unchanged lines hidden (view full) --- 1076 if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) 1077 error("%s", pcap_geterr(pd)); 1078 if (dflag) { 1079 bpf_dump(&fcode, dflag); 1080 pcap_close(pd); 1081 exit(0); 1082 } 1083 init_addrtoname(localnet, netmask); |
1084 init_checksum(); |
|
951 952#ifndef WIN32 953 (void)setsignal(SIGPIPE, cleanup); | 1085 1086#ifndef WIN32 1087 (void)setsignal(SIGPIPE, cleanup); |
954#endif /* WIN32 */ | |
955 (void)setsignal(SIGTERM, cleanup); 956 (void)setsignal(SIGINT, cleanup); | 1088 (void)setsignal(SIGTERM, cleanup); 1089 (void)setsignal(SIGINT, cleanup); |
1090 (void)setsignal(SIGCHLD, child_cleanup); 1091#endif /* WIN32 */ |
|
957 /* Cooperate with nohup(1) */ 958#ifndef WIN32 959 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) 960 (void)setsignal(SIGHUP, oldhandler); 961#endif /* WIN32 */ 962 963 if (pcap_setfilter(pd, &fcode) < 0) 964 error("%s", pcap_geterr(pd)); 965 if (WFileName) { 966 pcap_dumper_t *p; | 1092 /* Cooperate with nohup(1) */ 1093#ifndef WIN32 1094 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) 1095 (void)setsignal(SIGHUP, oldhandler); 1096#endif /* WIN32 */ 1097 1098 if (pcap_setfilter(pd, &fcode) < 0) 1099 error("%s", pcap_geterr(pd)); 1100 if (WFileName) { 1101 pcap_dumper_t *p; |
1102 /* Do not exceed the default NAME_MAX for files. */ 1103 dumpinfo.CurrentFileName = (char *)malloc(NAME_MAX + 1); |
|
967 | 1104 |
968 WFileNameAlt = (char *)malloc(strlen(WFileName) + MAX_CFLAG_CHARS + 1); 969 if (WFileNameAlt == NULL) 970 error("malloc of WFileNameAlt"); 971 MakeFilename(WFileNameAlt, WFileName, 0, WflagChars); 972 p = pcap_dump_open(pd, WFileNameAlt); | 1105 if (dumpinfo.CurrentFileName == NULL) 1106 error("malloc of dumpinfo.CurrentFileName"); 1107 1108 /* We do not need numbering for dumpfiles if Cflag isn't set. */ 1109 if (Cflag != 0) 1110 MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars); 1111 else 1112 MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0); 1113 1114 p = pcap_dump_open(pd, dumpinfo.CurrentFileName); |
973 if (p == NULL) 974 error("%s", pcap_geterr(pd)); | 1115 if (p == NULL) 1116 error("%s", pcap_geterr(pd)); |
975 if (Cflag != 0) { | 1117 if (Cflag != 0 || Gflag != 0) { |
976 callback = dump_packet_and_trunc; 977 dumpinfo.WFileName = WFileName; 978 dumpinfo.pd = pd; 979 dumpinfo.p = p; 980 pcap_userdata = (u_char *)&dumpinfo; 981 } else { 982 callback = dump_packet; 983 pcap_userdata = (u_char *)p; --- 18 unchanged lines hidden (view full) --- 1002 * the file (if done) for writing before giving up permissions. 1003 */ 1004 if (getuid() == 0 || geteuid() == 0) { 1005 if (username || chroot_dir) 1006 droproot(username, chroot_dir); 1007 } 1008#endif /* WIN32 */ 1009#ifdef SIGINFO | 1118 callback = dump_packet_and_trunc; 1119 dumpinfo.WFileName = WFileName; 1120 dumpinfo.pd = pd; 1121 dumpinfo.p = p; 1122 pcap_userdata = (u_char *)&dumpinfo; 1123 } else { 1124 callback = dump_packet; 1125 pcap_userdata = (u_char *)p; --- 18 unchanged lines hidden (view full) --- 1144 * the file (if done) for writing before giving up permissions. 1145 */ 1146 if (getuid() == 0 || geteuid() == 0) { 1147 if (username || chroot_dir) 1148 droproot(username, chroot_dir); 1149 } 1150#endif /* WIN32 */ 1151#ifdef SIGINFO |
1010 (void)setsignal(SIGINFO, requestinfo); | 1152 /* 1153 * We can't get statistics when reading from a file rather 1154 * than capturing from a device. 1155 */ 1156 if (RFileName == NULL) 1157 (void)setsignal(SIGINFO, requestinfo); |
1011#endif 1012 1013 if (vflag > 0 && WFileName) { 1014 /* 1015 * When capturing to a file, "-v" means tcpdump should, 1016 * every 10 secodns, "v"erbosely report the number of 1017 * packets captured. 1018 */ --- 101 unchanged lines hidden (view full) --- 1120 putchar('\n'); 1121 (void)fflush(stdout); 1122 info(1); 1123 } 1124 exit(0); 1125#endif 1126} 1127 | 1158#endif 1159 1160 if (vflag > 0 && WFileName) { 1161 /* 1162 * When capturing to a file, "-v" means tcpdump should, 1163 * every 10 secodns, "v"erbosely report the number of 1164 * packets captured. 1165 */ --- 101 unchanged lines hidden (view full) --- 1267 putchar('\n'); 1268 (void)fflush(stdout); 1269 info(1); 1270 } 1271 exit(0); 1272#endif 1273} 1274 |
1275/* 1276 On windows, we do not use a fork, so we do not care less about 1277 waiting a child processes to die 1278 */ 1279#ifndef WIN32 1280static RETSIGTYPE 1281child_cleanup(int signo _U_) 1282{ 1283 wait(NULL); 1284} 1285#endif /* WIN32 */ 1286 |
|
1128static void 1129info(register int verbose) 1130{ 1131 struct pcap_stat stat; 1132 1133 if (pcap_stats(pd, &stat) < 0) { 1134 (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd)); 1135 infoprint = 0; --- 12 unchanged lines hidden (view full) --- 1148 if (!verbose) 1149 fputs(", ", stderr); 1150 else 1151 putc('\n', stderr); 1152 (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop); 1153 infoprint = 0; 1154} 1155 | 1287static void 1288info(register int verbose) 1289{ 1290 struct pcap_stat stat; 1291 1292 if (pcap_stats(pd, &stat) < 0) { 1293 (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd)); 1294 infoprint = 0; --- 12 unchanged lines hidden (view full) --- 1307 if (!verbose) 1308 fputs(", ", stderr); 1309 else 1310 putc('\n', stderr); 1311 (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop); 1312 infoprint = 0; 1313} 1314 |
1315#ifndef WIN32 |
|
1156static void | 1316static void |
1317compress_savefile(const char *filename) 1318{ 1319 if (fork()) 1320 return; 1321 /* 1322 * Set to lowest priority so that this doesn't disturb the capture 1323 */ 1324#ifdef NZERO 1325 setpriority(PRIO_PROCESS, 0, NZERO - 1); 1326#else 1327 setpriority(PRIO_PROCESS, 0, 19); 1328#endif 1329 if (execlp(zflag, zflag, filename, NULL) == -1) 1330 fprintf(stderr, 1331 "compress_savefile:execlp(%s, %s): %s\n", 1332 zflag, 1333 filename, 1334 strerror(errno)); 1335} 1336#else /* WIN32 */ 1337static void 1338compress_savefile(const char *filename) 1339{ 1340 fprintf(stderr, 1341 "compress_savefile failed. Functionality not implemented under windows\n"); 1342} 1343#endif /* WIN32 */ 1344 1345static void |
|
1157dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) 1158{ 1159 struct dump_info *dump_info; | 1346dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) 1347{ 1348 struct dump_info *dump_info; |
1160 char *name; | |
1161 1162 ++packets_captured; 1163 1164 ++infodelay; 1165 1166 dump_info = (struct dump_info *)user; 1167 1168 /* | 1349 1350 ++packets_captured; 1351 1352 ++infodelay; 1353 1354 dump_info = (struct dump_info *)user; 1355 1356 /* |
1357 * XXX - this won't force the file to rotate on the specified time 1358 * boundary, but it will rotate on the first packet received after the 1359 * specified Gflag number of seconds. Note: if a Gflag time boundary 1360 * and a Cflag size boundary coincide, the time rotation will occur 1361 * first thereby cancelling the Cflag boundary (since the file should 1362 * be 0). 1363 */ 1364 if (Gflag != 0) { 1365 /* Check if it is time to rotate */ 1366 time_t t; 1367 1368 /* Get the current time */ 1369 if ((t = time(NULL)) == (time_t)-1) { 1370 error("dump_and_trunc_packet: can't get current_time: %s", 1371 pcap_strerror(errno)); 1372 } 1373 1374 1375 /* If the time is greater than the specified window, rotate */ 1376 if (t - Gflag_time >= Gflag) { 1377 /* Update the Gflag_time */ 1378 Gflag_time = t; 1379 /* Update Gflag_count */ 1380 Gflag_count++; 1381 /* 1382 * Close the current file and open a new one. 1383 */ 1384 pcap_dump_close(dump_info->p); 1385 1386 /* 1387 * Compress the file we just closed, if the user asked for it 1388 */ 1389 if (zflag != NULL) 1390 compress_savefile(dump_info->CurrentFileName); 1391 1392 /* 1393 * Check to see if we've exceeded the Wflag (when 1394 * not using Cflag). 1395 */ 1396 if (Cflag == 0 && Wflag > 0 && Gflag_count >= Wflag) { 1397 (void)fprintf(stderr, "Maximum file limit reached: %d\n", 1398 Wflag); 1399 exit(0); 1400 /* NOTREACHED */ 1401 } 1402 if (dump_info->CurrentFileName != NULL) 1403 free(dump_info->CurrentFileName); 1404 /* Allocate space for max filename + \0. */ 1405 dump_info->CurrentFileName = (char *)malloc(NAME_MAX + 1); 1406 if (dump_info->CurrentFileName == NULL) 1407 error("dump_packet_and_trunc: malloc"); 1408 /* 1409 * This is always the first file in the Cflag 1410 * rotation: e.g. 0 1411 * We also don't need numbering if Cflag is not set. 1412 */ 1413 if (Cflag != 0) 1414 MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 1415 WflagChars); 1416 else 1417 MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0); 1418 1419 dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); 1420 if (dump_info->p == NULL) 1421 error("%s", pcap_geterr(pd)); 1422 } 1423 } 1424 1425 /* |
|
1169 * XXX - this won't prevent capture files from getting 1170 * larger than Cflag - the last packet written to the 1171 * file could put it over Cflag. 1172 */ | 1426 * XXX - this won't prevent capture files from getting 1427 * larger than Cflag - the last packet written to the 1428 * file could put it over Cflag. 1429 */ |
1173 if (pcap_dump_ftell(dump_info->p) > Cflag) { | 1430 if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) { |
1174 /* 1175 * Close the current file and open a new one. 1176 */ 1177 pcap_dump_close(dump_info->p); | 1431 /* 1432 * Close the current file and open a new one. 1433 */ 1434 pcap_dump_close(dump_info->p); |
1435 1436 /* 1437 * Compress the file we just closed, if the user asked for it 1438 */ 1439 if (zflag != NULL) 1440 compress_savefile(dump_info->CurrentFileName); 1441 |
|
1178 Cflag_count++; 1179 if (Wflag > 0) { 1180 if (Cflag_count >= Wflag) 1181 Cflag_count = 0; | 1442 Cflag_count++; 1443 if (Wflag > 0) { 1444 if (Cflag_count >= Wflag) 1445 Cflag_count = 0; |
1182 } else { 1183 if (Cflag_count >= MAX_CFLAG) 1184 error("too many output files"); | |
1185 } | 1446 } |
1186 name = (char *)malloc(strlen(dump_info->WFileName) + MAX_CFLAG_CHARS + 1); 1187 if (name == NULL) | 1447 if (dump_info->CurrentFileName != NULL) 1448 free(dump_info->CurrentFileName); 1449 dump_info->CurrentFileName = (char *)malloc(NAME_MAX + 1); 1450 if (dump_info->CurrentFileName == NULL) |
1188 error("dump_packet_and_trunc: malloc"); | 1451 error("dump_packet_and_trunc: malloc"); |
1189 MakeFilename(name, dump_info->WFileName, Cflag_count, WflagChars); 1190 dump_info->p = pcap_dump_open(dump_info->pd, name); 1191 free(name); | 1452 MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars); 1453 dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); |
1192 if (dump_info->p == NULL) 1193 error("%s", pcap_geterr(pd)); 1194 } 1195 1196 pcap_dump((u_char *)dump_info->p, h, sp); 1197#ifdef HAVE_PCAP_DUMP_FLUSH 1198 if (Uflag) 1199 pcap_dump_flush(dump_info->p); --- 160 unchanged lines hidden (view full) --- 1360} 1361#endif 1362 1363/* 1364 * Called once each second in verbose mode while dumping to file 1365 */ 1366#ifdef USE_WIN32_MM_TIMER 1367void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_, | 1454 if (dump_info->p == NULL) 1455 error("%s", pcap_geterr(pd)); 1456 } 1457 1458 pcap_dump((u_char *)dump_info->p, h, sp); 1459#ifdef HAVE_PCAP_DUMP_FLUSH 1460 if (Uflag) 1461 pcap_dump_flush(dump_info->p); --- 160 unchanged lines hidden (view full) --- 1622} 1623#endif 1624 1625/* 1626 * Called once each second in verbose mode while dumping to file 1627 */ 1628#ifdef USE_WIN32_MM_TIMER 1629void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_, |
1368 DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) | 1630 DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) |
1369{ 1370 struct pcap_stat stat; 1371 1372 if (infodelay == 0 && pcap_stats(pd, &stat) >= 0) 1373 fprintf(stderr, "Got %u\r", packets_captured); 1374} 1375#elif defined(HAVE_ALARM) 1376static void verbose_stats_dump(int sig _U_) --- 30 unchanged lines hidden (view full) --- 1407 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version); 1408 (void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version); 1409#else /* WIN32 */ 1410 (void)fprintf(stderr, "%s version %s\n", program_name, version); 1411 (void)fprintf(stderr, "libpcap version %s\n", pcap_version); 1412#endif /* WIN32 */ 1413#endif /* HAVE_PCAP_LIB_VERSION */ 1414 (void)fprintf(stderr, | 1631{ 1632 struct pcap_stat stat; 1633 1634 if (infodelay == 0 && pcap_stats(pd, &stat) >= 0) 1635 fprintf(stderr, "Got %u\r", packets_captured); 1636} 1637#elif defined(HAVE_ALARM) 1638static void verbose_stats_dump(int sig _U_) --- 30 unchanged lines hidden (view full) --- 1669 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version); 1670 (void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version); 1671#else /* WIN32 */ 1672 (void)fprintf(stderr, "%s version %s\n", program_name, version); 1673 (void)fprintf(stderr, "libpcap version %s\n", pcap_version); 1674#endif /* WIN32 */ 1675#endif /* HAVE_PCAP_LIB_VERSION */ 1676 (void)fprintf(stderr, |
1415"Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name); | 1677"Usage: %s [-aAd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); |
1416 (void)fprintf(stderr, | 1678 (void)fprintf(stderr, |
1417"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]\n"); | 1679"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n"); |
1418 (void)fprintf(stderr, | 1680 (void)fprintf(stderr, |
1419"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]\n"); | 1681"\t\t[ -i interface ] [ -M secret ] [ -r file ]\n"); |
1420 (void)fprintf(stderr, | 1682 (void)fprintf(stderr, |
1421"\t\t[ -W filecount ] [ -y datalinktype ] [ -Z user ]\n"); | 1683"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]\n"); |
1422 (void)fprintf(stderr, | 1684 (void)fprintf(stderr, |
1685"\t\t[ -y datalinktype ] [ -z command ] [ -Z user ]\n"); 1686 (void)fprintf(stderr, |
|
1423"\t\t[ expression ]\n"); 1424 exit(1); 1425} 1426 1427 1428 1429/* VARARGS */ 1430static void --- 25 unchanged lines hidden (view full) --- 1456 (void)vfprintf(stderr, fmt, ap); 1457 va_end(ap); 1458 if (*fmt) { 1459 fmt += strlen(fmt); 1460 if (fmt[-1] != '\n') 1461 (void)fputc('\n', stderr); 1462 } 1463} | 1687"\t\t[ expression ]\n"); 1688 exit(1); 1689} 1690 1691 1692 1693/* VARARGS */ 1694static void --- 25 unchanged lines hidden (view full) --- 1720 (void)vfprintf(stderr, fmt, ap); 1721 va_end(ap); 1722 if (*fmt) { 1723 fmt += strlen(fmt); 1724 if (fmt[-1] != '\n') 1725 (void)fputc('\n', stderr); 1726 } 1727} |
1464 | |