summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-08 23:20:56 +0100
committerTom Gundersen <teg@jklm.no>2015-02-09 12:20:10 +0100
commit7f77697a1744f8df2089848b9d718faf7ba6c665 (patch)
tree294907c72f1008bfe7189e81ec27e8a4bae0131c /src/network/networkd-network.c
parentd0d6a4cd70477970812bff0a37e70f66208d7c14 (diff)
networkd: add support for IPv6 tokens
This allows the admin to set the host-specific part of IPv6 addresses, but still receive the prefix via SLAAC. .network file snippet: [Network] IPv6Token=::12 gives: $ ip token token ::12 dev eth0 This closes https://bugs.freedesktop.org/show_bug.cgi?id=81177.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c45
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;
+}