Merge branch 'ieee802154'
This commit is contained in:
commit
7a9e931010
@ -115,12 +115,11 @@ int netlib_getmacaddr(FAR const char *ifname, FAR uint8_t *macaddr);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
/* Get IEEE802.15.4 MAC driver node address */
|
/* Set IEEE 802.15.4 extended address. */
|
||||||
|
|
||||||
|
int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr);
|
||||||
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid);
|
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid);
|
||||||
int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr);
|
bool netlib_eaddrconv(FAR const char *hwstr, FAR uint8_t *hw);
|
||||||
int netlib_setpanid(FAR const char *ifname, uint16_t panid);
|
|
||||||
bool netlib_nodeaddrconv(FAR const char *hwstr, FAR uint8_t *hw);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* IP address support */
|
/* IP address support */
|
||||||
|
@ -87,8 +87,7 @@ CSRCS += netlib_setmacaddr.c netlib_getmacaddr.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||||
CSRCS += netlib_getpanid.c netlib_setnodeaddr.c netlib_setpanid.c
|
CSRCS += netlib_seteaddr.c netlib_getpanid.c netlib_eaddrconv.c
|
||||||
CSRCS += netlib_nodeaddrconv.c
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# IGMP support
|
# IGMP support
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* netutils/netlib/netlib_nodeaddrconv.c
|
* netutils/netlib/netlib_eaddrconv.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@ -50,26 +50,26 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netlib_nodeaddrconv
|
* Name: netlib_eaddrconv
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool netlib_nodeaddrconv(FAR const char *hwstr, FAR uint8_t *hw)
|
bool netlib_eaddrconv(FAR const char *hwstr, FAR uint8_t *hw)
|
||||||
{
|
{
|
||||||
unsigned char tmp;
|
unsigned char tmp;
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
unsigned char j;
|
unsigned char j;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
/* Form xx:xx or xx:xx:xx:xx:xx:xx:xx:xx for extended Rime address */
|
/* Extended Address Form: xx:xx:xx:xx:xx:xx:xx:xx */
|
||||||
|
|
||||||
if (strlen(hwstr) != 3 * NET_6LOWPAN_ADDRSIZE - 1)
|
if (strlen(hwstr) != 3 * 8 - 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
|
|
||||||
for (i = 0; i < NET_6LOWPAN_ADDRSIZE; ++i)
|
for (i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
do
|
do
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* netutils/netlib/netlib_setpanid.c
|
* netutils/netlib/netlib_seteaddr.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@ -56,21 +56,21 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netlib_setpanid
|
* Name: netlib_seteaddr
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Join the specified PAN ID
|
* Set the IEEE802.15.4 extended MAC address
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ifname The name of the interface to use
|
* ifname The name of the interface to use
|
||||||
* panid The PAN ID to join
|
* eaddr The new extended address
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* 0 on success; -1 on failure. errno will be set on failure.
|
* 0 on success; -1 on failure. errno will be set on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int netlib_setpanid(FAR const char *ifname, uint16_t panid)
|
int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr)
|
||||||
{
|
{
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ int netlib_setpanid(FAR const char *ifname, uint16_t panid)
|
|||||||
{
|
{
|
||||||
/* Use the helper provided in libmac */
|
/* Use the helper provided in libmac */
|
||||||
|
|
||||||
ret = sixlowpan_setpanid(sockfd, ifname, panid);
|
ret = sixlowpan_seteaddr(sockfd, ifname, eaddr);
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,109 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* netutils/netlib/netlib_setnodeaddr.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <nuttx/net/sixlowpan.h>
|
|
||||||
|
|
||||||
#include "netutils/netlib.h"
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: netlib_setnodeaddr
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set the 6loWPAN IEEE802.15.4 MAC network driver node address
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* ifname The name of the interface to use
|
|
||||||
* nodeaddr Node address to set, size must be NET_6LOWPAN_ADDRSIZE
|
|
||||||
*
|
|
||||||
* Return:
|
|
||||||
* 0 on success; -1 on failure
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr)
|
|
||||||
{
|
|
||||||
int ret = ERROR;
|
|
||||||
|
|
||||||
if (ifname && nodeaddr)
|
|
||||||
{
|
|
||||||
/* Get a socket (only so that we get access to the INET subsystem) */
|
|
||||||
|
|
||||||
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
|
|
||||||
if (sockfd >= 0)
|
|
||||||
{
|
|
||||||
struct ifreq req;
|
|
||||||
|
|
||||||
/* Put the driver name into the request */
|
|
||||||
|
|
||||||
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
|
||||||
|
|
||||||
/* Put the new MAC address into the request */
|
|
||||||
|
|
||||||
req.ifr_hwaddr.sa_family = AF_INET6;
|
|
||||||
memcpy(&req.ifr_hwaddr.sa_data, nodeaddr, NET_6LOWPAN_ADDRSIZE);
|
|
||||||
|
|
||||||
/* Perform the ioctl to set the node address */
|
|
||||||
|
|
||||||
ret = ioctl(sockfd, SIOCSIFHWADDR, (unsigned long)&req);
|
|
||||||
close(sockfd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
|
|
@ -1129,7 +1129,10 @@ config NSH_NETINIT_DEBUG
|
|||||||
or CONFIG_DEBUG_INFO are not selected. This allows for focused, unit-
|
or CONFIG_DEBUG_INFO are not selected. This allows for focused, unit-
|
||||||
level debug of the NSH network initialization logic.
|
level debug of the NSH network initialization logic.
|
||||||
|
|
||||||
|
# No IP address if 6LOWPAN selected; but Ethernet has precedence.
|
||||||
|
|
||||||
menu "IP Address Configuration"
|
menu "IP Address Configuration"
|
||||||
|
depends on NET_ETHERNET || !NET_6LOWPAN
|
||||||
|
|
||||||
config NSH_DHCPC
|
config NSH_DHCPC
|
||||||
bool "Use DHCP to get IP address"
|
bool "Use DHCP to get IP address"
|
||||||
@ -1426,7 +1429,7 @@ config NSH_IPv6NETMASK_8
|
|||||||
individually. This is the eighth of the 8-values. The default for
|
individually. This is the eighth of the 8-values. The default for
|
||||||
all eight values is fe00::0.
|
all eight values is fe00::0.
|
||||||
|
|
||||||
endif #NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
endif # NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
||||||
endmenu # IP Address Configuration
|
endmenu # IP Address Configuration
|
||||||
|
|
||||||
config NSH_DNS
|
config NSH_DNS
|
||||||
@ -1472,8 +1475,9 @@ endchoice # MAC address selection
|
|||||||
|
|
||||||
config NSH_MACADDR
|
config NSH_MACADDR
|
||||||
hex "Fixed MAC address"
|
hex "Fixed MAC address"
|
||||||
default 0x00e0deadbeef
|
default 0x00e0deadbeef if NET_ETHERNET
|
||||||
depends on NSH_SWMAC
|
default 0x00fade00deadbeef if !NET_ETHERNET && NET_6LOWPAN
|
||||||
|
depends on NSH_SWMAC && (NET_ETHERNET || NET_6LOWPAN)
|
||||||
---help---
|
---help---
|
||||||
If the hardware has no built-in MAC address and if the NSH_SWMAC
|
If the hardware has no built-in MAC address and if the NSH_SWMAC
|
||||||
option is selected, then the fixed, software-assigned MAC address
|
option is selected, then the fixed, software-assigned MAC address
|
||||||
@ -1481,14 +1485,6 @@ config NSH_MACADDR
|
|||||||
|
|
||||||
endif # NSH_NOMAC
|
endif # NSH_NOMAC
|
||||||
|
|
||||||
config NSH_PANID
|
|
||||||
hex "6loWPAN PAN ID"
|
|
||||||
default 0xface
|
|
||||||
depends on NET_6LOWPAN
|
|
||||||
range 0x0000 0xffff
|
|
||||||
---help---
|
|
||||||
Select the PAN ID to join upon initialization.
|
|
||||||
|
|
||||||
menu "WAPI Configuration"
|
menu "WAPI Configuration"
|
||||||
depends on NET && WIRELESS_WAPI
|
depends on NET && WIRELESS_WAPI
|
||||||
|
|
||||||
|
@ -762,7 +762,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
uint8_t mac[IFHWADDRLEN];
|
uint8_t mac[IFHWADDRLEN];
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
uint8_t nodeaddr[NET_6LOWPAN_ADDRSIZE];
|
uint8_t eaddr[8];
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_NSH_DHCPC)
|
#if defined(CONFIG_NSH_DHCPC)
|
||||||
FAR void *handle;
|
FAR void *handle;
|
||||||
@ -862,7 +862,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
#ifdef CONFIG_NET_ETHERNET
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
badarg = !netlib_ethaddrconv(hw, mac);
|
badarg = !netlib_ethaddrconv(hw, mac);
|
||||||
#else
|
#else
|
||||||
badarg = !netlib_nodeaddrconv(hw, nodeaddr);
|
badarg = !netlib_eaddrconv(hw, eaddr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -906,7 +906,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
#ifdef CONFIG_NET_ETHERNET
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
netlib_setmacaddr(intf, mac);
|
netlib_setmacaddr(intf, mac);
|
||||||
#else
|
#else
|
||||||
netlib_setnodeaddr(intf, nodeaddr);
|
netlib_seteaddr(intf, eaddr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,20 +88,48 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Pick one and at most one supported link layer so that all decisions are
|
||||||
|
* made consistently.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_ETHERNET)
|
||||||
|
# undef CONFIG_NET_6LOWPAN
|
||||||
|
# undef CONFIG_NET_SLIP
|
||||||
|
# undef CONFIG_NET_TUN
|
||||||
|
# undef CONFIG_NET_LOCAL
|
||||||
|
# undef CONFIG_NET_USRSOCK
|
||||||
|
# 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_LOOPBACK
|
||||||
|
#elif defined(CONFIG_NET_SLIP)
|
||||||
|
# undef CONFIG_NET_TUN
|
||||||
|
# undef CONFIG_NET_LOCAL
|
||||||
|
# undef CONFIG_NET_USRSOCK
|
||||||
|
# undef CONFIG_NET_LOOPBACK
|
||||||
|
#elif defined(CONFIG_NET_TUN)
|
||||||
|
# undef CONFIG_NET_LOCAL
|
||||||
|
# undef CONFIG_NET_USRSOCK
|
||||||
|
# undef CONFIG_NET_LOOPBACK
|
||||||
|
#elif defined(CONFIG_NET_LOCAL)
|
||||||
|
# undef CONFIG_NET_USRSOCK
|
||||||
|
# undef CONFIG_NET_LOOPBACK
|
||||||
|
#elif defined(CONFIG_NET_USRSOCK)
|
||||||
|
# undef CONFIG_NET_LOOPBACK
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Only Ethernet and 6loWPAN have MAC layer addresses */
|
/* Only Ethernet and 6loWPAN have MAC layer addresses */
|
||||||
|
|
||||||
#undef HAVE_MAC
|
#undef HAVE_MAC
|
||||||
#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN)
|
#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN)
|
||||||
# define HAVE_MAC 1
|
# define HAVE_MAC 1
|
||||||
# if defined(CONFIG_NET_6LOWPAN)
|
|
||||||
# if !defined(CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED) && CONFIG_NSH_MACADDR > 0xffff
|
|
||||||
# error Invalid 6loWPAN node address for SIZE == 2
|
|
||||||
# elif defined(CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED) && CONFIG_NSH_MACADDR > 0xffffffffffffffffull
|
|
||||||
# error Invalid 6loWPAN node address for SIZE == 8
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Provide a default DNS address */
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_DRIPADDR) && !defined(CONFIG_NSH_DNSIPADDR)
|
#if defined(CONFIG_NSH_DRIPADDR) && !defined(CONFIG_NSH_DNSIPADDR)
|
||||||
# define CONFIG_NSH_DNSIPADDR CONFIG_NSH_DRIPADDR
|
# define CONFIG_NSH_DNSIPADDR CONFIG_NSH_DRIPADDR
|
||||||
#endif
|
#endif
|
||||||
@ -185,7 +213,8 @@
|
|||||||
static sem_t g_notify_sem;
|
static sem_t g_notify_sem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF)
|
#if defined(CONFIG_NET_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF) && \
|
||||||
|
!defined(CONFIG_NET_6LOWPAN)
|
||||||
/* Host IPv6 address */
|
/* Host IPv6 address */
|
||||||
|
|
||||||
static const uint16_t g_ipv6_hostaddr[8] =
|
static const uint16_t g_ipv6_hostaddr[8] =
|
||||||
@ -227,45 +256,32 @@ static const uint16_t g_ipv6_netmask[8] =
|
|||||||
HTONS(CONFIG_NSH_IPv6NETMASK_7),
|
HTONS(CONFIG_NSH_IPv6NETMASK_7),
|
||||||
HTONS(CONFIG_NSH_IPv6NETMASK_8),
|
HTONS(CONFIG_NSH_IPv6NETMASK_8),
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
|
#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF && !CONFIG_NET_6LOWPAN */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nsh_netinit_configure
|
* Name: nsh_set_macaddr
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the network per the selected NuttX configuration
|
* Set the hardware MAC address if the hardware is not capable of doing
|
||||||
|
* that for itself.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void nsh_netinit_configure(void)
|
#if defined(NSH_HAVE_NETDEV) && defined(CONFIG_NSH_NOMAC) && defined(HAVE_MAC)
|
||||||
|
static void nsh_set_macaddr(void)
|
||||||
{
|
{
|
||||||
#ifdef NSH_HAVE_NETDEV
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
|
||||||
struct in_addr addr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)
|
|
||||||
FAR void *handle;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (((defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)) || \
|
|
||||||
defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC))
|
|
||||||
#if defined(CONFIG_NET_ETHERNET)
|
#if defined(CONFIG_NET_ETHERNET)
|
||||||
uint8_t mac[IFHWADDRLEN];
|
uint8_t mac[IFHWADDRLEN];
|
||||||
#elif defined(CONFIG_NET_6LOWPAN)
|
#elif defined(CONFIG_NET_6LOWPAN)
|
||||||
uint8_t nodeaddr[NET_6LOWPAN_ADDRSIZE];
|
uint8_t eaddr[NET_6LOWPAN_ADDRSIZE];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
ninfo("Entry\n");
|
|
||||||
|
|
||||||
/* Many embedded network interfaces must have a software assigned MAC */
|
/* Many embedded network interfaces must have a software assigned MAC */
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_NOMAC) && defined(HAVE_MAC)
|
|
||||||
#if defined(CONFIG_NET_ETHERNET)
|
#if defined(CONFIG_NET_ETHERNET)
|
||||||
/* Use the configured, fixed MAC address */
|
/* Use the configured, fixed MAC address */
|
||||||
|
|
||||||
@ -281,33 +297,44 @@ static void nsh_netinit_configure(void)
|
|||||||
netlib_setmacaddr(NET_DEVNAME, mac);
|
netlib_setmacaddr(NET_DEVNAME, mac);
|
||||||
|
|
||||||
#elif defined(CONFIG_NET_6LOWPAN)
|
#elif defined(CONFIG_NET_6LOWPAN)
|
||||||
/* Use the configured, fixed MAC address */
|
/* Use the configured, fixed extended address */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
|
eaddr[0] = (CONFIG_NSH_MACADDR >> (8 * 7)) & 0xff;
|
||||||
nodeaddr[0] = (CONFIG_NSH_MACADDR >> (8 * 7)) & 0xff;
|
eaddr[1] = (CONFIG_NSH_MACADDR >> (8 * 6)) & 0xff;
|
||||||
nodeaddr[1] = (CONFIG_NSH_MACADDR >> (8 * 6)) & 0xff;
|
eaddr[2] = (CONFIG_NSH_MACADDR >> (8 * 5)) & 0xff;
|
||||||
nodeaddr[2] = (CONFIG_NSH_MACADDR >> (8 * 5)) & 0xff;
|
eaddr[3] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
|
||||||
nodeaddr[3] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
|
eaddr[4] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
|
||||||
nodeaddr[4] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
|
eaddr[5] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
|
||||||
nodeaddr[5] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
|
eaddr[6] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
||||||
nodeaddr[6] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
eaddr[7] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
||||||
nodeaddr[7] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
|
||||||
|
/* Set the 6loWPAN extended address */
|
||||||
|
|
||||||
|
(void)netlib_seteaddr(NET_DEVNAME, eaddr);
|
||||||
|
|
||||||
|
#endif /* CONFIG_NET_ETHERNET */
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
nodeaddr[0] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
# define nsh_set_macaddr()
|
||||||
nodeaddr[1] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the 6loWPAN node address */
|
/****************************************************************************
|
||||||
|
* Name: nsh_set_ipaddrs
|
||||||
(void)netlib_setnodeaddr(NET_DEVNAME, nodeaddr);
|
*
|
||||||
|
* Description:
|
||||||
/* Set the 6loWPAN PAN ID */
|
* Setup IP addresses.
|
||||||
|
*
|
||||||
(void)netlib_setpanid(NET_DEVNAME, CONFIG_NSH_PANID);
|
* For 6loWPAN, the IP address derives from the MAC address. Setting it
|
||||||
#endif /* CONFIG_NET_ETHERNET */
|
* to any user provided value is asking for trouble.
|
||||||
#endif /* CONFIG_NSH_NOMAC && HAVE_MAC */
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NET_6LOWPAN)
|
||||||
|
static void nsh_set_ipaddrs(void)
|
||||||
|
{
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
struct in_addr addr;
|
||||||
|
|
||||||
/* Set up our host address */
|
/* Set up our host address */
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_DHCPC
|
#ifndef CONFIG_NSH_DHCPC
|
||||||
@ -358,13 +385,30 @@ static void nsh_netinit_configure(void)
|
|||||||
addr.s_addr = HTONL(CONFIG_NSH_DNSIPADDR);
|
addr.s_addr = HTONL(CONFIG_NSH_DNSIPADDR);
|
||||||
netlib_set_ipv4dnsaddr(&addr);
|
netlib_set_ipv4dnsaddr(&addr);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nsh_set_ipaddrs()
|
||||||
|
#endif
|
||||||
|
|
||||||
/* That completes the 'local' initialization of the network device. */
|
/****************************************************************************
|
||||||
|
* Name: nsh_net_bringup()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Bring up the configured network
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NSH_NETLOCAL)
|
||||||
|
static void nsh_net_bringup(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NSH_DHCPC
|
||||||
|
uint8_t mac[IFHWADDRLEN];
|
||||||
|
FAR void *handle;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_NETLOCAL
|
|
||||||
/* Bring the network up. */
|
/* Bring the network up. */
|
||||||
|
|
||||||
netlib_ifup("eth0");
|
netlib_ifup(NET_DEVNAME);
|
||||||
|
|
||||||
#ifdef CONFIG_WIRELESS_WAPI
|
#ifdef CONFIG_WIRELESS_WAPI
|
||||||
/* Associate the wlan with an access point. */
|
/* Associate the wlan with an access point. */
|
||||||
@ -415,10 +459,38 @@ static void nsh_netinit_configure(void)
|
|||||||
|
|
||||||
ntpc_start();
|
ntpc_start();
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_NSH_NETLOCAL */
|
}
|
||||||
#endif /* NSH_HAVE_NETDEV */
|
#else
|
||||||
|
# define nsh_net_bringup()
|
||||||
|
#endif
|
||||||
|
|
||||||
ninfo("Exit\n");
|
/****************************************************************************
|
||||||
|
* Name: nsh_netinit_configure
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the network per the selected NuttX configuration
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void nsh_netinit_configure(void)
|
||||||
|
{
|
||||||
|
#ifdef NSH_HAVE_NETDEV
|
||||||
|
/* Many embedded network interfaces must have a software assigned MAC */
|
||||||
|
|
||||||
|
nsh_set_macaddr();
|
||||||
|
|
||||||
|
/* Set up IP addresses */
|
||||||
|
|
||||||
|
nsh_set_ipaddrs();
|
||||||
|
|
||||||
|
/* That completes the 'local' initialization of the network device. */
|
||||||
|
|
||||||
|
#ifndef CONFIG_NSH_NETLOCAL
|
||||||
|
/* Bring the network up. */
|
||||||
|
|
||||||
|
nsh_net_bringup();
|
||||||
|
#endif
|
||||||
|
#endif /* NSH_HAVE_NETDEV */
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user