diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2015-07-06 15:00:12 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2015-08-21 11:23:22 +0300 |
commit | 07bdc70d1685ded36a910c16502a1ee57ebb540c (patch) | |
tree | a0e38729385f26135f9aafb863d27f771aeeb034 /src/network/networkd-link.c | |
parent | b729fa14aa118d4c7cd6846ff66d8cf1e885d900 (diff) |
network: Save DNS and NTP data for a DHCPv6 link
Append DNS and NTP data obtained via DHCPv6 when the Link is saved.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r-- | src/network/networkd-link.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 78e96c4e5b..91b9cdf30d 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2240,6 +2240,14 @@ int link_save(Link *link) { if (link->network) { char **address, **domain; bool space; + sd_dhcp6_lease *dhcp6_lease = NULL; + + if (link->dhcp6_client) { + r = sd_dhcp6_client_get_lease(link->dhcp6_client, + &dhcp6_lease); + if (r < 0) + log_link_debug(link, "No DHCPv6 lease"); + } fprintf(f, "NETWORK_FILE=%s\n", link->network->filename); @@ -2261,6 +2269,19 @@ int link_save(Link *link) { if (space) fputc(' ', f); serialize_in_addrs(f, addresses, r); + space = true; + } + } + + if (link->network->dhcp_dns && dhcp6_lease) { + struct in6_addr *in6_addrs; + + r = sd_dhcp6_lease_get_dns(dhcp6_lease, &in6_addrs); + if (r > 0) { + if (space) + fputc(' ', f); + serialize_in6_addrs(f, in6_addrs, r); + space = true; } } @@ -2284,6 +2305,32 @@ int link_save(Link *link) { if (space) fputc(' ', f); serialize_in_addrs(f, addresses, r); + space = true; + } + } + + if (link->network->dhcp_ntp && dhcp6_lease) { + struct in6_addr *in6_addrs; + char **hosts; + char **hostname; + + r = sd_dhcp6_lease_get_ntp_addrs(dhcp6_lease, + &in6_addrs); + if (r > 0) { + if (space) + fputc(' ', f); + serialize_in6_addrs(f, in6_addrs, r); + space = true; + } + + r = sd_dhcp6_lease_get_ntp_fqdn(dhcp6_lease, &hosts); + if (r > 0) { + STRV_FOREACH(hostname, hosts) { + if (space) + fputc(' ', f); + fputs(*hostname, f); + space = true; + } } } @@ -2307,6 +2354,21 @@ int link_save(Link *link) { if (space) fputc(' ', f); fputs(domainname, f); + space = true; + } + } + + if (link->network->dhcp_domains && dhcp6_lease) { + char **domains; + + r = sd_dhcp6_lease_get_domains(dhcp6_lease, &domains); + if (r >= 0) { + STRV_FOREACH(domain, domains) { + if (space) + fputc(' ', f); + fputs(*domain, f); + space = true; + } } } |