]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp-identifier: introduce duid_type_to_string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Feb 2022 06:08:27 +0000 (15:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 05:58:49 +0000 (14:58 +0900)
src/libsystemd-network/dhcp-identifier.c
src/libsystemd-network/dhcp-identifier.h
src/libsystemd-network/sd-dhcp6-client.c

index 4f02022cd36daf17bbc4d39261c8b5ef8096d3a4..313d0a43f1fa30cac554777443b524c16aa0f46f 100644 (file)
@@ -8,19 +8,26 @@
 #include "sd-id128.h"
 
 #include "dhcp-identifier.h"
-#include "dhcp6-protocol.h"
 #include "netif-util.h"
 #include "siphash24.h"
 #include "sparse-endian.h"
 #include "stat-util.h"
-#include "stdio-util.h"
+#include "string-table.h"
 #include "udev-util.h"
-#include "virt.h"
 
 #define HASH_KEY       SD_ID128_MAKE(80,11,8c,c2,fe,4a,03,ee,3e,d6,0c,6f,36,39,14,09)
 #define APPLICATION_ID SD_ID128_MAKE(a5,0a,d1,12,bf,60,45,77,a2,fb,74,1a,b1,95,5b,03)
 #define USEC_2000       ((usec_t) 946684800000000) /* 2000-01-01 00:00:00 UTC */
 
+static const char * const duid_type_table[_DUID_TYPE_MAX] = {
+        [DUID_TYPE_LLT]  = "DUID-LLT",
+        [DUID_TYPE_EN]   = "DUID-EN/Vendor",
+        [DUID_TYPE_LL]   = "DUID-LL",
+        [DUID_TYPE_UUID] = "UUID",
+};
+
+DEFINE_STRING_TABLE_LOOKUP_TO_STRING(duid_type, DUIDType);
+
 int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len, bool strict) {
         struct duid d;
 
index 6c24af0326a6d4766f697cc99b58d0cf5f3e463e..31a96b20b39ce4a1a6b72090c6d3c54798c59d54 100644 (file)
@@ -60,3 +60,5 @@ int dhcp_identifier_set_duid_ll(struct duid *duid, const uint8_t *addr, size_t a
 int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
 int dhcp_identifier_set_duid_uuid(struct duid *duid, size_t *len);
 int dhcp_identifier_set_iaid(int ifindex, const uint8_t *mac, size_t mac_len, bool legacy_unstable_byteorder, bool use_mac, void *_id);
+
+const char *duid_type_to_string(DUIDType t) _const_;
index 1d1e2633063367e36a5661950908a0b39a889a55..1ae7a03728318a5ce6896fc2201ba6ebfba6d482 100644 (file)
@@ -353,14 +353,6 @@ int sd_dhcp6_client_set_duid_llt(
         return dhcp6_client_set_duid_internal(client, DUID_TYPE_LLT, NULL, 0, llt_time);
 }
 
-static const char* const dhcp6_duid_type_table[_DUID_TYPE_MAX] = {
-        [DUID_TYPE_LLT]  = "DUID-LLT",
-        [DUID_TYPE_EN]   = "DUID-EN/Vendor",
-        [DUID_TYPE_LL]   = "DUID-LL",
-        [DUID_TYPE_UUID] = "UUID",
-};
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_duid_type, DUIDType);
-
 int sd_dhcp6_client_duid_as_string(
                 sd_dhcp6_client *client,
                 char **duid) {
@@ -372,7 +364,7 @@ int sd_dhcp6_client_duid_as_string(
         assert_return(client->duid_len > 0, -ENODATA);
         assert_return(duid, -EINVAL);
 
-        v = dhcp6_duid_type_to_string(be16toh(client->duid.type));
+        v = duid_type_to_string(be16toh(client->duid.type));
         if (v) {
                 s = strdup(v);
                 if (!s)