diff options
author | Tom Gundersen <teg@jklm.no> | 2015-10-19 22:15:50 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-11-11 15:42:38 +0100 |
commit | 9d96e6c3efbe5ef52b2855612d51db52c469beb2 (patch) | |
tree | 8398fd74f30954af3e427be8e19e93b58545889e /src/network/networkd-ndisc.c | |
parent | cb53894d3b6e90edaee4219fe716850d01242f46 (diff) |
sd-ndisc: introduce separate callbacks
As the data passed is very different, we introduce four different callbacks:
- Generic - router discovery timed out or state machine stopped
- Router - router and link configuration received
- Prefix onlink - configuration for an onlink prefix received
- Prefix autonomous - configuration for to configure a SLAAC address for a prefix received
Diffstat (limited to 'src/network/networkd-ndisc.c')
-rw-r--r-- | src/network/networkd-ndisc.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 50661c65f7..dfbc5a866e 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -20,41 +20,44 @@ ***/ #include <netinet/ether.h> +#include <netinet/icmp6.h> #include <linux/if.h> #include "sd-ndisc.h" #include "networkd-link.h" -static void ndisc_router_handler(sd_ndisc *nd, int event, void *userdata) { +static void ndisc_router_handler(sd_ndisc *nd, uint8_t flags, const struct in6_addr *gateway, unsigned lifetime, int pref, void *userdata) { Link *link = userdata; assert(link); assert(link->network); - assert(link->manager); if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) return; - switch(event) { - case SD_NDISC_EVENT_STOP: - case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE: - return; - - case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER: + if (flags & ND_RA_FLAG_MANAGED) + dhcp6_configure(link, false); + else if (flags & ND_RA_FLAG_OTHER) dhcp6_configure(link, true); +} - break; - case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT: - case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED: - dhcp6_configure(link, false); +static void ndisc_handler(sd_ndisc *nd, int event, void *userdata) { + Link *link = userdata; - break; + assert(link); - default: - log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event); + if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) + return; + switch (event) { + case SD_NDISC_EVENT_TIMEOUT: + dhcp6_configure(link, false); break; + case SD_NDISC_EVENT_STOP: + break; + default: + log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event); } } @@ -80,7 +83,11 @@ int ndisc_configure(Link *link) { return r; r = sd_ndisc_set_callback(link->ndisc_router_discovery, - ndisc_router_handler, link); + ndisc_router_handler, + NULL, + NULL, + ndisc_handler, + link); return r; } |