Commit Graph

84 Commits

Author SHA1 Message Date
mcr
8c59e1bd93 use new ip_print_demux() routine in ISAKMP UDP-ESP encap
printer.
2005-04-07 00:28:17 +00:00
mcr
4189fb7df6 refactored ip_print() so that chained header parser (ESP/AH) can
more easily call the inner parts.
2005-04-06 21:32:38 +00:00
hannes
c8623960f0 from Rick Jones <rick.jones2@hp.com>:
suppress the IP printers "bad-len" error message in case
  TSO (TCP segment offload) is enabled
2005-01-21 08:02:06 +00:00
hannes
b7370aa82b from nicolas ferrero <toorop@babylo.net>:
- fix EGP boundary testing
2005-01-12 11:19:08 +00:00
guy
846ce366e9 Get rid of an unused variable. 2004-12-27 22:30:54 +00:00
hannes
5e6014ea38 clean up the ip options printer:
- make more use of tok2str()
  - always display the option length
  - move option defines into ip.h
2004-09-27 21:13:09 +00:00
guy
99711cd61e Use %u to print unsigned quantities.
Check, and use, the supplied packet length in the PPPoE dissector.  (It
reflects the actual packet length; snapend reflects the captured packet
length.)

As we're now doing bounds checks with TCHECK, the loop over the tagged
fields doesn't have to check against snapend.
2004-08-27 03:57:40 +00:00
hannes
89e2e0c7be print the packet length for ESP packets 2004-07-16 14:05:59 +00:00
guy
6c02156d08 From Eddie Kohler <xexd@sourceforge.net>: In "ip_finddst()":
quit as soon as we see IPOPT_EOL;

	*don't* quit as soon as we see IPOPT_NOP, just advance to the
	next option, if any;

	implement "quit" as "return the destination address from the IP
	header rather than as "return 0".

Also, return the IP header destination address if we see a
source-routing option with a too-short length.
2004-06-25 01:20:08 +00:00
hannes
b41f0d1ca3 supress printing of the L3 protoname if eflag is set 2004-05-01 10:15:33 +00:00
hannes
8b3d754999 -add baseline support for dissecting EIGRP-IP and EIGRP-IPX messages
-FIXME: complete TLV dissection (today we just show the TLV name and
        hexdump the TLV value)
2004-04-30 22:22:04 +00:00
guy
f06770b12d Some BSDs define IPPROTO_IGRP as 88 and don't define IPPROTO_EIGRP, so
we also define it as 88, so we can't have

	case IPPROTO_IGRP:
	case IPPROTO_EIGRP:

in a switch statement.

The current IANA protocol number assignments page lists 9 as "any
private interior gateway (used by Cisco for their IGRP)" and 88 as
"EIGRP" from Cisco, so we define IPPROTO_PIGP as 9 (which matches what
those BSDs do) and IPPROTO_EIGRP as 88 (so we don't bother with
IPPROTO_IGRP at all), and do

	case IPPROTO_PIGP:
	case IPPROTO_EIGRP:

It's not clear that we should handle both with the same print routine,
however - Cisco IGRP and Cisco EIGRP don't appear to have the same
packet format.
2004-04-28 22:02:23 +00:00
hannes
49dabbe043 do host-OS indep. ipproto name resolution 2004-04-26 18:27:57 +00:00
mcr
6bb10ee1e5 print-esp has been "NDO"-ized.
replace error() and warning() with ndo-ized version.
	moved snaplen/snapend to ndo structure.
2004-04-05 00:15:50 +00:00
guy
64313f0136 Do the length checks only for IP options with a length field. 2004-03-24 09:00:08 +00:00
guy
8b9bab2bd1 Add bounds and option length checking.
Use "%u", not "%d", for unsigned values.
2004-03-24 01:26:56 +00:00
hannes
6e624bf87a print the proto-id in verbose mode 2004-03-17 13:24:09 +00:00
guy
988cd2bb0e Have various routines for printing non-final headers for IPv4/IPv6
return -1 if they run out of data.

Have the IPv4 and IPv6 dissectors check for non-positive return values
from those routines and quit if they see one.
2003-11-19 00:36:06 +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
fb7621f6ae Fix the separator for "bad cksum". 2003-07-08 01:14:44 +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
hannes
56e21a1064 warn if v6 was found using ip_print() 2003-05-25 16:40:48 +00:00
hannes
0bae66a939 bugfix: print the real version number instead of always 4 if version != 4 2003-05-21 08:39:57 +00:00
hannes
0bda4e776b don't attempt checksumming in ICMP if the packet is a fragment 2003-05-15 16:58:03 +00:00
hannes
63c668cbeb minor display cosmetics:
print 3-digit ttl field in print-ip.c
  unbracketize the LCP id in print-ppp.c
2003-05-15 15:25:18 +00:00
hannes
5cfe70f498 print IP keyword plus optional version number 2003-05-08 14:26:54 +00:00
hannes
4a6df9a1d8 per George Bakos' suggestion:
backout some of the v1.118 changes
  now we hide frag processing under the
  vflag option where we print: id, offset.
    plus the (+,DF,res) flags using bittok2string

    also decode the rfc3514 "evil" bit to keep the security
    guys happy;
2003-04-24 12:51:35 +00:00
guy
65bb7952a1 Get rid of the added "IP " - IPv6 doesn't do it, and previous versions
of tcpdump didn't do it.
2003-02-05 02:30:39 +00:00
guy
788ad8429f Fix up long vs. int issues. 2003-01-03 08:37:22 +00:00
hannes
1e876008df - move IP option processing from the trail up to the header
- suppress IP id == 0
2002-12-28 17:59:09 +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
itojun
9fb628d4cd remove buffer move in LBL_ALIGN case, which does more bad things than good things.
(if there's unaligned access, they must be converted to EXTRACT_xx)
2002-10-18 04:40:02 +00:00
hannes
a828d7723c support for RSVP 2002-10-04 08:30:18 +00:00
hannes
f60a1bd8cb hide multiline output using vflag plus enhanced, ES-IS decoder 2002-10-03 16:00:32 +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
risso
3d932490b8 Added support for Win32, based on WinPcap. 2002-08-01 08:52:55 +00:00
fenner
a71d112b5c Calculate UDP/TCP pseudo-checksum properly in the presence of
source-route options.
2002-07-28 04:14:21 +00:00
guy
5ada73a5d2 Add a "in_cksum_shouldbe()" to compute, given an Internet checksum field
in a packet header and the computed checksum for the data that the
checksum covers, what the checksum field's value should have been.

Use that routine in the IP printer.
2002-07-21 20:48:26 +00:00
guy
aa266b3ec5 Set "off" before using it. 2002-07-20 23:37:40 +00:00
hannes
2bb13d73f1 the last commit contained a bogus commit message;
purpose of 1.105 was to print the ip header values (len, ttl, tos)
at the beginning of the line (where it belongs to) and not at the end;
it is only displayed using the -v(erbose) options;
the BGP output (where i am working now on) gets much more cleaner now;
2002-07-14 19:46:51 +00:00
hannes
ed37a22318 split BGP output to multiple lines;
added support for Originator_ID, Cluster List Attributes;
reworked BGP Open Message Decoder do decode optional Capabilities;
fixed the NEXTHOP decoder of MP_REACH and MP_UNREACH to honor
 NH length based on AFI,SAFI
2002-07-14 14:14:50 +00:00
itojun
111ff8a61d whitespace cleanup 2002-06-11 17:08:37 +00:00
guy
591b988f14 Fix a typo. 2002-05-29 09:47:04 +00:00
mcr
68ed33e995 when reporting a bad checksum, indicate what it should have been. 2002-05-29 03:09:48 +00:00
itojun
93882321a8 remove comment which may not be correct; i've experienced unaligned header
on bpf taps with netbsd 1.5Y.
2001-11-16 02:17:36 +00:00
guy
740e55c20b From Crist J. Clark <cjclark@alum.mit.edu>: print the IP protocol field
for fragments other than the first fragment.

Also, for packets whose IP protocols we don't handle ourselves, print
the protocol name if "getprotobynumber()" finds it, otherwise print the
protocol number.
2001-10-27 07:42:45 +00:00
fenner
c672f00276 Eliminate some unused parameters.
Use const more.
Use EXTRACT_* macros more.
Use TCHECK* more.
Use tok2str() to replace some home-grown workalikes.
smb:
 - Get rid of private types, use tcpdump-defined types
 - Rename fdata and fdata1 to smb_fdata and smb_fdata1 to avoid conflict
   with IRIX library function.
2001-09-17 21:57:50 +00:00