]> The Tcpdump Group git mirrors - tcpdump/blob - tcpdump.c
2f2710e56ef90ace91bf5e393b8673217b867834
[tcpdump] / tcpdump.c
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
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Support for splitting captures into multiple files with a maximum
22 * file size:
23 *
24 * Copyright (c) 2001
25 * Seth Webster <swebster@sst.ll.mit.edu>
26 */
27
28 #ifndef lint
29 static const char copyright[] =
30 "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
31 The Regents of the University of California. All rights reserved.\n";
32 static const char rcsid[] =
33 "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.184 2002-08-09 13:50:15 risso Exp $ (LBL)";
34 #endif
35
36 /*
37 * tcpdump - monitor tcp/ip traffic on an ethernet.
38 *
39 * First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory.
40 * Mercilessly hacked and occasionally improved since then via the
41 * combined efforts of Van, Steve McCanne and Craig Leres of LBL.
42 */
43
44 #ifdef HAVE_CONFIG_H
45 #include "config.h"
46 #endif
47
48 #include <tcpdump-stdinc.h>
49
50 #ifdef WIN32
51 #include "getopt.h"
52 #include "w32_fzs.h"
53 extern int strcasecmp (const char *__s1, const char *__s2);
54 extern int SIZE_BUF;
55 #define off_t long
56 #define uint UINT
57 #endif /* WIN32 */
58
59 #include <pcap.h>
60 #include <signal.h>
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <string.h>
64
65
66 #include "interface.h"
67 #include "addrtoname.h"
68 #include "machdep.h"
69 #include "setsignal.h"
70 #include "gmt2local.h"
71
72 int aflag; /* translate network and broadcast addresses */
73 int dflag; /* print filter code */
74 int eflag; /* print ethernet header */
75 int fflag; /* don't translate "foreign" IP address */
76 int nflag; /* leave addresses as numbers */
77 int Nflag; /* remove domains from printed host names */
78 int Oflag = 1; /* run filter code optimizer */
79 int pflag; /* don't go promiscuous */
80 int qflag; /* quick (shorter) output */
81 int Rflag = 1; /* print sequence # field in AH/ESP*/
82 int sflag = 0; /* use the libsmi to translate OIDs */
83 int Sflag; /* print raw TCP sequence numbers */
84 int tflag = 1; /* print packet arrival time */
85 int uflag = 0; /* Print undecoded NFS handles */
86 int vflag; /* verbose */
87 int xflag; /* print packet in hex */
88 int Xflag; /* print packet in ascii as well as hex */
89 off_t Cflag = 0; /* rotate dump files after this many bytes */
90 int Aflag = 0; /* print packet only in ascii observing LF, CR, TAB, SPACE */
91
92 char *espsecret = NULL; /* ESP secret key */
93
94 int packettype;
95
96 int infodelay;
97 int infoprint;
98
99 char *program_name;
100
101 int32_t thiszone; /* seconds offset from gmt to local time */
102
103 /* Forwards */
104 static RETSIGTYPE cleanup(int);
105 static void usage(void) __attribute__((noreturn));
106
107 static void dump_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
108
109 #ifdef SIGINFO
110 RETSIGTYPE requestinfo(int);
111 #endif
112
113 /* Length of saved portion of packet. */
114 int snaplen = DEFAULT_SNAPLEN;
115
116 struct printer {
117 pcap_handler f;
118 int type;
119 };
120
121 static struct printer printers[] = {
122 { arcnet_if_print, DLT_ARCNET },
123 { ether_if_print, DLT_EN10MB },
124 { token_if_print, DLT_IEEE802 },
125 #ifdef DLT_LANE8023
126 { lane_if_print, DLT_LANE8023 },
127 #endif
128 #ifdef DLT_CIP
129 { cip_if_print, DLT_CIP },
130 #endif
131 #ifdef DLT_ATM_CLIP
132 { cip_if_print, DLT_ATM_CLIP },
133 #endif
134 { sl_if_print, DLT_SLIP },
135 { sl_bsdos_if_print, DLT_SLIP_BSDOS },
136 { ppp_if_print, DLT_PPP },
137 { ppp_bsdos_if_print, DLT_PPP_BSDOS },
138 { fddi_if_print, DLT_FDDI },
139 { null_if_print, DLT_NULL },
140 #ifdef DLT_LOOP
141 { null_if_print, DLT_LOOP },
142 #endif
143 { raw_if_print, DLT_RAW },
144 { atm_if_print, DLT_ATM_RFC1483 },
145 #ifdef DLT_C_HDLC
146 { chdlc_if_print, DLT_C_HDLC },
147 #endif
148 #ifdef DLT_HDLC
149 { chdlc_if_print, DLT_HDLC },
150 #endif
151 #ifdef DLT_PPP_SERIAL
152 { ppp_hdlc_if_print, DLT_PPP_SERIAL },
153 #endif
154 #ifdef DLT_PPP_ETHER
155 { pppoe_if_print, DLT_PPP_ETHER },
156 #endif
157 #ifdef DLT_LINUX_SLL
158 { sll_if_print, DLT_LINUX_SLL },
159 #endif
160 #ifdef DLT_IEEE802_11
161 { ieee802_11_if_print, DLT_IEEE802_11},
162 #endif
163 #ifdef DLT_LTALK
164 { ltalk_if_print, DLT_LTALK },
165 #endif
166 #ifdef DLT_PFLOG
167 { pflog_if_print, DLT_PFLOG },
168 #endif
169 #ifdef DLT_FR
170 { fr_if_print, DLT_FR },
171 #endif
172 #ifdef DLT_FRELAY
173 { fr_if_print, DLT_FRELAY },
174 #endif
175 #ifdef DLT_SUNATM
176 { sunatm_if_print, DLT_SUNATM },
177 #endif
178 { NULL, 0 },
179 };
180
181 static pcap_handler
182 lookup_printer(int type)
183 {
184 struct printer *p;
185
186 for (p = printers; p->f; ++p)
187 if (type == p->type)
188 return p->f;
189
190 error("unknown data link type %d", type);
191 /* NOTREACHED */
192 }
193
194 static pcap_t *pd;
195
196 extern int optind;
197 extern int opterr;
198 extern char *optarg;
199
200 struct dump_info {
201 char *WFileName;
202 pcap_t *pd;
203 pcap_dumper_t *p;
204 };
205
206 int
207 main(int argc, char **argv)
208 {
209 register int cnt, op, i;
210 bpf_u_int32 localnet, netmask;
211 register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName;
212 pcap_handler printer;
213 struct bpf_program fcode;
214 #ifndef WIN32
215 RETSIGTYPE (*oldhandler)(int);
216 #endif
217 struct dump_info dumpinfo;
218 u_char *pcap_userdata;
219 char ebuf[PCAP_ERRBUF_SIZE];
220 #ifdef HAVE_PCAP_FINDALLDEVS
221 pcap_if_t *devpointer;
222 int devnum;
223 #endif
224 #ifdef WIN32
225 DWORD dwVersion;
226 DWORD dwWindowsMajorVersion;
227 u_int UserBufferSize=1000000;
228 #endif
229
230 #ifdef WIN32
231 dwVersion=GetVersion(); /* get the OS version */
232 dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
233 if(wsockinit()!=0) return 1;
234 #endif /* WIN32 */
235
236 cnt = -1;
237 device = NULL;
238 infile = NULL;
239 RFileName = NULL;
240 WFileName = NULL;
241 if ((cp = strrchr(argv[0], '/')) != NULL)
242 program_name = cp + 1;
243 else
244 program_name = argv[0];
245
246 if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
247 error("%s", ebuf);
248
249 #ifdef LIBSMI
250 smiInit("tcpdump");
251 #endif
252
253 opterr = 0;
254 while (
255 #ifdef WIN32
256 (op = getopt(argc, argv, "aAB:c:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
257 #else /* WIN32 */
258 #ifdef HAVE_PCAP_FINDALLDEVS
259 (op = getopt(argc, argv, "aAc:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
260 #else /* HAVE_PCAP_FINDALLDEVS */
261 (op = getopt(argc, argv, "aAc:C:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
262 #endif /* HAVE_PCAP_FINDALLDEVS */
263 #endif /* WIN32 */
264 switch (op) {
265
266 case 'a':
267 ++aflag;
268 break;
269
270 case 'A':
271 ++xflag;
272 ++Xflag;
273 ++Aflag;
274 break;
275
276 #ifdef WIN32
277 case 'B':
278 UserBufferSize = atoi(optarg)*1024;
279 if (UserBufferSize < 0)
280 error("invalid packet buffer size %s", optarg);
281 break;
282 #endif /* WIN32 */
283
284 case 'c':
285 cnt = atoi(optarg);
286 if (cnt <= 0)
287 error("invalid packet count %s", optarg);
288 break;
289
290 case 'C':
291 Cflag = atoi(optarg) * 1000000;
292 if (Cflag < 0)
293 error("invalid file size %s", optarg);
294 break;
295
296 case 'd':
297 ++dflag;
298 break;
299
300 #ifdef HAVE_PCAP_FINDALLDEVS
301 case 'D':
302 if (pcap_findalldevs(&devpointer, ebuf) < 0)
303 error("%s", ebuf);
304 else {
305 for (i = 0; devpointer != 0; i++) {
306 printf("%d.%s", i+1, devpointer->name);
307 if (devpointer->description != NULL)
308 printf(" (%s)", devpointer->description);
309 printf("\n");
310 devpointer = devpointer->next;
311 }
312 }
313 return 0;
314 #endif /* HAVE_PCAP_FINDALLDEVS */
315
316 case 'e':
317 ++eflag;
318 break;
319
320 case 'E':
321 #ifndef HAVE_LIBCRYPTO
322 warning("crypto code not compiled in");
323 #endif
324 espsecret = optarg;
325 break;
326
327 case 'f':
328 ++fflag;
329 break;
330
331 case 'F':
332 infile = optarg;
333 break;
334
335 case 'i':
336 if (optarg[0] == '0' && optarg[1] == 0)
337 error("Invalid adapter index");
338
339 #ifdef HAVE_PCAP_FINDALLDEVS
340 /*
341 * If the argument is a number, treat it as
342 * an index into the list of adapters, as
343 * printed by "tcpdump -D".
344 *
345 * This should be OK on UNIX systems, as interfaces
346 * shouldn't have names that begin with digits.
347 * It can be useful on Windows, where more than
348 * one interface can have the same name.
349 */
350 if ((devnum = atoi(optarg)) != 0) {
351 if (devnum < 0)
352 error("Invalid adapter index");
353
354 if (pcap_findalldevs(&devpointer, ebuf) < 0)
355 error("%s", ebuf);
356 else {
357 for (i = 0; i < devnum-1; i++){
358 devpointer = devpointer->next;
359 if (devpointer == NULL)
360 error("Invalid adapter index");
361 }
362 }
363 device = devpointer->name;
364 break;
365 }
366 #endif /* HAVE_PCAP_FINDALLDEVS */
367 device = optarg;
368 break;
369
370 case 'l':
371 #ifdef HAVE_SETLINEBUF
372 setlinebuf(stdout);
373 #else
374 setvbuf(stdout, NULL, _IOLBF, 0);
375 #endif
376 break;
377
378 case 'n':
379 ++nflag;
380 break;
381
382 case 'N':
383 ++Nflag;
384 break;
385
386 case 'm':
387 #ifdef LIBSMI
388 if (smiLoadModule(optarg) == 0) {
389 error("could not load MIB module %s", optarg);
390 }
391 sflag = 1;
392 #else
393 (void)fprintf(stderr, "%s: ignoring option `-m %s' ",
394 program_name, optarg);
395 (void)fprintf(stderr, "(no libsmi support)\n");
396 #endif
397
398 case 'O':
399 Oflag = 0;
400 break;
401
402 case 'p':
403 ++pflag;
404 break;
405
406 case 'q':
407 ++qflag;
408 break;
409
410 case 'r':
411 RFileName = optarg;
412 break;
413
414 case 'R':
415 Rflag = 0;
416 break;
417
418 case 's': {
419 char *end;
420
421 snaplen = strtol(optarg, &end, 0);
422 if (optarg == end || *end != '\0'
423 || snaplen < 0 || snaplen > 65535)
424 error("invalid snaplen %s", optarg);
425 else if (snaplen == 0)
426 snaplen = 65535;
427 break;
428 }
429
430 case 'S':
431 ++Sflag;
432 break;
433
434 case 't':
435 --tflag;
436 break;
437
438 case 'T':
439 if (strcasecmp(optarg, "vat") == 0)
440 packettype = PT_VAT;
441 else if (strcasecmp(optarg, "wb") == 0)
442 packettype = PT_WB;
443 else if (strcasecmp(optarg, "rpc") == 0)
444 packettype = PT_RPC;
445 else if (strcasecmp(optarg, "rtp") == 0)
446 packettype = PT_RTP;
447 else if (strcasecmp(optarg, "rtcp") == 0)
448 packettype = PT_RTCP;
449 else if (strcasecmp(optarg, "snmp") == 0)
450 packettype = PT_SNMP;
451 else if (strcasecmp(optarg, "cnfp") == 0)
452 packettype = PT_CNFP;
453 else
454 error("unknown packet type `%s'", optarg);
455 break;
456
457 case 'u':
458 ++uflag;
459 break;
460
461 case 'v':
462 ++vflag;
463 break;
464
465 case 'w':
466 WFileName = optarg;
467 break;
468
469 case 'x':
470 ++xflag;
471 break;
472
473 case 'X':
474 ++xflag;
475 ++Xflag;
476 break;
477
478 #ifdef YYDEBUG
479 case 'Y':
480 {
481 /* Undocumented flag */
482 extern int yydebug;
483 yydebug = 1;
484 }
485 break;
486 #endif
487 default:
488 usage();
489 /* NOTREACHED */
490 }
491
492 if (aflag && nflag)
493 error("-a and -n options are incompatible");
494
495 if (tflag > 0)
496 thiszone = gmt2local(0);
497
498 if (RFileName != NULL) {
499 /*
500 * We don't need network access, so set it back to the user id.
501 * Also, this prevents the user from reading anyone's
502 * trace file.
503 */
504 #ifndef WIN32
505 setuid(getuid());
506 #endif /* WIN32 */
507
508 pd = pcap_open_offline(RFileName, ebuf);
509 if (pd == NULL)
510 error("%s", ebuf);
511 localnet = 0;
512 netmask = 0;
513 if (fflag != 0)
514 error("-f and -r options are incompatible");
515 } else {
516 if (device == NULL) {
517 device = pcap_lookupdev(ebuf);
518 if (device == NULL)
519 error("%s", ebuf);
520 }
521 #ifdef WIN32
522 PrintCapBegins(program_name,device);
523 #endif /* WIN32 */
524 *ebuf = '\0';
525 pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
526 if (pd == NULL)
527 error("%s", ebuf);
528 else if (*ebuf)
529 warning("%s", ebuf);
530 #ifdef WIN32
531 if(UserBufferSize != 1000000)
532 if(pcap_setbuff(pd, UserBufferSize)==-1){
533 error("%s", pcap_geterr(pd));
534 }
535 #endif /* WIN32 */
536 i = pcap_snapshot(pd);
537 if (snaplen < i) {
538 warning("snaplen raised from %d to %d", snaplen, i);
539 snaplen = i;
540 }
541 if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
542 localnet = 0;
543 netmask = 0;
544 warning("%s", ebuf);
545 }
546 /*
547 * Let user own process after socket has been opened.
548 */
549 #ifndef WIN32
550 setuid(getuid());
551 #endif /* WIN32 */
552 }
553 if (infile)
554 cmdbuf = read_infile(infile);
555 else
556 cmdbuf = copy_argv(&argv[optind]);
557
558 if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
559 error("%s", pcap_geterr(pd));
560 if (dflag) {
561 bpf_dump(&fcode, dflag);
562 pcap_close(pd);
563 exit(0);
564 }
565 init_addrtoname(localnet, netmask);
566
567 (void)setsignal(SIGTERM, cleanup);
568 (void)setsignal(SIGINT, cleanup);
569 /* Cooperate with nohup(1) */
570 #ifndef WIN32
571 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
572 (void)setsignal(SIGHUP, oldhandler);
573 #endif /* WIN32 */
574
575 if (pcap_setfilter(pd, &fcode) < 0)
576 error("%s", pcap_geterr(pd));
577 if (WFileName) {
578 pcap_dumper_t *p = pcap_dump_open(pd, WFileName);
579 if (p == NULL)
580 error("%s", pcap_geterr(pd));
581 if (Cflag != 0) {
582 printer = dump_and_trunc;
583 dumpinfo.WFileName = WFileName;
584 dumpinfo.pd = pd;
585 dumpinfo.p = p;
586 pcap_userdata = (u_char *)&dumpinfo;
587 } else {
588 printer = pcap_dump;
589 pcap_userdata = (u_char *)p;
590 }
591 } else {
592 printer = lookup_printer(pcap_datalink(pd));
593 pcap_userdata = 0;
594 #ifdef SIGINFO
595 (void)setsignal(SIGINFO, requestinfo);
596 #endif
597 }
598 #ifndef WIN32
599 if (RFileName == NULL) {
600 (void)fprintf(stderr, "%s: listening on %s\n",
601 program_name, device);
602 (void)fflush(stderr);
603 }
604 #endif /* WIN32 */
605 if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
606 (void)fprintf(stderr, "%s: pcap_loop: %s\n",
607 program_name, pcap_geterr(pd));
608 cleanup(0);
609 pcap_close(pd);
610 exit(1);
611 }
612 if (RFileName == NULL)
613 info(1);
614 pcap_close(pd);
615 exit(0);
616 }
617
618 /* make a clean exit on interrupts */
619 static RETSIGTYPE
620 cleanup(int signo)
621 {
622
623 /* Can't print the summary if reading from a savefile */
624 if (pd != NULL && pcap_file(pd) == NULL) {
625 (void)fflush(stdout);
626 putc('\n', stderr);
627 info(1);
628 }
629 if (signo)
630 exit(0);
631 }
632
633 void
634 info(register int verbose)
635 {
636 struct pcap_stat stat;
637
638 if (pcap_stats(pd, &stat) < 0) {
639 (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd));
640 return;
641 }
642
643 if (!verbose)
644 fprintf(stderr, "%s: ", program_name);
645
646 (void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
647 if (!verbose)
648 fputs(", ", stderr);
649 else
650 putc('\n', stderr);
651 (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop);
652 infoprint = 0;
653 }
654
655 static void
656 reverse(char *s)
657 {
658 int i, j, c;
659
660 for (i = 0, j = strlen(s) - 1; i < j; i++, j--) {
661 c = s[i];
662 s[i] = s[j];
663 s[j] = c;
664 }
665 }
666
667
668 static void
669 swebitoa(unsigned int n, char *s)
670 {
671 unsigned int i;
672
673 i = 0;
674 do {
675 s[i++] = n % 10 + '0';
676 } while ((n /= 10) > 0);
677
678 s[i] = '\0';
679 reverse(s);
680 }
681
682 static void
683 dump_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
684 {
685 struct dump_info *info;
686 static uint cnt = 2;
687 char *name;
688
689 info = (struct dump_info *)user;
690
691 /*
692 * XXX - this won't prevent capture files from getting
693 * larger than Cflag - the last packet written to the
694 * file could put it over Cflag.
695 */
696 if (ftell((FILE *)info->p) > Cflag) {
697 name = (char *) malloc(strlen(info->WFileName) + 4);
698 if (name == NULL)
699 error("dump_and_trunc: malloc");
700 strcpy(name, info->WFileName);
701 swebitoa(cnt, name + strlen(info->WFileName));
702 cnt++;
703 pcap_dump_close(info->p);
704 info->p = pcap_dump_open(info->pd, name);
705 free(name);
706 if (info->p == NULL)
707 error("%s", pcap_geterr(pd));
708 }
709
710 pcap_dump((u_char *)info->p, h, sp);
711 }
712
713 /* Like default_print() but data need not be aligned */
714 void
715 default_print_unaligned(register const u_char *cp, register u_int length)
716 {
717 register u_int i, s;
718 register int nshorts;
719
720 if (Xflag) {
721 ascii_print(cp, length);
722 return;
723 }
724 nshorts = (u_int) length / sizeof(u_short);
725 i = 0;
726 while (--nshorts >= 0) {
727 if ((i++ % 8) == 0)
728 (void)printf("\n\t\t\t");
729 s = *cp++;
730 (void)printf(" %02x%02x", s, *cp++);
731 }
732 if (length & 1) {
733 if ((i % 8) == 0)
734 (void)printf("\n\t\t\t");
735 (void)printf(" %02x", *cp);
736 }
737 }
738
739 #ifdef WIN32
740 /*
741 * XXX - there should really be libpcap calls to get the version
742 * number as a string (the string would be generated from #defines
743 * at run time, so that it's not generated from string constants
744 * in the library, as, on many UNIX systems, those constants would
745 * be statically linked into the application executable image, and
746 * would thus reflect the version of libpcap on the system on
747 * which the application was *linked*, not the system on which it's
748 * *running*.
749 *
750 * That routine should be documented, unlike the "version[]"
751 * string, so that UNIX vendors providing their own libpcaps
752 * don't omit it (as a couple of vendors have...).
753 *
754 * Packet.dll should perhaps also export a routine to return the
755 * version number of the Packet.dll code, to supply the
756 * "Wpcap_version" information on Windows.
757 */
758 char WDversion[]="current-cvs.tcpdump.org";
759 char version[]="current-cvs.tcpdump.org";
760 char pcap_version[]="current-cvs.tcpdump.org";
761 char Wpcap_version[]="3.0 alpha";
762 #endif
763
764 /*
765 * By default, print the packet out in hex.
766 */
767 void
768 default_print(register const u_char *bp, register u_int length)
769 {
770 default_print_unaligned(bp, length);
771 }
772
773 #ifdef SIGINFO
774 RETSIGTYPE requestinfo(int signo)
775 {
776 if (infodelay)
777 ++infoprint;
778 else
779 info(0);
780 }
781 #endif
782
783 static void
784 usage(void)
785 {
786 extern char version[];
787 extern char pcap_version[];
788
789 #ifdef WIN32
790 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
791 (void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version);
792 #else
793 (void)fprintf(stderr, "%s version %s\n", program_name, version);
794 (void)fprintf(stderr, "libpcap version %s\n", pcap_version);
795 #endif /* WIN32 */
796 (void)fprintf(stderr,
797 #ifdef WIN32
798 "Usage: %s [-aAdDeflnNOpqRStuvxX] [-B size] [-c count] [ -C file_size ]\n", program_name);
799 #else /* WIN32 */
800 #ifdef HAVE_PCAP_FINDALLDEVS
801 "Usage: %s [-aAdDeflnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name);
802 #else /* HAVE_PCAP_FINDALLDEVS */
803 "Usage: %s [-aAdeflnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name);
804 #endif /* HAVE_PCAP_FINDALLDEVS */
805 #endif /* WIN32 */
806 (void)fprintf(stderr,
807 "\t\t[ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ]\n");
808 (void)fprintf(stderr,
809 "\t\t[ -T type ] [ -w file ] [ -E algo:secret ] [ expression ]\n");
810 exit(1);
811 }