net/iface: Add IPv4 route find and add
Removing an IPv4 router was missing, as well as finding the default router for an IPv4 address. Note howevere that IPv4 router features are not used anywhere yet. But at least the API is there and is a 1:1 to IPv6, if that matters. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
eccc268d0a
commit
d80d181d04
2 changed files with 31 additions and 0 deletions
|
@ -1628,6 +1628,17 @@ static inline struct in_addr *net_if_router_ipv4(struct net_if_router *router)
|
|||
struct net_if_router *net_if_ipv4_router_lookup(struct net_if *iface,
|
||||
struct in_addr *addr);
|
||||
|
||||
/**
|
||||
* @brief Find default router for this IPv4 address.
|
||||
*
|
||||
* @param iface Network interface. This can be NULL in which case we
|
||||
* go through all the network interfaces to find a suitable router.
|
||||
* @param addr IPv4 address
|
||||
*
|
||||
* @return Pointer to router information, NULL if cannot be found
|
||||
*/
|
||||
struct net_if_router *net_if_ipv4_router_find_default(struct net_if *iface,
|
||||
struct in_addr *addr);
|
||||
/**
|
||||
* @brief Add IPv4 router to the system.
|
||||
*
|
||||
|
@ -1643,6 +1654,15 @@ struct net_if_router *net_if_ipv4_router_add(struct net_if *iface,
|
|||
bool is_default,
|
||||
u16_t router_lifetime);
|
||||
|
||||
/**
|
||||
* @brief Remove IPv4 router from the system.
|
||||
*
|
||||
* @param router Router information.
|
||||
*
|
||||
* @return True if successfully removed, false otherwise
|
||||
*/
|
||||
bool net_if_ipv4_router_rm(struct net_if_router *router);
|
||||
|
||||
/**
|
||||
* @brief Check if the given IPv4 address belongs to local subnet.
|
||||
*
|
||||
|
|
|
@ -2447,6 +2447,12 @@ struct net_if_router *net_if_ipv4_router_lookup(struct net_if *iface,
|
|||
return iface_router_lookup(iface, AF_INET, addr);
|
||||
}
|
||||
|
||||
struct net_if_router *net_if_ipv4_router_find_default(struct net_if *iface,
|
||||
struct in_addr *addr)
|
||||
{
|
||||
return iface_router_find_default(iface, AF_INET, addr);
|
||||
}
|
||||
|
||||
struct net_if_router *net_if_ipv4_router_add(struct net_if *iface,
|
||||
struct in_addr *addr,
|
||||
bool is_default,
|
||||
|
@ -2455,6 +2461,11 @@ struct net_if_router *net_if_ipv4_router_add(struct net_if *iface,
|
|||
return iface_router_add(iface, AF_INET, addr, is_default, lifetime);
|
||||
}
|
||||
|
||||
bool net_if_ipv4_router_rm(struct net_if_router *router)
|
||||
{
|
||||
return iface_router_rm(router);
|
||||
}
|
||||
|
||||
bool net_if_ipv4_addr_mask_cmp(struct net_if *iface,
|
||||
const struct in_addr *addr)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue