X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fodhcp6c.h;h=08a816f4446dd893d89db315bf6f8932200ab2b8;hp=d202790a1115e96efb5c1c142e64157d8b28a8b4;hb=687b3c65c0460dd8c4ba7e63e3ae0ab20836e6e8;hpb=dc186d6d2b0dd4ad23ca5fc69c00e81f796ff6d9 diff --git a/src/odhcp6c.h b/src/odhcp6c.h index d202790..08a816f 100644 --- a/src/odhcp6c.h +++ b/src/odhcp6c.h @@ -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; @@ -335,7 +344,7 @@ bool odhcp6c_is_bound(void); void odhcp6c_clear_state(enum odhcp6c_state state); void odhcp6c_add_state(enum odhcp6c_state state, const void *data, size_t len); void odhcp6c_append_state(enum odhcp6c_state state, const void *data, size_t len); -void odhcp6c_insert_state(enum odhcp6c_state state, size_t offset, const void *data, size_t len); +int odhcp6c_insert_state(enum odhcp6c_state state, size_t offset, const void *data, size_t len); size_t odhcp6c_remove_state(enum odhcp6c_state state, size_t offset, size_t len); void* odhcp6c_move_state(enum odhcp6c_state state, size_t *len); void* odhcp6c_get_state(enum odhcp6c_state state, size_t *len);