diff options
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r-- | src/network/networkd-network.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index c39ba6dfa2..9ebc2d15aa 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -626,7 +626,7 @@ int config_parse_llmnr( assert(filename); assert(lvalue); assert(rvalue); - assert(data); + assert(llmnr); /* Our enum shall be a superset of booleans, hence first try * to parse as boolean, and then as enum */ @@ -650,3 +650,46 @@ int config_parse_llmnr( return 0; } + +int config_parse_token( + 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) { + + union in_addr_union buffer; + struct in6_addr *token = data; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(token); + + r = in_addr_from_string(AF_INET6, rvalue, &buffer); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse IPv6 token, ignoring: %s", rvalue); + return 0; + } + + r = in_addr_is_null(AF_INET6, &buffer); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, -r, "IPv6 token canno t be the ANY address, ignoring: %s", rvalue); + return 0; + } + + if ((buffer.in6.s6_addr32[0] | buffer.in6.s6_addr32[1]) != 0) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "IPv6 token canno t be longer than 64 bits, ignoring: %s", rvalue); + return 0; + } + + *token = buffer.in6; + + return 0; +} |