From ebfa17eebe2fdb192c5af2a96c903221cb9977b5 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 19 May 2016 16:31:28 +0300 Subject: [PATCH] net: yaip: Add utility function to return default network interface Change-Id: Ia64d263831e2842883404d25b7ea429bea80ca1d Signed-off-by: Jukka Rissanen --- include/net/yaip/net_if.h | 6 ++++++ net/yaip/net_if.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/include/net/yaip/net_if.h b/include/net/yaip/net_if.h index 2a35479151b..9e8107b8496 100644 --- a/include/net/yaip/net_if.h +++ b/include/net/yaip/net_if.h @@ -316,6 +316,12 @@ struct in6_addr *net_if_ipv6_unspecified_addr(void); struct in6_addr *net_if_ipv6_get_ll(struct net_if *iface, enum net_addr_state addr_state); +/** + * @brief Get the default network interface. + * @return Default interface or NULL if no interfaces are configured. + */ +struct net_if *net_if_get_default(void); + struct net_if_api { void (*init)(struct net_if *iface); int (*send)(struct net_if *iface, struct net_buf *buf); diff --git a/net/yaip/net_if.c b/net/yaip/net_if.c index 450e697e1db..59c8b9f6a11 100644 --- a/net/yaip/net_if.c +++ b/net/yaip/net_if.c @@ -418,6 +418,11 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, return NULL; } +struct net_if *net_if_get_default(void) +{ + return __net_if_start; +} + int net_if_init(void) { struct net_if_api *api;