net: if: Add net_if_select_src_iface() function

Add a function which returns proper network interface to send either
IPv4 or IPv6 network packet to corresponding destination address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2018-08-07 13:05:55 +03:00
commit d0205693ae
2 changed files with 44 additions and 1 deletions

View file

@ -1502,9 +1502,22 @@ static inline void net_if_ipv4_set_gw(struct net_if *iface,
net_ipaddr_copy(&iface->config.ip.ipv4->gw, gw);
}
#else
#define net_if_ipv4_select_src_iface(...) NULL
#endif /* CONFIG_NET_IPV4 */
/**
* @brief Get a network interface that should be used when sending
* IPv6 or IPv4 network data to destination.
*
* @param dst IPv6 or IPv4 destination address
*
* @return Pointer to network interface to use. Note that the function
* will return the default network interface if the best network interface
* is not found.
*/
struct net_if *net_if_select_src_iface(const struct sockaddr *dst);
/**
* @typedef net_if_link_callback_t
* @brief Define callback that is called after a network packet