summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-23 13:48:18 +0200
committerTom Gundersen <teg@jklm.no>2014-07-23 23:54:51 +0200
commitb0e39c8284b5195850a58e4efcce2f059bdcc6ad (patch)
treee5f1183bec258450f9cd59ce1a8e255179467e0d /src/libsystemd-network
parent36d054aae0847df38687640909304dde1452b22d (diff)
networkd: merge DNS and NTP entries when exporting
In the state files, do not distinguish where the various entries came from (static or DHCP), but include them all in the same list.
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/network-internal.c7
-rw-r--r--src/libsystemd-network/network-internal.h2
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c8
3 files changed, 8 insertions, 9 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index 3407537eb5..603ee6dbe9 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -339,21 +339,16 @@ int net_parse_inaddr(const char *address, int *family, void *dst) {
return 0;
}
-void serialize_in_addrs(FILE *f, const char *key, const struct in_addr *addresses, size_t size) {
+void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size) {
unsigned i;
assert(f);
- assert(key);
assert(addresses);
assert(size);
- fprintf(f, "%s=", key);
-
for (i = 0; i < size; i++)
fprintf(f, "%s%s", inet_ntoa(addresses[i]),
(i < (size - 1)) ? " ": "");
-
- fputs("\n", f);
}
int deserialize_in_addrs(struct in_addr **ret, const char *string) {
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
index 765dff4f3f..6dd518bb48 100644
--- a/src/libsystemd-network/network-internal.h
+++ b/src/libsystemd-network/network-internal.h
@@ -67,7 +67,7 @@ int net_parse_inaddr(const char *address, int *family, void *dst);
int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]);
const char *net_get_name(struct udev_device *device);
-void serialize_in_addrs(FILE *f, const char *key, const struct in_addr *addresses, size_t size);
+void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size);
int deserialize_in_addrs(struct in_addr **addresses, const char *string);
int deserialize_in6_addrs(struct in6_addr **addresses, const char *string);
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 4ed30f5d03..bfd1b0cd18 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -629,13 +629,17 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
if (r >= 0)
fprintf(f, "MTU=%" PRIu16 "\n", mtu);
+ fputs("DNS=", f);
r = sd_dhcp_lease_get_dns(lease, &addresses);
if (r >= 0)
- serialize_in_addrs(f, "DNS", addresses, r);
+ serialize_in_addrs(f, addresses, r);
+ fputs("\n", f);
+ fputs("NTP=", f);
r = sd_dhcp_lease_get_ntp(lease, &addresses);
if (r >= 0)
- serialize_in_addrs(f, "NTP", addresses, r);
+ serialize_in_addrs(f, addresses, r);
+ fputs("\n", f);
r = sd_dhcp_lease_get_domainname(lease, &string);
if (r >= 0)