6LoWPAN: Fixes needed when extended addressing is enabled. Currently breaks short addressing.
This commit is contained in:
parent
6903e5895c
commit
b5994560cc
@ -343,7 +343,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
*/
|
||||
|
||||
fragptr = fptr + hdrsize;
|
||||
switch ((GETHOST16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0xf800) >> 8)
|
||||
switch ((GETUINT16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0xf800) >> 8)
|
||||
{
|
||||
/* First fragment of new reassembly */
|
||||
|
||||
@ -351,8 +351,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
{
|
||||
/* Set up for the reassembly */
|
||||
|
||||
fragsize = GETHOST16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0x07ff;
|
||||
fragtag = GETHOST16(fragptr, SIXLOWPAN_FRAG_TAG);
|
||||
fragsize = GETUINT16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0x07ff;
|
||||
fragtag = GETUINT16(fragptr, SIXLOWPAN_FRAG_TAG);
|
||||
g_frame_hdrlen += SIXLOWPAN_FRAG1_HDR_LEN;
|
||||
|
||||
ninfo("FRAG1: fragsize=%d fragtag=%d fragoffset=%d\n",
|
||||
@ -370,8 +370,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
/* Set offset, tag, size. Offset is in units of 8 bytes. */
|
||||
|
||||
fragoffset = fragptr[SIXLOWPAN_FRAG_OFFSET];
|
||||
fragtag = GETHOST16(fragptr, SIXLOWPAN_FRAG_TAG);
|
||||
fragsize = GETHOST16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0x07ff;
|
||||
fragtag = GETUINT16(fragptr, SIXLOWPAN_FRAG_TAG);
|
||||
fragsize = GETUINT16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE) & 0x07ff;
|
||||
g_frame_hdrlen += SIXLOWPAN_FRAGN_HDR_LEN;
|
||||
|
||||
ninfo("FRAGN: fragsize=%d fragtag=%d fragoffset=%d\n",
|
||||
|
@ -102,16 +102,11 @@
|
||||
|
||||
/* General helper macros ****************************************************/
|
||||
|
||||
/* GET 16-bit data: source in network order, result in host order */
|
||||
/* GET 16-bit data: source in network order */
|
||||
|
||||
#define GETHOST16(ptr,index) \
|
||||
#define GETUINT16(ptr,index) \
|
||||
((((uint16_t)((ptr)[index])) << 8) | ((uint16_t)(((ptr)[(index) + 1]))))
|
||||
|
||||
/* GET 16-bit data: source in network order, result in network order */
|
||||
|
||||
#define GETNET16(ptr,index) \
|
||||
((((uint16_t)((ptr)[(index) + 1])) << 8) | ((uint16_t)(((ptr)[index]))))
|
||||
|
||||
/* PUT 16-bit data: source in host order, result in newtwork order */
|
||||
|
||||
#define PUTHOST16(ptr,index,value) \
|
||||
|
@ -89,6 +89,8 @@ void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
||||
{
|
||||
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
||||
|
||||
/* Big-endian uint16_t to byte order */
|
||||
|
||||
saddr->u8[0] = ipaddr[7] >> 8;
|
||||
saddr->u8[1] = ipaddr[7] & 0xff;
|
||||
saddr->u8[0] ^= 0x02;
|
||||
@ -97,9 +99,19 @@ void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
|
||||
void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
||||
FAR struct sixlowpan_eaddr_s *eaddr)
|
||||
{
|
||||
FAR uint8_t *eptr = eaddr->u8;
|
||||
int i;
|
||||
|
||||
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
||||
|
||||
memcpy(eaddr, &ipaddr[4], NET_6LOWPAN_EADDRSIZE);
|
||||
for (i = 4; i < 8; i++)
|
||||
{
|
||||
/* Big-endian uint16_t to byte order */
|
||||
|
||||
*eptr++ = ipaddr[i] >> 8;
|
||||
*eptr++ = ipaddr[i] & 0xff;
|
||||
}
|
||||
|
||||
eaddr->u8[0] ^= 0x02;
|
||||
}
|
||||
|
||||
@ -145,7 +157,7 @@ bool sixlowpan_issaddrbased(const net_ipv6addr_t ipaddr,
|
||||
FAR const uint8_t *byteptr = saddr->u8;
|
||||
|
||||
return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) &&
|
||||
ipaddr[7] == (GETNET16(byteptr, 0) ^ HTONS(0x0200)));
|
||||
ipaddr[7] == (GETUINT16(byteptr, 0) ^ 0x0200));
|
||||
}
|
||||
|
||||
bool sixlowpan_iseaddrbased(const net_ipv6addr_t ipaddr,
|
||||
@ -153,10 +165,10 @@ bool sixlowpan_iseaddrbased(const net_ipv6addr_t ipaddr,
|
||||
{
|
||||
FAR const uint8_t *byteptr = eaddr->u8;
|
||||
|
||||
return (ipaddr[4] == (GETNET16(byteptr, 0) ^ HTONS(0x0200)) &&
|
||||
ipaddr[5] == GETNET16(byteptr, 2) &&
|
||||
ipaddr[6] == GETNET16(byteptr, 4) &&
|
||||
ipaddr[7] == GETNET16(byteptr, 6));
|
||||
return (ipaddr[4] == (GETUINT16(byteptr, 0) ^ 0x0200) &&
|
||||
ipaddr[5] == GETUINT16(byteptr, 2) &&
|
||||
ipaddr[6] == GETUINT16(byteptr, 4) &&
|
||||
ipaddr[7] == GETUINT16(byteptr, 6));
|
||||
}
|
||||
|
||||
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
|
@ -270,7 +270,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[4] = (uint16_t)eaddr[0] << 8 | (uint16_t)eaddr[1];
|
||||
dev->d_ipv6addr[5] = (uint16_t)eaddr[2] << 8 | (uint16_t)eaddr[3];
|
||||
dev->d_ipv6addr[6] = (uint16_t)eaddr[4] << 8 | (uint16_t)eaddr[5];
|
||||
dev->d_ipv6addr[7] = (uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[6];
|
||||
dev->d_ipv6addr[7] = (uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[7];
|
||||
dev->d_ipv6addr[4] ^= 0x200;
|
||||
return OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user