summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-13 19:48:19 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-13 20:17:06 +0100
commitcb9fc36a1211967e8c58b0502a26c42552ac8060 (patch)
tree6693e9724db113f07fb6655e13f0c7780779d9c3 /src/network/networkd-network.c
parent66518acd40fbd99a87e553b2d0904c37c8929fb2 (diff)
networkd: introduce an AddressFamilyBoolean enum type
This introduces am AddressFamilyBoolean type that works more or less like a booleaan, but can optionally turn on/off things for ipv4 and ipv6 independently. THis also ports the DHCP field over to it.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index d6504cc178..98f199ad72 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -84,7 +84,7 @@ static int network_load_one(Manager *manager, const char *filename) {
if (!network->filename)
return log_oom();
- network->dhcp = DHCP_SUPPORT_NONE;
+ network->dhcp = ADDRESS_FAMILY_NO;
network->dhcp_ntp = true;
network->dhcp_dns = true;
network->dhcp_hostname = true;
@@ -470,15 +470,6 @@ int config_parse_tunnel(const char *unit,
return 0;
}
-static const char* const dhcp_support_table[_DHCP_SUPPORT_MAX] = {
- [DHCP_SUPPORT_NONE] = "none",
- [DHCP_SUPPORT_BOTH] = "both",
- [DHCP_SUPPORT_V4] = "v4",
- [DHCP_SUPPORT_V6] = "v6",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(dhcp_support, DHCPSupport);
-
int config_parse_dhcp(
const char* unit,
const char *filename,
@@ -491,34 +482,34 @@ int config_parse_dhcp(
void *data,
void *userdata) {
- DHCPSupport *dhcp = data;
- int k;
+ AddressFamilyBoolean *dhcp = data, s;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
- /* 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)
- *dhcp = DHCP_SUPPORT_BOTH;
- else if (k == 0)
- *dhcp = DHCP_SUPPORT_NONE;
- else {
- DHCPSupport s;
-
- s = dhcp_support_from_string(rvalue);
- if (s < 0){
- log_syntax(unit, LOG_ERR, filename, line, -s, "Failed to parse DHCP option, ignoring: %s", rvalue);
+ s = address_family_boolean_from_string(rvalue);
+ if (s < 0) {
+
+ /* Previously, we had a slightly different enum here,
+ * support its values for compatbility. */
+
+ if (streq(rvalue, "none"))
+ s = ADDRESS_FAMILY_NO;
+ else if (streq(rvalue, "v4"))
+ s = ADDRESS_FAMILY_IPV4;
+ else if (streq(rvalue, "v6"))
+ s = ADDRESS_FAMILY_IPV6;
+ else if (streq(rvalue, "both"))
+ s = ADDRESS_FAMILY_YES;
+ else {
+ log_syntax(unit, LOG_ERR, filename, line, s, "Failed to parse DHCP option, ignoring: %s", rvalue);
return 0;
}
-
- *dhcp = s;
}
+ *dhcp = s;
return 0;
}