Commit Graph

132 Commits

Author SHA1 Message Date
Guy Harris
1cde6435df Netdissectify the to-name resolution routines.
Have them take a netdissect_options * argument, and get the "no name
resolution" flag from it.

Move the declaration of dnaddr_string to addrtoname.h, along with the
other XXX-to-string routines.
2014-04-04 00:43:46 -07:00
Denis Ovsienko
fc6f112b40 NDOize LLDP, PPP and RSVP decoders 2014-04-02 18:22:28 +04:00
Denis Ovsienko
2b753f8058 NDOize DECnet, OSPF and TCP decoders 2014-04-02 14:24:56 +04:00
Denis Ovsienko
c91ffeae22 NDOize OSPFv3 decoder 2014-03-27 10:21:14 +04:00
Denis Ovsienko
b6303af682 NDOize AODV, IPv4 and SCTP decoders 2014-03-26 15:49:27 +04:00
Denis Ovsienko
d6af516cbc finalize some previous NDO conversions
Eliminate a number of fputs(), putchar() and fflush() uses. Justify
preprocessor directives. Don't typecast ND_PRINT() to void and fix some
indentation.
2014-03-26 15:49:27 +04:00
Denis Ovsienko
59690cf6b7 NDOize BOOTP, DHCPv6, DNS, PIM and sFlow decoders
Also add/remove tabs in a few involved functions to justify indentation.
2014-03-25 23:27:23 +04:00
Denis Ovsienko
17934c433e NDOize 7 bigger decoders
This change converts IGMP, IPv6 mobility options, LDP, Lightweight
Access Point, PGM, PPTP and RIP decoders.
2014-03-19 14:16:56 +04:00
Denis Ovsienko
d57e945e5e NDOize EIGRP, ICMP, L2TP, STP and UDP decoders 2014-03-15 23:25:06 +04:00
Denis Ovsienko
1fe6e66ece make use of NETDISSECT_REWORKED
Update the already converted decoders to define the macro and to include
interface.h instead of netdissect.h. Fix incurred compile errors.
2014-03-15 14:19:49 +04:00
Denis Ovsienko
85a2dd977c NDOize DCCP, Linux socket and RPKI-Router decoders 2014-03-14 20:57:32 +04:00
Denis Ovsienko
d29f3dab95 NDOize 8 more small decoders
This change converts ZeroMQ, IPX, MPLS, IPv6 options, PPPoE, RIPng,
PFLOG and Sun RPC decoders.
2014-03-13 17:21:55 +04:00
Denis Ovsienko
ce1fc8263d NDOize more small decoders
This change converts decoders for: DLT_RAW, IPv6 routing header, USB,
Symantec firewall and cHDLC.
2014-03-12 20:02:32 +04:00
Denis Ovsienko
83bec9d56c refine some past NDO conversions
Don't include unneeded headers and replace a few remaining printf's.
2014-03-12 18:11:23 +04:00
Denis Ovsienko
cf90fd1a84 NDOize ARCNET, BFD and GRE decoders 2014-03-11 17:36:46 +04:00
Denis Ovsienko
374aad6c0e NDOize 5 more decoders
Update Apple's IP over IEEE1394, Bluetooth, CALM/FAST, IPv6 fragments
and LAN emulation decoders. Remove some stray passages while at it.
2014-03-07 19:51:31 +04:00
Denis Ovsienko
207f31f2bd NDOize CIP, IPComp and IPFC decoders
Also remove some unneeded includes while at it.
2014-02-28 18:42:47 +04:00
Denis Ovsienko
39d15607ca NDOize AH, BEEP and DTP decoders
Also remove some unnecessary passages.
2014-02-27 16:01:23 +04:00
Francois-Xavier Le Bail
3625533c9a fix partial checksum errors in DCCP decoder, IPv6 case 2014-02-16 18:29:37 +01:00
Guy Harris
941a2c08f1 Only do the unaligned_mem{cpy,cmp} hack if necessary.
If the processor does unaligned accesses, it's not necessary.
2014-01-17 17:51:04 -08:00
Guy Harris
c947c9dd69 More possibly-unaligned memcpy()s and assignments - use unaligned_memcpy(). 2014-01-17 17:24:23 -08:00
Denis Ovsienko
fe3253b9b8 remove tcpdump's own CVS keywords
Remove lots of $Header's and a few $Id's that all belong to the former
CVS repository of tcpdump itself. These keywords have been frozen since
the migration to git in late 2008.
2014-01-03 00:59:08 +04:00
Michael Richardson
ac910c086e ndo-ize print-ascii: hex_print_with_offset() 2014-01-01 21:31:18 -05:00
fxlb
7be1e976c9 print-ip6: add a test on the header version value 2013-11-12 11:01:20 +01: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
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
a91d20cc84 Convert the IPv6 printer to use netdissect. 2010-11-07 12:50:16 -08:00
Guy Harris
d8b1b0fa48 Include "netdissect.h" in print-ip6.c, and move icmp6_print's
declaration out from inside #if 0/#endif, to get it declared in
print-ip6.c.
2009-11-26 15:07:47 -08:00
Michael Richardson
27e7cefadd netdisect converted icmp6_print() 2009-11-14 21:36:05 -05: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
hannes
b348069d2b in tcpdump a length field has the semantics of a 'total length field'
i.e. including the header - the IP6 payload length field differs
from that ...
highlight the difference by printing 'payload length' rather than 'length'
2007-09-21 07:05:33 +00:00
guy
2b9311703d From pfhunt on SourceForge:
When a packet contains an IPv6 options header followed by an unknown IPv6
protocol payload, tcpdump displays the proto ID for the known option
header, not for the unknown payload.

For example, this is the output for an IPv6 packet containing a destination
options header, followed by a payload of (unknown) protocol 138:

# tcpdump -s 128 -i eth1
tcpdump: WARNING: addresses not searched
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 128 bytes
11:44:40.862572 I IP6 2007::10:5:2:163 > 2007::10:5:2:164: DSTOPT ip-proto-60 16

The ip-proto-60 refers to the destination option header (DSTOPT), rather
than displaying the unknown option 138, which I think would be more
informative.

The attached patch fixes this problem. With the patch applied, the output
for the packet is:

# tcpdump -s 128 -i eth1
tcpdump: WARNING: addresses not searched
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 128 bytes
11:48:26.160462 I IP6 2007::10:5:2:163 > 2007::10:5:2:164: DSTOPT ip-proto-138 16
2007-09-14 00:38:41 +00:00
guy
1c902dcdf3 From Ian McDonald and Arnaldo Carvalho de Melo: DCCP support. 2005-09-20 06:01:20 +00:00
hannes
75d10a57f7 add GRE and RSVP to the supported IPv6 protos 2005-07-03 20:33:06 +00:00
hannes
a5370b71fe from Andy Heffernan <ahh@juniper.net>:
add PGM upport as per rfc3208
2005-05-20 21:02:29 +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
18c020c000 -display cosmetics: make the output more conistent:
- consistent use of length field (not payload-len)
 - no message type number given in PIM/OSPF printers

as those changes affect only verbose mode and/or
routing protocols we hope not to break existing scripts;
2004-09-29 16:49:31 +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
hannes
b41f0d1ca3 supress printing of the L3 protoname if eflag is set 2004-05-01 10:15:33 +00:00
hannes
30a1d3fc14 print header related information earlier - in order to not break multi-line outputs 2004-04-26 17:59:37 +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
4bf6f976ab 135 appears to be the current IP protocol number for mobility headers;
support it, as well as 62 (which presumably was one that was used
before, even though it was already assigned to some protocol named
CFTP).
2003-11-24 20:30:51 +00:00
guy
d511b994b9 Use "len", not "payload_len", as we step through the packet; use
"payload_len" to report the raw value from the header.
2003-11-19 06:31:28 +00:00
guy
914cf46872 Keep the remaining payload length in a separate variable from the total
payload length, so we can report the latter at the end of dissection.
2003-11-19 06:17:10 +00:00
guy
d3d2f39461 "icmp6_rrenum_print()" doesn't use its "icmp6len" argument (and, as that
just reflects the payload length, the snapshot length has been trimmed
to correspond to it, so it doesn't need to check it merely to avoid
running past the end of the IPv6 payload); get rid of it.

Pass "icmp6_print()" the IPv6 payload length (i.e., the length of the
ICMPv6 packet), rather than having it compre the length itself.

Make the length argument to "icmp6_cksum()" unsigned, to match the value
passed to it.

Fix the lengths passed to "sctp_print()", "tcp_print()", and
"udp_print()" (we update "len" in the header-processing loop to
correspond to the remaining payload, so we just pass it to those
routines).
2003-11-19 01:27:54 +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
itojun
53b421eb0f style 2003-10-28 03:14:16 +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
c4aa80257a The SCTP dissector is only called for SCTP packets, so there's no reason
for it to check the protocol number in the IP header.

Have the IPv6 dissector call the SCTP dissector for SCTP packets.

Get rid of the definition of IPPROTO_SCTP in sctpConstants.h, so we
don't have problems if <netinet/in.h> also defines it.
2003-06-03 23:49:22 +00:00
itojun
ba8e54bc85 verify/warn icmpv6 checksum. from jinmei@kame 2003-05-02 08:13:54 +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
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
3913fd0f19 Make "mobility_opt_print()" static, as it's not used outside
"print-mobility.c".

Make sure "mobility_print()" returns a valid value even if there's no
data available in the mobility header - but note that the value isn't
used.  (Is there ever a need to use the value?)
2002-08-02 04:10:14 +00:00
risso
3d932490b8 Added support for Win32, based on WinPcap. 2002-08-01 08:52:55 +00:00
guy
86cfeae8ab From Kazushi Sugyo <sugyo@pb.jp.nec.com>:
Here is a patch for draft-ietf-mobileip-ipv6-17.
	- print-mobility.c: Mobility header(MIPv6 defines a new IPv6 protocol)
	  printing
	- added Routing header type 2
	- ICMPv6 Home Agent Address Discovery and Mobile Prefix Sol., Adv.
	  message update
2002-06-27 08:21:39 +00:00
itojun
111ff8a61d whitespace cleanup 2002-06-11 17:08:37 +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
itojun
5d2f5336f3 adjust bp when packet is moved by LBL_ALIGN 2001-11-15 07:51:09 +00:00
itojun
fd7fd3af66 die if malloc fails in #ifdef LBL_ALIGN.
XXX LBL_ALIGN path is not really torture-tested, and at this moment it
can affect field printing badly (like TCP).
2001-11-15 07:43:31 +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
fenner
31a13fa966 Don't try decrypting a fragmented ESP packet; the IP proto number and
padding info are in the last fragment but the header is in the first
 fragment.
Pass padding length back to IP to allow trimming the padding.
Update in_cksum() prototype to allow using it for checksums including
 the pseudo-header.
2001-08-20 17:52:38 +00:00
itojun
8f002a3ccc do not try to compute tcp/udp checksum for fragmented datagram.
from: jinmei@kame.net
2000-11-17 19:08:14 +00:00
itojun
1395abcd2b repair IPv6 ESP decoder 2000-11-09 07:43:50 +00:00
itojun
ce132b307b put stripped-down version of ip6.h and icmp6.h into tcpdump tree.
ip6.h is almost normal RFC2292 header.
icmp6.h has couple of extensions (not covered by RFC2292),
like MLD, ICMPv6 nodeinfo, and router renumber.

XXX how to synchronize with future kame changes?
2000-10-07 05:53:09 +00:00
itojun
febfc92d3f include string.h for memcpy/memset.
on some architecutrees, sizeof(void *) > sizeof(int).   don't try to cast
pointer to int to check alignment issues.
2000-10-03 04:19:07 +00:00
guy
cf53dc05f1 Get rid of includes of <netinet/in_systm.h>, and replace "n_short",
"n_long", and "n_time", defined in that file, with other types.
2000-09-29 04:58:33 +00:00
guy
536f512583 Add an "ip.h" header, to declare the IP stuff needed by dissectors, and
have dissectors include them rather than <netinet/ip.h> or
<netinet/ip_var.h>, if they actually need that stuff.

Put the declarations of the ICMP stuff directly into "print-icmp.c".

Remove all unnecessary includes of <netinet/ip*.h> files.

Copy the byte-order stuff from "nameser.h" into "tcp.h".
2000-09-23 08:54:24 +00:00
guy
7b50febe28 Add "tcp.h" and "udp.h" headers, to declare the TCP and UDP stuff needed
by dissectors, and have dissectors include them rather than
<netinet/udp.h>, <netinet/udp_var.h>, or <netinet/tcp.h>, if they
actually need that stuff.

Remove all unnecessary includes of <netinet/udp*.h> or <netinet/tcp*.h>
files.
2000-09-23 08:26:30 +00:00
assar
1bdce8fba3 (ip6_print): fix flipped arguments to memcpy. From Rafal Maszkowski
<rzm@icm.edu.pl>
2000-07-29 07:53:28 +00:00
assar
b487688fc8 (ip6_print): rewrite the alignment code to be for v6 and not v4.
based on a patch from Love <lha@stacken.kth.se>
2000-07-11 01:14:41 +00:00
assar
1b918881d8 TCPDUMP_ALIGN -> LBL_ALIGN 2000-07-11 00:55:22 +00:00
assar
3cd171317f remove non-STDC code 2000-07-01 03:38:59 +00:00
assar
4f56a7066b fallback definition for IPPROTO_PIM 2000-04-09 19:15:14 +00:00
fenner
fa2305bb99 Now that print-pim.c says "pim", don't print it here too. 2000-02-17 02:21:20 +00:00
fenner
34ff77ff43 Unify rcsid[]'s. 2000-01-09 21:34:14 +00:00
fenner
b9ac23ce92 Switch to config.h instead of passing defines in DEFS. 1999-11-21 09:36:43 +00:00
itojun
c9d84d15c5 Bring in KAME IPv6 tcpdump. replaces esp/ah/isakmp decoder.
Hope I did not break anything.  Portability on IPv4-only node needs checking,
I'll do this very soon.  (sorry for rather jumbo commit)

XXx what is _FAVOR_BSD?
1999-10-30 05:11:06 +00:00