summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-16 17:07:47 +0200
committerTom Gundersen <teg@jklm.no>2015-10-22 17:19:54 +0200
commit4d7b83da7b78647f4ba3f1d6fa2dc8d7b9833d93 (patch)
treea086a78437d3549e06f5697910c6ec2466942c41 /src
parent3ad0c5d8a4e2e2fa7ffcccd7f3457f577908494e (diff)
sd-ndisc: rename API from sd-icmp6-nd
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/network-internal.c4
-rw-r--r--src/libsystemd-network/sd-ndisc.c84
-rw-r--r--src/libsystemd-network/test-ndisc-rs.c66
-rw-r--r--src/network/networkd-dhcp6.c48
-rw-r--r--src/network/networkd-link.c6
-rw-r--r--src/network/networkd-link.h2
-rw-r--r--src/systemd/sd-ndisc.h48
7 files changed, 129 insertions, 129 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index a33affb773..faf14fe6a2 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -390,8 +390,8 @@ void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses,
assert(size);
for (i = 0; i < size; i++)
- fprintf(f, SD_ICMP6_ND_ADDRESS_FORMAT_STR"%s",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(addresses[i]),
+ fprintf(f, SD_NDISC_ADDRESS_FORMAT_STR"%s",
+ SD_NDISC_ADDRESS_FORMAT_VAL(addresses[i]),
(i < (size - 1)) ? " ": "");
}
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index 8545344fd7..eb6529287f 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -55,7 +55,7 @@ struct ICMP6Prefix {
struct in6_addr addr;
};
-struct sd_icmp6_nd {
+struct sd_ndisc {
unsigned n_ref;
enum icmp6_nd_state state;
@@ -70,7 +70,7 @@ struct sd_icmp6_nd {
sd_event_source *recv;
sd_event_source *timeout;
int nd_sent;
- sd_icmp6_nd_callback_t callback;
+ sd_ndisc_callback_t callback;
void *userdata;
};
@@ -110,12 +110,12 @@ static int icmp6_prefix_new(ICMP6Prefix **ret) {
return 0;
}
-static void icmp6_nd_notify(sd_icmp6_nd *nd, int event) {
+static void icmp6_nd_notify(sd_ndisc *nd, int event) {
if (nd->callback)
nd->callback(nd, event, nd->userdata);
}
-int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t callback,
+int sd_ndisc_set_callback(sd_ndisc *nd, sd_ndisc_callback_t callback,
void *userdata) {
assert(nd);
@@ -125,7 +125,7 @@ int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t callback,
return 0;
}
-int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index) {
+int sd_ndisc_set_index(sd_ndisc *nd, int interface_index) {
assert(nd);
assert(interface_index >= -1);
@@ -134,7 +134,7 @@ int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index) {
return 0;
}
-int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr) {
+int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr) {
assert(nd);
if (mac_addr)
@@ -146,7 +146,7 @@ int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr) {
}
-int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority) {
+int sd_ndisc_attach_event(sd_ndisc *nd, sd_event *event, int priority) {
int r;
assert_return(nd, -EINVAL);
@@ -165,7 +165,7 @@ int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority) {
return 0;
}
-int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd) {
+int sd_ndisc_detach_event(sd_ndisc *nd) {
assert_return(nd, -EINVAL);
nd->event = sd_event_unref(nd->event);
@@ -173,13 +173,13 @@ int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd) {
return 0;
}
-sd_event *sd_icmp6_nd_get_event(sd_icmp6_nd *nd) {
+sd_event *sd_ndisc_get_event(sd_ndisc *nd) {
assert(nd);
return nd->event;
}
-sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd) {
+sd_ndisc *sd_ndisc_ref(sd_ndisc *nd) {
if (!nd)
return NULL;
@@ -190,7 +190,7 @@ sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd) {
return nd;
}
-static int icmp6_nd_init(sd_icmp6_nd *nd) {
+static int icmp6_nd_init(sd_ndisc *nd) {
assert(nd);
nd->recv = sd_event_source_unref(nd->recv);
@@ -200,7 +200,7 @@ static int icmp6_nd_init(sd_icmp6_nd *nd) {
return 0;
}
-sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd) {
+sd_ndisc *sd_ndisc_unref(sd_ndisc *nd) {
ICMP6Prefix *prefix, *p;
if (!nd)
@@ -213,7 +213,7 @@ sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd) {
return NULL;
icmp6_nd_init(nd);
- sd_icmp6_nd_detach_event(nd);
+ sd_ndisc_detach_event(nd);
LIST_FOREACH_SAFE(prefixes, prefix, p, nd->prefixes) {
LIST_REMOVE(prefixes, nd->prefixes, prefix);
@@ -226,15 +226,15 @@ sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd) {
return NULL;
}
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_icmp6_nd*, sd_icmp6_nd_unref);
-#define _cleanup_sd_icmp6_nd_free_ _cleanup_(sd_icmp6_nd_unrefp)
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_ndisc*, sd_ndisc_unref);
+#define _cleanup_sd_ndisc_free_ _cleanup_(sd_ndisc_unrefp)
-int sd_icmp6_nd_new(sd_icmp6_nd **ret) {
- _cleanup_sd_icmp6_nd_free_ sd_icmp6_nd *nd = NULL;
+int sd_ndisc_new(sd_ndisc **ret) {
+ _cleanup_sd_ndisc_free_ sd_ndisc *nd = NULL;
assert(ret);
- nd = new0(sd_icmp6_nd, 1);
+ nd = new0(sd_ndisc, 1);
if (!nd)
return -ENOMEM;
@@ -251,7 +251,7 @@ int sd_icmp6_nd_new(sd_icmp6_nd **ret) {
return 0;
}
-int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu) {
+int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *mtu) {
assert_return(nd, -EINVAL);
assert_return(mtu, -EINVAL);
@@ -265,7 +265,7 @@ int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu) {
static int icmp6_ra_prefix_timeout(sd_event_source *s, uint64_t usec,
void *userdata) {
- sd_icmp6_nd *nd = userdata;
+ sd_ndisc *nd = userdata;
ICMP6Prefix *prefix, *p;
assert(nd);
@@ -274,15 +274,15 @@ static int icmp6_ra_prefix_timeout(sd_event_source *s, uint64_t usec,
if (prefix->timeout_valid != s)
continue;
- log_icmp6_nd(nd, "Prefix expired "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(prefix->addr),
+ log_icmp6_nd(nd, "Prefix expired "SD_NDISC_ADDRESS_FORMAT_STR"/%d",
+ SD_NDISC_ADDRESS_FORMAT_VAL(prefix->addr),
prefix->len);
LIST_REMOVE(prefixes, nd->prefixes, prefix);
nd->expired_prefix = prefix;
icmp6_nd_notify(nd,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED);
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED);
nd->expired_prefix = NULL;
prefix = icmp6_prefix_unref(prefix);
@@ -293,7 +293,7 @@ static int icmp6_ra_prefix_timeout(sd_event_source *s, uint64_t usec,
return 0;
}
-static int icmp6_ra_prefix_set_timeout(sd_icmp6_nd *nd,
+static int icmp6_ra_prefix_set_timeout(sd_ndisc *nd,
ICMP6Prefix *prefix,
usec_t valid) {
usec_t time_now;
@@ -364,13 +364,13 @@ static int icmp6_ra_prefix_match(ICMP6Prefix *head, const struct in6_addr *addr,
return -EADDRNOTAVAIL;
}
-int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
+int sd_ndisc_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
struct in6_addr *addr) {
return icmp6_prefix_match(prefix, prefixlen, addr,
sizeof(addr->s6_addr) * 8);
}
-int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
+int sd_ndisc_get_prefixlen(sd_ndisc *nd, const struct in6_addr *addr,
uint8_t *prefixlen) {
int r;
ICMP6Prefix *prefix;
@@ -389,7 +389,7 @@ 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) {
+int sd_ndisc_get_expired_prefix(sd_ndisc *nd, struct in6_addr **addr, uint8_t *prefixlen) {
assert_return(nd, -EINVAL);
assert_return(addr, -EINVAL);
assert_return(prefixlen, -EINVAL);
@@ -403,7 +403,7 @@ int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr, uint
return 0;
}
-static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len,
+static int icmp6_ra_prefix_update(sd_ndisc *nd, ssize_t len,
const struct nd_opt_prefix_info *prefix_opt) {
int r;
ICMP6Prefix *prefix;
@@ -441,8 +441,8 @@ static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len,
memcpy(&prefix->addr, &prefix_opt->nd_opt_pi_prefix,
sizeof(prefix->addr));
- log_icmp6_nd(nd, "New prefix "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(prefix->addr),
+ log_icmp6_nd(nd, "New prefix "SD_NDISC_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
+ SD_NDISC_ADDRESS_FORMAT_VAL(prefix->addr),
prefix->len, lifetime,
format_timespan(time_string, FORMAT_TIMESPAN_MAX, lifetime * USEC_PER_SEC, USEC_PER_SEC));
@@ -462,8 +462,8 @@ static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len,
prefix->len = prefixlen;
}
- log_icmp6_nd(nd, "Update prefix "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(prefix->addr),
+ log_icmp6_nd(nd, "Update prefix "SD_NDISC_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
+ SD_NDISC_ADDRESS_FORMAT_VAL(prefix->addr),
prefix->len, lifetime,
format_timespan(time_string, FORMAT_TIMESPAN_MAX, lifetime * USEC_PER_SEC, USEC_PER_SEC));
}
@@ -473,7 +473,7 @@ static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len,
return r;
}
-static int icmp6_ra_parse(sd_icmp6_nd *nd, struct nd_router_advert *ra,
+static int icmp6_ra_parse(sd_ndisc *nd, struct nd_router_advert *ra,
ssize_t len) {
void *opt;
struct nd_opt_hdr *opt_hdr;
@@ -535,11 +535,11 @@ static int icmp6_ra_parse(sd_icmp6_nd *nd, struct nd_router_advert *ra,
}
static int icmp6_router_advertisment_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- sd_icmp6_nd *nd = userdata;
+ sd_ndisc *nd = userdata;
int r, buflen = 0;
ssize_t len;
_cleanup_free_ struct nd_router_advert *ra = NULL;
- int event = SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_NONE;
+ int event = SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE;
assert(s);
assert(nd);
@@ -570,16 +570,16 @@ static int icmp6_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
nd->state = ICMP6_ROUTER_ADVERTISMENT_LISTEN;
if (ra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER )
- event = SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER;
+ event = SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER;
if (ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED)
- event = SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED;
+ event = SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED;
log_icmp6_nd(nd, "Received Router Advertisement flags %s/%s",
ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED? "MANAGED": "none",
ra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER? "OTHER": "none");
- if (event != SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_NONE) {
+ if (event != SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE) {
r = icmp6_ra_parse(nd, ra, len);
if (r < 0) {
log_icmp6_nd(nd, "Could not parse Router Advertisement: %s",
@@ -594,7 +594,7 @@ static int icmp6_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
}
static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
- sd_icmp6_nd *nd = userdata;
+ sd_ndisc *nd = userdata;
uint64_t time_now, next_timeout;
struct ether_addr unset = { };
struct ether_addr *addr = NULL;
@@ -607,7 +607,7 @@ static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
nd->timeout = sd_event_source_unref(nd->timeout);
if (nd->nd_sent >= ICMP6_MAX_ROUTER_SOLICITATIONS) {
- icmp6_nd_notify(nd, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_TIMEOUT);
+ icmp6_nd_notify(nd, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT);
nd->state = ICMP6_ROUTER_ADVERTISMENT_LISTEN;
} else {
if (memcmp(&nd->mac_addr, &unset, sizeof(struct ether_addr)))
@@ -656,7 +656,7 @@ static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
return 0;
}
-int sd_icmp6_nd_stop(sd_icmp6_nd *nd) {
+int sd_ndisc_stop(sd_ndisc *nd) {
assert_return(nd, -EINVAL);
assert_return(nd->event, -EINVAL);
@@ -669,7 +669,7 @@ int sd_icmp6_nd_stop(sd_icmp6_nd *nd) {
return 0;
}
-int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd) {
+int sd_ndisc_router_discovery_start(sd_ndisc *nd) {
int r;
assert(nd);
diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c
index 49305e297b..6c79e89881 100644
--- a/src/libsystemd-network/test-ndisc-rs.c
+++ b/src/libsystemd-network/test-ndisc-rs.c
@@ -70,7 +70,7 @@ static int send_ra_short_prefix(uint8_t flags) {
return 0;
}
-static void test_short_prefix_cb(sd_icmp6_nd *nd, int event, void *userdata) {
+static void test_short_prefix_cb(sd_ndisc *nd, int event, void *userdata) {
sd_event *e = userdata;
struct {
struct in6_addr addr;
@@ -105,12 +105,12 @@ static void test_short_prefix_cb(sd_icmp6_nd *nd, int event, void *userdata) {
addrs[i].addr.s6_addr[6], addrs[i].addr.s6_addr[7]);
if (addrs[i].success) {
- assert_se(sd_icmp6_ra_get_prefixlen(nd, &addrs[i].addr,
+ assert_se(sd_ndisc_get_prefixlen(nd, &addrs[i].addr,
&prefixlen) >= 0);
assert_se(addrs[i].prefixlen == prefixlen);
printf("/%d onlink\n", prefixlen);
} else {
- assert_se(sd_icmp6_ra_get_prefixlen(nd, &addrs[i].addr,
+ assert_se(sd_ndisc_get_prefixlen(nd, &addrs[i].addr,
&prefixlen) == -EADDRNOTAVAIL);
printf("/128 offlink\n");
}
@@ -154,7 +154,7 @@ static int send_ra_prefixes(uint8_t flags) {
return 0;
}
-static void test_prefixes_cb(sd_icmp6_nd *nd, int event, void *userdata) {
+static void test_prefixes_cb(sd_ndisc *nd, int event, void *userdata) {
sd_event *e = userdata;
struct {
struct in6_addr addr;
@@ -189,26 +189,26 @@ static void test_prefixes_cb(sd_icmp6_nd *nd, int event, void *userdata) {
addrs[i].addr.s6_addr[6], addrs[i].addr.s6_addr[7]);
if (addrs[i].success) {
- assert_se(sd_icmp6_ra_get_prefixlen(nd, &addrs[i].addr,
+ assert_se(sd_ndisc_get_prefixlen(nd, &addrs[i].addr,
&prefixlen) >= 0);
assert_se(addrs[i].prefixlen == prefixlen);
printf("/%d onlink\n", prefixlen);
} else {
- assert_se(sd_icmp6_ra_get_prefixlen(nd, &addrs[i].addr,
+ assert_se(sd_ndisc_get_prefixlen(nd, &addrs[i].addr,
&prefixlen) == -EADDRNOTAVAIL);
printf("/128 offlink\n");
}
}
send_ra_function = send_ra_short_prefix;
- assert_se(sd_icmp6_nd_set_callback(nd, test_short_prefix_cb, e) >= 0);
- assert_se(sd_icmp6_nd_stop(nd) >= 0);
- assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
+ assert_se(sd_ndisc_set_callback(nd, test_short_prefix_cb, e) >= 0);
+ assert_se(sd_ndisc_stop(nd) >= 0);
+ assert_se(sd_ndisc_router_discovery_start(nd) >= 0);
}
static void test_prefixes(void) {
sd_event *e;
- sd_icmp6_nd *nd;
+ sd_ndisc *nd;
if (verbose)
printf("* %s\n", __FUNCTION__);
@@ -217,20 +217,20 @@ static void test_prefixes(void) {
assert_se(sd_event_new(&e) >= 0);
- assert_se(sd_icmp6_nd_new(&nd) >= 0);
+ assert_se(sd_ndisc_new(&nd) >= 0);
assert_se(nd);
- assert_se(sd_icmp6_nd_attach_event(nd, e, 0) >= 0);
+ assert_se(sd_ndisc_attach_event(nd, e, 0) >= 0);
- assert_se(sd_icmp6_nd_set_index(nd, 42) >= 0);
- assert_se(sd_icmp6_nd_set_mac(nd, &mac_addr) >= 0);
- assert_se(sd_icmp6_nd_set_callback(nd, test_prefixes_cb, e) >= 0);
+ assert_se(sd_ndisc_set_index(nd, 42) >= 0);
+ assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
+ assert_se(sd_ndisc_set_callback(nd, test_prefixes_cb, e) >= 0);
- assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
+ assert_se(sd_ndisc_router_discovery_start(nd) >= 0);
sd_event_loop(e);
- nd = sd_icmp6_nd_unref(nd);
+ nd = sd_ndisc_unref(nd);
assert_se(!nd);
close(test_fd[1]);
@@ -270,16 +270,16 @@ int dhcp_network_icmp6_send_router_solicitation(int s, const struct ether_addr *
return send_ra_function(0);
}
-static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) {
+static void test_rs_done(sd_ndisc *nd, int event, void *userdata) {
sd_event *e = userdata;
static int idx = 0;
struct {
uint8_t flag;
int event;
} flag_event[] = {
- { 0, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_NONE },
- { ND_RA_FLAG_OTHER, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER },
- { ND_RA_FLAG_MANAGED, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED }
+ { 0, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE },
+ { ND_RA_FLAG_OTHER, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER },
+ { ND_RA_FLAG_MANAGED, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED }
};
uint32_t mtu;
@@ -296,14 +296,14 @@ static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) {
return;
}
- assert_se(sd_icmp6_ra_get_mtu(nd, &mtu) == -ENOMSG);
+ assert_se(sd_ndisc_get_mtu(nd, &mtu) == -ENOMSG);
sd_event_exit(e, 0);
}
static void test_rs(void) {
sd_event *e;
- sd_icmp6_nd *nd;
+ sd_ndisc *nd;
usec_t time_now = now(clock_boottime_or_monotonic());
if (verbose)
@@ -313,30 +313,30 @@ static void test_rs(void) {
assert_se(sd_event_new(&e) >= 0);
- assert_se(sd_icmp6_nd_new(&nd) >= 0);
+ assert_se(sd_ndisc_new(&nd) >= 0);
assert_se(nd);
- assert_se(sd_icmp6_nd_attach_event(nd, e, 0) >= 0);
+ assert_se(sd_ndisc_attach_event(nd, e, 0) >= 0);
- assert_se(sd_icmp6_nd_set_index(nd, 42) >= 0);
- assert_se(sd_icmp6_nd_set_mac(nd, &mac_addr) >= 0);
- assert_se(sd_icmp6_nd_set_callback(nd, test_rs_done, e) >= 0);
+ assert_se(sd_ndisc_set_index(nd, 42) >= 0);
+ assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
+ assert_se(sd_ndisc_set_callback(nd, test_rs_done, e) >= 0);
assert_se(sd_event_add_time(e, &test_hangcheck, clock_boottime_or_monotonic(),
time_now + 2 *USEC_PER_SEC, 0,
test_rs_hangcheck, NULL) >= 0);
- assert_se(sd_icmp6_nd_stop(nd) >= 0);
- assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
- assert_se(sd_icmp6_nd_stop(nd) >= 0);
+ assert_se(sd_ndisc_stop(nd) >= 0);
+ assert_se(sd_ndisc_router_discovery_start(nd) >= 0);
+ assert_se(sd_ndisc_stop(nd) >= 0);
- assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
+ assert_se(sd_ndisc_router_discovery_start(nd) >= 0);
sd_event_loop(e);
test_hangcheck = sd_event_source_unref(test_hangcheck);
- nd = sd_icmp6_nd_unref(nd);
+ nd = sd_ndisc_unref(nd);
assert_se(!nd);
close(test_fd[1]);
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index e572ad4595..0023c51b86 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -83,8 +83,8 @@ static int dhcp6_address_change(Link *link, struct in6_addr *ip6_addr,
addr->cinfo.ifa_valid = lifetime_valid;
log_link_info(link,
- "DHCPv6 address "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d timeout preferred %d valid %d",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(addr->in_addr.in6),
+ "DHCPv6 address "SD_NDISC_ADDRESS_FORMAT_STR"/%d timeout preferred %d valid %d",
+ SD_NDISC_ADDRESS_FORMAT_VAL(addr->in_addr.in6),
addr->prefixlen, lifetime_preferred, lifetime_valid);
r = address_configure(addr, link, dhcp6_address_handler, true);
@@ -111,7 +111,7 @@ static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link) {
&lifetime_preferred,
&lifetime_valid) >= 0) {
- r = sd_icmp6_ra_get_prefixlen(link->icmp6_router_discovery,
+ r = sd_ndisc_get_prefixlen(link->icmp6_router_discovery,
&ip6_addr, &prefixlen);
if (r < 0 && r != -EADDRNOTAVAIL) {
log_link_warning_errno(link, r, "Could not get prefix information: %m");
@@ -184,9 +184,9 @@ static int dhcp6_configure(Link *link, int event) {
bool information_request;
assert_return(link, -EINVAL);
- assert_return(IN_SET(event, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_TIMEOUT,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED), -EINVAL);
+ assert_return(IN_SET(event, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED), -EINVAL);
link->dhcp6_configured = false;
@@ -198,7 +198,7 @@ static int dhcp6_configure(Link *link, int event) {
goto error;
}
- if (information_request && event != SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER) {
+ if (information_request && event != SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER) {
r = sd_dhcp6_client_stop(link->dhcp6_client);
if (r < 0) {
log_link_warning_errno(link, r, "Could not stop DHCPv6 while setting Managed mode: %m");
@@ -249,7 +249,7 @@ static int dhcp6_configure(Link *link, int event) {
if (r < 0)
goto error;
- if (event == SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER) {
+ if (event == SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER) {
r = sd_dhcp6_client_set_information_request(link->dhcp6_client,
true);
if (r < 0)
@@ -274,7 +274,7 @@ static int dhcp6_prefix_expired(Link *link) {
uint8_t expired_prefixlen;
uint32_t lifetime_preferred, lifetime_valid;
- r = sd_icmp6_ra_get_expired_prefix(link->icmp6_router_discovery,
+ r = sd_ndisc_get_expired_prefix(link->icmp6_router_discovery,
&expired_prefix, &expired_prefixlen);
if (r < 0)
return r;
@@ -283,8 +283,8 @@ static int dhcp6_prefix_expired(Link *link) {
if (r < 0)
return r;
- log_link_info(link, "IPv6 prefix "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d expired",
- SD_ICMP6_ND_ADDRESS_FORMAT_VAL(*expired_prefix),
+ log_link_info(link, "IPv6 prefix "SD_NDISC_ADDRESS_FORMAT_STR"/%d expired",
+ SD_NDISC_ADDRESS_FORMAT_VAL(*expired_prefix),
expired_prefixlen);
sd_dhcp6_lease_reset_address_iter(lease);
@@ -293,12 +293,12 @@ static int dhcp6_prefix_expired(Link *link) {
&lifetime_preferred,
&lifetime_valid) >= 0) {
- r = sd_icmp6_prefix_match(expired_prefix, expired_prefixlen,
+ r = sd_ndisc_prefix_match(expired_prefix, expired_prefixlen,
&ip6_addr);
if (r < 0)
continue;
- log_link_info(link, "IPv6 prefix length updated "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d", SD_ICMP6_ND_ADDRESS_FORMAT_VAL(ip6_addr), 128);
+ log_link_info(link, "IPv6 prefix length updated "SD_NDISC_ADDRESS_FORMAT_STR"/%d", SD_NDISC_ADDRESS_FORMAT_VAL(ip6_addr), 128);
dhcp6_address_change(link, &ip6_addr, 128, lifetime_preferred, lifetime_valid);
}
@@ -306,7 +306,7 @@ static int dhcp6_prefix_expired(Link *link) {
return 0;
}
-static void icmp6_router_handler(sd_icmp6_nd *nd, int event, void *userdata) {
+static void icmp6_router_handler(sd_ndisc *nd, int event, void *userdata) {
Link *link = userdata;
assert(link);
@@ -317,17 +317,17 @@ static void icmp6_router_handler(sd_icmp6_nd *nd, int event, void *userdata) {
return;
switch(event) {
- case SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_NONE:
+ case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE:
return;
- case SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_TIMEOUT:
- case SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER:
- case SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED:
+ case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT:
+ case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER:
+ case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED:
dhcp6_configure(link, event);
break;
- case SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED:
+ case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED:
if (!link->rtnl_extended_attrs)
dhcp6_prefix_expired(link);
@@ -349,23 +349,23 @@ int icmp6_configure(Link *link) {
assert_return(link, -EINVAL);
- r = sd_icmp6_nd_new(&link->icmp6_router_discovery);
+ r = sd_ndisc_new(&link->icmp6_router_discovery);
if (r < 0)
return r;
- r = sd_icmp6_nd_attach_event(link->icmp6_router_discovery, NULL, 0);
+ r = sd_ndisc_attach_event(link->icmp6_router_discovery, NULL, 0);
if (r < 0)
return r;
- r = sd_icmp6_nd_set_mac(link->icmp6_router_discovery, &link->mac);
+ r = sd_ndisc_set_mac(link->icmp6_router_discovery, &link->mac);
if (r < 0)
return r;
- r = sd_icmp6_nd_set_index(link->icmp6_router_discovery, link->ifindex);
+ r = sd_ndisc_set_index(link->icmp6_router_discovery, link->ifindex);
if (r < 0)
return r;
- r = sd_icmp6_nd_set_callback(link->icmp6_router_discovery,
+ r = sd_ndisc_set_callback(link->icmp6_router_discovery,
icmp6_router_handler, link);
return r;
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index ec4b082542..c46ab9b798 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -370,7 +370,7 @@ static void link_free(Link *link) {
sd_ipv4ll_unref(link->ipv4ll);
sd_dhcp6_client_unref(link->dhcp6_client);
- sd_icmp6_nd_unref(link->icmp6_router_discovery);
+ sd_ndisc_unref(link->icmp6_router_discovery);
if (link->manager)
hashmap_remove(link->manager->links, INT_TO_PTR(link->ifindex));
@@ -488,7 +488,7 @@ static int link_stop_clients(Link *link) {
r = log_link_warning_errno(link, r, "Could not stop DHCPv6 client: %m");
}
- k = sd_icmp6_nd_stop(link->icmp6_router_discovery);
+ k = sd_ndisc_stop(link->icmp6_router_discovery);
if (k < 0)
r = log_link_warning_errno(link, r, "Could not stop ICMPv6 router discovery: %m");
}
@@ -1242,7 +1242,7 @@ static int link_acquire_conf(Link *link) {
log_link_debug(link, "Discovering IPv6 routers");
- r = sd_icmp6_router_solicitation_start(link->icmp6_router_discovery);
+ r = sd_ndisc_router_discovery_start(link->icmp6_router_discovery);
if (r < 0)
return log_link_warning_errno(link, r, "Could not start IPv6 router discovery: %m");
}
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 5bba313049..668b636620 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -104,7 +104,7 @@ struct Link {
sd_dhcp_server *dhcp_server;
- sd_icmp6_nd *icmp6_router_discovery;
+ sd_ndisc *icmp6_router_discovery;
sd_dhcp6_client *dhcp6_client;
bool rtnl_extended_attrs;
diff --git a/src/systemd/sd-ndisc.h b/src/systemd/sd-ndisc.h
index 240feb7bbe..8cee7343b5 100644
--- a/src/systemd/sd-ndisc.h
+++ b/src/systemd/sd-ndisc.h
@@ -27,46 +27,46 @@
#include "sd-event.h"
enum {
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_NONE = 0,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
- SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED = 4,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE = 0,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
+ SD_NDISC_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED = 4,
};
-typedef struct sd_icmp6_nd sd_icmp6_nd;
+typedef struct sd_ndisc sd_ndisc;
-typedef void(*sd_icmp6_nd_callback_t)(sd_icmp6_nd *nd, int event,
+typedef void(*sd_ndisc_callback_t)(sd_ndisc *nd, int event,
void *userdata);
-int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t cb,
+int sd_ndisc_set_callback(sd_ndisc *nd, sd_ndisc_callback_t cb,
void *userdata);
-int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index);
-int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr);
+int sd_ndisc_set_index(sd_ndisc *nd, int interface_index);
+int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr);
-int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority);
-int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd);
-sd_event *sd_icmp6_nd_get_event(sd_icmp6_nd *nd);
+int sd_ndisc_attach_event(sd_ndisc *nd, sd_event *event, int priority);
+int sd_ndisc_detach_event(sd_ndisc *nd);
+sd_event *sd_ndisc_get_event(sd_ndisc *nd);
-sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd);
-sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd);
-int sd_icmp6_nd_new(sd_icmp6_nd **ret);
+sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);
+sd_ndisc *sd_ndisc_unref(sd_ndisc *nd);
+int sd_ndisc_new(sd_ndisc **ret);
-int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
+int sd_ndisc_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
struct in6_addr *addr);
-int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu);
-int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
+int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *mtu);
+int sd_ndisc_get_prefixlen(sd_ndisc *nd, const struct in6_addr *addr,
uint8_t *prefixlen);
-int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr,
+int sd_ndisc_get_expired_prefix(sd_ndisc *nd, struct in6_addr **addr,
uint8_t *prefixlen);
-int sd_icmp6_nd_stop(sd_icmp6_nd *nd);
-int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd);
+int sd_ndisc_stop(sd_ndisc *nd);
+int sd_ndisc_router_discovery_start(sd_ndisc *nd);
-#define SD_ICMP6_ND_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
+#define SD_NDISC_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
-#define SD_ICMP6_ND_ADDRESS_FORMAT_VAL(address) \
+#define SD_NDISC_ADDRESS_FORMAT_VAL(address) \
be16toh((address).s6_addr16[0]), \
be16toh((address).s6_addr16[1]), \
be16toh((address).s6_addr16[2]), \