]> The Tcpdump Group git mirrors - tcpdump/blob - tcpdump.c
Tweak the description of the "-D" flag, add an indication of when "-D"
[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.182 2002-08-03 23:16:57 guy 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 int ii;
226 DWORD dwVersion;
227 DWORD dwWindowsMajorVersion;
228 u_int UserBufferSize=1000000;
229 #endif
230
231 #ifdef WIN32
232 dwVersion=GetVersion(); /* get the OS version */
233 dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
234 if(wsockinit()!=0) return 1;
235 #endif /* WIN32 */
236
237 cnt = -1;
238 device = NULL;
239 infile = NULL;
240 RFileName = NULL;
241 WFileName = NULL;
242 if ((cp = strrchr(argv[0], '/')) != NULL)
243 program_name = cp + 1;
244 else
245 program_name = argv[0];
246
247 if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
248 error("%s", ebuf);
249
250 #ifdef LIBSMI
251 smiInit("tcpdump");
252 #endif
253
254 opterr = 0;
255 while (
256 #ifdef WIN32
257 (op = getopt(argc, argv, "aB:c:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
258 #else /* WIN32 */
259 #ifdef HAVE_PCAP_FINDALLDEVS
260 (op = getopt(argc, argv, "ac:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
261 #else /* HAVE_PCAP_FINDALLDEVS */
262 (op = getopt(argc, argv, "ac:C:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
263 #endif /* HAVE_PCAP_FINDALLDEVS */
264 #endif /* WIN32 */
265 switch (op) {
266
267 case 'a':
268 ++aflag;
269 break;
270
271 case 'A':
272 ++xflag;
273 ++Xflag;
274 ++Aflag;
275 break;
276
277 #ifdef WIN32
278 case 'B':
279 UserBufferSize = atoi(optarg)*1024;
280 if (UserBufferSize < 0)
281 error("invalid packet buffer size %s", optarg);
282 break;
283 #endif /* WIN32 */
284
285 case 'c':
286 cnt = atoi(optarg);
287 if (cnt <= 0)
288 error("invalid packet count %s", optarg);
289 break;
290
291 case 'C':
292 Cflag = atoi(optarg) * 1000000;
293 if (Cflag < 0)
294 error("invalid file size %s", optarg);
295 break;
296
297 case 'd':
298 ++dflag;
299 break;
300
301 #ifdef HAVE_PCAP_FINDALLDEVS
302 case 'D':
303 if (pcap_findalldevs(&devpointer, ebuf) < 0)
304 error("%s", ebuf);
305 else {
306 for (i = 0; devpointer != 0; i++) {
307 printf("%d.%s", i+1, devpointer->name);
308 if (devpointer->description != NULL)
309 printf(" (%s)", devpointer->description);
310 printf("\n");
311 devpointer = devpointer->next;
312 }
313 }
314 return 0;
315 #endif /* HAVE_PCAP_FINDALLDEVS */
316
317 case 'e':
318 ++eflag;
319 break;
320
321 case 'E':
322 #ifndef HAVE_LIBCRYPTO
323 warning("crypto code not compiled in");
324 #endif
325 espsecret = optarg;
326 break;
327
328 case 'f':
329 ++fflag;
330 break;
331
332 case 'F':
333 infile = optarg;
334 break;
335
336 case 'i':
337 if (optarg[0] == '0' && optarg[1] == 0)
338 error("Invalid adapter index");
339
340 #ifdef HAVE_PCAP_FINDALLDEVS
341 /*
342 * If the argument is a number, treat it as
343 * an index into the list of adapters, as
344 * printed by "tcpdump -D".
345 *
346 * This should be OK on UNIX systems, as interfaces
347 * shouldn't have names that begin with digits.
348 * It can be useful on Windows, where more than
349 * one interface can have the same name.
350 */
351 if ((devnum = atoi(optarg)) != 0) {
352 if (devnum < 0)
353 error("Invalid adapter index");
354
355 if (pcap_findalldevs(&devpointer, ebuf) < 0)
356 error("%s", ebuf);
357 else {
358 for (i = 0; i < devnum-1; i++){
359 devpointer = devpointer->next;
360 if (devpointer == NULL)
361 error("Invalid adapter index");
362 }
363 }
364 device = devpointer->name;
365 break;
366 }
367 #endif /* HAVE_PCAP_FINDALLDEVS */
368 device = optarg;
369 break;
370
371 case 'l':
372 #ifdef HAVE_SETLINEBUF
373 setlinebuf(stdout);
374 #else
375 setvbuf(stdout, NULL, _IOLBF, 0);
376 #endif
377 break;
378
379 case 'n':
380 ++nflag;
381 break;
382
383 case 'N':
384 ++Nflag;
385 break;
386
387 case 'm':
388 #ifdef LIBSMI
389 if (smiLoadModule(optarg) == 0) {
390 error("could not load MIB module %s", optarg);
391 }
392 sflag = 1;
393 #else
394 (void)fprintf(stderr, "%s: ignoring option `-m %s' ",
395 program_name, optarg);
396 (void)fprintf(stderr, "(no libsmi support)\n");
397 #endif
398
399 case 'O':
400 Oflag = 0;
401 break;
402
403 case 'p':
404 ++pflag;
405 break;
406
407 case 'q':
408 ++qflag;
409 break;
410
411 case 'r':
412 RFileName = optarg;
413 break;
414
415 case 'R':
416 Rflag = 0;
417 break;
418
419 case 's': {
420 char *end;
421
422 snaplen = strtol(optarg, &end, 0);
423 if (optarg == end || *end != '\0'
424 || snaplen < 0 || snaplen > 65535)
425 error("invalid snaplen %s", optarg);
426 else if (snaplen == 0)
427 snaplen = 65535;
428 break;
429 }
430
431 case 'S':
432 ++Sflag;
433 break;
434
435 case 't':
436 --tflag;
437 break;
438
439 case 'T':
440 if (strcasecmp(optarg, "vat") == 0)
441 packettype = PT_VAT;
442 else if (strcasecmp(optarg, "wb") == 0)
443 packettype = PT_WB;
444 else if (strcasecmp(optarg, "rpc") == 0)
445 packettype = PT_RPC;
446 else if (strcasecmp(optarg, "rtp") == 0)
447 packettype = PT_RTP;
448 else if (strcasecmp(optarg, "rtcp") == 0)
449 packettype = PT_RTCP;
450 else if (strcasecmp(optarg, "snmp") == 0)
451 packettype = PT_SNMP;
452 else if (strcasecmp(optarg, "cnfp") == 0)
453 packettype = PT_CNFP;
454 else
455 error("unknown packet type `%s'", optarg);
456 break;
457
458 case 'u':
459 ++uflag;
460 break;
461
462 case 'v':
463 ++vflag;
464 break;
465
466 case 'w':
467 WFileName = optarg;
468 break;
469
470 case 'x':
471 ++xflag;
472 break;
473
474 case 'X':
475 ++xflag;
476 ++Xflag;
477 break;
478
479 #ifdef YYDEBUG
480 case 'Y':
481 {
482 /* Undocumented flag */
483 extern int yydebug;
484 yydebug = 1;
485 }
486 break;
487 #endif
488 default:
489 usage();
490 /* NOTREACHED */
491 }
492
493 if (aflag && nflag)
494 error("-a and -n options are incompatible");
495
496 if (tflag > 0)
497 thiszone = gmt2local(0);
498
499 if (RFileName != NULL) {
500 /*
501 * We don't need network access, so set it back to the user id.
502 * Also, this prevents the user from reading anyone's
503 * trace file.
504 */
505 #ifndef WIN32
506 setuid(getuid());
507 #endif /* WIN32 */
508
509 pd = pcap_open_offline(RFileName, ebuf);
510 if (pd == NULL)
511 error("%s", ebuf);
512 localnet = 0;
513 netmask = 0;
514 if (fflag != 0)
515 error("-f and -r options are incompatible");
516 } else {
517 if (device == NULL) {
518 device = pcap_lookupdev(ebuf);
519 if (device == NULL)
520 error("%s", ebuf);
521 }
522 #ifdef WIN32
523 else
524 {
525 if (!(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4)) /* Windows '95 */
526 {
527 if(device[1]!=0)
528 device=(char*)SChar2WChar(device);
529 }
530 else{
531 for (ii=0;ii<(signed)strlen(device);ii++)
532 for (ii=strlen(device)-1;ii>0&&(device[ii]==' '||device[ii]=='\t');ii--)device[ii]='\0';
533 for (ii=0;ii<(signed)strlen(device)&&(device[ii]==' '||device[ii]=='\t');ii++);
534 strcpy(device,device+ii);
535 }
536 }
537 PrintCapBegins (program_name,device);
538 #endif /* WIN32 */
539 *ebuf = '\0';
540 pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
541 if (pd == NULL)
542 error("%s", ebuf);
543 else if (*ebuf)
544 warning("%s", ebuf);
545 #ifdef WIN32
546 if(UserBufferSize != 1000000)
547 if(pcap_setbuff(pd, UserBufferSize)==-1){
548 error("%s", pcap_geterr(pd));
549 }
550 #endif /* WIN32 */
551 i = pcap_snapshot(pd);
552 if (snaplen < i) {
553 warning("snaplen raised from %d to %d", snaplen, i);
554 snaplen = i;
555 }
556 if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
557 localnet = 0;
558 netmask = 0;
559 warning("%s", ebuf);
560 }
561 /*
562 * Let user own process after socket has been opened.
563 */
564 #ifndef WIN32
565 setuid(getuid());
566 #endif /* WIN32 */
567 }
568 if (infile)
569 cmdbuf = read_infile(infile);
570 else
571 cmdbuf = copy_argv(&argv[optind]);
572
573 if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
574 error("%s", pcap_geterr(pd));
575 if (dflag) {
576 bpf_dump(&fcode, dflag);
577 #ifdef WIN32
578 pcap_close(pd);
579 #endif /* WIN32 */
580 exit(0);
581 }
582 init_addrtoname(localnet, netmask);
583
584 (void)setsignal(SIGTERM, cleanup);
585 (void)setsignal(SIGINT, cleanup);
586 /* Cooperate with nohup(1) */
587 #ifndef WIN32
588 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
589 (void)setsignal(SIGHUP, oldhandler);
590 #endif /* WIN32 */
591
592 if (pcap_setfilter(pd, &fcode) < 0)
593 error("%s", pcap_geterr(pd));
594 if (WFileName) {
595 pcap_dumper_t *p = pcap_dump_open(pd, WFileName);
596 if (p == NULL)
597 error("%s", pcap_geterr(pd));
598 if (Cflag != 0) {
599 printer = dump_and_trunc;
600 dumpinfo.WFileName = WFileName;
601 dumpinfo.pd = pd;
602 dumpinfo.p = p;
603 pcap_userdata = (u_char *)&dumpinfo;
604 } else {
605 printer = pcap_dump;
606 pcap_userdata = (u_char *)p;
607 }
608 } else {
609 printer = lookup_printer(pcap_datalink(pd));
610 pcap_userdata = 0;
611 #ifdef SIGINFO
612 (void)setsignal(SIGINFO, requestinfo);
613 #endif
614 }
615 #ifndef WIN32
616 if (RFileName == NULL) {
617 (void)fprintf(stderr, "%s: listening on %s\n",
618 program_name, device);
619 (void)fflush(stderr);
620 }
621 #endif /* WIN32 */
622 if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
623 (void)fprintf(stderr, "%s: pcap_loop: %s\n",
624 program_name, pcap_geterr(pd));
625 cleanup(0);
626 pcap_close(pd);
627 exit(1);
628 }
629 if (RFileName == NULL)
630 info(1);
631 pcap_close(pd);
632 exit(0);
633 }
634
635 /* make a clean exit on interrupts */
636 static RETSIGTYPE
637 cleanup(int signo)
638 {
639
640 /* Can't print the summary if reading from a savefile */
641 if (pd != NULL && pcap_file(pd) == NULL) {
642 (void)fflush(stdout);
643 putc('\n', stderr);
644 info(1);
645 }
646 if (signo)
647 exit(0);
648 }
649
650 void
651 info(register int verbose)
652 {
653 struct pcap_stat stat;
654
655 if (pcap_stats(pd, &stat) < 0) {
656 (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd));
657 return;
658 }
659
660 if (!verbose)
661 fprintf(stderr, "%s: ", program_name);
662
663 (void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
664 if (!verbose)
665 fputs(", ", stderr);
666 else
667 putc('\n', stderr);
668 (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop);
669 infoprint = 0;
670 }
671
672 static void
673 reverse(char *s)
674 {
675 int i, j, c;
676
677 for (i = 0, j = strlen(s) - 1; i < j; i++, j--) {
678 c = s[i];
679 s[i] = s[j];
680 s[j] = c;
681 }
682 }
683
684
685 static void
686 swebitoa(unsigned int n, char *s)
687 {
688 unsigned int i;
689
690 i = 0;
691 do {
692 s[i++] = n % 10 + '0';
693 } while ((n /= 10) > 0);
694
695 s[i] = '\0';
696 reverse(s);
697 }
698
699 static void
700 dump_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
701 {
702 struct dump_info *info;
703 static uint cnt = 2;
704 char *name;
705
706 info = (struct dump_info *)user;
707
708 /*
709 * XXX - this won't prevent capture files from getting
710 * larger than Cflag - the last packet written to the
711 * file could put it over Cflag.
712 */
713 if (ftell((FILE *)info->p) > Cflag) {
714 name = (char *) malloc(strlen(info->WFileName) + 4);
715 if (name == NULL)
716 error("dump_and_trunc: malloc");
717 strcpy(name, info->WFileName);
718 swebitoa(cnt, name + strlen(info->WFileName));
719 cnt++;
720 pcap_dump_close(info->p);
721 info->p = pcap_dump_open(info->pd, name);
722 free(name);
723 if (info->p == NULL)
724 error("%s", pcap_geterr(pd));
725 }
726
727 pcap_dump((u_char *)info->p, h, sp);
728 }
729
730 /* Like default_print() but data need not be aligned */
731 void
732 default_print_unaligned(register const u_char *cp, register u_int length)
733 {
734 register u_int i, s;
735 register int nshorts;
736
737 if (Xflag) {
738 ascii_print(cp, length);
739 return;
740 }
741 nshorts = (u_int) length / sizeof(u_short);
742 i = 0;
743 while (--nshorts >= 0) {
744 if ((i++ % 8) == 0)
745 (void)printf("\n\t\t\t");
746 s = *cp++;
747 (void)printf(" %02x%02x", s, *cp++);
748 }
749 if (length & 1) {
750 if ((i % 8) == 0)
751 (void)printf("\n\t\t\t");
752 (void)printf(" %02x", *cp);
753 }
754 }
755
756 #ifdef WIN32
757 char WDversion[]="current-cvs.tcpdump.org";
758 char version[]="current-cvs.tcpdump.org";
759 char pcap_version[]="current-cvs.tcpdump.org";
760 char Wpcap_version[]="3.0 alpha";
761 #endif
762
763 /*
764 * By default, print the packet out in hex.
765 */
766 void
767 default_print(register const u_char *bp, register u_int length)
768 {
769 default_print_unaligned(bp, length);
770 }
771
772 #ifdef SIGINFO
773 RETSIGTYPE requestinfo(int signo)
774 {
775 if (infodelay)
776 ++infoprint;
777 else
778 info(0);
779 }
780 #endif
781
782 static void
783 usage(void)
784 {
785 extern char version[];
786 extern char pcap_version[];
787
788 #ifdef WIN32
789 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
790 (void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version);
791 #else
792 (void)fprintf(stderr, "%s version %s\n", program_name, version);
793 (void)fprintf(stderr, "libpcap version %s\n", pcap_version);
794 #endif /* WIN32 */
795 (void)fprintf(stderr,
796 #ifdef WIN32
797 "Usage: %s [-adDeflnNOpqStuvxX] [-B size] [-c count] [ -C file_size ]\n", program_name);
798 #else /* WIN32 */
799 #ifdef HAVE_PCAP_FINDALLDEVS
800 "Usage: %s [-adDeflnNOpqStuvxX] [-c count] [ -C file_size ]\n", program_name);
801 #else /* HAVE_PCAP_FINDALLDEVS */
802 "Usage: %s [-adeflnNOpqStuvxX] [-c count] [ -C file_size ]\n", program_name);
803 #endif /* HAVE_PCAP_FINDALLDEVS */
804 #endif /* WIN32 */
805 (void)fprintf(stderr,
806 "\t\t[ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ]\n");
807 (void)fprintf(stderr,
808 "\t\t[ -T type ] [ -w file ] [ -E algo:secret ] [ expression ]\n");
809 exit(1);
810 }