Skip to content
Permalink
Browse files

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>
  • Loading branch information...
tbursztyka authored and jukkar committed May 22, 2019
1 parent eccc268 commit d80d181d04f022589586543d4da1be067f56786f
Showing with 31 additions and 0 deletions.
  1. +20 −0 include/net/net_if.h
  2. +11 −0 subsys/net/ip/net_if.c
@@ -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)
{

0 comments on commit d80d181

Please sign in to comment.
You can’t perform that action at this time.