diff --git a/src/core/netif.c b/src/core/netif.c index a3b91de0..959cd610 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -51,6 +51,7 @@ #include "lwip/opt.h" #include +#include /* atoi */ #include "lwip/def.h" #include "lwip/ip_addr.h" @@ -471,37 +472,6 @@ netif_remove(struct netif *netif) LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); } -/** - * @ingroup netif - * Find a network interface by searching for its name - * - * @param name the name of the netif (like netif->name) plus concatenated number - * in ascii representation (e.g. 'en0') - */ -struct netif * -netif_find(const char *name) -{ - struct netif *netif; - u8_t num; - - if (name == NULL) { - return NULL; - } - - num = (u8_t)(name[2] - '0'); - - for (netif = netif_list; netif != NULL; netif = netif->next) { - if (num == netif->num && - name[0] == netif->name[0] && - name[1] == netif->name[1]) { - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); - return netif; - } - } - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); - return NULL; -} - #if LWIP_IPV4 /** * @ingroup netif_ip4 @@ -1359,3 +1329,34 @@ netif_get_by_index(u8_t idx) return NULL; } + +/** + * @ingroup netif + * Find a network interface by searching for its name + * + * @param name the name of the netif (like netif->name) plus concatenated number + * in ascii representation (e.g. 'en0') + */ +struct netif * +netif_find(const char *name) +{ + struct netif *netif; + u8_t num; + + if (name == NULL) { + return NULL; + } + + num = (u8_t)atoi(&name[2]); + + for (netif = netif_list; netif != NULL; netif = netif->next) { + if (num == netif->num && + name[0] == netif->name[0] && + name[1] == netif->name[1]) { + LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); + return netif; + } + } + LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); + return NULL; +}