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