Commit Graph

26 Commits

Author SHA1 Message Date
Denis Ovsienko
ca71c84728 Fix some spelling. [skip ci] 2020-10-09 13:19:10 +01:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
2019-03-26 21:06:24 +01:00
Guy Harris
3f3f2505f2 Make nd_uint8_t and nd_int8_t arrays, to catch direct references.
This catches direct references, so we can change them to use EXTRACT_U_1
or EXTRACT_S_1.

Also, change some structures to use the nd_ types that weren't already
using them.

Then make the appropriate EXTRACT_{U,S}_1() changes.
2017-12-10 16:23:34 -08:00
Guy Harris
bfe9582ec6 Use the nd_uintN_t types more.
Define them in netdissect.h.

Use them in ip.h, and *don't* mark the structures as UNALIGNED; that
should no longer be necessary.

Add a new nd_ipv4 type to use as an IPv4 address; it represents the 4
bytes of IPv4 address as an array of unsigned chars, so that its natural
alignment is only on a byte boundary.

Those changes found some places where we weren't using
UNALIGNED_MEMCPY() to extract IPv4 addresses from packets; use it.
2015-10-07 00:14:20 -07:00
Francois-Xavier Le Bail
8b20c46532 Get rid of "tcpdump" in some libnetdissect codes 2015-09-08 21:06:49 +02:00
Francois-Xavier Le Bail
175481a517 Remove useless include 2015-09-08 12:32:29 +02:00
Michael Richardson
66f50e74e1 make sure to include tcpdump-stdinc.h; it is required 2014-07-07 22:04:30 -04:00
Guy Harris
a2633f2f21 More fixes for uint8_t being shorter than u_int8_t.
Fix a typo while we're at it.
2014-04-23 11:53:22 -07:00
Guy Harris
dbddfda2c8 More getting rid of old u_intN_t. 2014-04-23 00:45:13 -07:00
Denis Ovsienko
b6303af682 NDOize AODV, IPv4 and SCTP decoders 2014-03-26 15:49:27 +04:00
Francois-Xavier Le Bail
c025e64b9e fix partial checksum errors in DCCP decoder, IPv4 case 2014-02-15 12:36:02 +01: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
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
53412397f6 Mark various IPv4 and IPv6 headers as unaligned.
This prevents GCC on SPARC from generating code that assumes those
structures are aligned naturally, which they are not guaranteed to be.

Move some #defines from interface.h to tcpdump-stdinc.h to make them
available to code that doesn't include interface.h.

Move the declaration of nextproto6_cksum() to ip6.h, so that only files
that use it get it declared, and thus so that you don't need to define
"struct ip6_hdr" in everything that includes interface.h.  Don't include
ip6.h in tcpdump-stdinc.h.
2010-08-31 10:03:47 -07:00
guy
9a0974cf30 From Victor Oppleman: add support for RFC 1393 traceroute. 2007-09-14 01:29:28 +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
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
10afb02ac8 put __attribute__((packed)) to packet headers. s/u_short/u_int16_t/ and so
forth while i'm here
2002-11-09 17:19:16 +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
2030f51199 C bitfields are no longer being used to extract bit fields from the IP
and TCP headers, so there's no need to stuff the byte-order stuff into
these header files.
2000-10-03 09:17:40 +00:00
itojun
9d45fb750b fix mistake in bitfield conversion 2000-10-03 03:14:46 +00:00
itojun
fb75d3cd5a always use u_intXX_t for protocol format declaration. char/short/int may not
come with exact size.  while at it, correct signedness of ip/udp header field.
nuke most of the use of bitfield.
TODO: bitfield in namser.h
2000-10-03 02:54:54 +00:00
guy
6de29a0314 Declare bitfields as "u_int", not "u_char"; ANSI C doesn't guarantee
that bitfields other than "int" or "unsigned int" are allowed, some
compilers warn about them, and, given that the declaration of a bit
field says how many bits it is wide, declaring them "u_char" doesn't
have any advantage (other than making it a bit clearer, when reading the
header, that the bitfields in question are part of a single byte).
2000-09-29 05:05:47 +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
ae1c61d25e Get rid of some "__attribute__ ((packed))"s that I missed. 2000-09-24 07:40:45 +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