Then, introduce more generic ndisc_option_get().
int ndisc_option_get_mac(Set *options, uint8_t type, struct ether_addr *ret) {
assert(IN_SET(type, SD_NDISC_OPTION_SOURCE_LL_ADDRESS, SD_NDISC_OPTION_TARGET_LL_ADDRESS));
- sd_ndisc_option *p = ndisc_option_get(options, type);
+ sd_ndisc_option *p = ndisc_option_get_by_type(options, type);
if (!p)
return -ENODATA;
int ndisc_parse_options(ICMP6Packet *p, Set **ret_options);
-static inline sd_ndisc_option* ndisc_option_get(Set *options, uint8_t type) {
- return set_get(options, &(sd_ndisc_option) { .type = type, });
+static inline sd_ndisc_option* ndisc_option_get(Set *options, const sd_ndisc_option *p) {
+ return set_get(options, ASSERT_PTR(p));
+}
+static inline sd_ndisc_option* ndisc_option_get_by_type(Set *options, uint8_t type) {
+ return ndisc_option_get(options, &(const sd_ndisc_option) { .type = type });
}
-
int ndisc_option_get_mac(Set *options, uint8_t type, struct ether_addr *ret);
int ndisc_option_add_raw(
assert_return(rt, -EINVAL);
assert_return(ret, -EINVAL);
- sd_ndisc_option *p = ndisc_option_get(rt->options, SD_NDISC_OPTION_FLAGS_EXTENSION);
+ sd_ndisc_option *p = ndisc_option_get_by_type(rt->options, SD_NDISC_OPTION_FLAGS_EXTENSION);
*ret = rt->flags | (p ? p->extended_flags : 0);
return 0;
assert_return(rt, -EINVAL);
assert_return(ret, -EINVAL);
- sd_ndisc_option *p = ndisc_option_get(rt->options, SD_NDISC_OPTION_MTU);
+ sd_ndisc_option *p = ndisc_option_get_by_type(rt->options, SD_NDISC_OPTION_MTU);
if (!p)
return -ENODATA;
assert_return(rt, -EINVAL);
assert_return(ret, -EINVAL);
- sd_ndisc_option *p = ndisc_option_get(rt->options, SD_NDISC_OPTION_CAPTIVE_PORTAL);
+ sd_ndisc_option *p = ndisc_option_get_by_type(rt->options, SD_NDISC_OPTION_CAPTIVE_PORTAL);
if (!p)
return -ENODATA;