mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-05 09:17:44 +03:00
network: introduce callback called when an address becomes ready
This commit is contained in:
parent
c9d223e803
commit
97f000744f
@ -359,15 +359,21 @@ int address_update(
|
||||
link_update_operstate(address->link, true);
|
||||
link_check_ready(address->link);
|
||||
|
||||
if (!ready &&
|
||||
address_is_ready(address) &&
|
||||
address->family == AF_INET6 &&
|
||||
in_addr_is_link_local(AF_INET6, &address->in_addr) > 0 &&
|
||||
in_addr_is_null(AF_INET6, (const union in_addr_union*) &address->link->ipv6ll_address) > 0) {
|
||||
if (!ready && address_is_ready(address)) {
|
||||
if (address->callback) {
|
||||
r = address->callback(address);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (address->family == AF_INET6 &&
|
||||
in_addr_is_link_local(AF_INET6, &address->in_addr) > 0 &&
|
||||
IN6_IS_ADDR_UNSPECIFIED(&address->link->ipv6ll_address) > 0) {
|
||||
|
||||
r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -20,6 +20,7 @@ typedef struct Address Address;
|
||||
typedef struct Network Network;
|
||||
typedef struct Link Link;
|
||||
typedef struct NetworkConfigSection NetworkConfigSection;
|
||||
typedef int (*address_ready_callback_t)(Address *address);
|
||||
|
||||
struct Address {
|
||||
Network *network;
|
||||
@ -47,6 +48,9 @@ struct Address {
|
||||
bool autojoin:1;
|
||||
AddressFamily duplicate_address_detection;
|
||||
|
||||
/* Called when address become ready */
|
||||
address_ready_callback_t callback;
|
||||
|
||||
sd_ipv4acd *acd;
|
||||
|
||||
LIST_FIELDS(Address, addresses);
|
||||
|
Loading…
Reference in New Issue
Block a user