From c189ed5d1b37e901fd9ffc23c01022db4834b77a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 22 Jul 2021 13:24:03 +0200 Subject: [PATCH] gnrc_ipv6_nib: add _nib_onl_nc_get() --- .../network_layer/ipv6/nib/_nib-internal.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h index cc3e62a863..602bc3da92 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h @@ -350,6 +350,26 @@ _nib_onl_entry_t *_nib_onl_iter(const _nib_onl_entry_t *last); */ _nib_onl_entry_t *_nib_onl_get(const ipv6_addr_t *addr, unsigned iface); +/** + * @brief Gets a node by IPv6 address and interface from the neighbor cache + * + * @pre `(addr != NULL)` + * + * @param[in] addr The address of a node. Must not be NULL. + * @param[in] iface The interface to the node. May be 0 for any interface. + * + * @return The Neighbor Cache entry for node with @p addr and @p iface on success. + * @return NULL, if there is no such entry. + */ +static inline _nib_onl_entry_t *_nib_onl_nc_get(const ipv6_addr_t *addr, unsigned iface) +{ + _nib_onl_entry_t *nce = _nib_onl_get(addr, iface); + if (nce && (nce->mode & _NC)) { + return nce; + } + return NULL; +} + /** * @brief Creates or gets an existing node from the neighbor cache by address *