apps/netutils/netlib: All IOCTLs must use a valid address family -- even if the address family does not matter such as when getting the MAC address or the network flags

This commit is contained in:
Gregory Nutt 2015-01-19 11:41:46 -06:00
parent 71d2ae0fac
commit 2668e34f5a
5 changed files with 61 additions and 9 deletions

View File

@ -58,8 +58,10 @@ endif
# These require TCP support
ifeq ($(CONFIG_NET_TCP),y)
ifeq ($(CONFIG_NET_IPv4),y) # Not yet available for IPv6
CSRCS += netlib_server.c netlib_listenon.c
endif
endif
# No MAC address support for SLIP (Ethernet only)
@ -70,8 +72,10 @@ endif
# IGMP support
ifeq ($(CONFIG_NET_IGMP),y)
ifeq ($(CONFIG_NET_IPv4),y) # Not yet available for IPv6
CSRCS += netlib_ipmsfilter.c
endif
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))

View File

@ -53,6 +53,19 @@
#include <apps/netutils/netlib.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket really does not
* matter. It should, however, be valid in the current configuration.
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -79,7 +92,7 @@ int netlib_getifstatus(FAR const char *ifname, FAR uint8_t *flags)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;

View File

@ -52,6 +52,19 @@
#include <apps/netutils/netlib.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket really does not
* matter. It should, however, be valid in the current configuration.
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -78,7 +91,7 @@ int netlib_getmacaddr(const char *ifname, uint8_t *macaddr)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;

View File

@ -52,6 +52,19 @@
#include <apps/netutils/netlib.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket really does not
* matter. It should, however, be valid in the current configuration.
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -77,7 +90,7 @@ int netlib_ifup(const char *ifname)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;
@ -120,7 +133,7 @@ int netlib_ifdown(const char *ifname)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;

View File

@ -55,11 +55,20 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket and in the IOCTL
* data really does not matter. It should, however, be valid in the current
* configuration.
*/
#ifdef CONFIG_NET_IPv6
# define AF_INETX AF_INET6
#else
# define AF_INETX AF_INET
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
#endif
/****************************************************************************
@ -89,7 +98,7 @@ int netlib_setmacaddr(const char *ifname, const uint8_t *macaddr)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;