Commit Graph

94 Commits

Author SHA1 Message Date
Guy Harris
57bfcb4ebe Add a routine to do the "checksum with pseudo-header" stuff for IPv4.
Clean up some other stuff while we're at it.
2011-06-17 01:09:16 -07:00
Guy Harris
d18bb2331d Use nextproto6_cksum() for XXX-over-IPv6 checksums.
Get rid of duplicated checksums with IPv6 pseudo-headers.
2011-06-17 00:51:47 -07:00
Guy Harris
730d36df2c Clean up the checksum checking.
Check -v and -K, and the fragmented flag, up front; then check the IP
version etc..  Don't check for IPv6 if we already know it's IPv4.  Fetch
the checksum field only once.
2011-06-16 21:50:26 -07:00
Hannes Gredler
917f5f341f add support for the RPKI/Router Protocol as per draft-ietf-sidr-rpki-rtr-12 2011-06-16 17:17:20 +02:00
Guy Harris
94a4b46080 Go with Wireshark's Internet checksum routine.
The Wireshark routine is based on the BSD in-kernel portable checksum
routine (thus BSD-licensed); it takes a vector of pointers and lengths
and checksums the concatenation of the buffers in question (just as the
BSD in-kernel routine checksums a chain of mbufs).

This simplifies the "with a pseudo-header" checksums; hopefully it'll
fix up the problems being seen on some big-endian platforms, which might
be due to hand-calculating some or all of the checksum and doing so
incorrectly.  It also gets rid of some code that might be dereferencing
unaligned pointers.
2011-06-13 14:08:51 -07:00
Guy Harris
7e44242ea8 Fix a comment, and note a potential issue. 2011-03-01 16:41:39 -08:00
Guy Harris
64c6e944c6 Don't clear stuff we'll be overwriting in its entirety.
We only need to clear out the tha structure if we support IPv6, so that
the addresses are IPv6 addresses, but we only have IPv4 addresses, so
that the rest of the address bytes need to be set somehow.

Also, explain what we're doing, so people don't ask why we're not
zeroing it if we don't support IPv6.
2011-03-01 16:38:24 -08:00
Guy Harris
e8b5237589 Don't directly fetch multi-byte integers from packets.
Use the EXTRACT_ macros to extract multi-byte integral values from
packets, rather than just dereferencing pointers into the packet; there
is no guarantee that the packet data will be aligned on the right
boundary, and there is no guarantee that, if they're not, a direct
access will work correctly.
2010-02-21 00:27:00 -08:00
Hannes Gredler
a0275861d3 modularize ip6 nextlayer checksum generation and
change tcp6 and pim6 to use it.
2009-10-12 10:16:58 +02:00
Guy Harris
8d0935ca9b Don't use "uint"; it's not guaranteed to be defined.
Don't define a variable in the middle of a block; not all C compilers
support that.
2009-09-21 10:02:05 -07:00
Guy Harris
832d2c7338 From Fang Wang:
RFC 5482 specifies a new TCP option -- the TCP User Timeout
	Option (UTO) -- that allows one end of a TCP connection to
	advertise its current user timeout value.  The Kind of UTO
	option is 28 and the Length is 4.  The tcpdump currently does
	not recognize UTO option.
2009-08-18 15:02:37 -07:00
Guy Harris
1859a4aac8 From Ilpo Järvinen: fix printing of TCP sequence number for data segments
so it's printed for segments containing data regardless of whether -v was
used or not.
2009-03-01 13:57:53 -08:00
Guy Harris
e195fc87a8 Make sure the packet isn't cut short before verifying the MD5 signature.
Indicate why we can't verify the MD5 signature.
2009-02-26 01:45:39 -08:00
mcr
3157c6dc25 pulled up some changes from the 4.0 release branch 2008-11-09 23:35:03 +00:00
hannes
3d3c70fbe9 add infrastructure for verifiying the HMAC-MD5 digest in routing protocols.
The shared secret is passed using the already existing -M option which is
used for TCP-MD5 checking.

add initial supoort for RSVP Integrity object verification.
2008-08-16 11:36:20 +00:00
guy
ed1906f1fe Add more bounds checks to the NFS dissector - check before references to
items in the RPC header.

When dissecting NFS over TCP, fetch the fragment header length, use it
to limit the dissection of the request or reply (in case there's more
than one request or reply in the packet), and do the same
direction-plus-port checks that are done for NFS over UDP.  Also
eliminate the bounds check for the RPC header in the TCP dissector code,
and do checks for the fields it looks at (other checks are done by the
NFS dissector).
2007-12-22 03:08:04 +00:00
guy
a11ed8914e SMB-over-TCP (port 445) support. 2007-12-09 00:30:47 +00:00
guy
54702e0cac Fix typo in "incorrect checksum" message for IPv6. 2007-11-09 00:34:25 +00:00
mcr
05b7f224d8 Patches from NetBSD tree. 2007-08-29 02:31:44 +00:00
guy
75335912eb From Alexander Dupuy: if the separator character is null, it means "no
separator needed", so don't print it.
2007-04-03 20:02:56 +00:00
hannes
674d23116f From Kevin Steves <stevesk@pobox.com>:
remove extra comma after checksum verification print.
2007-01-29 19:19:51 +00:00
hannes
9427d40c14 change the TCP printer to print new-style order:
- seperate fields by comma
  - use [] for flags and options sets
  - print a trailing length field

make use of tok2str() and bitttok2str()
move port definitions into tcp.h
2007-01-29 09:59:42 +00:00
hannes
3472526186 from Gerrit Renker <gerrit@erg.abdn.ac.uk>:
remove duplicate code for v6 checksum calculation
unify the output for broken checksums
2006-11-02 08:56:16 +00:00
guy
90c94a8265 From Ben Byer <bushing@sourceforge.net>: add a "-K" flag to suppress the
checking of TCP checksums.

Sort the argument processing code alphabetically.
2006-05-05 23:13:00 +00:00
hannes
95f66c8c62 add basic support for keyed authentication TCP option 2005-11-29 09:07:47 +00:00
guy
463199df7a From Noritoshi Demizu: memcmp() returns a value = 0 if the two memory
regions are =, < 0 if the first memory region is < the second, or > 0 if
the first memory region is > the second, so to check whether two memory
regions are equal, check whether memcmp()'s return value is == 0.
2005-10-16 06:05:03 +00:00
guy
c0fcc3c0d2 Squelch a signed vs. unsigned warning. 2005-04-21 06:35:52 +00:00
guy
9f529d7c77 From Noritoshi Demizu <demizu@users.sourceforge.net>: don't print "sack"
twice.
2005-04-18 00:22:39 +00:00
mcr
6abf40c3e8 tweaked copyright. 2005-04-06 18:53:56 +00:00
guy
af0a039080 Have our own headers to declare the format of ONC (Sun) RPC messages on
the wire; the definitions in many systems use u_long, which is 64 bits
long on many platforms - that's OK for in-memory structures, but it
doesn't match what's on the wire.  Use headers based on the Sun ones,
but use u_int32_t for fields, and otherwise make the structures match
what's on the wire, and change some names to avoid collision with
<rpc/rpc.h>, which print-sunrpc.c includes to declare "getrpcbynumber()"
and the structure it returns.

Record whether "getrpcbynumber()" is found, and use it only if it's
found, rather than basing the decisison on whether we're building for
Win32 or not.
2004-12-27 00:41:29 +00:00
guy
7c5a9ceee5 In "tcp_verify_signature()", don't assume we can do IPv6, and
distinguish between "signature invalid" and "we can't check the
signature".  Have its caller show the raw signature if we can't check
it.
2004-09-15 01:21:17 +00:00
guy
00c74e34be "sizeof()" could be "unsigned long" or "unsigned int"; cast it to
"unsigned long" and print it with "%lu", so it works in either case,
regardless of whether "long" is the same size as "int" or not.
2004-07-15 00:13:01 +00:00
guy
9d1b396853 Check for a TCP header length that's too short, report more information
if it's too long, and check for NFS only if the header length is OK.
2004-07-08 10:25:08 +00:00
guy
f5ad5cff18 From Steiner Haug: handle LDP-over-TCP, and do more complete LDP
decoding.
2004-05-27 21:20:49 +00:00
itojun
5758027110 TCP MD5 signature for IPv6. XXX not really tested yet 2004-04-26 06:17:31 +00:00
hannes
f14a23ad5a display cosmetics: be more verbose on IP6 TCP checksum errors, align IP4,IP6 checksum printing 2004-04-24 17:19:00 +00:00
mcr
1cca963b1d get rid of warning in print-tcp.c about const violations.
the signature checker was writing over a structure that
	should not have been modified - change the code to make a copy
	instead.
2004-04-05 00:12:54 +00:00
guy
8234cdad9b From Bruce M. Simpson: add a "-M" flag to specify a shared secret for
TCP-MD5 (RFC 2385) digest verification if we have libcrypto.
2004-03-23 07:15:36 +00:00
guy
d6cf0925b2 Cut off "snapend" at the length of the IPv4 or IPv6 payload, so we don't
run past the end of that payload.

Check that the IPv4 total length isn't less than the header length.

Use "%u", not "%d", to print unsigned values.

Properly update "len" in the header-processing loop for IPv6.

Doing so means we can trust the length passed to the TCP and UDP
dissectors when constructing the IPv6 pseudo-header; do so (but fix the
length we pass to the UDP-over-IPv6 checksum routine).

That length is unsigned; make the corresponding arguments to the TCP and
UDP checksum routines unsigned.
2003-11-19 00:17:32 +00:00
guy
bbc1cfa669 Have the configure script arrange that the Makefile define _U_
appropriately, and that GNUmakefile and the MSVC++ project file define
it apppriately, as we do with libpcap, rather than defining it in
"interface.h".

Undo the rcsid-shuffling and addition of extra #includes, as we no
longer need to arrange that "interface.h" be included before using _U_
in an RCS ID or copyright.
2003-11-16 09:36:07 +00:00
guy
3824a6c041 From Neil Spring:
use "_U_" in the definitions of "rcsid[]", to eliminate
	complaints about those variables being unused;

	move the definitions after the include of "interface.h", or add
	an include of "interface.h", so that "_U_" is defined.

Include "config.h" before including "tcpdump-stdinc.h" in
"missing/datalinks.c".
2003-11-15 00:39:12 +00:00
guy
f4d64fe38b In mDNS, report IN-class records with the "cache flush" bit set as such,
rather than as "Class 32769".
2003-11-05 06:02:58 +00:00
itojun
e2826164d4 unsigned/signed mixup 2003-10-28 03:16:35 +00:00
guy
c90e936060 Add a new "ipproto.h" header file, with definitions of IP protocol type
values.  Use that rather than private definitions in various files.

Add "gmpls.h" to the list of files in FILES, and add it and "ipfc.h" to
the list of files in INSTALL.
2003-06-07 11:57:51 +00:00
guy
fcc82f451d The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the
structures are being declared.

Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun
C to generate code that's safe with unaligned accesses, as
"__attribute__" is defined as a do-nothing macro with compilers that
don't support it.

Therefore, we get rid of that tag on the structures to which it was
added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch
16-bit and 32-bit big-endian quantities from packets.  We also fix some
other references to multi-byte quantities to get rid of code that tries
to do unaligned loads on platforms that don't support them.

We also throw in a hack that makes those macros use
"__attribute__((packed))" on structures containing only one 16-bit or
32-bit integer to get the compiler to generate unaligned-safe code
rather than doing it by hand.  (GCC on SPARC produces the same code that
doing it by hand does; I don't know if GCC on any other big-endian
strict-alignment processor generates better code for that case.  On
little-endian processors, as "ntohs()" and "ntohl()" might be functions,
that might actually produce worse code.)

Fix some places to use "%u" rather than "%d" to print unsigned
quantities.
2002-12-11 07:13:49 +00:00
guy
c422d3ab0f Get rid of the "-Wno-unused" flag, and fix up most of the
unused-parameter problems reported by GCC.  Add an _U_ tag to label
parameters as unused if the function is called through a pointer (so
that you can't change its signature by removing parameters) or if there
are unused parameters only because the function isn't complete.

Add some additional bounds checks the necessity for which was revealed
while cleaning up unused-parameter problems.

Make some routines static.

"lcp_print()", defined in "print-lcp.c", isn't called anywhere -
"print-ppp.c" has the code to dissect LCP.  Get rid of "print-lcp.c".
2002-09-05 21:25:34 +00:00
guy
edb0e92cdc Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:

	addrtoname.c, configure.in: Linux needs netinet/ether.h for
	ether_ntohost

	print-*.c: change char *foo = "bar" to const char *foo = "bar"
	to appease -Wwrite-strings; should affect no run-time behavior.

	print-*.c: make some variables unsigned.

	print-bgp.c: plen ('prefix len') is unsigned, no reason to
	validate by comparing to zero.

	print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
	instead of inet_ntoa.

	print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
	be false, so check for (u_int)-1, which represents failure,
	explicitly.

	print-isakmp.c: complete initialization of attrmap objects.

	print-lwres.c: "if(x); print foo;" seemed much more likely to be
	intended to be "if(x) { print foo; }".

	print-smb.c: complete initialization of some structures.

In addition, add some fixes for the signed vs. unsigned comparison
warnings:

	extract.h: cast the result of the byte-extraction-and-combining,
	as, at least for the 16-bit version, C's integral promotions
	will turn "u_int16_t" into "int" if there are other "int"s
	nearby.

	print-*.c: make some more variables unsigned, or add casts to an
	unsigned type of signed values known not to be negative, or add
	casts to "int" of unsigned values known to fit in an "int", and
	make other changes needed to handle the aforementioned variables
	now being unsigned.

	print-isakmp.c: clean up the handling of error/status indicators
	in notify messages.

	print-ppp.c: get rid of a check that an unsigned quantity is >=
	0.

	print-radius.c: clean up some of the bounds checking.

	print-smb.c: extract the word count into a "u_int" to avoid the
	aforementioned problems with C's integral promotions.

	print-snmp.c: change a check that an unsigned variable is >= 0
	to a check that it's != 0.

Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 00:00:07 +00:00
hannes
973a00103a more consistent use of the length: indicator; 2002-08-20 00:17:23 +00:00
hannes
239977c8d2 tell the world that its LDP, rather than port 646; 2002-08-20 00:01:38 +00:00
itojun
5a5ccbf6d3 dissect traffic on port 5353 as multicast DNS. vlubet@apple.com 2002-08-16 22:40:33 +00:00