# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.255 2001-09-17 20:06:17 fenner Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.256 2001-10-01 01:12:00 mcr Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@rm -f $@
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
-CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \
+CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c pcap-dump-trunc.c \
print-802_11.c print-ah.c print-arcnet.c print-arp.c \
print-ascii.c print-atalk.c print-atm.c print-bgp.c \
print-bootp.c print-bxxp.c print-cdp.c print-chdlc.c \
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.171 2001-09-17 21:57:52 fenner Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.172 2001-10-01 01:12:00 mcr Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
#endif
#endif
-extern char *program_name; /* used to generate self-identifying messages */
+extern char *program_name; /*used to generate self-identifying messages */
+
+extern char *WFileName;
extern int32_t thiszone; /* seconds offset from gmt to local time */
#include <pcap.h>
+extern void dump_and_trunc(u_char *, const struct pcap_pkthdr *,
+ const u_char *);
extern void ascii_print_with_offset(const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, u_int);
extern void hex_print_with_offset(const u_char *, u_int, u_int);
struct bpf_program;
extern void bpf_dump(struct bpf_program *, int);
+
+extern pcap_t *pd;
+
#endif
--- /dev/null
+/*\r
+ * Copyright (c) 2001\r
+ *\r
+ * License: BSD\r
+ * \r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * \r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in\r
+ * the documentation and/or other materials provided with the\r
+ * distribution.\r
+ * 3. The names of the authors may not be used to endorse or promote\r
+ * products derived from this software without specific prior\r
+ * written permission.\r
+ * \r
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\r
+ *\r
+ */\r
+\r
+#include <sys/param.h>\r
+#include <sys/time.h>\r
+#include <sys/socket.h>\r
+\r
+#if __STDC__\r
+struct mbuf;\r
+struct rtentry;\r
+#endif\r
+#include <net/if.h>\r
+\r
+#include <netinet/in.h>\r
+#include <netinet/if_ether.h>\r
+#include <netinet/in_systm.h>\r
+#include <netinet/ip.h>\r
+#include <netinet/ip_var.h>\r
+#include <netinet/udp.h>\r
+#include <netinet/udp_var.h>\r
+#include <netinet/tcp.h>\r
+#include <netinet/tcpip.h>\r
+\r
+#include <stdio.h>\r
+#include <pcap.h>\r
+#include <unistd.h>\r
+#include <stdlib.h>\r
+\r
+#include "interface.h"\r
+#include "addrtoname.h"\r
+#include "ethertype.h"\r
+\r
+static void reverse(char *s);\r
+static void swebitoa(unsigned int n, char s[]);\r
+\r
+static void reverse (char s[]) {\r
+ int i, j, c;\r
+ \r
+ for (i = 0, j = strlen(s)-1; i < j; i++, j--) {\r
+ c = s[i];\r
+ s[i] = s[j];\r
+ s[j] = c;\r
+ }\r
+}\r
+\r
+\r
+static void swebitoa (unsigned int n, char s[]) {\r
+ \r
+ unsigned int i;\r
+ \r
+ i = 0;\r
+ do {\r
+ s[i++] = n % 10 + '0';\r
+ } while ((n /= 10) > 0);\r
+ \r
+ s[i] = '\0';\r
+ reverse(s);\r
+}\r
+\r
+void\r
+dump_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)\r
+{\r
+ extern char *WFileName;\r
+ register FILE *f;\r
+ static uint cnt = 2;\r
+ char *name;\r
+ extern pcap_t *pd;\r
+ extern long int Cflag;\r
+\r
+ f = (FILE *)user;\r
+ \r
+ if (Cflag && ftell(f) > Cflag) {\r
+ name = (char *) malloc(strlen(WFileName) + 4);\r
+ strcpy(name, WFileName);\r
+ swebitoa(cnt, name + strlen(WFileName));\r
+ cnt++;\r
+ pcap_dump_close((pcap_dumper_t *) f);\r
+ f = (FILE *) pcap_dump_open(pd, name); \r
+ free(name);\r
+ }\r
+\r
+ /* XXX we should check the return status */\r
+ (void)fwrite((char *)h, sizeof(*h), 1, f);\r
+ (void)fwrite((char *)sp, h->caplen, 1, f);\r
+}\r
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.166 2001-07-04 22:03:13 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.167 2001-10-01 01:12:01 mcr Exp $ (LBL)";
#endif
/*
int vflag; /* verbose */
int xflag; /* print packet in hex */
int Xflag; /* print packet in ascii as well as hex */
+off_t Cflag = 0; /* rotate dump files after this many bytes */
char *espsecret = NULL; /* ESP secret key */
int infoprint;
char *program_name;
+char *WFileName;
int32_t thiszone; /* seconds offset from gmt to local time */
/* Forwards */
static RETSIGTYPE cleanup(int);
static void usage(void) __attribute__((noreturn));
+
+extern void dump_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp);
+
#ifdef SIGINFO
RETSIGTYPE requestinfo(int);
#endif
/* NOTREACHED */
}
-static pcap_t *pd;
+pcap_t *pd;
extern int optind;
extern int opterr;
{
register int cnt, op, i;
bpf_u_int32 localnet, netmask;
- register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName;
+ register char *cp, *infile, *cmdbuf, *device, *RFileName;
+ extern char *WFileName;
pcap_handler printer;
struct bpf_program fcode;
RETSIGTYPE (*oldhandler)(int);
opterr = 0;
while (
- (op = getopt(argc, argv, "ac:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
+ (op = getopt(argc, argv, "ac:C:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
switch (op) {
case 'a':
error("invalid packet count %s", optarg);
break;
+ case 'C':
+ Cflag = atoi(optarg) * 1000000;
+ if (Cflag < 0)
+ error("invalid file size %s", optarg);
+ break;
+
case 'd':
++dflag;
break;
pcap_dumper_t *p = pcap_dump_open(pd, WFileName);
if (p == NULL)
error("%s", pcap_geterr(pd));
- printer = pcap_dump;
+ printer = dump_and_trunc;
pcap_userdata = (u_char *)p;
} else {
printer = lookup_printer(pcap_datalink(pd));
(void)setsignal(SIGINFO, requestinfo);
#endif
}
+
if (RFileName == NULL) {
(void)fprintf(stderr, "%s: listening on %s\n",
program_name, device);