network: introduce link_serialize_ipv4ll()
This commit is contained in:
parent
daad60d19e
commit
ca21a19a2e
|
@ -195,6 +195,28 @@ int ipv4ll_configure(Link *link) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int link_serialize_ipv4ll(Link *link, FILE *f) {
|
||||||
|
struct in_addr address;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(link);
|
||||||
|
|
||||||
|
if (!link->ipv4ll)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
r = sd_ipv4ll_get_address(link->ipv4ll, &address);
|
||||||
|
if (r == -ENOENT)
|
||||||
|
return 0;
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
fputs("IPV4LL_ADDRESS=", f);
|
||||||
|
serialize_in_addrs(f, &address, 1, false, NULL);
|
||||||
|
fputc('\n', f);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address) {
|
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address) {
|
||||||
union in_addr_union address;
|
union in_addr_union address;
|
||||||
int r;
|
int r;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
typedef struct Link Link;
|
typedef struct Link Link;
|
||||||
|
|
||||||
int ipv4ll_configure(Link *link);
|
int ipv4ll_configure(Link *link);
|
||||||
|
int link_serialize_ipv4ll(Link *link, FILE *f);
|
||||||
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address);
|
int link_deserialize_ipv4ll(Link *link, const char *ipv4ll_address);
|
||||||
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll);
|
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll);
|
||||||
|
|
|
@ -3511,16 +3511,9 @@ int link_save(Link *link) {
|
||||||
} else
|
} else
|
||||||
(void) unlink(link->lease_file);
|
(void) unlink(link->lease_file);
|
||||||
|
|
||||||
if (link->ipv4ll) {
|
r = link_serialize_ipv4ll(link, f);
|
||||||
struct in_addr address;
|
if (r < 0)
|
||||||
|
goto fail;
|
||||||
r = sd_ipv4ll_get_address(link->ipv4ll, &address);
|
|
||||||
if (r >= 0) {
|
|
||||||
fputs("IPV4LL_ADDRESS=", f);
|
|
||||||
serialize_in_addrs(f, &address, 1, false, NULL);
|
|
||||||
fputc('\n', f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (link->dhcp6_client) {
|
if (link->dhcp6_client) {
|
||||||
_cleanup_free_ char *duid = NULL;
|
_cleanup_free_ char *duid = NULL;
|
||||||
|
|
Loading…
Reference in a new issue