]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: move config_parse_ifalias()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Oct 2020 14:55:19 +0000 (23:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 29 Oct 2020 05:23:49 +0000 (14:23 +0900)
src/libsystemd-network/network-internal.c
src/libsystemd-network/network-internal.h
src/udev/net/link-config.c
src/udev/net/link-config.h

index f6e836e3997a39788affda0da907859d1ecc6044..96aeea3cbdc425bde7c76b5bde64bbfc4573482a 100644 (file)
@@ -24,7 +24,6 @@
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
-#include "utf8.h"
 #include "util.h"
 
 const char *net_get_name_persistent(sd_device *device) {
@@ -486,47 +485,6 @@ int config_parse_match_property(
         }
 }
 
-int config_parse_ifalias(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) {
-
-        char **s = data;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        if (!isempty(rvalue)) {
-                *s = mfree(*s);
-                return 0;
-        }
-
-        if (!ascii_is_valid(rvalue)) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Interface alias is not ASCII clean, ignoring assignment: %s", rvalue);
-                return 0;
-        }
-
-        if (strlen(rvalue) >= IFALIASZ) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Interface alias is too long, ignoring assignment: %s", rvalue);
-                return 0;
-        }
-
-        if (free_and_strdup(s, rvalue) < 0)
-                return log_oom();
-
-        return 0;
-}
-
 int config_parse_hwaddr(const char *unit,
                         const char *filename,
                         unsigned line,
index 170117e9007a18f9ca20c2543b67b6a3de4a5927..7f6ddae7391f990dcb724471bd2b01c7db508776 100644 (file)
@@ -39,7 +39,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_hwaddrs);
 CONFIG_PARSER_PROTOTYPE(config_parse_match_strv);
 CONFIG_PARSER_PROTOTYPE(config_parse_match_ifnames);
 CONFIG_PARSER_PROTOTYPE(config_parse_match_property);
-CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
 
 int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *result);
 const char *net_get_name_persistent(sd_device *device);
index c23c2bdd2057624f4ed66d6b5f63d02ee6983552..fe542ca8a5becc17505826259c28818a816fe6d5 100644 (file)
@@ -30,6 +30,7 @@
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
+#include "utf8.h"
 
 struct link_config_ctx {
         LIST_HEAD(link_config, links);
@@ -661,6 +662,48 @@ int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret) {
         return 0;
 }
 
+int config_parse_ifalias(
+                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) {
+
+        char **s = data;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        if (!isempty(rvalue)) {
+                *s = mfree(*s);
+                return 0;
+        }
+
+        if (!ascii_is_valid(rvalue)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Interface alias is not ASCII clean, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if (strlen(rvalue) >= IFALIASZ) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Interface alias is too long, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if (free_and_strdup(s, rvalue) < 0)
+                return log_oom();
+
+        return 0;
+}
+
 static const char* const mac_address_policy_table[_MAC_ADDRESS_POLICY_MAX] = {
         [MAC_ADDRESS_POLICY_PERSISTENT] = "persistent",
         [MAC_ADDRESS_POLICY_RANDOM] = "random",
index 8b5801c003fd15070099b64df7dab10980fd0021..8bed27e272fd78567a7a4148f3a8a57ec1ada725 100644 (file)
@@ -93,6 +93,7 @@ MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
 /* gperf lookup function */
 const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
 
+CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
 CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
 CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);