* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-/*
- * Data types corresponding to multi-byte integral values within data
- * structures. These are defined as arrays of octets, so that they're
- * not aligned on their "natural" boundaries, and so that you *must*
- * use the EXTRACT_ macros to extract them (which you should be doing
- * *anyway*, so as not to assume a particular byte order or alignment
- * in your code).
- */
-typedef unsigned char nd_uint16_t[2];
-typedef unsigned char nd_uint24_t[3];
-typedef unsigned char nd_uint32_t[4];
-typedef unsigned char nd_uint40_t[5];
-typedef unsigned char nd_uint48_t[6];
-typedef unsigned char nd_uint56_t[7];
-typedef unsigned char nd_uint64_t[8];
-
-/*
- * Data types corresponding to single-byte integral values, for
- * completeness.
- */
-typedef unsigned char nd_uint8_t;
-typedef signed char nd_int8_t;
-
/*
* Macros to extract possibly-unaligned big-endian integral values.
*/
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
}
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
+
+/*
+ * Macros to check the presence of the values in question.
+ */
+#define ND_TTEST_8BITS(p) ND_TTEST2(*(p), 1)
+#define ND_TCHECK_8BITS(p) ND_TCHECK2(*(p), 1)
+
+#define ND_TTEST_16BITS(p) ND_TTEST2(*(p), 2)
+#define ND_TCHECK_16BITS(p) ND_TCHECK2(*(p), 2)
+
+#define ND_TTEST_24BITS(p) ND_TTEST2(*(p), 3)
+#define ND_TCHECK_24BITS(p) ND_TCHECK2(*(p), 3)
+
+#define ND_TTEST_32BITS(p) ND_TTEST2(*(p), 4)
+#define ND_TCHECK_32BITS(p) ND_TCHECK2(*(p), 4)
+
+#define ND_TTEST_40BITS(p) ND_TTEST2(*(p), 5)
+#define ND_TCHECK_40BITS(p) ND_TCHECK2(*(p), 5)
+
+#define ND_TTEST_48BITS(p) ND_TTEST2(*(p), 6)
+#define ND_TCHECK_48BITS(p) ND_TCHECK2(*(p), 6)
+
+#define ND_TTEST_56BITS(p) ND_TTEST2(*(p), 7)
+#define ND_TCHECK_56BITS(p) ND_TCHECK2(*(p), 7)
+
+#define ND_TTEST_64BITS(p) ND_TTEST2(*(p), 8)
+#define ND_TCHECK_64BITS(p) ND_TCHECK2(*(p), 8)