summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-icmp6-nd.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2015-01-20 19:36:03 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2015-01-27 09:35:24 +0200
commitbd1957e906fbf92fca6c97bc6cadcf89248d2419 (patch)
treecd66d22024d8b522cd20c3726eb3cf2a1777c327 /src/libsystemd-network/sd-icmp6-nd.c
parent99af546d0ee63ac4af3f234a448d4a3b7bdcfab4 (diff)
sd-icmp6-nd: Add support for fetching the latest expired prefix
Keep the expired prefix for the duration of the prefix expiration event and remove it afterwards.
Diffstat (limited to 'src/libsystemd-network/sd-icmp6-nd.c')
-rw-r--r--src/libsystemd-network/sd-icmp6-nd.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c
index eb00b1ab32..2f867e8562 100644
--- a/src/libsystemd-network/sd-icmp6-nd.c
+++ b/src/libsystemd-network/sd-icmp6-nd.c
@@ -65,6 +65,7 @@ struct sd_icmp6_nd {
int index;
struct ether_addr mac_addr;
uint32_t mtu;
+ ICMP6Prefix *expired_prefix;
LIST_HEAD(ICMP6Prefix, prefixes);
int fd;
sd_event_source *recv;
@@ -266,8 +267,11 @@ static int icmp6_ra_prefix_timeout(sd_event_source *s, uint64_t usec,
LIST_REMOVE(prefixes, nd->prefixes, prefix);
+ nd->expired_prefix = prefix;
icmp6_nd_notify(nd,
ICMP6_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED);
+ nd->expired_prefix = NULL;
+
prefix = icmp6_prefix_unref(prefix);
break;
@@ -372,6 +376,22 @@ int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
return 0;
}
+int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr,
+ uint8_t *prefixlen)
+{
+ assert_return(nd, -EINVAL);
+ assert_return(addr, -EINVAL);
+ assert_return(prefixlen, -EINVAL);
+
+ if (!nd->expired_prefix)
+ return -EADDRNOTAVAIL;
+
+ *addr = &nd->expired_prefix->addr;
+ *prefixlen = nd->expired_prefix->len;
+
+ return 0;
+}
+
static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len,
const struct nd_opt_prefix_info *prefix_opt) {
int r;