diff --git a/src/libsystemd-network/dhcp-protocol.h b/src/libsystemd-network/dhcp-protocol.h index d7bb203aab..b3b247a567 100644 --- a/src/libsystemd-network/dhcp-protocol.h +++ b/src/libsystemd-network/dhcp-protocol.h @@ -19,22 +19,25 @@ * MIN_V6ONLY_WAIT: The lower boundary for V6ONLY_WAIT. Value: 300 seconds */ #define MIN_V6ONLY_WAIT_USEC (300U * USEC_PER_SEC) -struct DHCPMessage { - uint8_t op; - uint8_t htype; - uint8_t hlen; - uint8_t hops; - be32_t xid; - be16_t secs; - be16_t flags; - be32_t ciaddr; - be32_t yiaddr; - be32_t siaddr; - be32_t giaddr; - uint8_t chaddr[16]; - uint8_t sname[64]; - uint8_t file[128]; +#define DHCP_MESSAGE_HEADER_DEFINITION \ + uint8_t op; \ + uint8_t htype; \ + uint8_t hlen; \ + uint8_t hops; \ + be32_t xid; \ + be16_t secs; \ + be16_t flags; \ + be32_t ciaddr; \ + be32_t yiaddr; \ + be32_t siaddr; \ + be32_t giaddr; \ + uint8_t chaddr[16]; \ + uint8_t sname[64]; \ + uint8_t file[128]; \ be32_t magic; + +struct DHCPMessage { + DHCP_MESSAGE_HEADER_DEFINITION; uint8_t options[]; } _packed_; diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c index 97e4b04475..a067fc0da5 100644 --- a/src/libsystemd-network/test-dhcp-server.c +++ b/src/libsystemd-network/test-dhcp-server.c @@ -82,7 +82,9 @@ static int test_basic(bool bind_to_interface) { static void test_message_handler(void) { _cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL; struct { - DHCPMessage message; + struct { + DHCP_MESSAGE_HEADER_DEFINITION; + } _packed_ message; struct { uint8_t code; uint8_t length;