Commit Graph

34 Commits

Author SHA1 Message Date
Denis Ovsienko
b5cbb4d2bb Lose some more unnecessary #include lines. [skip ci]
This trivial change compiles fine with GCC 7.5.0 on Linux and Clang
10.0.1 on FreeBSD, so let's not run the full round of CI this time.
2020-11-27 16:18:40 +00:00
Denis Ovsienko
9169e4e194 Include <string.h> only if required. 2020-10-17 17:55:37 +01:00
Francois-Xavier Le Bail
6288c273b6 Remove useless 'return' at end of void functions (style) 2020-09-28 17:04:08 +02:00
Francois-Xavier Le Bail
aad6ac30ce Remove some now redundant ND_TCHECK_4() calls
ND_TCHECK_4(e).

They are redundant because they are followed by a GET_IPADDR_STRING(e)
call, same e, which do the bounds check.

Remove unused 'trunc' labels and associated codes.

Update the output of a test accordingly.
2020-09-08 14:14:13 +02:00
Francois-Xavier Le Bail
7ae1579954 Remove some now redundant ND_TCHECK_16() calls
ND_TCHECK_16(e).

They are redundant because they are followed by a GET_IP6ADDR_STRING(e)
call, same e, which do the bounds check.
2020-09-07 18:36:18 +02:00
Guy Harris
bb5d16f3b6 lisp: don't call hex_print_with_offset() with a zero offset. 2020-05-25 19:07:16 -07:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.

Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.

Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
2020-01-19 19:55:38 -08:00
Guy Harris
07a7f33ba3 Fix some narrowing warnings on LP64/LLP64 platforms.
Add a ND_BYTES_AVAILABLE_AFTER() macro to find the number of bytes
available in the captured data, starting at the byte pointed to by the
argument.  It returns a u_int rather than a ptrdiff_t, so it'll be
32 bits on LP64 and LLP64 platforms as well as on ILP32 platforms.  Use
that macro.

Make size-of-buffer arguments size_t.

Cast some size_t and ptrdiff_t values to u_int or int.
2019-04-18 10:13:49 -07: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
Francois-Xavier Le Bail
77a49fcb6e Add the nd_print_invalid() function
It prints " (invalid)", used for malformed or corrupted packets.

Moreover:
Update CONTRIBUTING.
2018-09-11 13:09:05 +02:00
Francois-Xavier Le Bail
45ecddd334 Fix space printing with istr[]
Because istr[] is assign to " (invalid)", avoid adding a space before it.

Moreover:
Avoid also useless '\n'
2018-05-18 10:03:59 +02:00
Francois-Xavier Le Bail
ba8936b39b Print truncations with nd_print_trunc() instead of tstr[] strings
Remove the tstr[] strings.
Update the output of some tests accordingly.

Moreover:
Add or update some ndo_protocol fields.
2018-05-04 13:47:49 +02:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00
Francois-Xavier Le Bail
944e93fa4c Remove function specifier 'inline' in printers
It was mostly used with large functions.

Moreover:
Put some function definition names at the beginning of line.
Fix a space.
2018-01-26 20:59:32 +01:00
Guy Harris
fb2479d733 Always include <config.h> rather than "config.h".
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options.  This way, we always pick up the
same config.h, in the build directory.
2018-01-21 12:27:28 -08:00
Francois-Xavier Le Bail
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
84ef17ac0e Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)
ND_TTEST2(var, l)  -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
2017-12-11 22:11:01 +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
Francois-Xavier Le Bail
39c8c55aa9 Use more ND_TCHECK_n()/ND_TTEST_n() macros 2017-11-24 22:48:55 +01:00
Francois-Xavier Le Bail
da20bc56d6 Rename EXTRACT_ macros
Now all the macros have a name meaning a count in bytes.

With _S_: signed, _U_: unsigned

e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4

and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8  -> EXTRACT_S_1
2017-11-22 23:54:09 +01:00
Francois-Xavier Le Bail
577621026d Rename EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()
It indicates clearly that these macros are used to extract big-endian
integral values.
2017-11-18 13:56:40 +01:00
Francois-Xavier Le Bail
45c9c5e5c2 Put some function definition names at the beginning of line 2017-11-16 08:46:28 +01:00
Denis Ovsienko
c6a993a4a3 LISP: include local netdissect.h first
This doesn't fix any known issue, just for consistency with all other
decoders.
2017-03-12 10:07:42 +00:00
Francois-Xavier Le Bail
b38f324af9 Add a summary comment in all other printers
Moreover:
Remove some redundant comments
Update some summary comments
Update the specification URL for ATA over Ethernet (AoE) protocol
2016-08-15 22:42:38 +02:00
Denis Ovsienko
bd2b067d7b call ipaddr_string() instead of getname()
Same as in the previous commit.
2016-07-11 11:56:53 +01:00
Denis Ovsienko
d2aa4eec28 call ip6addr_string() instead of getname6()
This replaces a few explicit type casts with one type cast in the macro
and makes the source code mean one thing with one term instead of two.
2016-07-11 11:56:29 +01:00
Francois-Xavier Le Bail
436ced3bd8 Change istr[] (for invalid string) to be global 2016-01-28 14:24:19 +01:00
Francois-Xavier Le Bail
ba983e34ca LISP: Add and use istr[] and tstr[] strings
Update the output of a test accordingly.

Moreover:
Delete extra blank lines.
2015-11-21 10:41:05 +01:00
Francois-Xavier Le Bail
38e91e5c3f Fix a comment
Moreover:
s/tcpdump/netdissect/
2015-10-08 16:26:36 +02:00
Guy Harris
1376682ba5 Introduce data types to use for integral values in packet structures.
They are defined as arrays of bytes, so

	1) no padding is inserted before them to put them on natural
	   boundaries, so they can be used if the values *aren't* so
	   aligned;

	2) you have to use EXTRACT_ macros with them - which you should
	   be doing *anyway*, to avoid explicitly or implicitly making
	   assumptions about byte order or alignment safety on the
	   platform for which your code is being built (it'd better work
	   when built for little-endian x86 or for big-endian *and*
	   strict-alignment-requiring SPARC).

Use them in the LISP (no, not the programming language!) dissector;
UNALIGNED means "this structure is not guaranteed to be aligned as a
whole, so don't generate code that assumes it is", not "this structure's
individual members shouldn't have padding to put them on natural
boundaries", so it's not sufficient to do that.  (Using these types
*might* suffice to ensure that code that assumes alignment not be
generated, but never underestimate SPARC compilers' eagerness to use
single load and store instructions to fetch big-endian 16-bit, 32-bit,
and 64-bit values from packets that really aren't guaranteed to be
aligned.)
2015-10-06 09:41:01 -07:00
Francois-Xavier Le Bail
bbf859b415 LISP: Fix a Clang warning
The warning was:
./print-lisp.c:401:11: warning: variable 'xtr_present' is used uninitialized
      whenever 'if' condition is false [-Wsometimes-uninitialized]
        else if (type == LISP_MAP_NOTIFY)
                 ^~~~~~~~~~~~~~~~~~~~~~~

./print-lisp.c:404:9: note: uninitialized use occurs here
        return xtr_present;
               ^~~~~~~~~~~

Moreover:
Remove unused 'interface.h' include.
2015-10-05 11:29:35 +02:00
Francois-Xavier Le Bail
eea2b6d5dd LISP: We always support IPv6 addresses now
INET6 is no more used.
2015-10-05 09:25:46 +02:00
ritsz
823644a72d Initial commit for support of Type 3 and Type 4 LISP packets.
Fixing Travis CI build for LISP commit

Adding testcases for lisp notify and register

Fixing build warnings

Added ND_TCHECK for relevant headers

Fixing ND_TCHECK2 issues

Adding support for multiple LOC records for same EID entry

Fixing review issues, adding detailed tests

Adding support for verbose outputs

Adding RFC information for UDP PORT defination

Removing Spaces in type names

Print EID record related flags in verbose mode

Using tok2str

Fixing -Wpedantic issues

Negative testcases, Packet structure comments, verbose mode flag printing

Printing Map Version

Print auth_data, decouple type and xtr_present extraction, handle malformed packets correctly

Tests for latest code changes

Printing useful info incase not built with IPv6 support
2015-10-04 12:47:13 +02:00