mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 22:14:25 +00:00
Add errno support to if_indextoname()
This commit adds support in if_indextoname() to return ENXIO when no interface is found. This conforms to the Open Group/RFC 3493 specification In order to leverage errno set support, the set_errno macro from sockets.c was moved to sockets_priv.h
This commit is contained in:
parent
852993029d
commit
3a7e03aaff
@ -43,8 +43,10 @@
|
|||||||
|
|
||||||
#if LWIP_SOCKET
|
#if LWIP_SOCKET
|
||||||
|
|
||||||
|
#include "lwip/errno.h"
|
||||||
#include "lwip/if_api.h"
|
#include "lwip/if_api.h"
|
||||||
#include "lwip/netifapi.h"
|
#include "lwip/netifapi.h"
|
||||||
|
#include "lwip/priv/sockets_priv.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup if_api
|
* @ingroup if_api
|
||||||
@ -59,19 +61,17 @@ char *
|
|||||||
lwip_if_indextoname(unsigned int ifindex, char *ifname)
|
lwip_if_indextoname(unsigned int ifindex, char *ifname)
|
||||||
{
|
{
|
||||||
#if LWIP_NETIF_API
|
#if LWIP_NETIF_API
|
||||||
err_t err;
|
if (ifindex <= 0xff) {
|
||||||
if (ifindex > 0xff) {
|
err_t err = netifapi_netif_index_to_name((u8_t)ifindex, ifname);
|
||||||
return NULL;
|
if (!err && ifname[0] != '\0') {
|
||||||
}
|
return ifname;
|
||||||
|
}
|
||||||
err = netifapi_netif_index_to_name((u8_t)ifindex, ifname);
|
|
||||||
if (!err && ifname[0] != '\0') {
|
|
||||||
return ifname;
|
|
||||||
}
|
}
|
||||||
#else /* LWIP_NETIF_API */
|
#else /* LWIP_NETIF_API */
|
||||||
LWIP_UNUSED_ARG(ifindex);
|
LWIP_UNUSED_ARG(ifindex);
|
||||||
LWIP_UNUSED_ARG(ifname);
|
LWIP_UNUSED_ARG(ifname);
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
set_errno(ENXIO);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,14 +293,6 @@ static struct lwip_select_cb *select_cb_list;
|
|||||||
and checked in event_callback to see if it has changed. */
|
and checked in event_callback to see if it has changed. */
|
||||||
static volatile int select_cb_ctr;
|
static volatile int select_cb_ctr;
|
||||||
|
|
||||||
#if LWIP_SOCKET_SET_ERRNO
|
|
||||||
#ifndef set_errno
|
|
||||||
#define set_errno(err) do { if (err) { errno = (err); } } while(0)
|
|
||||||
#endif
|
|
||||||
#else /* LWIP_SOCKET_SET_ERRNO */
|
|
||||||
#define set_errno(err)
|
|
||||||
#endif /* LWIP_SOCKET_SET_ERRNO */
|
|
||||||
|
|
||||||
#define sock_set_errno(sk, e) do { \
|
#define sock_set_errno(sk, e) do { \
|
||||||
const int sockerr = (e); \
|
const int sockerr = (e); \
|
||||||
sk->err = (u8_t)sockerr; \
|
sk->err = (u8_t)sockerr; \
|
||||||
|
@ -48,6 +48,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_SOCKET_SET_ERRNO
|
||||||
|
#ifndef set_errno
|
||||||
|
#define set_errno(err) do { if (err) { errno = (err); } } while(0)
|
||||||
|
#endif
|
||||||
|
#else /* LWIP_SOCKET_SET_ERRNO */
|
||||||
|
#define set_errno(err)
|
||||||
|
#endif /* LWIP_SOCKET_SET_ERRNO */
|
||||||
|
|
||||||
#if !LWIP_TCPIP_CORE_LOCKING
|
#if !LWIP_TCPIP_CORE_LOCKING
|
||||||
/** Maximum optlen used by setsockopt/getsockopt */
|
/** Maximum optlen used by setsockopt/getsockopt */
|
||||||
#define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
|
#define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
|
||||||
|
Loading…
x
Reference in New Issue
Block a user