From: Yu Watanabe Date: Thu, 3 Apr 2025 16:12:54 +0000 (+0900) Subject: dhcp: split out DHCP_MESSAGE_HEADER_DEFINITION to allow building test-dhcp-server... X-Git-Tag: v258-rc1~910^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b160db520e6d4ec7aa71024499d64599ced9631;p=thirdparty%2Fsystemd.git dhcp: split out DHCP_MESSAGE_HEADER_DEFINITION to allow building test-dhcp-server.c with -Werror=flex-array-member-not-at-end --- diff --git a/src/libsystemd-network/dhcp-protocol.h b/src/libsystemd-network/dhcp-protocol.h index d7bb203aaba..b3b247a567e 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 97e4b04475d..a067fc0da59 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;