]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/odhcp6c.h
Fix alignment of buffers in ra_process and dhcpv6_request
[odhcp6c.git] / src / odhcp6c.h
index 928f82f32e1004502ecaf2b61e8439af9e9716d5..08a816f4446dd893d89db315bf6f8932200ab2b8 100644 (file)
@@ -18,6 +18,7 @@
 
 #define _unused __attribute__((unused))
 #define _packed __attribute__((packed))
+#define __aligned(n) __attribute__((aligned(n)))
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
@@ -302,6 +303,14 @@ struct odhcp6c_entry {
        uint8_t auxtarget[];
 };
 
+// Include padding after auxtarget to align the next entry
+#define odhcp6c_entry_size(entry) \
+       (sizeof(struct odhcp6c_entry) + (((entry)->auxlen + 3) & ~3))
+
+#define odhcp6c_next_entry(entry) \
+       ((struct odhcp6c_entry *)((uint8_t *)(entry) + odhcp6c_entry_size(entry)))
+
+
 struct odhcp6c_request_prefix {
        uint32_t iaid;
        uint16_t length;