]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: split out DHCP_MESSAGE_HEADER_DEFINITION to allow building test-dhcp-server...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Apr 2025 16:12:54 +0000 (01:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Apr 2025 11:54:53 +0000 (20:54 +0900)
src/libsystemd-network/dhcp-protocol.h
src/libsystemd-network/test-dhcp-server.c

index d7bb203aaba44916f441c41d335fd1faf4835785..b3b247a567e8b6f7db22b7078e925e5747450fec 100644 (file)
  * 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_;
 
index 97e4b04475d8fc04486bb6c1b227fbb9915667f5..a067fc0da59244f20e1a64db22e46bd15de0054a 100644 (file)
@@ -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;