api:if: Handle case when LWIP_NETIF_API is not defined

When LWIP_NETIF_API is not enabled in lwipopts.h. Return error from if
APIs

Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
This commit is contained in:
Ajay Bhargav 2017-01-23 09:26:57 -06:00 committed by Joel Cunningham
parent e158f87286
commit b5011e7012

View File

@ -45,6 +45,7 @@
char * char *
lwip_if_indextoname(unsigned ifindex, char *ifname) lwip_if_indextoname(unsigned ifindex, char *ifname)
{ {
#if LWIP_NETIF_API
err_t err; err_t err;
if (ifindex > 0xff) { if (ifindex > 0xff) {
return NULL; return NULL;
@ -54,12 +55,17 @@ lwip_if_indextoname(unsigned ifindex, char *ifname)
if (!err && ifname[0] != '\0') { if (!err && ifname[0] != '\0') {
return ifname; return ifname;
} }
#else /* LWIP_NETIF_API */
LWIP_UNUSED_ARG(ifindex);
LWIP_UNUSED_ARG(ifname);
#endif /* LWIP_NETIF_API */
return NULL; return NULL;
} }
unsigned int unsigned int
lwip_if_nametoindex(const char *ifname) lwip_if_nametoindex(const char *ifname)
{ {
#if LWIP_NETIF_API
err_t err; err_t err;
u8_t index; u8_t index;
@ -67,6 +73,9 @@ lwip_if_nametoindex(const char *ifname)
if (!err) { if (!err) {
return index; return index;
} }
#else /* LWIP_NETIF_API */
LWIP_UNUSED_ARG(ifname);
#endif /* LWIP_NETIF_API */
return 0; /* invalid index */ return 0; /* invalid index */
} }