From: guy Date: Fri, 5 May 2006 23:13:00 +0000 (+0000) Subject: From Ben Byer : add a "-K" flag to suppress the X-Git-Tag: tcpdump-4.0.0~225 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/90c94a826593a4c543f11ba4cefa71eafb7ae1c0 From Ben Byer : add a "-K" flag to suppress the checking of TCP checksums. Sort the argument processing code alphabetically. --- diff --git a/CREDITS b/CREDITS index 0d119407..e38eaf4c 100644 --- a/CREDITS +++ b/CREDITS @@ -22,6 +22,7 @@ Additional people who have contributed patches: Arkadiusz Miskiewicz Armando L. Caro Jr. Arnaldo Carvalho de Melo + Ben Byer Atsushi Onoe Ben Smithurst Brent L. Bates diff --git a/interface.h b/interface.h index 73a49700..8f347b07 100644 --- a/interface.h +++ b/interface.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.269 2006-03-03 22:31:16 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.270 2006-05-05 23:13:00 guy Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -346,6 +346,7 @@ extern netdissect_options *gndo; #define eflag gndo->ndo_eflag #define fflag gndo->ndo_fflag +#define Kflag gndo->ndo_Kflag #define nflag gndo->ndo_nflag #define Nflag gndo->ndo_Nflag #define Oflag gndo->ndo_Oflag diff --git a/netdissect.h b/netdissect.h index 1f1c1bbe..cfe086e3 100644 --- a/netdissect.h +++ b/netdissect.h @@ -21,7 +21,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.21 2006-02-08 01:38:17 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.22 2006-05-05 23:13:00 guy Exp $ (LBL) */ #ifndef netdissect_h @@ -85,6 +85,7 @@ struct netdissect_options { int ndo_aflag; /* translate network and broadcast addresses */ int ndo_eflag; /* print ethernet header */ int ndo_fflag; /* don't translate "foreign" IP address */ + int ndo_Kflag; /* don't check TCP checksums */ int ndo_nflag; /* leave addresses as numbers */ int ndo_Nflag; /* remove domains from printed host names */ int ndo_qflag; /* quick (shorter) output */ diff --git a/print-tcp.c b/print-tcp.c index b5d70c82..8a3e293a 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.124 2005-11-29 09:07:47 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.125 2006-05-05 23:13:00 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -420,7 +420,7 @@ tcp_print(register const u_char *bp, register u_int length, return; } - if (IP_V(ip) == 4 && vflag && !fragmented) { + if (IP_V(ip) == 4 && vflag && !Kflag && !fragmented) { u_int16_t sum, tcp_sum; if (TTEST2(tp->th_sport, length)) { sum = tcp_cksum(ip, tp, length); @@ -434,7 +434,7 @@ tcp_print(register const u_char *bp, register u_int length, } } #ifdef INET6 - if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) { + if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) { u_int16_t sum,tcp_sum; if (TTEST2(tp->th_sport, length)) { sum = tcp6_cksum(ip6, tp, length); diff --git a/tcpdump.1 b/tcpdump.1 index 0697588f..7077cf3b 100644 --- a/tcpdump.1 +++ b/tcpdump.1 @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.181 2006-03-23 17:33:02 hannes Exp $ (LBL) +.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.182 2006-05-05 23:13:00 guy Exp $ (LBL) .\" .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $ .\" @@ -29,7 +29,7 @@ tcpdump \- dump traffic on a network .na .B tcpdump [ -.B \-AdDeflLnNOpqRStuUvxX +.B \-AdDefKlLnNOpqRStuUvxX ] [ .B \-c .I count @@ -396,6 +396,11 @@ used as the .I interface argument. .TP +.B \-K +Don't attempt to verify TCP checksums. This is useful for interfaces +that perform the TCP checksum calculation in hardware; otherwise, +all outgoing TCP checksums will be flagged as bad. +.TP .B \-l Make stdout line buffered. Useful if you want to see the data diff --git a/tcpdump.c b/tcpdump.c index 918121a8..7e1f1299 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -30,7 +30,7 @@ static const char copyright[] _U_ = "@(#) 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[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.268 2006-03-23 17:33:01 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.269 2006-05-05 23:13:01 guy Exp $ (LBL)"; #endif /* @@ -523,7 +523,7 @@ main(int argc, char **argv) opterr = 0; while ( - (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) + (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) switch (op) { case 'a': @@ -668,12 +668,8 @@ main(int argc, char **argv) #endif /* WIN32 */ break; - case 'n': - ++nflag; - break; - - case 'N': - ++Nflag; + case 'K': + ++Kflag; break; case 'm': @@ -697,6 +693,14 @@ main(int argc, char **argv) tcpmd5secret = optarg; break; + case 'n': + ++nflag; + break; + + case 'N': + ++Nflag; + break; + case 'O': Oflag = 0; break; @@ -1567,7 +1571,7 @@ usage(void) #endif /* WIN32 */ #endif /* HAVE_PCAP_LIB_VERSION */ (void)fprintf(stderr, -"Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name); +"Usage: %s [-aAd" D_FLAG "efKlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name); (void)fprintf(stderr, "\t\t[ -E algo:secret ] [ -F file ] [ -G seconds ] [ -i interface ]\n"); (void)fprintf(stderr,