Merge remote-tracking branch 'origin/master' into ieee802154
This commit is contained in:
commit
cdd3cb2201
@ -498,7 +498,7 @@ do_qconfig: dirlinks apps_preconfig
|
||||
|
||||
qconfig: do_qconfig clean_context
|
||||
|
||||
gconfig: dirlinks apps_preconfig
|
||||
do_gconfig: dirlinks apps_preconfig
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} kconfig-gconf Kconfig
|
||||
|
||||
gconfig: do_gconfig clean_context
|
||||
|
@ -524,6 +524,8 @@ static void stm32_stdclockconfig(void)
|
||||
#if defined(CONFIG_RTC_HSECLOCK) || defined(CONFIG_LCD_HSECLOCK)
|
||||
uint16_t pwrcr;
|
||||
#endif
|
||||
uint32_t pwr_vos;
|
||||
bool flash_1ws;
|
||||
|
||||
/* Enable PWR clock from APB1 to give access to PWR_CR register */
|
||||
|
||||
@ -537,12 +539,39 @@ static void stm32_stdclockconfig(void)
|
||||
* Range 1: PLLVCO up to 96MHz in range 1 (1.8V)
|
||||
* Range 2: PLLVCO up to 48MHz in range 2 (1.5V) (default)
|
||||
* Range 3: PLLVCO up to 24MHz in range 3 (1.2V)
|
||||
*
|
||||
* Range 1: SYSCLK up to 32Mhz
|
||||
* Range 2: SYSCLK up to 16Mhz
|
||||
* Range 3: SYSCLK up to 4.2Mhz
|
||||
*
|
||||
* Range 1: Flash 1WS if SYSCLK > 16Mhz
|
||||
* Range 2: Flash 1WS if SYSCLK > 8Mhz
|
||||
* Range 3: Flash 1WS if SYSCLK > 2.1Mhz
|
||||
*/
|
||||
|
||||
#if STM32_PLL_FREQUENCY > 48000000
|
||||
stm32_pwr_setvos(PWR_CR_VOS_SCALE_1);
|
||||
pwr_vos = PWR_CR_VOS_SCALE_2;
|
||||
flash_1ws = false;
|
||||
|
||||
#ifdef STM32_PLL_FREQUENCY
|
||||
if (STM32_PLL_FREQUENCY > 48000000)
|
||||
{
|
||||
pwr_vos = PWR_CR_VOS_SCALE_1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (STM32_SYSCLK_FREQUENCY > 16000000)
|
||||
{
|
||||
pwr_vos = PWR_CR_VOS_SCALE_1;
|
||||
}
|
||||
|
||||
if ((pwr_vos == PWR_CR_VOS_SCALE_1 && STM32_SYSCLK_FREQUENCY > 16000000) ||
|
||||
(pwr_vos == PWR_CR_VOS_SCALE_2 && STM32_SYSCLK_FREQUENCY > 8000000))
|
||||
{
|
||||
flash_1ws = true;
|
||||
}
|
||||
|
||||
stm32_pwr_setvos(pwr_vos);
|
||||
|
||||
#if defined(CONFIG_RTC_HSECLOCK) || defined(CONFIG_LCD_HSECLOCK)
|
||||
/* If RTC / LCD selects HSE as clock source, the RTC prescaler
|
||||
* needs to be set before HSEON bit is set.
|
||||
@ -579,12 +608,11 @@ static void stm32_stdclockconfig(void)
|
||||
|
||||
#endif
|
||||
|
||||
/* Enable the source clock for the PLL (via HSE or HSI), HSE, and HSI.
|
||||
* NOTE that only PLL, HSE, or HSI are supported for the system clock
|
||||
* in this implementation
|
||||
*/
|
||||
/* Enable the source clock for the PLL (via HSE or HSI), HSE, and HSI. */
|
||||
|
||||
#if (STM32_SYSCLK_SW == RCC_CFGR_SW_HSE) || \
|
||||
((STM32_SYSCLK_SW == RCC_CFGR_SW_PLL) && (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC))
|
||||
|
||||
#if (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC) || (STM32_SYSCLK_SW == RCC_CFGR_SW_HSE)
|
||||
/* The PLL is using the HSE, or the HSE is the system clock. In either
|
||||
* case, we need to enable HSE clocking.
|
||||
*/
|
||||
@ -599,7 +627,9 @@ static void stm32_stdclockconfig(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#elif (STM32_CFGR_PLLSRC == 0) || (STM32_SYSCLK_SW == RCC_CFGR_SW_HSI)
|
||||
#elif (STM32_SYSCLK_SW == RCC_CFGR_SW_HSI) || \
|
||||
((STM32_SYSCLK_SW == RCC_CFGR_SW_PLL) && STM32_CFGR_PLLSRC == 0)
|
||||
|
||||
/* The PLL is using the HSI, or the HSI is the system clock. In either
|
||||
* case, we need to enable HSI clocking.
|
||||
*/
|
||||
@ -616,6 +646,8 @@ static void stm32_stdclockconfig(void)
|
||||
|
||||
#endif
|
||||
|
||||
#if (STM32_SYSCLK_SW != RCC_CFGR_SW_MSI)
|
||||
|
||||
/* Increasing the CPU frequency (in the same voltage range):
|
||||
*
|
||||
* After reset, the used clock is the MSI (2 MHz) with 0 WS configured in the
|
||||
@ -643,7 +675,15 @@ static void stm32_stdclockconfig(void)
|
||||
regval |= FLASH_ACR_ACC64; /* 64-bit access mode */
|
||||
putreg32(regval, STM32_FLASH_ACR);
|
||||
|
||||
regval |= FLASH_ACR_LATENCY; /* One wait state */
|
||||
if (flash_1ws)
|
||||
{
|
||||
regval |= FLASH_ACR_LATENCY; /* One wait state */
|
||||
}
|
||||
else
|
||||
{
|
||||
regval &= ~FLASH_ACR_LATENCY; /* Zero wait state */
|
||||
}
|
||||
|
||||
putreg32(regval, STM32_FLASH_ACR);
|
||||
|
||||
/* Enable FLASH prefetch */
|
||||
@ -651,6 +691,8 @@ static void stm32_stdclockconfig(void)
|
||||
regval |= FLASH_ACR_PRFTEN;
|
||||
putreg32(regval, STM32_FLASH_ACR);
|
||||
|
||||
#endif /* STM32_SYSCLK_SW != RCC_CFGR_SW_MSI */
|
||||
|
||||
/* Set the HCLK source/divider */
|
||||
|
||||
regval = getreg32(STM32_RCC_CFGR);
|
||||
|
@ -889,10 +889,10 @@ CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1=0xfe80
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5=0x1234
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5=0x0000
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6=0x00ff
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7=0xfe00
|
||||
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8=0x1034
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
# CONFIG_EXAMPLES_NULL is not set
|
||||
# CONFIG_EXAMPLES_NX is not set
|
||||
@ -1097,10 +1097,10 @@ CONFIG_NSH_IPv6ADDR_1=0xfe80
|
||||
CONFIG_NSH_IPv6ADDR_2=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_3=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_4=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_5=0xabcd
|
||||
CONFIG_NSH_IPv6ADDR_6=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_7=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_8=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_5=0x0000
|
||||
CONFIG_NSH_IPv6ADDR_6=0x00ff
|
||||
CONFIG_NSH_IPv6ADDR_7=0xfe00
|
||||
CONFIG_NSH_IPv6ADDR_8=0xa9cd
|
||||
|
||||
#
|
||||
# Router IPv6 address
|
||||
@ -1109,10 +1109,10 @@ CONFIG_NSH_DRIPv6ADDR_1=0xfe80
|
||||
CONFIG_NSH_DRIPv6ADDR_2=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_3=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_4=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_5=0x1234
|
||||
CONFIG_NSH_DRIPv6ADDR_6=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_7=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_8=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_5=0x0000
|
||||
CONFIG_NSH_DRIPv6ADDR_6=0x00ff
|
||||
CONFIG_NSH_DRIPv6ADDR_7=0xfe00
|
||||
CONFIG_NSH_DRIPv6ADDR_8=0x1034
|
||||
|
||||
#
|
||||
# IPv6 Network mask
|
||||
@ -1121,9 +1121,9 @@ CONFIG_NSH_IPv6NETMASK_1=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_2=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_3=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_4=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_5=0x0000
|
||||
CONFIG_NSH_IPv6NETMASK_6=0x0000
|
||||
CONFIG_NSH_IPv6NETMASK_7=0x0000
|
||||
CONFIG_NSH_IPv6NETMASK_5=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_6=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_7=0xffff
|
||||
CONFIG_NSH_IPv6NETMASK_8=0x0000
|
||||
# CONFIG_NSH_DNS is not set
|
||||
CONFIG_NSH_NOMAC=y
|
||||
|
@ -158,8 +158,8 @@ static const struct file_operations btn_fops =
|
||||
btn_open, /* open */
|
||||
btn_close, /* close */
|
||||
btn_read, /* read */
|
||||
0, /* write */
|
||||
0, /* seek */
|
||||
NULL, /* write */
|
||||
NULL, /* seek */
|
||||
btn_ioctl /* ioctl */
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
, btn_poll /* poll */
|
||||
|
@ -66,9 +66,9 @@
|
||||
/* Min and Max compressible UDP ports - HC06 */
|
||||
|
||||
#define SIXLOWPAN_UDP_4_BIT_PORT_MIN 0xf0b0
|
||||
#define SIXLOWPAN_UDP_4_BIT_PORT_MAX 0xf0bf /* F0B0 + 15 */
|
||||
#define SIXLOWPAN_UDP_8_BIT_PORT_MIN 0xF000
|
||||
#define SIXLOWPAN_UDP_8_BIT_PORT_MAX 0xf0ff /* F000 + 255 */
|
||||
#define SIXLOWPAN_UDP_4_BIT_PORT_MAX 0xf0bf /* f0b0 + 15 */
|
||||
#define SIXLOWPAN_UDP_8_BIT_PORT_MIN 0xf000
|
||||
#define SIXLOWPAN_UDP_8_BIT_PORT_MAX 0xf0ff /* f000 + 255 */
|
||||
|
||||
/* 6lowpan dispatches */
|
||||
|
||||
@ -364,6 +364,12 @@ struct ieee802154_driver_s
|
||||
|
||||
uint8_t i_dsn;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Fragmentation Support *************************************************/
|
||||
/* Fragmentation is handled frame by frame and requires that certain
|
||||
* state information be retained from frame to frame.
|
||||
*/
|
||||
|
||||
/* i_dgramtag. Datagram tag to be put in the header of the set of
|
||||
* fragments. It is used by the recipient to match fragments of the
|
||||
* same payload.
|
||||
@ -371,12 +377,6 @@ struct ieee802154_driver_s
|
||||
|
||||
uint16_t i_dgramtag;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Fragmentation Support *************************************************/
|
||||
/* Fragementation is handled frame by frame and requires that certain
|
||||
* state information be retained from frame to frame.
|
||||
*/
|
||||
|
||||
/* i_pktlen. The total length of the IPv6 packet to be re-assembled in
|
||||
* d_buf.
|
||||
*/
|
||||
|
@ -54,7 +54,7 @@ config NET_6LOWPAN_COMPRESSION_THRESHOLD
|
||||
|
||||
config NET_6LOWPAN_MINPORT
|
||||
hex "Minimum port nubmer"
|
||||
default 0x5471
|
||||
default 0xf0b0
|
||||
depends on NET_6LOWPAN_COMPRESSION_HC1
|
||||
---help---
|
||||
HC1 compression of UDP headersis feasible only if both src and dest
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
@ -171,13 +172,14 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR uint8_t *fptr;
|
||||
int framer_hdrlen;
|
||||
struct rimeaddr_s bcastmac;
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
uint16_t outlen = 0;
|
||||
#endif
|
||||
|
||||
/* Initialize global data. Locking the network guarantees that we have
|
||||
* exclusive use of the global values for intermediate calculations.
|
||||
*/
|
||||
|
||||
FRAME_RESET();
|
||||
g_uncomp_hdrlen = 0;
|
||||
g_frame_hdrlen = 0;
|
||||
|
||||
@ -278,7 +280,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
(int)CONFIG_NET_6LOWPAN_MAXPAYLOAD - framer_hdrlen -
|
||||
(int)g_frame_hdrlen)
|
||||
{
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
/* ieee->i_framelist will hold the generated frames; frames will be
|
||||
* added at qtail.
|
||||
*/
|
||||
|
@ -287,7 +287,7 @@ static int sixlowpan_802154_hdrlen(FAR struct frame802154_s *finfo)
|
||||
****************************************************************************/
|
||||
|
||||
static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, uint16_t dest_panid,
|
||||
uint16_t dest_panid,
|
||||
FAR struct frame802154_s *params)
|
||||
{
|
||||
bool rcvrnull;
|
||||
@ -296,10 +296,6 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
memset(params, 0, sizeof(params));
|
||||
|
||||
/* Reset to an empty frame */
|
||||
|
||||
FRAME_RESET();
|
||||
|
||||
/* Build the FCF (Only non-zero elements need to be initialized). */
|
||||
|
||||
params->fcf.frame_type = FRAME802154_DATAFRAME;
|
||||
@ -368,14 +364,6 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
/* Set the source address to the node address assigned to the device */
|
||||
|
||||
rimeaddr_copy((struct rimeaddr_s *)¶ms->src_addr, &ieee->i_nodeaddr.u8);
|
||||
|
||||
/* Configure the (optional) payload address and length */
|
||||
|
||||
if (iob != NULL)
|
||||
{
|
||||
params->payload = FRAME_DATA_START(iob);
|
||||
params->payload_len = FRAME_DATA_SIZE(iob);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -402,13 +390,13 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
uint16_t dest_panid)
|
||||
uint16_t dest_panid)
|
||||
{
|
||||
struct frame802154_s params;
|
||||
|
||||
/* Set up the frame parameters */
|
||||
|
||||
sixlowpan_setup_params(ieee, NULL, dest_panid, ¶ms);
|
||||
sixlowpan_setup_params(ieee, dest_panid, ¶ms);
|
||||
|
||||
/* Return the length of the header */
|
||||
|
||||
@ -427,7 +415,7 @@ int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
* the frame to send.
|
||||
* buf - Pointer to the buffer to use for the frame.
|
||||
* buflen - The length of the buffer to use for the frame.
|
||||
* finfo - I that specifies the frame to send.
|
||||
* finfo - Specifies the frame to send.
|
||||
*
|
||||
* Returned Value:
|
||||
* The length of the frame header or 0 if there was insufficient space in
|
||||
@ -539,33 +527,22 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, uint16_t dest_panid)
|
||||
{
|
||||
struct frame802154_s params;
|
||||
int len;
|
||||
int ret;
|
||||
int hdrlen;
|
||||
|
||||
/* Set up the frame parameters */
|
||||
|
||||
sixlowpan_setup_params(ieee, iob, dest_panid, ¶ms);
|
||||
sixlowpan_setup_params(ieee, dest_panid, ¶ms);
|
||||
|
||||
/* Get the length of the header */
|
||||
|
||||
len = sixlowpan_802154_hdrlen(¶ms);
|
||||
|
||||
/* Allocate space for the header in the frame buffer */
|
||||
|
||||
ret = sixlowpan_frame_hdralloc(iob, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Header too large: %u\n", len);
|
||||
return ret;
|
||||
}
|
||||
hdrlen = sixlowpan_802154_hdrlen(¶ms);
|
||||
|
||||
/* Then create the frame */
|
||||
|
||||
sixlowpan_802154_framecreate(¶ms, FRAME_HDR_START(iob), len);
|
||||
sixlowpan_802154_framecreate(¶ms, iob->io_data, hdrlen);
|
||||
|
||||
wlinfo("Frame type: %02x Data len: %d %u (%u)\n",
|
||||
params.fcf.frame_type, len, FRAME_DATA_SIZE(iob),
|
||||
FRAME_SIZE(ieee, iob));
|
||||
wlinfo("Frame type: %02x hdrlen: %d\n",
|
||||
params.fcf.frame_type, hdrlen);
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
wlinfo("Dest address: %02x:%02x\n",
|
||||
params.dest_addr[0], params.dest_addr[1]);
|
||||
@ -576,7 +553,7 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
params.dest_addr[6], params.dest_addr[7]);
|
||||
#endif
|
||||
|
||||
return len;
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
@ -76,10 +76,6 @@ uint8_t g_uncomp_hdrlen;
|
||||
|
||||
uint8_t g_frame_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
uint8_t g_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
uint16_t g_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Joel Hoglund <joel@sics.se>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* modification, are permitted provided that the following c/onditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
@ -74,9 +74,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF(ieee) \
|
||||
((FAR struct ipv6_hdr_s *)&(ieee)->i_dev.d_buf)
|
||||
((FAR struct ipv6_hdr_s *)((ieee)->i_dev.d_buf))
|
||||
#define UDPIPv6BUF(ieee) \
|
||||
((FAR struct udp_hdr_s *)&(ieee)->i_dev.d_buf[IPv6_HDRLEN])
|
||||
((FAR struct udp_hdr_s *)&((ieee)->i_dev.d_buf[IPv6_HDRLEN]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -239,13 +239,16 @@ static uint8_t compress_addr_64(FAR const net_ipv6addr_t ipaddr,
|
||||
FAR const struct rimeaddr_s *macaddr,
|
||||
uint8_t bitpos)
|
||||
{
|
||||
ninfo("ipaddr=%p macaddr=%p bitpos=%u g_hc06ptr=%p\n",
|
||||
ipaddr, macaddr, bitpos, g_hc06ptr);
|
||||
|
||||
if (sixlowpan_ismacbased(ipaddr, macaddr))
|
||||
{
|
||||
return 3 << bitpos; /* 0-bits */
|
||||
}
|
||||
else if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
|
||||
{
|
||||
/* Compress IID to 16 bits 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 += 2;
|
||||
@ -253,7 +256,7 @@ static uint8_t compress_addr_64(FAR const net_ipv6addr_t ipaddr,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do not compress IID => xxxx::IID */
|
||||
/* Do not compress IID: xxxx:xxxx:xxxx:xxxx:IID:IID:IID:IID */
|
||||
|
||||
memcpy(g_hc06ptr, &ipaddr[4], 8);
|
||||
g_hc06ptr += 8;
|
||||
@ -455,11 +458,9 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
uint8_t iphc1;
|
||||
uint8_t tmp;
|
||||
|
||||
sixlowpan_dumpbuffer("IPv6 before compression",
|
||||
(FAR const uint8_t *)ipv6,
|
||||
sizeof(struct ipv6_hdr_s));
|
||||
|
||||
g_hc06ptr = fptr + 2;
|
||||
ninfo("fptr=%p g_frame_hdrlen=%u iphc=%p g_hc06ptr=%p\n",
|
||||
fptr, g_frame_hdrlen, iphc, g_hc06ptr);
|
||||
|
||||
/* As we copy some bit-length fields, in the IPHC encoding bytes,
|
||||
* we sometimes use |=
|
||||
@ -516,7 +517,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Sompress only the flow label */
|
||||
/* Compress only the flow label */
|
||||
|
||||
*g_hc06ptr = tmp;
|
||||
g_hc06ptr += 1;
|
||||
@ -810,6 +811,10 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
iphc[1] = iphc1;
|
||||
|
||||
g_frame_hdrlen = g_hc06ptr - fptr;
|
||||
|
||||
ninfo("fptr=%p g_frame_hdrlen=%u iphc=%02x:%02x:%02x g_hc06ptr=%p\n",
|
||||
fptr, g_frame_hdrlen, iphc[0], iphc[1], iphc[2], g_hc06ptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -841,7 +846,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
uint16_t iplen, FAR struct iob_s *iob,
|
||||
FAR char *payptr)
|
||||
FAR uint8_t *payptr)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(ieee);
|
||||
FAR uint8_t *iphc = payptr + g_frame_hdrlen;
|
||||
@ -856,11 +861,14 @@ void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
iphc0 = iphc[0];
|
||||
iphc1 = iphc[1];
|
||||
|
||||
ninfo("payptr=%p g_frame_hdrlen=%u iphc[%p]=%02x:%02x:%02x g_hc06ptr=%p\n",
|
||||
payptr, g_frame_hdrlen, iphc, iphc[0], iphc[1], iphc[2], g_hc06ptr);
|
||||
|
||||
/* Another if the CID flag is set */
|
||||
|
||||
if (iphc1 & SIXLOWPAN_IPHC_CID)
|
||||
{
|
||||
ninfo("IPHC: CID flag set - increase header with one\n");
|
||||
ninfo("IPHC: CID flag set. Increase header by one\n");
|
||||
g_hc06ptr++;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
# include "nuttx/clock.h"
|
||||
#endif
|
||||
|
||||
@ -214,24 +214,17 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
uint16_t fragsize = 0; /* Size of the IP packet (read from fragment) */
|
||||
uint8_t fragoffset = 0; /* Offset of the fragment in the IP packet */
|
||||
bool isfrag = false;
|
||||
int reqsize; /* Required buffer size */
|
||||
int hdrsize; /* Size of the IEEE802.15.4 header */
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
bool isfrag = false;
|
||||
bool isfirstfrag = false;
|
||||
bool islastfrag = false;
|
||||
uint16_t fragtag = 0; /* Tag of the fragment */
|
||||
systime_t elapsed; /* Elapsed time */
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
|
||||
/* Initialize global data. Locking the network guarantees that we have
|
||||
* exclusive use of the global values for intermediate calculations.
|
||||
*/
|
||||
|
||||
g_uncomp_hdrlen = 0;
|
||||
g_frame_hdrlen = 0;
|
||||
|
||||
/* Get a pointer to the payload following the IEEE802.15.4 frame header. */
|
||||
|
||||
hdrsize = sixlowpan_recv_hdrlen(iob->io_data);
|
||||
@ -241,9 +234,18 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
return hdrsize;
|
||||
}
|
||||
|
||||
/* Initialize global data. Locking the network guarantees that we have
|
||||
* exclusive use of the global values for intermediate calculations.
|
||||
*/
|
||||
|
||||
g_uncomp_hdrlen = 0;
|
||||
g_frame_hdrlen = hdrsize;
|
||||
|
||||
/* Payload starts after the IEEE802.15.4 header */
|
||||
|
||||
payptr = &iob->io_data[hdrsize];
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Since we don't support the mesh and broadcast header, the first header
|
||||
* we look for is the fragmentation header
|
||||
*/
|
||||
@ -285,7 +287,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
g_frame_hdrlen += SIXLOWPAN_FRAGN_HDR_LEN;
|
||||
|
||||
ninfo("islastfrag?: i_accumlen %d g_rime_payloadlen %d fragsize %d\n",
|
||||
ninfo("FRAGN: i_accumlen %d g_rime_payloadlen %d fragsize %d\n",
|
||||
ieee->i_accumlen, iob->io_len - g_frame_hdrlen, fragsize);
|
||||
|
||||
/* Indicate that this frame is a another fragment for reassembly */
|
||||
@ -356,7 +358,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
else if (fragsize == 0)
|
||||
{
|
||||
nwarn("WARNING: Dropping zero-length 6loWPAN fragment\n");
|
||||
return OK;
|
||||
return INPUT_PARTIAL;
|
||||
}
|
||||
|
||||
/* A non-zero, first fragement received while we are in the middle of
|
||||
@ -381,7 +383,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
nwarn("WARNING: Dropping 6loWPAN packet that is not a fragment of "
|
||||
"the packet currently being reassembled\n");
|
||||
return OK;
|
||||
return INPUT_PARTIAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -438,7 +440,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Process next dispatch and headers */
|
||||
|
||||
hc1 = payptr + g_frame_hdrlen;
|
||||
hc1 = &iob->io_data[g_frame_hdrlen];
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
|
||||
if ((hc1[RIME_HC1_DISPATCH] & SIXLOWPAN_DISPATCH_IPHC_MASK) == SIXLOWPAN_DISPATCH_IPHC)
|
||||
@ -480,25 +482,24 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
return OK;
|
||||
}
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
copypayload:
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
|
||||
/* Copy "payload" from the rime buffer to the IEEE802.15.4 MAC drivers
|
||||
/* Copy "payload" from the rime buffer to the IEEE802.15.4 MAC driver's
|
||||
* d_buf. If this frame is a first fragment or not part of a fragmented
|
||||
* packet, we have already copied the compressed headers, g_uncomp_hdrlen
|
||||
* and g_frame_hdrlen are non-zerio, fragoffset is.
|
||||
*/
|
||||
|
||||
if (g_frame_hdrlen > CONFIG_NET_6LOWPAN_MTU)
|
||||
g_rime_payloadlen = iob->io_len - g_frame_hdrlen;
|
||||
if (g_rime_payloadlen > CONFIG_NET_6LOWPAN_MTU)
|
||||
{
|
||||
nwarn("WARNING: Packet dropped due to header (%u) > packet buffer (%u)\n",
|
||||
g_frame_hdrlen, CONFIG_NET_6LOWPAN_MTU);
|
||||
nwarn("WARNING: Packet dropped due to payload (%u) > packet buffer (%u)\n",
|
||||
g_rime_payloadlen, CONFIG_NET_6LOWPAN_MTU);
|
||||
return OK;
|
||||
}
|
||||
|
||||
g_rime_payloadlen = iob->io_len - g_frame_hdrlen;
|
||||
|
||||
/* Sanity-check size of incoming packet to avoid buffer overflow */
|
||||
|
||||
reqsize = g_uncomp_hdrlen + (uint16_t) (fragoffset << 3) + g_rime_payloadlen;
|
||||
@ -507,14 +508,14 @@ copypayload:
|
||||
ninfo("Required buffer size: %d+%d+%d=%d Available: %d\n",
|
||||
g_uncomp_hdrlen, (int)(fragoffset << 3), g_rime_payloadlen,
|
||||
reqsize, CONFIG_NET_6LOWPAN_MTU);
|
||||
return OK;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy((FAR uint8_t *)ieee->i_dev.d_buf + g_uncomp_hdrlen +
|
||||
(int)(fragoffset << 3), payptr + g_frame_hdrlen,
|
||||
g_rime_payloadlen);
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Update ieee->i_accumlen if the frame is a fragment, ieee->i_pktlen
|
||||
* otherwise.
|
||||
*/
|
||||
@ -545,12 +546,10 @@ copypayload:
|
||||
ieee->i_accumlen, g_rime_payloadlen);
|
||||
}
|
||||
else
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
{
|
||||
ieee->i_pktlen = g_rime_payloadlen + g_uncomp_hdrlen;
|
||||
}
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* If we have a full IP packet in sixlowpan_buf, deliver it to
|
||||
* the IP stack
|
||||
*/
|
||||
@ -560,23 +559,21 @@ copypayload:
|
||||
|
||||
if (ieee->i_accumlen == 0 || ieee->i_accumlen == ieee->i_pktlen)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(&ieee->i_dev);
|
||||
|
||||
ninfo("IP packet ready (length %d)\n", ieee->i_pktlen);
|
||||
|
||||
/* REVISIT -- clearly wrong. */
|
||||
memcpy((FAR uint8_t *)ipv6, (FAR uint8_t *)ipv6, ieee->i_pktlen);
|
||||
|
||||
ieee->i_pktlen = 0;
|
||||
ieee->i_accumlen = 0;
|
||||
|
||||
ieee->i_dev.d_len = ieee->i_pktlen;
|
||||
ieee->i_pktlen = 0;
|
||||
ieee->i_accumlen = 0;
|
||||
return INPUT_COMPLETE;
|
||||
}
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
|
||||
sixlowpan_dumpbuffer("IPv6 header",
|
||||
(FAR const uint8_t *)IPv6BUF(&ieee->i_dev),
|
||||
IPv6_HDRLEN);
|
||||
return OK;
|
||||
return INPUT_PARTIAL;
|
||||
#else
|
||||
/* Deliver the packet to the IP stack */
|
||||
|
||||
ieee->i_dev.d_len = g_rime_payloadlen + g_uncomp_hdrlen;
|
||||
return INPUT_COMPLETE;
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -215,25 +215,6 @@
|
||||
|
||||
#define PACKETBUF_NUM_ADDRS 4
|
||||
|
||||
/* Frame buffer helpers *****************************************************/
|
||||
|
||||
#define FRAME_RESET() \
|
||||
do \
|
||||
{ \
|
||||
g_dataoffset = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define FRAME_HDR_START(iob) ((iob)->io_data)
|
||||
#define FRAME_HDR_SIZE(iob) g_dataoffset
|
||||
|
||||
#define FRAME_DATA_START(iob) ((FAR uint8_t *)((iob)->io_data) + g_dataoffset)
|
||||
#define FRAME_DATA_SIZE(iob) ((iob)->io_len - g_dataoffset)
|
||||
|
||||
#define FRAME_REMAINING(iob) (CONFIG_NET_6LOWPAN_FRAMELEN - (iob)->io_len)
|
||||
#define FRAME_SIZE(ieee,iob) \
|
||||
((iob)->io_len)
|
||||
|
||||
/* Address compressibility test macros **************************************/
|
||||
|
||||
/* Check whether we can compress the IID in address 'a' to 16 bits. This is
|
||||
@ -407,8 +388,6 @@ struct frame802154_s
|
||||
uint16_t src_pid; /* Source PAN ID */
|
||||
uint8_t src_addr[8]; /* Source address */
|
||||
struct frame802154_aux_hdr_s aux_hdr; /* Aux security header */
|
||||
uint8_t *payload; /* Pointer to 802.15.4 frame payload */
|
||||
uint8_t payload_len; /* Length of payload field */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -452,10 +431,6 @@ extern uint8_t g_uncomp_hdrlen;
|
||||
|
||||
extern uint8_t g_frame_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
uint8_t g_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
extern uint16_t g_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
@ -745,16 +720,6 @@ int sixlowpan_uncompresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR uint8_t *payptr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_frame_hdralloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate space for a header within the frame buffer (IOB).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_islinklocal, sixlowpan_ipfromrime, sixlowpan_rimefromip,
|
||||
* and sixlowpan_ismacbased
|
||||
|
@ -45,20 +45,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Frame Organization. The IOB data is retained in the io_data[] field of the
|
||||
* IOB structure like:
|
||||
*
|
||||
* Content Offset
|
||||
* +------------------+ 0
|
||||
* | Frame Header |
|
||||
* +------------------+ g_dataoffset
|
||||
* | Procotol Headers |
|
||||
* | Data Payload |
|
||||
* +------------------+ iob->io_len
|
||||
* | Unused |
|
||||
* +------------------+ CONFIG_NET_6LOWPAN_FRAMELEN
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
@ -79,26 +65,6 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_frame_hdralloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate space for a header within the packet buffer (dev->d_buf).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size)
|
||||
{
|
||||
if (size <= FRAME_REMAINING(iob))
|
||||
{
|
||||
g_dataoffset += size;
|
||||
iob->io_len += size;
|
||||
return OK;
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_ipfromrime
|
||||
*
|
||||
@ -107,28 +73,30 @@ int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size)
|
||||
*
|
||||
* 128 112 96 80 64 48 32 16
|
||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||
* fe80 0000 0000 0000 xxxx xxxx 0000 0000 2-byte Rime address (VALID?)
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address
|
||||
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime,
|
||||
net_ipv6addr_t ipaddr)
|
||||
{
|
||||
/* We consider only links with IEEE EUI-64 identifier or IEEE 48-bit MAC
|
||||
* addresses.
|
||||
*/
|
||||
|
||||
memset(ipaddr, 0, sizeof(net_ipv6addr_t));
|
||||
ipaddr[0] = HTONS(0xfe80);
|
||||
|
||||
/* We consider only links with IEEE EUI-64 identifier or IEEE 48-bit MAC
|
||||
* addresses. NOTE: that CONFIG_NET_6LOWPAN_RIMEADDR_SIZE may be 2 or
|
||||
* 8. In the case of 2, we treat the address like an 8 byte address with
|
||||
* the lower bytes set to zero.
|
||||
*
|
||||
* REVISIT: This is just a guess so that I can continue making forward
|
||||
* progress. What is the correct policy?
|
||||
*/
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
ipaddr[5] = HTONS(0x00ff);
|
||||
ipaddr[6] = HTONS(0xfe00);
|
||||
memcpy(&ipaddr[7], rime, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ipaddr[7] ^= HTONS(0x0200);
|
||||
#else
|
||||
memcpy(&ipaddr[4], rime, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ipaddr[4] ^= HTONS(0x0200);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -139,8 +107,8 @@ void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime,
|
||||
*
|
||||
* 128 112 96 80 64 48 32 16
|
||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||
* fe80 0000 0000 0000 xxxx 0000 0000 0000 2-byte Rime address (VALID?)
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address
|
||||
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -151,7 +119,11 @@ void sixlowpan_rimefromip(const net_ipv6addr_t ipaddr,
|
||||
|
||||
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
memcpy(rime, &ipaddr[7], CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
#else
|
||||
memcpy(rime, &ipaddr[4], CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
#endif
|
||||
rime->u8[0] ^= 0x02;
|
||||
}
|
||||
|
||||
@ -159,12 +131,12 @@ void sixlowpan_rimefromip(const net_ipv6addr_t ipaddr,
|
||||
* Name: sixlowpan_ismacbased
|
||||
*
|
||||
* Description:
|
||||
* Extract the rime address from a link local IPv6 address:
|
||||
* Check if the MAC address is encoded in the IP address:
|
||||
*
|
||||
* 128 112 96 80 64 48 32 16
|
||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||
* fe80 0000 0000 0000 xxxx 0000 0000 0000 2-byte Rime address (VALID?)
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address
|
||||
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC
|
||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -174,13 +146,13 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
FAR const uint8_t *rimeptr = rime->u8;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) &&
|
||||
ipaddr[5] == 0 && ipaddr[6] == 0 && ipaddr[7] == 0);
|
||||
return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) &&
|
||||
ipaddr[7] == htons((GETINT16(rimeptr, 0) ^ 0x0200)));
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) &&
|
||||
ipaddr[5] == GETINT16(rimeptr, 2) &&
|
||||
ipaddr[6] == GETINT16(rimeptr, 4) &&
|
||||
ipaddr[7] == GETINT16(rimeptr, 6));
|
||||
return (ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200)) &&
|
||||
ipaddr[5] == GETINT16(rimeptr, 2) &&
|
||||
ipaddr[6] == GETINT16(rimeptr, 4) &&
|
||||
ipaddr[7] == GETINT16(rimeptr, 6));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user