]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-network: make LLMNR specific config parser generic
authorDaniel Mack <daniel@zonque.org>
Tue, 28 Jul 2015 13:00:59 +0000 (15:00 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 25 Aug 2015 12:26:01 +0000 (14:26 +0200)
Rename the enum, the lookup functions and the parser for LLMNRSupport so
the type can be reused for mDNS.

src/network/networkd-link.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd.h

index 91b9cdf30d40f6ee97084e6990f4ad2b9c184f72..cc9dc393c6a61af478bd728caee25c0d4aee413b 100644 (file)
@@ -2378,7 +2378,7 @@ int link_save(Link *link) {
                         yes_no(link->network->wildcard_domain));
 
                 fprintf(f, "LLMNR=%s\n",
-                        llmnr_support_to_string(link->network->llmnr));
+                        resolve_support_to_string(link->network->llmnr));
         }
 
         if (!hashmap_isempty(link->bound_to_links)) {
index 8735b395812db442b1a9a2570f4491631c42c4a9..7ac7ef1ea3a2342b6f209c89c8940f7c3f9580f1 100644 (file)
@@ -45,7 +45,7 @@ Network.Address,               config_parse_address,                           0
 Network.Gateway,               config_parse_gateway,                           0,                             0
 Network.Domains,               config_parse_domains,                           0,                             offsetof(Network, domains)
 Network.DNS,                   config_parse_strv,                              0,                             offsetof(Network, dns)
-Network.LLMNR,                 config_parse_llmnr,                             0,                             offsetof(Network, llmnr)
+Network.LLMNR,                 config_parse_resolve,                           0,                             offsetof(Network, llmnr)
 Network.NTP,                   config_parse_strv,                              0,                             offsetof(Network, ntp)
 Network.IPForward,             config_parse_address_family_boolean_with_kernel,0,                             offsetof(Network, ip_forward)
 Network.IPMasquerade,          config_parse_bool,                              0,                             offsetof(Network, ip_masquerade)
index 3f7e77da3eef451b84e8c0537a8852bef73a6574..6587ea994cf6536b21bc5074087501c7b1764b8d 100644 (file)
@@ -111,7 +111,7 @@ static int network_load_one(Manager *manager, const char *filename) {
         network->allow_port_to_be_root = true;
         network->unicast_flood = true;
 
-        network->llmnr = LLMNR_SUPPORT_YES;
+        network->llmnr = RESOLVE_SUPPORT_YES;
 
         network->link_local = ADDRESS_FAMILY_IPV6;
 
@@ -632,15 +632,15 @@ static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_client_identifier, DCHPClientIdentifier);
 DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_client_identifier, dhcp_client_identifier, DCHPClientIdentifier, "Failed to parse client identifier type");
 
-static const char* const llmnr_support_table[_LLMNR_SUPPORT_MAX] = {
-        [LLMNR_SUPPORT_NO] = "no",
-        [LLMNR_SUPPORT_YES] = "yes",
-        [LLMNR_SUPPORT_RESOLVE] = "resolve",
+static const char* const resolve_support_table[_RESOLVE_SUPPORT_MAX] = {
+        [RESOLVE_SUPPORT_NO] = "no",
+        [RESOLVE_SUPPORT_YES] = "yes",
+        [RESOLVE_SUPPORT_RESOLVE] = "resolve",
 };
 
-DEFINE_STRING_TABLE_LOOKUP(llmnr_support, LLMNRSupport);
+DEFINE_STRING_TABLE_LOOKUP(resolve_support, ResolveSupport);
 
-int config_parse_llmnr(
+int config_parse_resolve(
                 const char* unit,
                 const char *filename,
                 unsigned line,
@@ -652,32 +652,32 @@ int config_parse_llmnr(
                 void *data,
                 void *userdata) {
 
-        LLMNRSupport *llmnr = data;
+        ResolveSupport *resolve = data;
         int k;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
-        assert(llmnr);
+        assert(resolve);
 
         /* Our enum shall be a superset of booleans, hence first try
          * to parse as boolean, and then as enum */
 
         k = parse_boolean(rvalue);
         if (k > 0)
-                *llmnr = LLMNR_SUPPORT_YES;
+                *resolve = RESOLVE_SUPPORT_YES;
         else if (k == 0)
-                *llmnr = LLMNR_SUPPORT_NO;
+                *resolve = RESOLVE_SUPPORT_NO;
         else {
-                LLMNRSupport s;
+                ResolveSupport s;
 
-                s = llmnr_support_from_string(rvalue);
+                s = resolve_support_from_string(rvalue);
                 if (s < 0){
-                        log_syntax(unit, LOG_ERR, filename, line, -s, "Failed to parse LLMNR option, ignoring: %s", rvalue);
+                        log_syntax(unit, LOG_ERR, filename, line, -s, "Failed to parse %s option, ignoring: %s", lvalue, rvalue);
                         return 0;
                 }
 
-                *llmnr = s;
+                *resolve = s;
         }
 
         return 0;
index a285a4b08ff86a75650dccb5357edb563f2e5a0e..5340922bf1479cd43bc8e6de5776db8eceec1eed 100644 (file)
@@ -64,13 +64,13 @@ typedef enum AddressFamilyBoolean {
         _ADDRESS_FAMILY_BOOLEAN_INVALID = -1,
 } AddressFamilyBoolean;
 
-typedef enum LLMNRSupport {
-        LLMNR_SUPPORT_NO,
-        LLMNR_SUPPORT_YES,
-        LLMNR_SUPPORT_RESOLVE,
-        _LLMNR_SUPPORT_MAX,
-        _LLMNR_SUPPORT_INVALID = -1,
-} LLMNRSupport;
+typedef enum ResolveSupport {
+        RESOLVE_SUPPORT_NO,
+        RESOLVE_SUPPORT_YES,
+        RESOLVE_SUPPORT_RESOLVE,
+        _RESOLVE_SUPPORT_MAX,
+        _RESOLVE_SUPPORT_INVALID = -1,
+} ResolveSupport;
 
 typedef enum LinkOperationalState {
         LINK_OPERSTATE_OFF,
@@ -178,7 +178,7 @@ struct Network {
         bool wildcard_domain;
         char **domains, **dns, **ntp, **bind_carrier;
 
-        LLMNRSupport llmnr;
+        ResolveSupport llmnr;
 
         LIST_FIELDS(Network, networks);
 };
@@ -421,14 +421,14 @@ int config_parse_ipv6token(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);
 
-/* LLMNR support */
+/* Resolve protocols support */
 
-const char* llmnr_support_to_string(LLMNRSupport i) _const_;
-LLMNRSupport llmnr_support_from_string(const char *s) _pure_;
+const char* resolve_support_to_string(ResolveSupport i) _const_;
+ResolveSupport resolve_support_from_string(const char *s) _pure_;
 
-int config_parse_llmnr(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);
+int config_parse_resolve(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);
 
 /* Address Pool */