net: Add net_if_get_by_link_addr() util function
This will return the network interface that has some specific link address. Change-Id: Iaebcf6e769d4f91f3cda6d3a0779324f89603b54 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
33f56ce99b
commit
b33d8d6591
2 changed files with 21 additions and 0 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue