@@ -323,6 +323,39 @@ and ask!
323
323
the string is a sequence of XX:XX:... values for the bytes
324
324
of the address.
325
325
326
+ * When defining a structure corresponding to a packet or part of a
327
+ packet, so that a pointer to packet data can be cast to a pointer to
328
+ that structure and that structure pointer used to refer to fields in
329
+ the packet, use the ` nd_* ` types for the structure members.
330
+
331
+ Those types all are aligned only on a 1-byte boundary, so a
332
+ compiler will not assume that the structure is aligned on a boundary
333
+ stricter than one byte; there is no guarantee that fields in packets
334
+ are aligned on any particular boundary.
335
+
336
+ This means that all padding in the structure must be explicitly
337
+ declared as fields in the structure.
338
+
339
+ The ` nd_* ` types for integral values are:
340
+
341
+ * ` nd_uintN_t ` , for unsigned integral values, where * N* is the number
342
+ of bytes in the value.
343
+ * ` nd_intN_t ` , for signed integral values, where * N* is the number
344
+ of bytes in the value.
345
+
346
+ The ` nd_* ` types for IP addresses are:
347
+
348
+ * ` nd_ipv4 ` , for IPv4 addresses;
349
+ * ` nd_ipv6 ` , for IPv6 addresses.
350
+
351
+ The ` nd_* ` types for link-layer addresses are:
352
+
353
+ * ` nd_mac48 ` , for MAC-48 (Ethernet, 802.11, etc.) addresses;
354
+ * ` nd_eui64 ` , for EUI-64 values.
355
+
356
+ The ` nd_* ` type for a byte in a sequence of bytes is ` nd_byte ` ; an
357
+ * N* -byte sequence should be declared as ` nd_byte[N] ` .
358
+
326
359
* Do invalid packet checks in code: Think that your code can receive in input
327
360
not only a valid packet but any arbitrary random sequence of octets (packet
328
361
* built malformed originally by the sender or by a fuzz tester,
0 commit comments