]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: rename DHCPRawOption to DHCPOptionDataType
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 Nov 2019 13:59:58 +0000 (22:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 Nov 2019 14:00:11 +0000 (23:00 +0900)
And moves the definition from networkd-dhcp-server.[ch] to networkd-dhcp-common.[ch].

src/network/networkd-dhcp-common.c
src/network/networkd-dhcp-common.h
src/network/networkd-dhcp-server.c
src/network/networkd-dhcp-server.h

index bbf10affc4561136e32d08cc53dac0820192a5ff..7e42a6edd47de6fdf339d06e6e7cbabfd13d7262 100644 (file)
@@ -273,3 +273,13 @@ static const char* const dhcp_use_domains_table[_DHCP_USE_DOMAINS_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dhcp_use_domains, DHCPUseDomains, DHCP_USE_DOMAINS_YES);
+
+static const char * const dhcp_option_data_type_table[_DHCP_OPTION_DATA_MAX] = {
+        [DHCP_OPTION_DATA_UINT8]       = "uint8",
+        [DHCP_OPTION_DATA_UINT16]      = "uint16",
+        [DHCP_OPTION_DATA_UINT32]      = "uint32",
+        [DHCP_OPTION_DATA_STRING]      = "string",
+        [DHCP_OPTION_DATA_IPV4ADDRESS] = "ipv4address",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType);
index 8f280190b9978bbe1efd8464b782389fcd9bd78f..b194e0bfb785c743e6eb96111f1a35214e010faf 100644 (file)
@@ -15,6 +15,16 @@ typedef enum DHCPUseDomains {
         _DHCP_USE_DOMAINS_INVALID = -1,
 } DHCPUseDomains;
 
+typedef enum DHCPOptionDataType {
+        DHCP_OPTION_DATA_UINT8,
+        DHCP_OPTION_DATA_UINT16,
+        DHCP_OPTION_DATA_UINT32,
+        DHCP_OPTION_DATA_STRING,
+        DHCP_OPTION_DATA_IPV4ADDRESS,
+        _DHCP_OPTION_DATA_MAX,
+        _DHCP_OPTION_DATA_INVALID,
+} DHCPOptionDataType;
+
 typedef struct DUID {
         /* Value of Type in [DHCP] section */
         DUIDType type;
@@ -27,6 +37,9 @@ typedef struct DUID {
 const char* dhcp_use_domains_to_string(DHCPUseDomains p) _const_;
 DHCPUseDomains dhcp_use_domains_from_string(const char *s) _pure_;
 
+const char *dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
+DHCPOptionDataType dhcp_option_data_type_from_string(const char *d) _pure_;
+
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_dns);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains);
index f1a971c621b753bce758de83069fadcf1d50e3dc..79ac325926233a60e7b0aa25dfebeef2d35a1673 100644 (file)
@@ -480,16 +480,6 @@ int config_parse_dhcp_server_sip(
         }
 }
 
-static const char * const dhcp_raw_option_data_type_table[_DHCP_RAW_OPTION_DATA_MAX] = {
-        [DHCP_RAW_OPTION_DATA_UINT8]      = "uint8",
-        [DHCP_RAW_OPTION_DATA_UINT16]     = "uint16",
-        [DHCP_RAW_OPTION_DATA_UINT32]     = "uint32",
-        [DHCP_RAW_OPTION_DATA_STRING]     = "string",
-        [DHCP_RAW_OPTION_DATA_IPV4ADDRESS] = "ipv4address",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(dhcp_raw_option_data_type, DHCPRawOption);
-
 int config_parse_dhcp_server_raw_option_data(
                 const char *unit,
                 const char *filename,
@@ -505,11 +495,11 @@ int config_parse_dhcp_server_raw_option_data(
         _cleanup_(sd_dhcp_raw_option_unrefp) sd_dhcp_raw_option *opt = NULL, *old = NULL;
         _cleanup_free_ char *word = NULL, *q = NULL;
         union in_addr_union addr;
+        DHCPOptionDataType type;
         Network *network = data;
         uint16_t uint16_data;
         uint32_t uint32_data;
         uint8_t uint8_data;
-        DHCPRawOption type;
         const char *p;
         void *udata;
         ssize_t sz;
@@ -559,7 +549,7 @@ int config_parse_dhcp_server_raw_option_data(
                 return 0;
         }
 
-        type = dhcp_raw_option_data_type_from_string(word);
+        type = dhcp_option_data_type_from_string(word);
         if (type < 0) {
                 log_syntax(unit, LOG_ERR, filename, line, 0,
                            "Invalid DHCP server send data type, ignoring assignment: %s", p);
@@ -567,7 +557,7 @@ int config_parse_dhcp_server_raw_option_data(
         }
 
         switch(type) {
-        case DHCP_RAW_OPTION_DATA_UINT8:{
+        case DHCP_OPTION_DATA_UINT8:{
                 r = safe_atou8(p, &uint8_data);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r,
@@ -579,7 +569,7 @@ int config_parse_dhcp_server_raw_option_data(
                 sz = sizeof(uint8_t);
                 break;
         }
-        case DHCP_RAW_OPTION_DATA_UINT16:{
+        case DHCP_OPTION_DATA_UINT16:{
                 r = safe_atou16(p, &uint16_data);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r,
@@ -591,7 +581,7 @@ int config_parse_dhcp_server_raw_option_data(
                 sz = sizeof(uint16_t);
                 break;
         }
-        case DHCP_RAW_OPTION_DATA_UINT32: {
+        case DHCP_OPTION_DATA_UINT32: {
                 r = safe_atou32(p, &uint32_data);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r,
@@ -604,7 +594,7 @@ int config_parse_dhcp_server_raw_option_data(
 
                 break;
         }
-        case DHCP_RAW_OPTION_DATA_IPV4ADDRESS: {
+        case DHCP_OPTION_DATA_IPV4ADDRESS: {
                 r = in_addr_from_string(AF_INET, p, &addr);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r,
@@ -616,7 +606,7 @@ int config_parse_dhcp_server_raw_option_data(
                 sz = sizeof(addr.in.s_addr);
                 break;
         }
-        case DHCP_RAW_OPTION_DATA_STRING:
+        case DHCP_OPTION_DATA_STRING:
                 sz = cunescape(p, 0, &q);
                 if (sz < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, sz,
index c30162dd5b6a79da160264058a57344b036ef3e5..e0a7799b1c0956430082523b1e90d57c15edd779 100644 (file)
@@ -7,19 +7,6 @@
 
 typedef struct Link Link;
 
-typedef enum DHCPRawOption {
-        DHCP_RAW_OPTION_DATA_UINT8,
-        DHCP_RAW_OPTION_DATA_UINT16,
-        DHCP_RAW_OPTION_DATA_UINT32,
-        DHCP_RAW_OPTION_DATA_STRING,
-        DHCP_RAW_OPTION_DATA_IPV4ADDRESS,
-        _DHCP_RAW_OPTION_DATA_MAX,
-        _DHCP_RAW_OPTION_DATA_INVALID,
-} DHCPRawOption;
-
-const char *dhcp_raw_option_data_type_to_string(DHCPRawOption d) _const_;
-DHCPRawOption dhcp_raw_option_data_type_from_string(const char *d) _pure_;
-
 int dhcp4_server_configure(Link *link);
 
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_dns);