Changes to netlib and nsh so that you build build with PF_IEEE802154 enabled and 6LoWPAN disabled.

This commit is contained in:
Gregory Nutt 2017-08-20 09:09:47 -06:00
parent 6cbf2b9130
commit 41ce937ed0
16 changed files with 141 additions and 70 deletions

View File

@ -145,7 +145,7 @@ int pfserver_main(int argc, char *argv[])
if (client.sa_addr.s_mode == IEEE802154_ADDRMODE_SHORT)
{
printf("server: %d. Received %d bytes from %02x:02x\n",
printf("server: %d. Received %d bytes from %02x:%02x\n",
offset, nbytes,
client.sa_addr.s_saddr[0], client.sa_addr.s_saddr[1]);
}

View File

@ -114,7 +114,6 @@ int netlib_setmacaddr(FAR const char *ifname, FAR const uint8_t *macaddr);
int netlib_getmacaddr(FAR const char *ifname, FAR uint8_t *macaddr);
#endif
#ifdef CONFIG_NET_6LOWPAN
#ifdef CONFIG_WIRELESS_IEEE802154
/* IEEE 802.15.4 MAC IOCTL commands. */
@ -139,7 +138,6 @@ int netlib_getnodnodeaddr(FAR const char *ifname,
bool netlib_nodeaddrconv(FAR const char *addrstr,
FAR struct pktradio_addr_s *nodeaddr);
#endif
#endif
/* IP address support */

View File

@ -86,15 +86,14 @@ ifeq ($(CONFIG_NET_ETHERNET),y)
CSRCS += netlib_setmacaddr.c netlib_getmacaddr.c
endif
ifeq ($(CONFIG_NET_6LOWPAN),y)
ifeq ($(CONFIG_WIRELESS_IEEE802154),y)
CSRCS += netlib_seteaddr.c netlib_getpanid.c netlib_saddrconv.c netlib_eaddrconv.c
endif
ifeq ($(CONFIG_WIRELESS_PKTRADIO),y)
CSRCS += netlib_getproperties.c netlib_getnodeaddr.c netlib_setnodeaddr.c
CSRCS += netlib_nodeaddrconv.c
endif
endif
# IGMP support

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -54,6 +53,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -64,11 +65,14 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
# define PF_FAMILY PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
# define PF_FAMILY PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_IEEE802154)
# define PF_FAMILY PF_IEEE802154
# define AF_FAMILY AF_IEEE802154
#endif
/****************************************************************************
@ -100,7 +104,7 @@ int netlib_getessid(FAR const char *ifname, FAR char *essid, size_t idlen)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct iwreq req;

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -53,6 +52,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -61,15 +62,17 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_LOCAL)
# define PF_INETX PF_LOCAL
# define AF_FAMILY AF_LOCAL
#elif defined(CONFIG_NET_PKT)
# define PF_INETX PF_PACKET
# define AF_FAMILY AF_PACKET
#elif defined(CONFIG_NET_IEEE802154)
# define AF_FAMILY AF_IEEE802154
#elif defined(CONFIG_NET_USRSOCK)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#endif
/****************************************************************************
@ -98,7 +101,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_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(AF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -52,6 +51,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -60,13 +61,15 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_PKT)
# define PF_INETX PF_PACKET
# define AF_FAMILY AF_PACKET
#elif defined(CONFIG_NET_IEEE802154)
# define AF_FAMILY AF_IEEE802154
#elif defined(CONFIG_NET_USRSOCK)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#endif
/****************************************************************************
@ -95,7 +98,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_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(AF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;
@ -114,6 +117,7 @@ int netlib_getmacaddr(const char *ifname, uint8_t *macaddr)
memcpy(macaddr, &req.ifr_hwaddr.sa_data, IFHWADDRLEN);
}
close(sockfd);
}
}

View File

@ -50,7 +50,8 @@
#include "nuttx/wireless/pktradio.h"
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@ -108,4 +109,4 @@ int netlib_getnodnodeaddr(FAR const char *ifname,
return ret;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -42,14 +42,18 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "wireless/ieee802154.h"
#include <net/if.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@ -72,6 +76,7 @@
int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid)
{
struct ieee802154_netmac_s arg;
int ret = ERROR;
if (ifname != NULL && panid != NULL)
@ -81,14 +86,26 @@ int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid)
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
/* Use the helper provided in libmac */
/* Perform the IOCTL */
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_PANID;
ret = ioctl(sockfd, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n",
ret);
}
ret = sixlowpan_getpanid(sockfd, ifname, panid);
close(sockfd);
IEEE802154_PANIDCOPY(panid, arg.u.getreq.attrval.mac.panid);
}
}
return ret;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -50,7 +50,8 @@
#include "nuttx/wireless/pktradio.h"
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@ -108,4 +109,4 @@ int netlib_getproperties(FAR const char *ifname,
return ret;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -52,7 +52,8 @@
#include "nuttx/wireless/pktradio.h"
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Private Functions
@ -189,4 +190,5 @@ bool netlib_nodeaddrconv(FAR const char *addrstr,
return false;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -42,14 +42,18 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "wireless/ieee802154.h"
#include <net/if.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@ -72,6 +76,7 @@
int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr)
{
struct ieee802154_netmac_s arg;
int ret = ERROR;
if (ifname != NULL)
@ -81,9 +86,21 @@ int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr)
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
/* Use the helper provided in libmac */
/* Perform the IOCTL */
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.setreq.attr = IEEE802154_ATTR_MAC_EADDR;
IEEE802154_EADDRCOPY(arg.u.setreq.attrval.mac.eaddr, eaddr);
ret = ioctl(sockfd, MAC802154IOC_MLME_SET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n",
ret);
}
ret = sixlowpan_seteaddr(sockfd, ifname, eaddr);
close(sockfd);
}
}
@ -91,4 +108,4 @@ int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr)
return ret;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -54,6 +53,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -64,11 +65,14 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
# define PF_FAMILY PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
# define PF_FAMILY PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_IEEE802154)
# define PF_FAMILY PF_IEEE802154
# define AF_FAMILY AF_IEEE802154
#endif
/****************************************************************************
@ -99,7 +103,7 @@ int netlib_setessid(FAR const char *ifname, FAR const char *essid)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct iwreq req;

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -52,6 +51,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -60,15 +61,17 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_LOCAL)
# define PF_INETX PF_LOCAL
# define AF_FAMILY AF_LOCAL
#elif defined(CONFIG_NET_PKT)
# define PF_INETX PF_PACKET
# define AF_FAMILY AF_PACKET
#elif defined(CONFIG_NET_IEEE802154)
# define AF_FAMILY AF_IEEE802154
#elif defined(CONFIG_NET_USRSOCK)
# define PF_INETX PF_INET
# define AF_FAMILY AF_INET
#endif
/****************************************************************************
@ -96,7 +99,7 @@ int netlib_ifup(const char *ifname)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(AF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;
@ -139,7 +142,7 @@ int netlib_ifdown(const char *ifname)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(AF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
@ -52,6 +51,8 @@
#include "netutils/netlib.h"
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -61,17 +62,20 @@
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
# define PF_FAMILY PF_INET
# define AF_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
# define PF_FAMILY PF_INET6
# define AF_FAMILY AF_INET6
#elif defined(CONFIG_NET_PKT)
# define PF_INETX PF_PACKET
# define AF_INETX AF_PACKET
# define PF_FAMILY PF_PACKET
# define AF_FAMILY AF_PACKET
#elif defined(CONFIG_NET_IEEE802154)
# define PF_FAMILY PF_IEEE802154
# define AF_FAMILY AF_IEEE802154
#elif defined(CONFIG_NET_USRSOCK)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
# define PF_FAMILY PF_INET
# define AF_FAMILY AF_INET
#endif
/****************************************************************************
@ -101,7 +105,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_INETX, NETLIB_SOCK_IOCTL, 0);
int sockfd = socket(PF_FAMILY, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct ifreq req;
@ -112,7 +116,7 @@ int netlib_setmacaddr(const char *ifname, const uint8_t *macaddr)
/* Put the new MAC address into the request */
req.ifr_hwaddr.sa_family = AF_INETX;
req.ifr_hwaddr.sa_family = AF_FAMILY;
memcpy(&req.ifr_hwaddr.sa_data, macaddr, IFHWADDRLEN);
/* Perform the ioctl to set the MAC address */

View File

@ -50,7 +50,8 @@
#include "nuttx/wireless/pktradio.h"
#include "netutils/netlib.h"
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if (defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)) && \
CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@ -104,4 +105,4 @@ int netlib_setnodeaddr(FAR const char *ifname,
return ret;
}
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
#endif /* (CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154) && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -76,6 +76,10 @@
# include <nuttx/net/sixlowpan.h>
#endif
#ifdef CONFIG_NET_IEEE802154
# include <nuttx/net/ieee802154.h>
#endif
#ifdef CONFIG_NETUTILS_NTPCLIENT
# include "netutils/ntpclient.h"
#endif
@ -100,26 +104,34 @@
# undef CONFIG_NET_TUN
# undef CONFIG_NET_LOCAL
# undef CONFIG_NET_USRSOCK
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_6LOWPAN)
# undef CONFIG_NET_SLIP
# undef CONFIG_NET_TUN
# undef CONFIG_NET_LOCAL
# undef CONFIG_NET_USRSOCK
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_SLIP)
# undef CONFIG_NET_TUN
# undef CONFIG_NET_LOCAL
# undef CONFIG_NET_USRSOCK
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_TUN)
# undef CONFIG_NET_LOCAL
# undef CONFIG_NET_USRSOCK
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_LOCAL)
# undef CONFIG_NET_USRSOCK
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_USRSOCK)
# undef CONFIG_NET_IEEE802154
# undef CONFIG_NET_LOOPBACK
#elif defined(CONFIG_NET_IEEE802154)
# undef CONFIG_NET_LOOPBACK
#endif
@ -174,7 +186,7 @@
#elif defined(CONFIG_NET_ETHERNET)
# define NET_DEVNAME "eth0"
# define NSH_HAVE_NETDEV
#elif defined(CONFIG_NET_6LOWPAN)
#elif defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
# define NET_DEVNAME "wpan0"
# define NSH_HAVE_NETDEV
#elif defined(CONFIG_NET_SLIP)
@ -344,7 +356,8 @@ static void nsh_set_macaddr(void)
*
****************************************************************************/
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NET_6LOWPAN)
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NET_6LOWPAN) && ! \
defined(CONFIG_NET_IEEE802154)
static void nsh_set_ipaddrs(void)
{
#ifdef CONFIG_NET_IPv4