diff options
author | Daniel Mack <github@zonque.org> | 2015-07-05 13:08:13 -0400 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-07-05 13:08:13 -0400 |
commit | b5070ab9d0956ac3482262b17b20696b0f24622f (patch) | |
tree | 7dd0f682ab653b3442902019264235af452421b4 /src/network/networkd-network.c | |
parent | 604f02add68c10232876a868c2f04b77cdcefee0 (diff) | |
parent | a521dbf43be0a0ae4f3ec0db3b65b559834e9232 (diff) |
Merge pull request #417 from ssahani/ipv6-private
Ipv6 private extensions
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r-- | src/network/networkd-network.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index ec95c8661e..ddf03e67f9 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -111,6 +111,8 @@ static int network_load_one(Manager *manager, const char *filename) { network->link_local = ADDRESS_FAMILY_IPV6; + network->ipv6_privacy_extensions = _IPV6_PRIVACY_EXTENSIONS_INVALID; + r = config_parse(NULL, filename, file, "Match\0" "Link\0" @@ -751,3 +753,54 @@ int config_parse_address_family_boolean_with_kernel( return 0; } + +static const char* const ipv6_privacy_extensions_table[_IPV6_PRIVACY_EXTENSIONS_MAX] = { + [IPV6_PRIVACY_EXTENSIONS_DISABLE] = "no", + [IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC] = "yes", + [IPV6_PRIVACY_EXTENSIONS_PREFER_TEMPORARY] = "prefer-temporary", +}; + +DEFINE_STRING_TABLE_LOOKUP(ipv6_privacy_extensions, IPv6PrivacyExtensions); + +int config_parse_ipv6_privacy_extensions( + 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) { + + IPv6PrivacyExtensions *ipv6_privacy_extensions = data; + int k; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(ipv6_privacy_extensions); + + /* 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) + *ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC; + else if (k == 0) + *ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_DISABLE; + else { + IPv6PrivacyExtensions s; + + s = ipv6_privacy_extensions_from_string(rvalue); + if (s < 0){ + log_syntax(unit, LOG_ERR, filename, line, -s, "Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue); + return 0; + } + + *ipv6_privacy_extensions = s; + } + + return 0; +} |