summaryrefslogtreecommitdiff
path: root/apps/netutils/netlib/netlib_setmacaddr.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-19 11:41:46 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-19 11:41:46 -0600
commit0694c0413702a7ff4f6bcd2c862abd89f3e7b24c (patch)
tree298997f5a09dbe821254368446a4161bd4c74621 /apps/netutils/netlib/netlib_setmacaddr.c
parentcab1ffb52e219faa226e9d82ef3687a17797cba5 (diff)
downloadnuttx-0694c0413702a7ff4f6bcd2c862abd89f3e7b24c.tar.gz
nuttx-0694c0413702a7ff4f6bcd2c862abd89f3e7b24c.tar.bz2
nuttx-0694c0413702a7ff4f6bcd2c862abd89f3e7b24c.zip
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
Diffstat (limited to 'apps/netutils/netlib/netlib_setmacaddr.c')
-rw-r--r--apps/netutils/netlib/netlib_setmacaddr.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/apps/netutils/netlib/netlib_setmacaddr.c b/apps/netutils/netlib/netlib_setmacaddr.c
index 733690a18..0c5221789 100644
--- a/apps/netutils/netlib/netlib_setmacaddr.c
+++ b/apps/netutils/netlib/netlib_setmacaddr.c
@@ -55,11 +55,20 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-# define AF_INETX AF_INET6
-#else
-# define AF_INETX AF_INET
+/****************************************************************************
+ * 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.
+ */
+
+#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;