diff --git a/include/net/yaip/net_if.h b/include/net/yaip/net_if.h index d06699e4b53..e3d1223c43e 100644 --- a/include/net/yaip/net_if.h +++ b/include/net/yaip/net_if.h @@ -192,6 +192,13 @@ static inline uint16_t net_if_get_mtu(struct net_if *iface) return iface->mtu; } +/** + * @brief Get an interface according to link layer address. + * @param ll_addr Link layer address. + * @return Network interface or NULL if not found. + */ +struct net_if *net_if_get_by_link_addr(struct net_linkaddr *ll_addr); + struct net_if_api { void (*init)(struct net_if *iface); }; diff --git a/net/yaip/net_if.c b/net/yaip/net_if.c index 2a4f82531b1..621874adddd 100644 --- a/net/yaip/net_if.c +++ b/net/yaip/net_if.c @@ -56,6 +56,20 @@ static inline void init_tx_queue(struct net_if *iface) (nano_fiber_entry_t)net_if_tx_fiber, (int)iface, 0, 7, 0); } +struct net_if *net_if_get_by_link_addr(struct net_linkaddr *ll_addr) +{ + struct net_if *iface; + + for (iface = __net_if_start; iface != __net_if_end; iface++) { + if (!memcmp(iface->link_addr.addr, ll_addr->addr, + ll_addr->len)) { + return iface; + } + } + + return NULL; +} + int net_if_init(void) { struct net_if_api *api;