From: Yu Watanabe Date: Thu, 29 Feb 2024 03:45:51 +0000 (+0900) Subject: sd-ndisc-router: introduce sd_ndisc_router_get_sender_mac() X-Git-Tag: v256-rc1~539^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b43c2221f6df23770ff1b53679a330c39025afa9;p=thirdparty%2Fsystemd.git sd-ndisc-router: introduce sd_ndisc_router_get_sender_mac() The Router Advertisement option can take the MAC address of the sender. Let's introduce a function to get it from the parsed options. --- diff --git a/src/libsystemd-network/sd-ndisc-router.c b/src/libsystemd-network/sd-ndisc-router.c index 46baa4fc8ea..fcc2bbce6ee 100644 --- a/src/libsystemd-network/sd-ndisc-router.c +++ b/src/libsystemd-network/sd-ndisc-router.c @@ -175,6 +175,12 @@ int sd_ndisc_router_get_preference(sd_ndisc_router *rt, unsigned *ret) { return 0; } +int sd_ndisc_router_get_sender_mac(sd_ndisc_router *rt, struct ether_addr *ret) { + assert_return(rt, -EINVAL); + + return ndisc_option_get_mac(rt->options, SD_NDISC_OPTION_SOURCE_LL_ADDRESS, ret); +} + int sd_ndisc_router_get_mtu(sd_ndisc_router *rt, uint32_t *ret) { assert_return(rt, -EINVAL); assert_return(ret, -EINVAL); diff --git a/src/systemd/sd-ndisc-router.h b/src/systemd/sd-ndisc-router.h index 57dbb12817a..dde37bcfd76 100644 --- a/src/systemd/sd-ndisc-router.h +++ b/src/systemd/sd-ndisc-router.h @@ -18,6 +18,7 @@ ***/ #include +#include #include #include #include @@ -42,6 +43,7 @@ int sd_ndisc_router_get_lifetime(sd_ndisc_router *rt, uint64_t *ret); int sd_ndisc_router_get_lifetime_timestamp(sd_ndisc_router *rt, clockid_t clock, uint64_t *ret); int sd_ndisc_router_get_reachable_time(sd_ndisc_router *rt, uint64_t *ret); int sd_ndisc_router_get_retransmission_time(sd_ndisc_router *rt, uint64_t *ret); +int sd_ndisc_router_get_sender_mac(sd_ndisc_router *rt, struct ether_addr *ret); int sd_ndisc_router_get_mtu(sd_ndisc_router *rt, uint32_t *ret); /* Generic option access */