]> The Tcpdump Group git mirrors - tcpdump/commit
Introduce data types to use for integral values in packet structures.
authorGuy Harris <[email protected]>
Tue, 6 Oct 2015 16:41:01 +0000 (09:41 -0700)
committerGuy Harris <[email protected]>
Tue, 6 Oct 2015 16:41:01 +0000 (09:41 -0700)
commit1376682ba5650750600966ba910774ba26973b92
tree06132413e391f9431629e02b0da21d99c6f959f6
parentd7d269e8c67b6e8262db27bb92ae524aa3c3f439
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.)
extract.h
print-lisp.c