]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: move DHCPv6 related conf parsers to networkd-dhcp6.c
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Jun 2020 04:18:22 +0000 (13:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Jun 2020 08:06:00 +0000 (17:06 +0900)
src/network/networkd-dhcp-common.c
src/network/networkd-dhcp-common.h
src/network/networkd-dhcp6.c
src/network/networkd-dhcp6.h
src/network/networkd-network-gperf.gperf

index 9b30764c81fdaf656a9ed8dc5c7d5b2b5a01fe2a..cc0a490b1d1b54e8efa7252a10cebb45603dece7 100644 (file)
@@ -9,7 +9,6 @@
 #include "parse-util.h"
 #include "string-table.h"
 #include "strv.h"
-#include "web-util.h"
 
 int config_parse_dhcp(
                 const char* unit,
@@ -296,41 +295,6 @@ int config_parse_iaid(const char *unit,
         return 0;
 }
 
-int config_parse_dhcp6_pd_hint(
-                const char* unit,
-                const char *filename,
-                unsigned line,
-                const char *section,
-                unsigned section_line,
-                const char *lvalue,
-                int ltype,
-                const char *rvalue,
-                void *data,
-                void *userdata) {
-
-        Network *network = data;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
-        if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
-                return 0;
-        }
-
-        if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) {
-                log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
-                network->dhcp6_pd_length = 0;
-                return 0;
-        }
-
-        return 0;
-}
-
 int config_parse_dhcp_user_class(
                 const char *unit,
                 const char *filename,
@@ -446,47 +410,6 @@ int config_parse_dhcp_vendor_class(
         return 0;
 }
 
-int config_parse_dhcp6_mud_url(
-                const char *unit,
-                const char *filename,
-                unsigned line,
-                const char *section,
-                unsigned section_line,
-                const char *lvalue,
-                int ltype,
-                const char *rvalue,
-                void *data,
-                void *userdata) {
-        _cleanup_free_ char *unescaped = NULL;
-        Network *network = data;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-
-        if (isempty(rvalue)) {
-                network->dhcp6_mudurl = mfree(network->dhcp6_mudurl);
-                return 0;
-        }
-
-        r = cunescape(rvalue, 0, &unescaped);
-        if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
-                           "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
-                return 0;
-        }
-
-        if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
-                log_syntax(unit, LOG_ERR, filename, line, 0,
-                           "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
-
-                return 0;
-        }
-
-        return free_and_replace(network->dhcp6_mudurl, unescaped);
-}
-
 int config_parse_dhcp_send_option(
                 const char *unit,
                 const char *filename,
index dd574f1d569933192ceb92b446eaafbf217e38f0..2be9abba62c082c723b60f8ec9b1bac5fe0ae6a0 100644 (file)
@@ -49,8 +49,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_ntp);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_sip);
 CONFIG_PARSER_PROTOTYPE(config_parse_iaid);
 CONFIG_PARSER_PROTOTYPE(config_parse_section_route_table);
-CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
-CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_class);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_vendor_class);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_option);
index 6a1083fd5c96f91b46f08df4ea9e43b704e18fdd..f86fdc2103611f1af4f18c710f6cde21416c8cac 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "sd-dhcp6-client.h"
 
+#include "escape.h"
 #include "hashmap.h"
 #include "hostname-util.h"
 #include "missing_network.h"
@@ -20,6 +21,7 @@
 #include "siphash24.h"
 #include "string-util.h"
 #include "radv-internal.h"
+#include "web-util.h"
 
 static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link);
 static Link *dhcp6_prefix_get(Manager *m, struct in6_addr *addr);
@@ -1077,3 +1079,79 @@ static int dhcp6_assign_delegated_prefix(Link *link,
 
         return 0;
 }
+
+int config_parse_dhcp6_pd_hint(
+                const char* unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        Network *network = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
+                return 0;
+        }
+
+        if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) {
+                log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
+                network->dhcp6_pd_length = 0;
+                return 0;
+        }
+
+        return 0;
+}
+
+int config_parse_dhcp6_mud_url(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+        _cleanup_free_ char *unescaped = NULL;
+        Network *network = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        if (isempty(rvalue)) {
+                network->dhcp6_mudurl = mfree(network->dhcp6_mudurl);
+                return 0;
+        }
+
+        r = cunescape(rvalue, 0, &unescaped);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
+                log_syntax(unit, LOG_ERR, filename, line, 0,
+                           "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
+
+                return 0;
+        }
+
+        return free_and_replace(network->dhcp6_mudurl, unescaped);
+}
index 26d810f40c35a6a0f5fcad6ea906d794bfdf56b0..e7c180897bff86047b738bb0feea41bd7066be5e 100644 (file)
@@ -13,3 +13,6 @@ int dhcp6_configure(Link *link);
 int dhcp6_request_address(Link *link, int ir);
 int dhcp6_lease_pd_prefix_lost(sd_dhcp6_client *client, Link* link);
 int dhcp6_prefix_remove(Manager *m, struct in6_addr *addr);
+
+CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
+CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
index c6b9cb8ddcfb115018651058a452e84891211436..b3dde3bfac6b424b90971c900d00d3d2c3a2f0e0 100644 (file)
@@ -11,6 +11,7 @@ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
 #include "networkd-dhcp-common.h"
 #include "networkd-dhcp-server.h"
 #include "networkd-dhcp4.h"
+#include "networkd-dhcp6.h"
 #include "networkd-ipv4ll.h"
 #include "networkd-ndisc.h"
 #include "networkd-network.h"