net: if: Add helper to return interface of given type
The helper will return the first network interface of a desired L2 type. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
2975ca0754
commit
f6661512a4
2 changed files with 23 additions and 0 deletions
|
@ -529,6 +529,16 @@ static inline void net_if_router_rm(struct net_if_router *router)
|
|||
*/
|
||||
struct net_if *net_if_get_default(void);
|
||||
|
||||
/**
|
||||
* @brief Get the first network interface according to its type.
|
||||
*
|
||||
* @param l2 Layer 2 type of the network interface.
|
||||
*
|
||||
* @return First network interface of a given type or NULL if no such
|
||||
* interfaces was found.
|
||||
*/
|
||||
struct net_if *net_if_get_first_by_type(const struct net_l2 *l2);
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
/**
|
||||
* @brief Check if this IPv6 address belongs to one of the interfaces.
|
||||
|
|
|
@ -336,6 +336,19 @@ struct net_if *net_if_get_default(void)
|
|||
return __net_if_start;
|
||||
}
|
||||
|
||||
struct net_if *net_if_get_first_by_type(const struct net_l2 *l2)
|
||||
{
|
||||
struct net_if *iface;
|
||||
|
||||
for (iface = __net_if_start; iface != __net_if_end; iface++) {
|
||||
if (iface->l2 == l2) {
|
||||
return iface;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
|
||||
#if defined(CONFIG_NET_IPV6_MLD)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue