]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: split dhcp6-internal.h into two
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Feb 2022 19:05:00 +0000 (04:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 06:02:33 +0000 (15:02 +0900)
Also, this moves string tables to dhcp6-protocol.c.

src/libsystemd-network/dhcp6-internal.h
src/libsystemd-network/dhcp6-lease-internal.h
src/libsystemd-network/dhcp6-option.c
src/libsystemd-network/dhcp6-option.h [new file with mode: 0644]
src/libsystemd-network/dhcp6-protocol.c [new file with mode: 0644]
src/libsystemd-network/dhcp6-protocol.h
src/libsystemd-network/meson.build
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-dhcp6-lease.c

index aefcdc2d36f40c8098711024e9de423591720fb5..81497fda14a90239ea2f486c9bc5ce9d6228f28d 100644 (file)
 #include "sd-dhcp6-client.h"
 
 #include "dhcp-identifier.h"
+#include "dhcp6-option.h"
 #include "dhcp6-protocol.h"
 #include "ether-addr-util.h"
 #include "hashmap.h"
-#include "list.h"
 #include "macro.h"
 #include "network-common.h"
 #include "ordered-set.h"
 #include "sparse-endian.h"
-
-typedef struct sd_dhcp6_option {
-        unsigned n_ref;
-
-        uint32_t enterprise_identifier;
-        uint16_t option;
-        void *data;
-        size_t length;
-} sd_dhcp6_option;
-
-extern const struct hash_ops dhcp6_option_hash_ops;
-
-/* Common option header */
-typedef struct DHCP6Option {
-        be16_t code;
-        be16_t len;
-        uint8_t data[];
-} _packed_ DHCP6Option;
-
-/* Address option */
-struct iaaddr {
-        struct in6_addr address;
-        be32_t lifetime_preferred;
-        be32_t lifetime_valid;
-} _packed_;
-
-/* Prefix Delegation Prefix option */
-struct iapdprefix {
-        be32_t lifetime_preferred;
-        be32_t lifetime_valid;
-        uint8_t prefixlen;
-        struct in6_addr address;
-} _packed_;
-
-typedef struct DHCP6Address DHCP6Address;
-
-struct DHCP6Address {
-        LIST_FIELDS(DHCP6Address, addresses);
-
-        union {
-                struct iaaddr iaaddr;
-                struct iapdprefix iapdprefix;
-        };
-};
-
-struct ia_header {
-        be32_t id;
-        be32_t lifetime_t1;
-        be32_t lifetime_t2;
-} _packed_;
-
-typedef struct DHCP6IA {
-        uint16_t type;
-        struct ia_header header;
-
-        LIST_HEAD(DHCP6Address, addresses);
-} DHCP6IA;
+#include "time-util.h"
 
 /* what to request from the server, addresses (IA_NA) and/or prefixes (IA_PD) */
 typedef enum DHCP6RequestIA {
@@ -85,93 +29,62 @@ typedef enum DHCP6RequestIA {
         DHCP6_REQUEST_IA_PD = 1 << 2,
 } DHCP6RequestIA;
 
-typedef struct sd_dhcp6_client {
+struct sd_dhcp6_client {
         unsigned n_ref;
 
-        DHCP6State state;
-        sd_event *event;
-        int event_priority;
         int ifindex;
         char *ifname;
+
         struct in6_addr local_address;
         struct hw_addr_data hw_addr;
         uint16_t arp_type;
-        DHCP6IA ia_na;
-        DHCP6IA ia_pd;
-        DHCP6RequestIA request_ia;
-        be32_t transaction_id;
-        usec_t transaction_start;
-        struct sd_dhcp6_lease *lease;
+
+        sd_event *event;
+        sd_event_source *receive_message;
+        sd_event_source *timeout_resend;
+        sd_event_source *timeout_expire;
+        sd_event_source *timeout_t1;
+        sd_event_source *timeout_t2;
+        int event_priority;
         int fd;
+
+        DHCP6State state;
         bool information_request;
+        usec_t information_request_time_usec;
+        usec_t information_refresh_time_usec;
+        be32_t transaction_id;
+        usec_t transaction_start;
+        usec_t retransmit_time;
+        uint8_t retransmit_count;
+
         bool iaid_set;
+        DHCP6IA ia_na;
+        DHCP6IA ia_pd;
+        DHCP6RequestIA request_ia;
+        struct duid duid;
+        size_t duid_len;
         be16_t *req_opts;
         size_t req_opts_len;
         char *fqdn;
         char *mudurl;
         char **user_class;
         char **vendor_class;
-        sd_event_source *receive_message;
-        usec_t retransmit_time;
-        uint8_t retransmit_count;
-        sd_event_source *timeout_resend;
-        sd_event_source *timeout_expire;
-        sd_event_source *timeout_t1;
-        sd_event_source *timeout_t2;
-        sd_dhcp6_client_callback_t callback;
-        void *userdata;
-        struct duid duid;
-        size_t duid_len;
-        usec_t information_request_time_usec;
-        usec_t information_refresh_time_usec;
         OrderedHashmap *extra_options;
         OrderedSet *vendor_options;
 
+        struct sd_dhcp6_lease *lease;
+
+        sd_dhcp6_client_callback_t callback;
+        void *userdata;
+
         /* Ignore ifindex when generating iaid. See dhcp_identifier_set_iaid(). */
         bool test_mode;
-} sd_dhcp6_client;
-
-bool dhcp6_option_can_request(uint16_t option);
-int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
-                        size_t optlen, const void *optval);
-int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
-int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
-int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
-int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
-int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet *vendor_options);
-
-int dhcp6_option_parse(
-                const uint8_t *buf,
-                size_t buflen,
-                size_t *offset,
-                uint16_t *ret_option_code,
-                size_t *ret_option_data_len,
-                const uint8_t **ret_option_data);
-int dhcp6_option_parse_status(const uint8_t *data, size_t data_len, char **ret_status_message);
-int dhcp6_option_parse_ia(
-                sd_dhcp6_client *client,
-                be32_t iaid,
-                uint16_t option_code,
-                size_t option_data_len,
-                const uint8_t *option_data,
-                DHCP6IA **ret);
-int dhcp6_option_parse_addresses(
-                const uint8_t *optval,
-                size_t optlen,
-                struct in6_addr **addrs,
-                size_t *count);
-int dhcp6_option_parse_domainname_list(const uint8_t *optval, size_t optlen, char ***ret);
-int dhcp6_option_parse_domainname(const uint8_t *optval, size_t optlen, char **ret);
+};
 
 int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address);
 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
                                   const void *packet, size_t len);
 
-const char *dhcp6_message_type_to_string(DHCP6MessageType t) _const_;
-DHCP6MessageType dhcp6_message_type_from_string(const char *s) _pure_;
-const char *dhcp6_message_status_to_string(DHCP6Status s) _const_;
-DHCP6Status dhcp6_message_status_from_string(const char *s) _pure_;
-
 void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode);
 int dhcp6_client_set_transaction_id(sd_dhcp6_client *client, uint32_t transaction_id);
 
index a82e9fd06ba0fb3b5691ef8c9d03fa476d48a866..1fbaab96e95b54a2a813c7c984bc33c33ee9e1fa 100644 (file)
@@ -5,11 +5,11 @@
   Copyright © 2014-2015 Intel Corporation. All rights reserved.
 ***/
 
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "sd-dhcp6-lease.h"
 
-#include "dhcp6-internal.h"
+#include "dhcp6-option.h"
 #include "macro.h"
 #include "time-util.h"
 
@@ -45,12 +45,7 @@ struct sd_dhcp6_lease {
         char *fqdn;
 };
 
-void dhcp6_ia_clear_addresses(DHCP6IA *ia);
-DHCP6IA *dhcp6_ia_free(DHCP6IA *ia);
-DEFINE_TRIVIAL_CLEANUP_FUNC(DHCP6IA*, dhcp6_ia_free);
-
 int dhcp6_lease_get_lifetime(sd_dhcp6_lease *lease, usec_t *ret_t1, usec_t *ret_t2, usec_t *ret_valid);
-
 int dhcp6_lease_set_clientid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len);
 int dhcp6_lease_get_clientid(sd_dhcp6_lease *lease, uint8_t **ret_id, size_t *ret_len);
 int dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len);
index 544887b9bcc51f6fdacb7175bd1c10b9191510fa..27c907d9e9401c22b0eb0bbea9b40b55ffa6156d 100644 (file)
@@ -9,14 +9,12 @@
 #include "sd-dhcp6-client.h"
 
 #include "alloc-util.h"
-#include "dhcp-identifier.h"
 #include "dhcp6-internal.h"
-#include "dhcp6-lease-internal.h"
+#include "dhcp6-option.h"
 #include "dhcp6-protocol.h"
 #include "dns-domain.h"
 #include "escape.h"
 #include "memory-util.h"
-#include "sparse-endian.h"
 #include "strv.h"
 #include "unaligned.h"
 
diff --git a/src/libsystemd-network/dhcp6-option.h b/src/libsystemd-network/dhcp6-option.h
new file mode 100644 (file)
index 0000000..80aba7f
--- /dev/null
@@ -0,0 +1,104 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "sd-dhcp6-client.h"
+
+#include "hash-funcs.h"
+#include "list.h"
+#include "macro.h"
+#include "ordered-set.h"
+#include "sparse-endian.h"
+
+typedef struct sd_dhcp6_option {
+        unsigned n_ref;
+
+        uint32_t enterprise_identifier;
+        uint16_t option;
+        void *data;
+        size_t length;
+} sd_dhcp6_option;
+
+extern const struct hash_ops dhcp6_option_hash_ops;
+
+/* Common option header */
+typedef struct DHCP6Option {
+        be16_t code;
+        be16_t len;
+        uint8_t data[];
+} _packed_ DHCP6Option;
+
+/* Address option */
+struct iaaddr {
+        struct in6_addr address;
+        be32_t lifetime_preferred;
+        be32_t lifetime_valid;
+} _packed_;
+
+/* Prefix Delegation Prefix option */
+struct iapdprefix {
+        be32_t lifetime_preferred;
+        be32_t lifetime_valid;
+        uint8_t prefixlen;
+        struct in6_addr address;
+} _packed_;
+
+typedef struct DHCP6Address DHCP6Address;
+
+struct DHCP6Address {
+        LIST_FIELDS(DHCP6Address, addresses);
+
+        union {
+                struct iaaddr iaaddr;
+                struct iapdprefix iapdprefix;
+        };
+};
+
+struct ia_header {
+        be32_t id;
+        be32_t lifetime_t1;
+        be32_t lifetime_t2;
+} _packed_;
+
+typedef struct DHCP6IA {
+        uint16_t type;
+        struct ia_header header;
+
+        LIST_HEAD(DHCP6Address, addresses);
+} DHCP6IA;
+
+void dhcp6_ia_clear_addresses(DHCP6IA *ia);
+DHCP6IA *dhcp6_ia_free(DHCP6IA *ia);
+DEFINE_TRIVIAL_CLEANUP_FUNC(DHCP6IA*, dhcp6_ia_free);
+
+bool dhcp6_option_can_request(uint16_t option);
+
+int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
+                        size_t optlen, const void *optval);
+int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
+int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
+int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
+int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
+int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet *vendor_options);
+
+int dhcp6_option_parse(
+                const uint8_t *buf,
+                size_t buflen,
+                size_t *offset,
+                uint16_t *ret_option_code,
+                size_t *ret_option_data_len,
+                const uint8_t **ret_option_data);
+int dhcp6_option_parse_status(const uint8_t *data, size_t data_len, char **ret_status_message);
+int dhcp6_option_parse_ia(
+                sd_dhcp6_client *client,
+                be32_t iaid,
+                uint16_t option_code,
+                size_t option_data_len,
+                const uint8_t *option_data,
+                DHCP6IA **ret);
+int dhcp6_option_parse_addresses(
+                const uint8_t *optval,
+                size_t optlen,
+                struct in6_addr **addrs,
+                size_t *count);
+int dhcp6_option_parse_domainname_list(const uint8_t *optval, size_t optlen, char ***ret);
+int dhcp6_option_parse_domainname(const uint8_t *optval, size_t optlen, char **ret);
diff --git a/src/libsystemd-network/dhcp6-protocol.c b/src/libsystemd-network/dhcp6-protocol.c
new file mode 100644 (file)
index 0000000..c399a7a
--- /dev/null
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "dhcp6-protocol.h"
+#include "string-table.h"
+
+static const char * const dhcp6_state_table[_DHCP6_STATE_MAX] = {
+        [DHCP6_STATE_STOPPED]             = "stopped",
+        [DHCP6_STATE_INFORMATION_REQUEST] = "information-request",
+        [DHCP6_STATE_SOLICITATION]        = "solicitation",
+        [DHCP6_STATE_REQUEST]             = "request",
+        [DHCP6_STATE_BOUND]               = "bound",
+        [DHCP6_STATE_RENEW]               = "renew",
+        [DHCP6_STATE_REBIND]              = "rebind",
+};
+
+DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State);
+
+static const char * const dhcp6_message_type_table[_DHCP6_MESSAGE_TYPE_MAX] = {
+        [DHCP6_MESSAGE_SOLICIT]             = "Solicit",
+        [DHCP6_MESSAGE_ADVERTISE]           = "Advertise",
+        [DHCP6_MESSAGE_REQUEST]             = "Request",
+        [DHCP6_MESSAGE_CONFIRM]             = "Confirm",
+        [DHCP6_MESSAGE_RENEW]               = "Renew",
+        [DHCP6_MESSAGE_REBIND]              = "Rebind",
+        [DHCP6_MESSAGE_REPLY]               = "Reply",
+        [DHCP6_MESSAGE_RELEASE]             = "Release",
+        [DHCP6_MESSAGE_DECLINE]             = "Decline",
+        [DHCP6_MESSAGE_RECONFIGURE]         = "Reconfigure",
+        [DHCP6_MESSAGE_INFORMATION_REQUEST] = "Information Request",
+        [DHCP6_MESSAGE_RELAY_FORWARD]       = "Relay Forward",
+        [DHCP6_MESSAGE_RELAY_REPLY]         = "Relay Reply",
+        [DHCP6_MESSAGE_LEASE_QUERY]         = "Lease Query",
+        [DHCP6_MESSAGE_LEASE_QUERY_REPLY]   = "Lease Query Reply",
+        [DHCP6_MESSAGE_LEASE_QUERY_DONE]    = "Lease Query Done",
+        [DHCP6_MESSAGE_LEASE_QUERY_DATA]    = "Lease Query Data",
+        [DHCP6_MESSAGE_RECONFIGURE_REQUEST] = "Reconfigure Request",
+        [DHCP6_MESSAGE_RECONFIGURE_REPLY]   = "Reconfigure Reply",
+        [DHCP6_MESSAGE_DHCPV4_QUERY]        = "DHCPv4 Query",
+        [DHCP6_MESSAGE_DHCPV4_RESPONSE]     = "DHCPv4 Response",
+        [DHCP6_MESSAGE_ACTIVE_LEASE_QUERY]  = "Active Lease Query",
+        [DHCP6_MESSAGE_START_TLS]           = "Start TLS",
+        [DHCP6_MESSAGE_BINDING_UPDATE]      = "Binding Update",
+        [DHCP6_MESSAGE_BINDING_REPLY]       = "Binding Reply",
+        [DHCP6_MESSAGE_POOL_REQUEST]        = "Pool Request",
+        [DHCP6_MESSAGE_POOL_RESPONSE]       = "Pool Response",
+        [DHCP6_MESSAGE_UPDATE_REQUEST]      = "Update Request",
+        [DHCP6_MESSAGE_UPDATE_REQUEST_ALL]  = "Update Request All",
+        [DHCP6_MESSAGE_UPDATE_DONE]         = "Update Done",
+        [DHCP6_MESSAGE_CONNECT]             = "Connect",
+        [DHCP6_MESSAGE_CONNECT_REPLY]       = "Connect Reply",
+        [DHCP6_MESSAGE_DISCONNECT]          = "Disconnect",
+        [DHCP6_MESSAGE_STATE]               = "State",
+        [DHCP6_MESSAGE_CONTACT]             = "Contact",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType);
+
+static const char * const dhcp6_message_status_table[_DHCP6_STATUS_MAX] = {
+        [DHCP6_STATUS_SUCCESS]                      = "Success",
+        [DHCP6_STATUS_UNSPEC_FAIL]                  = "Unspecified failure",
+        [DHCP6_STATUS_NO_ADDRS_AVAIL]               = "No addresses available",
+        [DHCP6_STATUS_NO_BINDING]                   = "Binding unavailable",
+        [DHCP6_STATUS_NOT_ON_LINK]                  = "Not on link",
+        [DHCP6_STATUS_USE_MULTICAST]                = "Use multicast",
+        [DHCP6_STATUS_NO_PREFIX_AVAIL]              = "No prefix available",
+        [DHCP6_STATUS_UNKNOWN_QUERY_TYPE]           = "Unknown query type",
+        [DHCP6_STATUS_MALFORMED_QUERY]              = "Malformed query",
+        [DHCP6_STATUS_NOT_CONFIGURED]               = "Not configured",
+        [DHCP6_STATUS_NOT_ALLOWED]                  = "Not allowed",
+        [DHCP6_STATUS_QUERY_TERMINATED]             = "Query terminated",
+        [DHCP6_STATUS_DATA_MISSING]                 = "Data missing",
+        [DHCP6_STATUS_CATCHUP_COMPLETE]             = "Catch up complete",
+        [DHCP6_STATUS_NOT_SUPPORTED]                = "Not supported",
+        [DHCP6_STATUS_TLS_CONNECTION_REFUSED]       = "TLS connection refused",
+        [DHCP6_STATUS_ADDRESS_IN_USE]               = "Address in use",
+        [DHCP6_STATUS_CONFIGURATION_CONFLICT]       = "Configuration conflict",
+        [DHCP6_STATUS_MISSING_BINDING_INFORMATION]  = "Missing binding information",
+        [DHCP6_STATUS_OUTDATED_BINDING_INFORMATION] = "Outdated binding information",
+        [DHCP6_STATUS_SERVER_SHUTTING_DOWN]         = "Server shutting down",
+        [DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED]     = "DNS update not supported",
+        [DHCP6_STATUS_EXCESSIVE_TIME_SKEW]          = "Excessive time skew",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status);
index 5d2af439e280324deaea094b3afb280ab4b4853e..f4e47857e3e97137254f421bc380ad6ddd40a7e7 100644 (file)
@@ -28,8 +28,8 @@ typedef struct DHCP6Message DHCP6Message;
 #define DHCP6_MIN_OPTIONS_SIZE \
         1280 - sizeof(struct ip6_hdr) - sizeof(struct udphdr)
 
-#define IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT \
-        { { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+#define IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT                 \
+        { { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,           \
               0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02 } } }
 
 enum {
@@ -100,13 +100,15 @@ typedef enum DHCP6MessageType {
         DHCP6_MESSAGE_STATE                     = 34, /* RFC 8156 */
         DHCP6_MESSAGE_CONTACT                   = 35, /* RFC 8156 */
         _DHCP6_MESSAGE_TYPE_MAX,
-        _DHCP6_MESSAGE_TYPE_INVALID = -EINVAL,
+        _DHCP6_MESSAGE_TYPE_INVALID             = -EINVAL,
 } DHCP6MessageType;
 
 typedef enum DHCP6NTPSubOption {
         DHCP6_NTP_SUBOPTION_SRV_ADDR            = 1,
         DHCP6_NTP_SUBOPTION_MC_ADDR             = 2,
         DHCP6_NTP_SUBOPTION_SRV_FQDN            = 3,
+        _DHCP6_NTP_SUBOPTION_MAX,
+        _DHCP6_NTP_SUBOPTION_INVALID            = -EINVAL,
 } DHCP6NTPSubOption;
 
 /*
@@ -138,7 +140,7 @@ typedef enum DHCP6Status {
         DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED     = 21,
         DHCP6_STATUS_EXCESSIVE_TIME_SKEW          = 22,
         _DHCP6_STATUS_MAX,
-        _DHCP6_STATUS_INVALID = -EINVAL,
+        _DHCP6_STATUS_INVALID                     = -EINVAL,
 } DHCP6Status;
 
 typedef enum DHCP6FQDNFlag {
@@ -146,3 +148,9 @@ typedef enum DHCP6FQDNFlag {
         DHCP6_FQDN_FLAG_O = 1 << 1,
         DHCP6_FQDN_FLAG_N = 1 << 2,
 } DHCP6FQDNFlag;
+
+const char *dhcp6_state_to_string(DHCP6State s) _const_;
+const char *dhcp6_message_type_to_string(DHCP6MessageType s) _const_;
+DHCP6MessageType dhcp6_message_type_from_string(const char *s) _pure_;
+const char *dhcp6_message_status_to_string(DHCP6Status s) _const_;
+DHCP6Status dhcp6_message_status_from_string(const char *s) _pure_;
index a44e8c0824ea61821cddede5fc7461cd87845d8d..f82e2b257d4f3f7dfd2031aead82300692ce97be 100644 (file)
@@ -17,6 +17,8 @@ sources = files('''
         dhcp6-lease-internal.h
         dhcp6-network.c
         dhcp6-option.c
+        dhcp6-option.h
+        dhcp6-protocol.c
         dhcp6-protocol.h
         icmp6-util.c
         icmp6-util.h
index 4f92fd6b1ce801d47a3416184458c4abbf75d70f..bc76e026bd653209077ac782d643786f8984e675 100644 (file)
@@ -14,7 +14,6 @@
 #include "dhcp-identifier.h"
 #include "dhcp6-internal.h"
 #include "dhcp6-lease-internal.h"
-#include "dhcp6-protocol.h"
 #include "dns-domain.h"
 #include "event-util.h"
 #include "fd-util.h"
 #include "hostname-util.h"
 #include "in-addr-util.h"
 #include "io-util.h"
-#include "network-common.h"
 #include "random-util.h"
 #include "socket-util.h"
-#include "string-table.h"
 #include "strv.h"
-#include "util.h"
 #include "web-util.h"
 
 static const uint16_t default_req_opts[] = {
@@ -37,86 +33,6 @@ static const uint16_t default_req_opts[] = {
         SD_DHCP6_OPTION_SNTP_SERVERS,
 };
 
-static const char * const dhcp6_state_table[_DHCP6_STATE_MAX] = {
-        [DHCP6_STATE_STOPPED]             = "stopped",
-        [DHCP6_STATE_INFORMATION_REQUEST] = "information-request",
-        [DHCP6_STATE_SOLICITATION]        = "solicitation",
-        [DHCP6_STATE_REQUEST]             = "request",
-        [DHCP6_STATE_BOUND]               = "bound",
-        [DHCP6_STATE_RENEW]               = "renew",
-        [DHCP6_STATE_REBIND]              = "rebind",
-};
-
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State);
-
-static const char * const dhcp6_message_type_table[_DHCP6_MESSAGE_TYPE_MAX] = {
-        [DHCP6_MESSAGE_SOLICIT]             = "Solicit",
-        [DHCP6_MESSAGE_ADVERTISE]           = "Advertise",
-        [DHCP6_MESSAGE_REQUEST]             = "Request",
-        [DHCP6_MESSAGE_CONFIRM]             = "Confirm",
-        [DHCP6_MESSAGE_RENEW]               = "Renew",
-        [DHCP6_MESSAGE_REBIND]              = "Rebind",
-        [DHCP6_MESSAGE_REPLY]               = "Reply",
-        [DHCP6_MESSAGE_RELEASE]             = "Release",
-        [DHCP6_MESSAGE_DECLINE]             = "Decline",
-        [DHCP6_MESSAGE_RECONFIGURE]         = "Reconfigure",
-        [DHCP6_MESSAGE_INFORMATION_REQUEST] = "Information Request",
-        [DHCP6_MESSAGE_RELAY_FORWARD]       = "Relay Forward",
-        [DHCP6_MESSAGE_RELAY_REPLY]         = "Relay Reply",
-        [DHCP6_MESSAGE_LEASE_QUERY]         = "Lease Query",
-        [DHCP6_MESSAGE_LEASE_QUERY_REPLY]   = "Lease Query Reply",
-        [DHCP6_MESSAGE_LEASE_QUERY_DONE]    = "Lease Query Done",
-        [DHCP6_MESSAGE_LEASE_QUERY_DATA]    = "Lease Query Data",
-        [DHCP6_MESSAGE_RECONFIGURE_REQUEST] = "Reconfigure Request",
-        [DHCP6_MESSAGE_RECONFIGURE_REPLY]   = "Reconfigure Reply",
-        [DHCP6_MESSAGE_DHCPV4_QUERY]        = "DHCPv4 Query",
-        [DHCP6_MESSAGE_DHCPV4_RESPONSE]     = "DHCPv4 Response",
-        [DHCP6_MESSAGE_ACTIVE_LEASE_QUERY]  = "Active Lease Query",
-        [DHCP6_MESSAGE_START_TLS]           = "Start TLS",
-        [DHCP6_MESSAGE_BINDING_UPDATE]      = "Binding Update",
-        [DHCP6_MESSAGE_BINDING_REPLY]       = "Binding Reply",
-        [DHCP6_MESSAGE_POOL_REQUEST]        = "Pool Request",
-        [DHCP6_MESSAGE_POOL_RESPONSE]       = "Pool Response",
-        [DHCP6_MESSAGE_UPDATE_REQUEST]      = "Update Request",
-        [DHCP6_MESSAGE_UPDATE_REQUEST_ALL]  = "Update Request All",
-        [DHCP6_MESSAGE_UPDATE_DONE]         = "Update Done",
-        [DHCP6_MESSAGE_CONNECT]             = "Connect",
-        [DHCP6_MESSAGE_CONNECT_REPLY]       = "Connect Reply",
-        [DHCP6_MESSAGE_DISCONNECT]          = "Disconnect",
-        [DHCP6_MESSAGE_STATE]               = "State",
-        [DHCP6_MESSAGE_CONTACT]             = "Contact",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType);
-
-static const char * const dhcp6_message_status_table[_DHCP6_STATUS_MAX] = {
-        [DHCP6_STATUS_SUCCESS]                      = "Success",
-        [DHCP6_STATUS_UNSPEC_FAIL]                  = "Unspecified failure",
-        [DHCP6_STATUS_NO_ADDRS_AVAIL]               = "No addresses available",
-        [DHCP6_STATUS_NO_BINDING]                   = "Binding unavailable",
-        [DHCP6_STATUS_NOT_ON_LINK]                  = "Not on link",
-        [DHCP6_STATUS_USE_MULTICAST]                = "Use multicast",
-        [DHCP6_STATUS_NO_PREFIX_AVAIL]              = "No prefix available",
-        [DHCP6_STATUS_UNKNOWN_QUERY_TYPE]           = "Unknown query type",
-        [DHCP6_STATUS_MALFORMED_QUERY]              = "Malformed query",
-        [DHCP6_STATUS_NOT_CONFIGURED]               = "Not configured",
-        [DHCP6_STATUS_NOT_ALLOWED]                  = "Not allowed",
-        [DHCP6_STATUS_QUERY_TERMINATED]             = "Query terminated",
-        [DHCP6_STATUS_DATA_MISSING]                 = "Data missing",
-        [DHCP6_STATUS_CATCHUP_COMPLETE]             = "Catch up complete",
-        [DHCP6_STATUS_NOT_SUPPORTED]                = "Not supported",
-        [DHCP6_STATUS_TLS_CONNECTION_REFUSED]       = "TLS connection refused",
-        [DHCP6_STATUS_ADDRESS_IN_USE]               = "Address in use",
-        [DHCP6_STATUS_CONFIGURATION_CONFLICT]       = "Configuration conflict",
-        [DHCP6_STATUS_MISSING_BINDING_INFORMATION]  = "Missing binding information",
-        [DHCP6_STATUS_OUTDATED_BINDING_INFORMATION] = "Outdated binding information",
-        [DHCP6_STATUS_SERVER_SHUTTING_DOWN]         = "Server shutting down",
-        [DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED]     = "DNS update not supported",
-        [DHCP6_STATUS_EXCESSIVE_TIME_SKEW]          = "Excessive time skew",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status);
-
 #define DHCP6_CLIENT_DONT_DESTROY(client) \
         _cleanup_(sd_dhcp6_client_unrefp) _unused_ sd_dhcp6_client *_dont_destroy_##client = sd_dhcp6_client_ref(client)
 
index 8b8c2312ea1bd4c3f80cc0e7039409ae0143b77c..90adad16a6a0165c30f3893f52d38245e88cb0a8 100644 (file)
@@ -6,10 +6,9 @@
 #include <errno.h>
 
 #include "alloc-util.h"
+#include "dhcp6-internal.h"
 #include "dhcp6-lease-internal.h"
-#include "dhcp6-protocol.h"
 #include "strv.h"
-#include "util.h"
 
 #define IRT_DEFAULT (1 * USEC_PER_DAY)
 #define IRT_MINIMUM (600 * USEC_PER_SEC)