mirror of
https://github.com/apache/nuttx.git
synced 2026-03-27 02:29:15 +08:00
Merge remote-tracking branch 'origin/master' into composite
This commit is contained in:
@@ -603,7 +603,7 @@ Configurations
|
|||||||
CONFIG_NET_STAR=y
|
CONFIG_NET_STAR=y
|
||||||
CONFIG_NET_STARPOINT=y
|
CONFIG_NET_STARPOINT=y
|
||||||
|
|
||||||
The CONFIG_NET_STARPOINT selection informs the endpoint that is
|
The CONFIG_NET_STARPOINT selection informs the endpoint that it
|
||||||
must send all frames to the hub of the star, rather than directly
|
must send all frames to the hub of the star, rather than directly
|
||||||
to the recipient.
|
to the recipient.
|
||||||
|
|
||||||
@@ -649,17 +649,43 @@ Configurations
|
|||||||
|
|
||||||
Where <server-ip> is the IP address of the E1 endpoint.
|
Where <server-ip> is the IP address of the E1 endpoint.
|
||||||
|
|
||||||
|
Similarly for the UDP test:
|
||||||
|
|
||||||
|
E1: nsh> udpserver &
|
||||||
|
E2: nsh> udpclient <server-ip> &
|
||||||
|
|
||||||
The nsh> dmesg command can be use at any time on any node to see
|
The nsh> dmesg command can be use at any time on any node to see
|
||||||
any debug output that you have selected.
|
any debug output that you have selected.
|
||||||
|
|
||||||
Telenet sessions may be initiated from the hub:
|
Telenet sessions may be initiated only from the hub to a star
|
||||||
|
endpoint:
|
||||||
|
|
||||||
C: nsh> telnet <server-ip> <-- Runs the Telnet client
|
C: nsh> telnet <server-ip> <-- Runs the Telnet client
|
||||||
|
|
||||||
Where <server-ip> is the IP address of either the E1 or I2 endpoints.
|
Where <server-ip> is the IP address of either the E1 or I2 endpoints.
|
||||||
|
|
||||||
STATUS:
|
STATUS:
|
||||||
2017-06-29: Configurations added but not yet tested.
|
2017-06-29: Configurations added. Initial testing indicates that
|
||||||
|
the TCP Telnet client can successfully establish sessions with
|
||||||
|
the two star endpoints. When testing communications between the
|
||||||
|
two star endpoints via the hub, the frames are correctly directed
|
||||||
|
to the hub. However, they are not being forwarded to the other
|
||||||
|
endpoint.
|
||||||
|
2017-06-30: The failure to forward is understood: When the star
|
||||||
|
endpoint sent the IPv6 destination address, the HC06 compression
|
||||||
|
logic elided the address -- meaning that it could be reconstructed
|
||||||
|
based on the receiver's assigned short address. However, when
|
||||||
|
intercepted by the hub, the uncompressed address does not know
|
||||||
|
the short address of the recipient and instead uses the short
|
||||||
|
address of the hub. This means two things: (1) it looks like
|
||||||
|
the hub address is the destination address, and (2) the
|
||||||
|
uncompressed UDP packet has a bad checksum.
|
||||||
|
|
||||||
|
This required a change to assure that the destination IPv6 address
|
||||||
|
is not elided in the case of the star endpoint configuration. After
|
||||||
|
some additional fixes for byte ordering in 16-bit and 64-bit
|
||||||
|
compressed IPv6 addresses, the all tests are working as expectedd:
|
||||||
|
TCP, UDP, Telnet.
|
||||||
|
|
||||||
nsh:
|
nsh:
|
||||||
|
|
||||||
|
|||||||
@@ -992,9 +992,7 @@ CONFIG_NET_6LOWPAN_MAXAGE=20
|
|||||||
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4
|
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4
|
||||||
CONFIG_NET_6LOWPAN_MTU=1294
|
CONFIG_NET_6LOWPAN_MTU=1294
|
||||||
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=1220
|
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=1220
|
||||||
CONFIG_NET_HAVE_STAR=y
|
|
||||||
# CONFIG_NET_IPFORWARD is not set
|
# CONFIG_NET_IPFORWARD is not set
|
||||||
# CONFIG_NET_STAR is not set
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Socket Support
|
# Socket Support
|
||||||
@@ -1060,6 +1058,12 @@ CONFIG_NET_UDP_READAHEAD=y
|
|||||||
# CONFIG_NET_ARCH_INCR32 is not set
|
# CONFIG_NET_ARCH_INCR32 is not set
|
||||||
# CONFIG_NET_ARCH_CHKSUM is not set
|
# CONFIG_NET_ARCH_CHKSUM is not set
|
||||||
CONFIG_NET_STATISTICS=y
|
CONFIG_NET_STATISTICS=y
|
||||||
|
CONFIG_NET_HAVE_STAR=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Network Topologies
|
||||||
|
#
|
||||||
|
# CONFIG_NET_STAR is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Routing Table Configuration
|
# Routing Table Configuration
|
||||||
|
|||||||
@@ -556,9 +556,7 @@ CONFIG_NET_6LOWPAN_MAXAGE=20
|
|||||||
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4
|
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4
|
||||||
CONFIG_NET_6LOWPAN_MTU=1294
|
CONFIG_NET_6LOWPAN_MTU=1294
|
||||||
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=102
|
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=102
|
||||||
CONFIG_NET_HAVE_STAR=y
|
|
||||||
# CONFIG_NET_IPFORWARD is not set
|
# CONFIG_NET_IPFORWARD is not set
|
||||||
# CONFIG_NET_STAR is not set
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Socket Support
|
# Socket Support
|
||||||
@@ -625,6 +623,12 @@ CONFIG_NET_UDP_READAHEAD=y
|
|||||||
# CONFIG_NET_ARCH_INCR32 is not set
|
# CONFIG_NET_ARCH_INCR32 is not set
|
||||||
# CONFIG_NET_ARCH_CHKSUM is not set
|
# CONFIG_NET_ARCH_CHKSUM is not set
|
||||||
CONFIG_NET_STATISTICS=y
|
CONFIG_NET_STATISTICS=y
|
||||||
|
CONFIG_NET_HAVE_STAR=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Network Topologies
|
||||||
|
#
|
||||||
|
# CONFIG_NET_STAR is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Routing Table Configuration
|
# Routing Table Configuration
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
6LoWPAN Contents
|
||||||
|
----------------
|
||||||
|
|
||||||
|
o 6LoWPAN Addressing
|
||||||
|
o IPv6 Neighbor Discovery
|
||||||
|
o Optimal 6LoWPAN Configuration
|
||||||
|
o Star Configuration
|
||||||
|
|
||||||
6LoWPAN Addressing
|
6LoWPAN Addressing
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
@@ -142,3 +150,28 @@ The payload length is encoded in the LS 11-bits of the first 16-bit value:
|
|||||||
In this example the payload size is 0x050e or 1,294. The tag is 0x000b. In
|
In this example the payload size is 0x050e or 1,294. The tag is 0x000b. In
|
||||||
the second frame, the fifth byte contains the offset 0x0d which is 13 << 3 =
|
the second frame, the fifth byte contains the offset 0x0d which is 13 << 3 =
|
||||||
104 bytes, the size of the payload on the first packet.
|
104 bytes, the size of the payload on the first packet.
|
||||||
|
|
||||||
|
Star Configuration
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The 6LoWPAN stack can be specially configured as member in a star topology;
|
||||||
|
either as a endpoint on the star os the star hub. The endpoint is
|
||||||
|
created with the following settings in the configuration file:
|
||||||
|
|
||||||
|
CONFIG_NET_STAR=y
|
||||||
|
CONFIG_NET_STARPOINT=y
|
||||||
|
|
||||||
|
The CONFIG_NET_STARPOINT selection informs the endpoint 6LoWPAN stack that
|
||||||
|
it must send all frames to the hub of the star, rather than directly to the
|
||||||
|
recipient. The star hub is assumed to be the cooordinator.
|
||||||
|
|
||||||
|
The star hub configuration, on the other hand, uses these setting:
|
||||||
|
|
||||||
|
CONFIG_NET_STAR=y
|
||||||
|
CONFIG_NET_STARHUB=y
|
||||||
|
CONFIG_NET_IPFORWARD=y
|
||||||
|
|
||||||
|
The CONFIG_NET_IPFORWARD selection informs the hub that if it receives any
|
||||||
|
packets that are not destined for the hub, it should forward those packets
|
||||||
|
appropriately. This affects the behavior of IPv6 packet reception logic but
|
||||||
|
does not change the behavior of the 6LoWPAN stack.
|
||||||
|
|||||||
@@ -324,22 +324,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
&ieee->i_dev.d_mac.ieee802154);
|
&ieee->i_dev.d_mac.ieee802154);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_STARPOINT
|
/* Copy the destination node address into the meta data */
|
||||||
/* If this node is a "point" in a star topology, then the destination
|
|
||||||
* MAC address is the address of the hub/PAN coordinator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (destmac->extended)
|
|
||||||
{
|
|
||||||
pktmeta.dextended = TRUE;
|
|
||||||
ret = sixlowpan_coord_eaddr(ieee, pktmeta.dest.eaddr.u8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = sixlowpan_coord_saddr(ieee, pktmeta.dest.saddr.u8);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* Otherwise, it is the actual destination node address */
|
|
||||||
|
|
||||||
if (destmac->extended)
|
if (destmac->extended)
|
||||||
{
|
{
|
||||||
@@ -350,7 +335,6 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
{
|
{
|
||||||
sixlowpan_saddrcopy(pktmeta.dest.saddr.u8, destmac->u.saddr.u8);
|
sixlowpan_saddrcopy(pktmeta.dest.saddr.u8, destmac->u.saddr.u8);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get the destination PAN ID.
|
/* Get the destination PAN ID.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -251,16 +251,23 @@ static uint8_t compress_ipaddr(FAR const net_ipv6addr_t ipaddr, uint8_t bitpos)
|
|||||||
{
|
{
|
||||||
/* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */
|
/* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */
|
||||||
|
|
||||||
memcpy(g_hc06ptr, &ipaddr[7], 2);
|
*g_hc06ptr++ = ipaddr[7] >> 8; /* Big-endian, network order */
|
||||||
g_hc06ptr += 2;
|
*g_hc06ptr++ = ipaddr[7] & 0xff;
|
||||||
|
|
||||||
return 2 << bitpos; /* 16-bits */
|
return 2 << bitpos; /* 16-bits */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Do not compress IID: xxxx:xxxx:xxxx:xxxx:IID:IID:IID:IID */
|
/* Do not compress IID: xxxx:xxxx:xxxx:xxxx:IID:IID:IID:IID */
|
||||||
|
|
||||||
memcpy(g_hc06ptr, &ipaddr[4], 8);
|
for (i = 4; i < 8; i++)
|
||||||
g_hc06ptr += 8;
|
{
|
||||||
|
*g_hc06ptr++ = ipaddr[i] >> 8; /* Big-endian, network order */
|
||||||
|
*g_hc06ptr++ = ipaddr[i] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
return 1 << bitpos; /* 64-bits */
|
return 1 << bitpos; /* 64-bits */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,6 +436,8 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
|
|||||||
|
|
||||||
for (i = destndx; i < 8; i++)
|
for (i = destndx; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
/* Big-endian, network order */
|
||||||
|
|
||||||
ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1];
|
ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1];
|
||||||
srcptr += 2;
|
srcptr += 2;
|
||||||
}
|
}
|
||||||
@@ -437,11 +446,11 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
|
|||||||
|
|
||||||
if (fullmac)
|
if (fullmac)
|
||||||
{
|
{
|
||||||
ipaddr[destndx] ^= 0x200;
|
ipaddr[destndx] ^= 0x0200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* postcount is odd... */
|
/* postcount is odd... REVISIT: I am not sure about bye ordering. */
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -849,13 +858,13 @@ int sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
|||||||
{
|
{
|
||||||
/* Elide the prefix */
|
/* Elide the prefix */
|
||||||
|
|
||||||
iphc1 |= SIXLOWPAN_IPHC_DAC;
|
iphc1 |= SIXLOWPAN_IPHC_DAC;
|
||||||
iphc[2] |= addrcontext->number;
|
iphc[2] |= addrcontext->number;
|
||||||
|
|
||||||
/* Compession compare with link adress (destination) */
|
/* Compession compare with link adress (destination) */
|
||||||
|
|
||||||
iphc1 |= compress_tagaddr(ipv6->destipaddr, destmac,
|
iphc1 |= compress_tagaddr(ipv6->destipaddr, destmac,
|
||||||
SIXLOWPAN_IPHC_DAM_BIT);
|
SIXLOWPAN_IPHC_DAM_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No address context found for this address */
|
/* No address context found for this address */
|
||||||
|
|||||||
@@ -830,7 +830,13 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
|
|||||||
* address.
|
* address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sixlowpan_addrfromip(ipv6hdr->destipaddr, &destmac);
|
ret = sixlowpan_destaddrfromip(ieee, ipv6hdr->destipaddr,
|
||||||
|
&destmac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to dest MAC address: %d\n", ret);
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
/* The data payload should follow the IPv6 header plus
|
/* The data payload should follow the IPv6 header plus
|
||||||
* the protocol header.
|
* the protocol header.
|
||||||
|
|||||||
@@ -536,25 +536,28 @@ int sixlowpan_uncompresshdr_hc1(FAR const struct ieee802154_data_ind_s *ind,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_islinklocal, sixlowpan_addrfromip, and
|
* Name: sixlowpan_islinklocal, sixlowpan_destaddrfromip, and
|
||||||
* sixlowpan_ismacbased
|
* sixlowpan_ismacbased
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* sixlowpan_{s|e]addrfromip(): Extract the IEEE 802.15.14 address from a
|
* sixlowpan_destaddrfromip(): Extract the IEEE 802.15.14 destination
|
||||||
* MAC-based IPv6 address. sixlowpan_addrfromip() is intended to handle a
|
* address from a MAC-based destination IPv6 address. This function
|
||||||
* tagged address; sixlowpan_saddrfromip() and sixlowpan_eaddrfromip()
|
* handles a tagged address union which may either a short or and
|
||||||
* specifically handle short and extended addresses, respectively.
|
* extended destination address.
|
||||||
|
*
|
||||||
|
* In the case there the IEEE 802.15.4 node functions as an endpoint in a
|
||||||
|
* start topology, the destination address will, instead, be the address
|
||||||
|
* of the star hub (which is assumed to be the address of the cooordinator).
|
||||||
*
|
*
|
||||||
* sixlowpan_ipfrom[s|e]addr(): Create a link-local, MAC-based IPv6
|
* sixlowpan_ipfrom[s|e]addr(): Create a link-local, MAC-based IPv6
|
||||||
* address from an IEEE802.15.4 short address (saddr) or extended address
|
* address from an IEEE802.15.4 short address (saddr) or extended address
|
||||||
* (eaddr).
|
* (eaddr).
|
||||||
*
|
*
|
||||||
* sixlowpan_islinklocal() and sixlowpan_ismacbased() will return true for
|
* sixlowpan_islinklocal() and sixlowpan_ismacbased() will return true for
|
||||||
* address created in this fashion. sixlowpan_addrfromip() is intended to
|
* address created in this fashion. sixlowpan_destaddrfromip() is intended to
|
||||||
* handle a tagged address or any size; sixlowpan_issaddrbased() and
|
* handle a tagged address or any size. Local addresses are of a fixed but
|
||||||
* sixlowpan_iseaddrbased() specifically handle short and extended
|
* configurable size and sixlowpan_isaddrbased() is for use with such local
|
||||||
* addresses. Local addresses are of a fixed but configurable size and
|
* addresses.
|
||||||
* sixlowpan_isaddrbased() is for use with such local addresses.
|
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
@@ -565,12 +568,9 @@ int sixlowpan_uncompresshdr_hc1(FAR const struct ieee802154_data_ind_s *ind,
|
|||||||
|
|
||||||
#define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80))
|
#define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80))
|
||||||
|
|
||||||
void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
int sixlowpan_destaddrfromip(FAR struct ieee802154_driver_s *ieee,
|
||||||
FAR struct sixlowpan_saddr_s *saddr);
|
const net_ipv6addr_t ipaddr,
|
||||||
void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
FAR struct sixlowpan_tagaddr_s *addr);
|
||||||
FAR struct sixlowpan_eaddr_s *eaddr);
|
|
||||||
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
|
|
||||||
FAR struct sixlowpan_tagaddr_s *addr);
|
|
||||||
|
|
||||||
void sixlowpan_ipfromsaddr(FAR const uint8_t *saddr,
|
void sixlowpan_ipfromsaddr(FAR const uint8_t *saddr,
|
||||||
FAR net_ipv6addr_t ipaddr);
|
FAR net_ipv6addr_t ipaddr);
|
||||||
@@ -593,46 +593,6 @@ bool sixlowpan_iseaddrbased(const net_ipv6addr_t ipaddr,
|
|||||||
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||||
FAR const struct sixlowpan_tagaddr_s *addr);
|
FAR const struct sixlowpan_tagaddr_s *addr);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sixlowpan_coord_eaddr
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the extended address of the PAN coordinator.
|
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
|
||||||
* eaddr - The location in which to return the extended address.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) on success; a negated errno value on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_STARPOINT
|
|
||||||
int sixlowpan_coord_eaddr(FAR struct ieee802154_driver_s *ieee,
|
|
||||||
FAR uint8_t *eaddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sixlowpan_coord_saddr
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the short address of the PAN coordinator.
|
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
|
||||||
* saddr - The location in which to return the short address.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) on success; a negated errno value on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_STARPOINT
|
|
||||||
int sixlowpan_coord_saddr(FAR struct ieee802154_driver_s *ieee,
|
|
||||||
FAR uint8_t *saddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_src_panid
|
* Name: sixlowpan_src_panid
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev,
|
|||||||
* actually sent.
|
* actually sent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
sinfo->s_result = sinfo->s_sent;
|
||||||
goto end_wait;
|
goto end_wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,7 +836,13 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
* an encoding of the MAC address in the IPv6 address.
|
* an encoding of the MAC address in the IPv6 address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sixlowpan_addrfromip(conn->u.ipv6.raddr, &destmac);
|
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
|
||||||
|
conn->u.ipv6.raddr, &destmac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to dest MAC address: %d\n", ret);
|
||||||
|
return (ssize_t)ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the socket state to sending */
|
/* Set the socket state to sending */
|
||||||
|
|
||||||
@@ -859,7 +866,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
nerr("ERROR: sixlowpan_send_packet() failed: %d\n", ret);
|
nerr("ERROR: sixlowpan_send_packet() failed: %d\n", ret);
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||||
return (ssize_t)buflen;
|
return (ssize_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the socket state to idle */
|
/* Set the socket state to idle */
|
||||||
@@ -942,12 +949,19 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
|
|||||||
FAR uint8_t *buf;
|
FAR uint8_t *buf;
|
||||||
uint16_t hdrlen;
|
uint16_t hdrlen;
|
||||||
uint16_t buflen;
|
uint16_t buflen;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Get the IEEE 802.15.4 MAC address of the destination. This
|
/* Get the IEEE 802.15.4 MAC address of the destination. This
|
||||||
* assumes an encoding of the MAC address in the IPv6 address.
|
* assumes an encoding of the MAC address in the IPv6 address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sixlowpan_addrfromip(ipv6hdr->ipv6.destipaddr, &destmac);
|
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
|
||||||
|
ipv6hdr->ipv6.destipaddr, &destmac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to dest MAC address: %d\n", ret);
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the IPv6 + TCP combined header length. The size of the TCP
|
/* Get the IPv6 + TCP combined header length. The size of the TCP
|
||||||
* header is encoded in the top 4 bits of the tcpoffset field (in
|
* header is encoded in the top 4 bits of the tcpoffset field (in
|
||||||
@@ -977,6 +991,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop:
|
||||||
dev->d_len = 0;
|
dev->d_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,15 +297,21 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
|||||||
g_netstats.udp.sent++;
|
g_netstats.udp.sent++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the socket state to sending */
|
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
|
||||||
|
|
||||||
/* Get the IEEE 802.15.4 MAC address of the destination This assumes an
|
/* Get the IEEE 802.15.4 MAC address of the destination This assumes an
|
||||||
* encoding of the MAC address in the IPv6 address.
|
* encoding of the MAC address in the IPv6 address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sixlowpan_addrfromip(to6->sin6_addr.in6_u.u6_addr16, &destmac);
|
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
|
||||||
|
to6->sin6_addr.in6_u.u6_addr16, &destmac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to dest MAC address: %d\n", ret);
|
||||||
|
return (ssize_t)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the socket state to sending */
|
||||||
|
|
||||||
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
||||||
|
|
||||||
/* If routable, then call sixlowpan_send() to format and send the 6LoWPAN
|
/* If routable, then call sixlowpan_send() to format and send the 6LoWPAN
|
||||||
* packet.
|
* packet.
|
||||||
@@ -328,7 +334,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
|||||||
/* Set the socket state to idle */
|
/* Set the socket state to idle */
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||||
return ret;
|
return (ssize_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -465,12 +471,19 @@ void sixlowpan_udp_send(FAR struct net_driver_s *dev,
|
|||||||
FAR uint8_t *buf;
|
FAR uint8_t *buf;
|
||||||
uint16_t hdrlen;
|
uint16_t hdrlen;
|
||||||
uint16_t buflen;
|
uint16_t buflen;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Get the IEEE 802.15.4 MAC address of the destination. This
|
/* Get the IEEE 802.15.4 MAC address of the destination. This
|
||||||
* assumes an encoding of the MAC address in the IPv6 address.
|
* assumes an encoding of the MAC address in the IPv6 address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sixlowpan_addrfromip(ipv6udp->ipv6.destipaddr, &destmac);
|
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
|
||||||
|
ipv6udp->ipv6.destipaddr, &destmac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to dest MAC address: %d\n", ret);
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the IPv6 + UDP combined header length. */
|
/* Get the IPv6 + UDP combined header length. */
|
||||||
|
|
||||||
@@ -497,6 +510,7 @@ void sixlowpan_udp_send(FAR struct net_driver_s *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop:
|
||||||
dev->d_len = 0;
|
dev->d_len = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -64,17 +64,17 @@
|
|||||||
#ifdef CONFIG_NET_6LOWPAN
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_{s|e]addrfromip
|
* Name: sixlowpan_[s|e]addrfromip
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* sixlowpan_{s|e]addrfromip(): Extract the IEEE 802.15.14 address from a
|
* sixlowpan_[s|e]addrfromip(): Extract the IEEE 802.15.14 address from a
|
||||||
* MAC-based IPv6 address. sixlowpan_addrfromip() is intended to handle a
|
* MAC-based IPv6 address. sixlowpan_saddrfromip() and
|
||||||
* tagged address; sixlowpan_saddrfromip() and sixlowpan_eaddrfromip()
|
* sixlowpan_eaddrfromip() handle short and extended addresses,
|
||||||
* specifically handle short and extended addresses, respectively.
|
* respectively.
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
@@ -83,8 +83,9 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
#ifndef CONFIG_NET_STARPOINT
|
||||||
FAR struct sixlowpan_saddr_s *saddr)
|
static void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
||||||
|
FAR struct sixlowpan_saddr_s *saddr)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
||||||
|
|
||||||
@@ -95,8 +96,8 @@ void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
|||||||
saddr->u8[0] ^= 0x02;
|
saddr->u8[0] ^= 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
||||||
FAR struct sixlowpan_eaddr_s *eaddr)
|
FAR struct sixlowpan_eaddr_s *eaddr)
|
||||||
{
|
{
|
||||||
FAR uint8_t *eptr = eaddr->u8;
|
FAR uint8_t *eptr = eaddr->u8;
|
||||||
int i;
|
int i;
|
||||||
@@ -113,22 +114,147 @@ void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
|||||||
|
|
||||||
eaddr->u8[0] ^= 0x02;
|
eaddr->u8[0] ^= 0x02;
|
||||||
}
|
}
|
||||||
|
#endif /* !CONFIG_NET_STARPOINT */
|
||||||
|
|
||||||
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
|
/****************************************************************************
|
||||||
FAR struct sixlowpan_tagaddr_s *addr)
|
* Name: sixlowpan_coord_eaddr
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get the extended address of the PAN coordinator.
|
||||||
|
*
|
||||||
|
* Input parameters:
|
||||||
|
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
||||||
|
* 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 ieee802154_driver_s *ieee,
|
||||||
|
FAR struct sixlowpan_eaddr_s *eaddr)
|
||||||
{
|
{
|
||||||
|
FAR struct net_driver_s *dev = &ieee->i_dev;
|
||||||
|
struct ieee802154_netmac_s arg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memcpy(arg.ifr_name, ieee->i_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:
|
||||||
|
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
||||||
|
* 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 ieee802154_driver_s *ieee,
|
||||||
|
FAR struct sixlowpan_saddr_s *saddr)
|
||||||
|
{
|
||||||
|
FAR struct net_driver_s *dev = &ieee->i_dev;
|
||||||
|
struct ieee802154_netmac_s arg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memcpy(arg.ifr_name, ieee->i_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->u8, arg.u.getreq.attrval.mac.saddr);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sixlowpan_destaddrfromip
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* sixlowpan_destaddrfromip(): Extract the IEEE 802.15.14 destination
|
||||||
|
* address from a MAC-based destination IPv6 address. This function
|
||||||
|
* handles a tagged address union which may either a short or and
|
||||||
|
* extended destination address.
|
||||||
|
*
|
||||||
|
* 128 112 96 80 64 48 32 16
|
||||||
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
|
* xxxx 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
|
||||||
|
* xxxx 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
|
||||||
|
*
|
||||||
|
* In the case there the IEEE 802.15.4 node functions as an endpoint in a
|
||||||
|
* start topology, the destination address will, instead, be the address
|
||||||
|
* of the star hub (which is assumed to be the address of the cooordinator).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int sixlowpan_destaddrfromip(FAR struct ieee802154_driver_s *ieee,
|
||||||
|
const net_ipv6addr_t ipaddr,
|
||||||
|
FAR struct sixlowpan_tagaddr_s *destaddr)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NET_STARPOINT
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||||
|
ret = sixlowpan_coord_eaddr(ieee, &destaddr->u.eaddr);
|
||||||
|
destaddr->extended = true;
|
||||||
|
#else
|
||||||
|
memset(destaddr, 0, sizeof(struct sixlowpan_tagaddr_s));
|
||||||
|
ret = sixlowpan_coord_saddr(ieee, &destaddr->u.saddr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
#else
|
||||||
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
||||||
|
|
||||||
|
/* Otherwise, the destination MAC address is encoded in the IP address */
|
||||||
|
|
||||||
if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
|
if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
|
||||||
{
|
{
|
||||||
memset(addr, 0, sizeof(struct sixlowpan_tagaddr_s));
|
memset(destaddr, 0, sizeof(struct sixlowpan_tagaddr_s));
|
||||||
sixlowpan_saddrfromip(ipaddr, &addr->u.saddr);
|
sixlowpan_saddrfromip(ipaddr, &destaddr->u.saddr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sixlowpan_eaddrfromip(ipaddr, &addr->u.eaddr);
|
sixlowpan_eaddrfromip(ipaddr, &destaddr->u.eaddr);
|
||||||
addr->extended = true;
|
destaddr->extended = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -179,11 +305,10 @@ void sixlowpan_ipfromeaddr(FAR const uint8_t *eaddr,
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* sixlowpan_ismacbased() will return true for IP addresses formed from
|
* sixlowpan_ismacbased() will return true for IP addresses formed from
|
||||||
* IEEE802.15.4 MAC addresses. sixlowpan_addrfromip() is intended to
|
* IEEE802.15.4 MAC addresses. sixlowpan_destaddrfromip() is intended to
|
||||||
* handle a tagged address or any size; sixlowpan_issaddrbased() and
|
* handle a tagged address or any size. Local addresses are of a fixed
|
||||||
* sixlowpan_iseaddrbased() specifically handle short and extended
|
* but configurable size and sixlowpan_isaddrbased() is for use with such
|
||||||
* addresses. Local addresses are of a fixed but configurable size and
|
* local addresses.
|
||||||
* sixlowpan_isaddrbased() is for use with such local addresses.
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
@@ -227,82 +352,6 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sixlowpan_coord_eaddr
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the extended address of the PAN coordinator.
|
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
|
||||||
* eaddr - The location in which to return the extended address.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) on success; a negated errno value on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_STARPOINT
|
|
||||||
int sixlowpan_coord_eaddr(FAR struct ieee802154_driver_s *ieee,
|
|
||||||
FAR uint8_t *eaddr)
|
|
||||||
{
|
|
||||||
FAR struct net_driver_s *dev = &ieee->i_dev;
|
|
||||||
struct ieee802154_netmac_s arg;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
memcpy(arg.ifr_name, ieee->i_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, arg.u.getreq.attrval.mac.eaddr);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sixlowpan_coord_saddr
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the short address of the PAN coordinator.
|
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
|
||||||
* saddr - The location in which to return the short address.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) on success; a negated errno value on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_STARPOINT
|
|
||||||
int sixlowpan_coord_saddr(FAR struct ieee802154_driver_s *ieee,
|
|
||||||
FAR uint8_t *saddr)
|
|
||||||
{
|
|
||||||
FAR struct net_driver_s *dev = &ieee->i_dev;
|
|
||||||
struct ieee802154_netmac_s arg;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
memcpy(arg.ifr_name, ieee->i_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, arg.u.getreq.attrval.mac.saddr);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_src_panid
|
* Name: sixlowpan_src_panid
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user