Spirit + 6LoWPAN: In STAR configuration, Spirit must use a configured well known hub address. 6LoWPAN cannot assume that the PAN coordinator is the STAR hub; it must ask the radio to provide it with the address of the star hub
This commit is contained in:
parent
c2fbef2062
commit
a29a168086
@ -456,7 +456,6 @@ Configuration sub-directories
|
||||
steps with E1 and E2 representing the two star endpoints and C
|
||||
representing the star hub:
|
||||
|
||||
C: nsh> ifconfig wpan0 hw 34 <-- Sets hub node address
|
||||
C: nsh> ifup wpan0 <-- Brings up the network on the hub
|
||||
C: nsh> telnetd <-- Starts the Telnet daemon on the hub
|
||||
C: nsh> ifconfig <-- To get the IP address of the hub
|
||||
@ -471,7 +470,11 @@ Configuration sub-directories
|
||||
E2: nsh> telnetd <-- Starts the Telnet daemon on the E2 node
|
||||
E2: nsh> ifconfig <-- To get the IP address of E2 endpoint
|
||||
|
||||
The modified usage of the TCP test is show below:
|
||||
It is not necessary to set the hub node address, that will automatically
|
||||
be set to CONFIG_SPIRIT_HUBNODE when the hub boots. CONFIG_SPIRIT_HUBNODE
|
||||
is the "well-known" address of the star hub.
|
||||
|
||||
The modified usage of the TCP test is then show below:
|
||||
|
||||
E1: nsh> tcpserver &
|
||||
E2: nsh> tcpclient <server-ip> &
|
||||
|
@ -75,4 +75,12 @@ config SPIRIT_CRCDISABLE
|
||||
---help---
|
||||
Disables CRC calculation and filtering. Default is enabled.
|
||||
|
||||
config SPIRIT_HUBNODE
|
||||
hex "Address of hub node"
|
||||
default 0x34
|
||||
depends on NET_STAR
|
||||
---help---
|
||||
Provides the "well known" address of the hub node in the
|
||||
star configuration.
|
||||
|
||||
endif # SPIRIT_NETDEV
|
||||
|
@ -148,7 +148,11 @@
|
||||
|
||||
/* Default node address */
|
||||
|
||||
#define SPIRIT_NODE_ADDR 0x34
|
||||
#if defined(CONFIG_NET_STARHUB) && defined(CONFIG_SPIRIT_HUBNODE)
|
||||
# define SPIRIT_NODE_ADDR CONFIG_SPIRIT_HUBNODE
|
||||
#else
|
||||
# define SPIRIT_NODE_ADDR 0x34
|
||||
#endif
|
||||
|
||||
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
|
||||
|
||||
@ -1995,6 +1999,14 @@ static int spirit_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
|
||||
properties->sp_bcast.nv_addrlen = 1;
|
||||
properties->sp_bcast.nv_addr[0] = SPIRIT_BCAST_ADDRESS;
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
/* Star hub node address */
|
||||
|
||||
properties->sp_hubnode.nv_addrlen = 1;
|
||||
properties->sp_hubnode.nv_addr[0] = CONFIG_SPIRIT_HUBNODE;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -357,6 +357,9 @@ struct sixlowpan_properties_s
|
||||
uint8_t sp_pktlen; /* Fixed packet/frame size (up to 255) */
|
||||
struct netdev_varaddr_s sp_mcast; /* Multicast address */
|
||||
struct netdev_varaddr_s sp_bcast; /* Broadcast address */
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
struct netdev_varaddr_s sp_hubnode; /* Address of the hub node in a star */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The device structure for radio network device differs from the standard
|
||||
|
@ -123,6 +123,9 @@ struct pktradio_properties_s
|
||||
uint8_t pp_pktlen; /* Fixed packet/frame size (up to 255) */
|
||||
struct pktradio_addr_s pp_mcast; /* Multicast address */
|
||||
struct pktradio_addr_s pp_bcast; /* Broadcast address */
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
struct pktradio_addr_s pp_hubnode; /* Address of the hub node in a star */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This is the structure passed with all packet radio IOCTL commands.
|
||||
|
@ -166,82 +166,6 @@ static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *eadd
|
||||
#endif
|
||||
#endif /* !CONFIG_NET_STARPOINT */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_coord_eaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the extended address of the PAN coordinator.
|
||||
*
|
||||
* Input parameters:
|
||||
* radio - Reference to a radio network driver state instance.
|
||||
* eaddr - The location in which to return the extended address.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int sixlowpan_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct netdev_varaddr_s *eaddr)
|
||||
{
|
||||
FAR struct net_driver_s *dev = &radio->r_dev;
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
memcpy(arg.ifr_name, radio->r_dev.d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_COORD_EADDR ;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEEE802154_EADDRCOPY(eaddr->u8, arg.u.getreq.attrval.mac.eaddr);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_coord_saddr
|
||||
*
|
||||
* Description:
|
||||
* Get the short address of the PAN coordinator.
|
||||
*
|
||||
* Input parameters:
|
||||
* radio - Reference to a radio network driver state instance.
|
||||
* saddr - The location in which to return the short address.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && !defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int sixlowpan_coord_saddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct netdev_varaddr_s *saddr)
|
||||
{
|
||||
FAR struct net_driver_s *dev = &radio->r_dev;
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
memcpy(arg.ifr_name, radio->r_dev.d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_COORD_SADDR ;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEEE802154_SADDRCOPY(saddr->nv_addr, arg.u.getreq.attrval.mac.saddr);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -272,22 +196,23 @@ int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct netdev_varaddr_s *destaddr)
|
||||
{
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
struct sixlowpan_properties_s properties;
|
||||
int ret;
|
||||
|
||||
/* If this node is a "point" in a star topology, then the destination
|
||||
* MAC address is the address of the hub/PAN coordinator.
|
||||
/* Only the radio driver knows the correct address of the hub. For IEEE
|
||||
* 802.15.4 this will be the address of the PAN coordinator. For other
|
||||
* radios, this may be some configured, "well-known" address.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
ret = sixlowpan_coord_eaddr(radio, &destaddr->nv_addr);
|
||||
destaddr->nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
#else
|
||||
memset(destaddr, 0, sizeof(struct netdev_varaddr_s));
|
||||
ret = sixlowpan_coord_saddr(radio, &destaddr->nv_addr);
|
||||
destaddr->nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
#endif
|
||||
DEBUGASSERT(radio->r_properties != NULL);
|
||||
ret = radio->r_properties(radio, &properties);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
memcpy(destaddr, &properaties.sp_hubnode, sizeof(truct netdev_varaddr_s));
|
||||
return OK;
|
||||
|
||||
#else /* CONFIG_NET_STARPOINT */
|
||||
|
||||
|
@ -935,6 +935,11 @@ static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
|
||||
properties->sp_bcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
/* Star hub node address -- Not supported*/
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,16 @@ static int macnet_txpoll_callback(FAR struct net_driver_s *dev);
|
||||
static void macnet_txpoll_work(FAR void *arg);
|
||||
static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...);
|
||||
|
||||
/* IOCTL support */
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
static int macnet_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct uint8_t *eaddr);
|
||||
#else
|
||||
static int macnet_coord_saddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct uint8_t *saddr)
|
||||
|
||||
/* NuttX callback functions */
|
||||
|
||||
static int macnet_ifup(FAR struct net_driver_s *dev);
|
||||
@ -211,7 +221,7 @@ static int macnet_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
|
||||
static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
struct ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
@ -220,7 +230,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Get the eaddr from the MAC */
|
||||
|
||||
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
arg.getreq.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
@ -232,7 +242,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Set the MAC address as the eaddr */
|
||||
|
||||
eaddr = arg.u.getreq.attrval.mac.eaddr;
|
||||
eaddr = arg.getreq.attrval.mac.eaddr;
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.sixlowpan.nv_addr, eaddr);
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
|
||||
@ -256,7 +266,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Get the saddr from the MAC */
|
||||
|
||||
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
arg.getreq.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
@ -268,7 +278,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Set the MAC address as the saddr */
|
||||
|
||||
saddr = arg.u.getreq.attrval.mac.saddr;
|
||||
saddr = arg.getreq.attrval.mac.saddr;
|
||||
IEEE802154_SADDRCOPY(dev->d_mac.sixlowpan.nv_addr, saddr);
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
|
||||
@ -538,6 +548,78 @@ static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...)
|
||||
work_queue(WPANWORK, &priv->md_pollwork, macnet_txpoll_work, priv, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_coord_eaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the extended address of the PAN coordinator.
|
||||
*
|
||||
* Input parameters:
|
||||
* radio - Reference to a radio network driver state instance.
|
||||
* eaddr - The location in which to return the extended address.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int macnet_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.getreq.attr = IEEE802154_ATTR_MAC_COORD_EADDR ;
|
||||
ret = mac802154_ioctl(priv->md_mac, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEEE802154_EADDRCOPY(eaddr, arg.getreq.attrval.mac.eaddr);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_coord_saddr
|
||||
*
|
||||
* Description:
|
||||
* Get the short address of the PAN coordinator.
|
||||
*
|
||||
* Input parameters:
|
||||
* radio - Reference to a radio network driver state instance.
|
||||
* saddr - The location in which to return the short address.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && !defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int macnet_coord_saddr(FAR struct sixlowpan_driver_s *radio,
|
||||
FAR struct uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.getreq.attr = IEEE802154_ATTR_MAC_COORD_SADDR ;
|
||||
ret = mac802154_ioctl(priv->md_mac, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEEE802154_SADDRCOPY(saddr, arg.getreq.attrval.mac.saddr);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_ifup
|
||||
*
|
||||
@ -820,7 +902,6 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
unsigned long macarg = (unsigned int)((uintptr_t)&netmac->u);
|
||||
ret = mac802154_ioctl(priv->md_mac, cmd, macarg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -999,6 +1080,23 @@ static int macnet_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
|
||||
properties->sp_bcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
/* Star hub node address.
|
||||
*
|
||||
* If this node is a "point" in a star topology, then the hub node
|
||||
* MAC address is the address of the hub/PAN coordinator.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
(void)macnet_coord_eaddr(radio, properties->sp_hubnode.nv_addr);
|
||||
properties->sp_hubnode.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
#else
|
||||
(void)macnet_coord_saddr(radio, &properties->sp_hubnode.nv_addr);
|
||||
properties->sp_hubnode.>nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -948,6 +948,14 @@ static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
|
||||
properties->sp_bcast.nv_addrlen = CONFIG_PKTRADIO_ADDRLEN;
|
||||
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
/* Star hub node address */
|
||||
|
||||
properties->sp_hubnode.nv_addrlen = 1;
|
||||
properties->sp_hubnode.nv_addr[0] = CONFIG_SPIRIT_HUBNODE;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user