]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: split dhcp-internal.h into two 29652/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Oct 2023 16:27:52 +0000 (01:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Oct 2023 16:54:08 +0000 (01:54 +0900)
15 files changed:
src/libsystemd-network/dhcp-client-internal.h
src/libsystemd-network/dhcp-internal.h [deleted file]
src/libsystemd-network/dhcp-lease-internal.h
src/libsystemd-network/dhcp-option.c
src/libsystemd-network/dhcp-option.h [new file with mode: 0644]
src/libsystemd-network/dhcp-packet.c
src/libsystemd-network/dhcp-packet.h [new file with mode: 0644]
src/libsystemd-network/dhcp-protocol.h
src/libsystemd-network/dhcp-server-internal.h
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/sd-dhcp-server.c
src/libsystemd-network/test-dhcp-client.c
src/libsystemd-network/test-dhcp-option.c
src/network/networkd-dhcp-common.c

index cb8e3c332585878acd7ab48739b97e63cfb32964..28ce80cbf22e9212bdc1b181a64230e8e483da0a 100644 (file)
@@ -26,8 +26,6 @@ const char *dhcp_state_to_string(DHCPState s) _const_;
 
 typedef struct sd_dhcp_client sd_dhcp_client;
 
-extern const struct hash_ops dhcp_option_hash_ops;
-
 int dhcp_client_set_state_callback(
                 sd_dhcp_client *client,
                 sd_dhcp_client_callback_t cb,
diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h
deleted file mode 100644 (file)
index ba6090b..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#pragma once
-
-/***
-  Copyright © 2013 Intel Corporation. All rights reserved.
-***/
-
-#include <stdint.h>
-
-#include "sd-dhcp-client.h"
-
-#include "dhcp-client-internal.h"
-#include "dhcp-protocol.h"
-
-typedef struct sd_dhcp_option {
-        unsigned n_ref;
-
-        uint8_t option;
-        void *data;
-        size_t length;
-} sd_dhcp_option;
-
-typedef struct DHCPServerData {
-        struct in_addr *addr;
-        size_t size;
-} DHCPServerData;
-
-int dhcp_option_append(DHCPMessage *message, size_t size, size_t *offset, uint8_t overload,
-                       uint8_t code, size_t optlen, const void *optval);
-int dhcp_option_find_option(uint8_t *options, size_t length, uint8_t wanted_code, size_t *ret_offset);
-int dhcp_option_remove_option(uint8_t *options, size_t buflen, uint8_t option_code);
-
-typedef int (*dhcp_option_callback_t)(uint8_t code, uint8_t len,
-                                const void *option, void *userdata);
-
-int dhcp_option_parse(DHCPMessage *message, size_t len, dhcp_option_callback_t cb, void *userdata, char **ret_error_message);
-
-int dhcp_option_parse_string(const uint8_t *option, size_t len, char **ret);
-
-int dhcp_message_init(DHCPMessage *message, uint8_t op, uint32_t xid,
-                      uint8_t type, uint16_t arp_type, uint8_t hlen, const uint8_t *chaddr,
-                      size_t optlen, size_t *optoffset);
-
-uint16_t dhcp_packet_checksum(uint8_t *buf, size_t len);
-
-void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr,
-                                   uint16_t source, be32_t destination_addr,
-                                   uint16_t destination, uint16_t len, int ip_service_type);
-
-int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, uint16_t port);
index 54facc9c658e30ece89f2e64b3a7b64f3410cb42..ce1342e9fddf66a95918e38fc8577493cf2296c9 100644 (file)
@@ -8,8 +8,7 @@
 #include "sd-dhcp-client.h"
 
 #include "alloc-util.h"
-#include "dhcp-internal.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
 #include "list.h"
 #include "time-util.h"
 
index b60c7b443e417a03fa10d25fd15618aeec0d1d82..5e216c5139c728dfa85e5d8209af5d005b5c0101 100644 (file)
@@ -8,9 +8,10 @@
 #include <stdio.h>
 
 #include "alloc-util.h"
-#include "dhcp-internal.h"
+#include "dhcp-option.h"
 #include "dhcp-server-internal.h"
 #include "memory-util.h"
+#include "ordered-set.h"
 #include "strv.h"
 #include "utf8.h"
 
diff --git a/src/libsystemd-network/dhcp-option.h b/src/libsystemd-network/dhcp-option.h
new file mode 100644 (file)
index 0000000..425f5b5
--- /dev/null
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include <stdint.h>
+
+#include "sd-dhcp-option.h"
+
+#include "dhcp-protocol.h"
+#include "hash-funcs.h"
+
+struct sd_dhcp_option {
+        unsigned n_ref;
+
+        uint8_t option;
+        void *data;
+        size_t length;
+};
+
+extern const struct hash_ops dhcp_option_hash_ops;
+
+typedef struct DHCPServerData {
+        struct in_addr *addr;
+        size_t size;
+} DHCPServerData;
+
+int dhcp_option_append(
+                DHCPMessage *message,
+                size_t size,
+                size_t *offset,
+                uint8_t overload,
+                uint8_t code,
+                size_t optlen,
+                const void *optval);
+int dhcp_option_find_option(uint8_t *options, size_t length, uint8_t wanted_code, size_t *ret_offset);
+int dhcp_option_remove_option(uint8_t *options, size_t buflen, uint8_t option_code);
+
+typedef int (*dhcp_option_callback_t)(uint8_t code, uint8_t len, const void *option, void *userdata);
+
+int dhcp_option_parse(
+                DHCPMessage *message,
+                size_t len,
+                dhcp_option_callback_t cb,
+                void *userdata,
+                char **ret_error_message);
+
+int dhcp_option_parse_string(const uint8_t *option, size_t len, char **ret);
index b2efd5246df6b6b9e432b579b95eac13e9b5feb2..78eb36c73371df8f01bfe00e58c46316217d89ef 100644 (file)
@@ -8,8 +8,8 @@
 #include <net/if_arp.h>
 #include <string.h>
 
-#include "dhcp-internal.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
+#include "dhcp-packet.h"
 #include "memory-util.h"
 
 #define DHCP_CLIENT_MIN_OPTIONS_SIZE            312
diff --git a/src/libsystemd-network/dhcp-packet.h b/src/libsystemd-network/dhcp-packet.h
new file mode 100644 (file)
index 0000000..751321b
--- /dev/null
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "dhcp-protocol.h"
+
+int dhcp_message_init(
+                DHCPMessage *message,
+                uint8_t op,
+                uint32_t xid,
+                uint8_t type,
+                uint16_t arp_type,
+                uint8_t hlen,
+                const uint8_t *chaddr,
+                size_t optlen,
+                size_t *optoffset);
+
+uint16_t dhcp_packet_checksum(uint8_t *buf, size_t len);
+
+void dhcp_packet_append_ip_headers(
+                DHCPPacket *packet,
+                be32_t source_addr,
+                uint16_t source,
+                be32_t destination_addr,
+                uint16_t destination,
+                uint16_t len,
+                int ip_service_type);
+
+int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, uint16_t port);
index 34ab933360608ea05d4134e4c222d9e2d18e6d2a..d7bb203aaba44916f441c41d335fd1faf4835785 100644 (file)
@@ -9,6 +9,8 @@
 #include <netinet/udp.h>
 #include <stdint.h>
 
+#include "sd-dhcp-protocol.h"
+
 #include "macro.h"
 #include "sparse-endian.h"
 #include "time-util.h"
index ae61cd84799ac6377d8d973ebaf6389e5acdd08f..1879b5b159f81c69bd95d89ec42ee2b3fc086505 100644 (file)
@@ -8,7 +8,7 @@
 #include "sd-dhcp-server.h"
 #include "sd-event.h"
 
-#include "dhcp-internal.h"
+#include "dhcp-option.h"
 #include "network-common.h"
 #include "ordered-set.h"
 #include "time-util.h"
index dc61470afc91824c5ba5add13734a3789ea0f22f..bc73e87b95b793cf2c879c93a6a42684ce9d59a3 100644 (file)
 
 #include "alloc-util.h"
 #include "device-util.h"
+#include "dhcp-client-internal.h"
 #include "dhcp-identifier.h"
-#include "dhcp-internal.h"
 #include "dhcp-lease-internal.h"
 #include "dhcp-network.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
+#include "dhcp-packet.h"
 #include "dns-domain.h"
 #include "ether-addr-util.h"
 #include "event-util.h"
index d82ab938f73beeccf7777641e44171bdf46509b6..e0e8e81750526978beb4df11786acde905d20bde 100644 (file)
@@ -13,9 +13,8 @@
 #include "sd-dhcp-lease.h"
 
 #include "alloc-util.h"
-#include "dhcp-internal.h"
 #include "dhcp-lease-internal.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
 #include "dns-domain.h"
 #include "env-file.h"
 #include "fd-util.h"
@@ -24,6 +23,7 @@
 #include "hexdecoct.h"
 #include "hostname-util.h"
 #include "in-addr-util.h"
+#include "network-common.h"
 #include "network-internal.h"
 #include "parse-util.h"
 #include "stdio-util.h"
index 814021a2caf7fc2da4b000d3acff086aaca5f497..54a659766d38541f87a259c1c48ce25a70ef571f 100644 (file)
@@ -10,8 +10,9 @@
 #include "sd-id128.h"
 
 #include "alloc-util.h"
-#include "dhcp-internal.h"
 #include "dhcp-network.h"
+#include "dhcp-option.h"
+#include "dhcp-packet.h"
 #include "dhcp-server-internal.h"
 #include "dns-domain.h"
 #include "fd-util.h"
index f8baf2d46d9e96fa327d3f4a7ebaf38f5b7e54b6..e3f148daf5d3fd23b1a5b6526ca0ef1b42e4e130 100644 (file)
@@ -18,9 +18,9 @@
 
 #include "alloc-util.h"
 #include "dhcp-identifier.h"
-#include "dhcp-internal.h"
 #include "dhcp-network.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
+#include "dhcp-packet.h"
 #include "ether-addr-util.h"
 #include "fd-util.h"
 #include "random-util.h"
index 82c5cdb67a92f8023b5c73bf5fb52542f40009ee..47d799348f9a73e1fc309bec2275e8f7092091fa 100644 (file)
@@ -7,8 +7,9 @@
 #include <string.h>
 
 #include "alloc-util.h"
-#include "dhcp-internal.h"
-#include "dhcp-protocol.h"
+#include "dhcp-option.h"
+#include "dhcp-packet.h"
+#include "ether-addr-util.h"
 #include "macro.h"
 #include "memory-util.h"
 
index ff0ee717c5ddd51edd2e5ab9957f39aa6a2064fd..cfc7a388e8fdf07165d243f6ae62fb715d763f6a 100644 (file)
@@ -6,7 +6,7 @@
 #include "bus-error.h"
 #include "bus-locator.h"
 #include "dhcp-identifier.h"
-#include "dhcp-client-internal.h"
+#include "dhcp-option.h"
 #include "dhcp6-internal.h"
 #include "escape.h"
 #include "hexdecoct.h"