Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Sicslowpan

Data Structures

struct  sicslowpan_addr_context
 The header for fragments. More...
 
struct  sicslowpan_nh_compressor
 The structure of a next header compressor. More...
 

Files

file  sicslowpan.c
 
    6lowpan implementation (RFC4944 and draft-ietf-6lowpan-hc-06)

 
file  sicslowpan.h
 
    Header file for the 6lowpan implementation
    (RFC4944 and draft-hui-6lowpan-hc-01)

 

Macros

#define _DEBUG_   DEBUG_NONE
 FOR HC-06 COMPLIANCE TODO: -Add compression options to UDP, currently only supports both ports compressed or both ports elided. More...
 
#define COMPRESSION_THRESHOLD   0
 Some MAC layers need a minimum payload, which is configurable through the SICSLOWPAN_CONF_MIN_MAC_PAYLOAD option. More...
 
#define FRAG_IN_DEBUG   DEBUG_NONE
 
#define FRAG_OUT_DEBUG   DEBUG_NONE
 
#define GET16(ptr, index)   (((uint16_t)((ptr)[index] << 8)) | ((ptr)[(index) + 1]))
 
#define MAC_MAX_PAYLOAD   102
 Size of the 802.15.4 payload (127byte - 25 for MAC header) More...
 
#define PRINTF(...)
 
#define PRINTFI(...)
 
#define PRINTFO(...)
 
#define PRINTPACKETBUF()
 
#define PRINTSICSLOWPANBUF()
 
#define PRINTUIPBUF()
 
#define SET16(ptr, index, value)
 
#define sicslowpan_buf   uip_buf
 The buffer used for the 6lowpan processing is uip_buf. More...
 
#define SICSLOWPAN_COMPRESSION   SICSLOWPAN_COMPRESSION_IPV6
 
#define sicslowpan_len   uip_len
 
#define SICSLOWPAN_MAX_MAC_TRANSMISSIONS   4
 
#define SICSLOWPAN_NHC_EXT_HDR   0xE0
 
#define SICSLOWPAN_NHC_MASK   0xF0
 
#define UIP_LOG(m)
 
#define USE_FRAMER_HDRLEN   1
 

Functions

static void input (void)
 Process a received 6lowpan packet. More...
 
void rime_sniffer_add (struct rime_sniffer *s)
 
void rime_sniffer_remove (struct rime_sniffer *s)
 
static void set_packet_attrs (void)
 
int sicslowpan_get_last_rssi (void)
 
void sicslowpan_init (void)
 

Variables

static struct rime_sniffercallback = NULL
 
static int last_rssi
 

Pointers in the packetbuf buffer

#define PACKETBUF_FRAG_PTR   (packetbuf_ptr)
 
#define PACKETBUF_FRAG_DISPATCH_SIZE   0 /* 16 bit */
 
#define PACKETBUF_FRAG_TAG   2 /* 16 bit */
 
#define PACKETBUF_FRAG_OFFSET   4 /* 8 bit */
 
#define PACKETBUF_HC1_DISPATCH   0 /* 8 bit */
 
#define PACKETBUF_HC1_ENCODING   1 /* 8 bit */
 
#define PACKETBUF_HC1_TTL   2 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_DISPATCH   0 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_HC1_ENCODING   1 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_UDP_ENCODING   2 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_TTL   3 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_PORTS   4 /* 8 bit */
 
#define PACKETBUF_HC1_HC_UDP_CHKSUM   5 /* 16 bit */
 

Pointers in the sicslowpan and uip buffer

#define SICSLOWPAN_IP_BUF   ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN])
 
#define SICSLOWPAN_UDP_BUF   ((struct uip_udp_hdr *)&sicslowpan_buf[UIP_LLIPH_LEN])
 
#define UIP_IP_BUF   ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
 
#define UIP_UDP_BUF   ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN])
 
#define UIP_TCP_BUF   ((struct uip_tcp_hdr *)&uip_buf[UIP_LLIPH_LEN])
 
#define UIP_ICMP_BUF   ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN])
 

General variables

static uint8_t * packetbuf_ptr
 A pointer to the packetbuf buffer. More...
 
static uint8_t uncomp_hdr_len
 uncomp_hdr_len is the length of the headers before compression (if HC2 is used this includes the UDP header in addition to the IP header). More...
 
static int last_tx_status
 the result of the last transmitted fragment More...
 

HC06 specific variables

static struct
sicslowpan_addr_context
context
 Addresses contexts for IPHC. More...
 
static uint8_t * hc06_ptr
 pointer to the byte where to write next inline field. More...
 
const uint8_t unc_llconf [] = {0x0f,0x28,0x22,0x20}
 
const uint8_t unc_ctxconf [] = {0x00,0x88,0x82,0x80}
 
const uint8_t unc_mxconf [] = {0x0f, 0x25, 0x23, 0x21}
 
const uint8_t llprefix [] = {0xfe, 0x80}
 
static const uint8_t ttl_values [] = {0, 1, 64, 255}
 

HC06 related functions

static struct
sicslowpan_addr_context
addr_context_lookup_by_prefix (uip_ipaddr_t *ipaddr)
 find the context corresponding to prefix ipaddr More...
 
static struct
sicslowpan_addr_context
addr_context_lookup_by_number (uint8_t number)
 find the context with the given number More...
 
static uint8_t compress_addr_64 (uint8_t bitpos, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
 
static void uncompress_addr (uip_ipaddr_t *ipaddr, uint8_t const prefix[], uint8_t pref_post_count, uip_lladdr_t *lladdr)
 
static void compress_hdr_hc06 (linkaddr_t *link_destaddr, uint8_t *tx_hdr_len)
 Compress IP/UDP header. More...
 
static void uncompress_hdr_hc06 (uint16_t ip_len, uint8_t *uip_buff, uint8_t *rx_hdr_len)
 Uncompress HC06 (i.e., IPHC and LOWPAN_UDP) headers and put them in sicslowpan_buf. More...
 

HC1 compression and uncompression functions

static void compress_hdr_hc1 (linkaddr_t *link_destaddr, uint8_t *tx_hdr_len)
 Compress IP/UDP header using HC1 and HC_UDP. More...
 
static void uncompress_hdr_hc1 (uint16_t ip_len, uint8_t *uip_buff, uint8_t **rx_hdr_len)
 Uncompress HC1 (and HC_UDP) headers and put them in sicslowpan_buf. More...
 

IPv6 dispatch "compression" function

static void compress_hdr_ipv6 (linkaddr_t *link_destaddr, uint8_t *tx_hdr_len)
 

Input/output functions common to all compression schemes

static void packet_sent (void *ptr, int status, int transmissions)
 Callback function for the MAC packet sent callback. More...
 
static void send_packet (linkaddr_t *dest)
 This function is called by the 6lowpan code to send out a packet. More...
 
static uint8_t output (const uip_lladdr_t *localdest)
 Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan. More...
 

General sicslowpan defines

#define SICSLOWPAN_UDP_4_BIT_PORT_MIN   0xF0B0
 
#define SICSLOWPAN_UDP_4_BIT_PORT_MAX   0xF0BF /* F0B0 + 15 */
 
#define SICSLOWPAN_UDP_8_BIT_PORT_MIN   0xF000
 
#define SICSLOWPAN_UDP_8_BIT_PORT_MAX   0xF0FF /* F000 + 255 */
 

6lowpan compressions

#define SICSLOWPAN_COMPRESSION_IPV6   0
 
#define SICSLOWPAN_COMPRESSION_HC1   1
 
#define SICSLOWPAN_COMPRESSION_HC06   2
 

6lowpan dispatches

#define SICSLOWPAN_DISPATCH_NALP   0x00 /* 00xxxxxx */
 
#define SICSLOWPAN_DISPATCH_IPV6   0x41 /* 01000001 = 65 */
 
#define SICSLOWPAN_DISPATCH_HC1   0x42 /* 01000010 = 66 */
 
#define SICSLOWPAN_DISPATCH_IPHC   0x60 /* 011xxxxx = ... */
 
#define SICSLOWPAN_DISPATCH_FRAG1   0xc0 /* 11000xxx */
 
#define SICSLOWPAN_DISPATCH_FRAGN   0xe0 /* 11100xxx */
 

HC1 encoding

#define SICSLOWPAN_HC1_NH_UDP   0x02
 
#define SICSLOWPAN_HC1_NH_TCP   0x06
 
#define SICSLOWPAN_HC1_NH_ICMP6   0x04
 

HC_UDP encoding (works together with HC1)

#define SICSLOWPAN_HC_UDP_ALL_C   0xE0
 

IPHC encoding

#define SICSLOWPAN_IPHC_FL_C   0x10
 
#define SICSLOWPAN_IPHC_TC_C   0x08
 
#define SICSLOWPAN_IPHC_NH_C   0x04
 
#define SICSLOWPAN_IPHC_TTL_1   0x01
 
#define SICSLOWPAN_IPHC_TTL_64   0x02
 
#define SICSLOWPAN_IPHC_TTL_255   0x03
 
#define SICSLOWPAN_IPHC_TTL_I   0x00
 
#define SICSLOWPAN_IPHC_CID   0x80
 
#define SICSLOWPAN_IPHC_SAC   0x40
 
#define SICSLOWPAN_IPHC_SAM_00   0x00
 
#define SICSLOWPAN_IPHC_SAM_01   0x10
 
#define SICSLOWPAN_IPHC_SAM_10   0x20
 
#define SICSLOWPAN_IPHC_SAM_11   0x30
 
#define SICSLOWPAN_IPHC_SAM_BIT   4
 
#define SICSLOWPAN_IPHC_M   0x08
 
#define SICSLOWPAN_IPHC_DAC   0x04
 
#define SICSLOWPAN_IPHC_DAM_00   0x00
 
#define SICSLOWPAN_IPHC_DAM_01   0x01
 
#define SICSLOWPAN_IPHC_DAM_10   0x02
 
#define SICSLOWPAN_IPHC_DAM_11   0x03
 
#define SICSLOWPAN_IPHC_DAM_BIT   0
 
#define SICSLOWPAN_IPHC_ADDR_CONTEXT_LL   0
 
#define SICSLOWPAN_IPHC_MCAST_RANGE   0xA0
 

LOWPAN_UDP encoding (works together with IPHC)

#define SICSLOWPAN_NHC_UDP_MASK   0xF8
 
#define SICSLOWPAN_NHC_UDP_ID   0xF0
 
#define SICSLOWPAN_NHC_UDP_CHECKSUMC   0x04
 
#define SICSLOWPAN_NHC_UDP_CHECKSUMI   0x00
 
#define SICSLOWPAN_NHC_UDP_CS_P_00   0xF0 /* all inline */
 
#define SICSLOWPAN_NHC_UDP_CS_P_01   0xF1 /* source 16bit inline, dest = 0xF0 + 8 bit inline */
 
#define SICSLOWPAN_NHC_UDP_CS_P_10   0xF2 /* source = 0xF0 + 8bit inline, dest = 16 bit inline */
 
#define SICSLOWPAN_NHC_UDP_CS_P_11   0xF3 /* source & dest = 0xF0B + 4bit inline */
 

The 6lowpan "headers" length

#define SICSLOWPAN_IPV6_HDR_LEN   1 /*one byte*/
 
#define SICSLOWPAN_HC1_HDR_LEN   3
 
#define SICSLOWPAN_HC1_HC_UDP_HDR_LEN   7
 
#define SICSLOWPAN_FRAG1_HDR_LEN   4
 
#define SICSLOWPAN_FRAGN_HDR_LEN   5
 

Address compressibility test functions

#define sicslowpan_is_iid_16_bit_compressable(a)
 check whether we can compress the IID in address 'a' to 16 bits. More...
 
#define sicslowpan_is_mcast_addr_decompressable(a)
 check whether the 9-bit group-id of the compressed multicast address is known. More...
 
#define sicslowpan_is_mcast_addr_compressable(a)
 check whether the 112-bit group-id of the multicast address is mappable to a 9-bit group-id It is true if the group is the all nodes or all routers group. More...
 
#define sicslowpan_is_mcast_addr_compressable48(a)
 
#define sicslowpan_is_mcast_addr_compressable32(a)
 
#define sicslowpan_is_mcast_addr_compressable8(a)
 

#define _DEBUG_   DEBUG_NONE

FOR HC-06 COMPLIANCE TODO: -Add compression options to UDP, currently only supports both ports compressed or both ports elided.

-Verify TC/FL compression works

-Add stateless multicast option

#define COMPRESSION_THRESHOLD   0

Some MAC layers need a minimum payload, which is configurable through the SICSLOWPAN_CONF_MIN_MAC_PAYLOAD option.

Referenced by output().

#define FRAG_IN_DEBUG   DEBUG_NONE
#define FRAG_OUT_DEBUG   DEBUG_NONE
#define GET16 (   ptr,
  index 
)    (((uint16_t)((ptr)[index] << 8)) | ((ptr)[(index) + 1]))

Referenced by input().

#define MAC_MAX_PAYLOAD   102

Size of the 802.15.4 payload (127byte - 25 for MAC header)

Referenced by output().

#define PACKETBUF_FRAG_DISPATCH_SIZE   0 /* 16 bit */

Referenced by input(), and output().

#define PACKETBUF_FRAG_OFFSET   4 /* 8 bit */

Referenced by input(), and output().

#define PACKETBUF_FRAG_PTR   (packetbuf_ptr)

Referenced by input(), and output().

#define PACKETBUF_FRAG_TAG   2 /* 16 bit */

Referenced by input(), and output().

#define PACKETBUF_HC1_DISPATCH   0 /* 8 bit */

Referenced by compress_hdr_hc1(), and input().

#define PACKETBUF_HC1_ENCODING   1 /* 8 bit */
#define PACKETBUF_HC1_HC_UDP_CHKSUM   5 /* 16 bit */
#define PACKETBUF_HC1_HC_UDP_DISPATCH   0 /* 8 bit */
#define PACKETBUF_HC1_HC_UDP_HC1_ENCODING   1 /* 8 bit */
#define PACKETBUF_HC1_HC_UDP_PORTS   4 /* 8 bit */
#define PACKETBUF_HC1_HC_UDP_TTL   3 /* 8 bit */
#define PACKETBUF_HC1_HC_UDP_UDP_ENCODING   2 /* 8 bit */
#define PACKETBUF_HC1_TTL   2 /* 8 bit */
#define PRINTFI (   ...)

Referenced by input().

#define PRINTFO (   ...)

Referenced by output().

#define PRINTPACKETBUF ( )
#define PRINTSICSLOWPANBUF ( )
#define PRINTUIPBUF ( )
#define SET16 (   ptr,
  index,
  value 
)
Value:
do { \
(ptr)[index] = ((value) >> 8) & 0xff; \
(ptr)[index + 1] = (value) & 0xff; \
} while(0)
ptr
Definition: wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/httpd.c:236

Referenced by output().

#define sicslowpan_buf   uip_buf

The buffer used for the 6lowpan processing is uip_buf.

We do not use any additional buffer.

Referenced by input(), and uncompress_hdr_hc06().

#define SICSLOWPAN_COMPRESSION   SICSLOWPAN_COMPRESSION_IPV6
#define SICSLOWPAN_COMPRESSION_HC06   2
#define SICSLOWPAN_COMPRESSION_HC1   1
#define SICSLOWPAN_COMPRESSION_IPV6   0
#define SICSLOWPAN_DISPATCH_FRAG1   0xc0 /* 11000xxx */

Referenced by input(), and output().

#define SICSLOWPAN_DISPATCH_FRAGN   0xe0 /* 11100xxx */

Referenced by input(), and output().

#define SICSLOWPAN_DISPATCH_HC1   0x42 /* 01000010 = 66 */

Referenced by compress_hdr_hc1(), and input().

#define SICSLOWPAN_DISPATCH_IPHC   0x60 /* 011xxxxx = ... */

Referenced by compress_hdr_hc06(), and input().

#define SICSLOWPAN_DISPATCH_IPV6   0x41 /* 01000001 = 65 */
#define SICSLOWPAN_DISPATCH_NALP   0x00 /* 00xxxxxx */
#define SICSLOWPAN_FRAG1_HDR_LEN   4

Referenced by input(), and output().

#define SICSLOWPAN_FRAGN_HDR_LEN   5

Referenced by input(), and output().

#define SICSLOWPAN_HC1_HC_UDP_HDR_LEN   7
#define SICSLOWPAN_HC1_HDR_LEN   3
#define SICSLOWPAN_HC1_NH_ICMP6   0x04

Referenced by uncompress_hdr_hc1().

#define SICSLOWPAN_HC1_NH_TCP   0x06

Referenced by uncompress_hdr_hc1().

#define SICSLOWPAN_HC1_NH_UDP   0x02

Referenced by uncompress_hdr_hc1().

#define SICSLOWPAN_HC_UDP_ALL_C   0xE0

Referenced by uncompress_hdr_hc1().

#define SICSLOWPAN_IP_BUF   ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN])

Referenced by input(), and uncompress_hdr_hc06().

#define SICSLOWPAN_IPHC_ADDR_CONTEXT_LL   0
#define SICSLOWPAN_IPHC_CID   0x80
#define SICSLOWPAN_IPHC_DAC   0x04
#define SICSLOWPAN_IPHC_DAM_00   0x00

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_DAM_01   0x01

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_DAM_10   0x02

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_DAM_11   0x03
#define SICSLOWPAN_IPHC_DAM_BIT   0
#define SICSLOWPAN_IPHC_FL_C   0x10
#define SICSLOWPAN_IPHC_M   0x08
#define SICSLOWPAN_IPHC_MCAST_RANGE   0xA0
#define SICSLOWPAN_IPHC_NH_C   0x04
#define SICSLOWPAN_IPHC_SAC   0x40
#define SICSLOWPAN_IPHC_SAM_00   0x00

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_SAM_01   0x10
#define SICSLOWPAN_IPHC_SAM_10   0x20
#define SICSLOWPAN_IPHC_SAM_11   0x30

Referenced by uncompress_hdr_hc06().

#define SICSLOWPAN_IPHC_SAM_BIT   4
#define SICSLOWPAN_IPHC_TC_C   0x08
#define SICSLOWPAN_IPHC_TTL_1   0x01

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_TTL_255   0x03

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_TTL_64   0x02

Referenced by compress_hdr_hc06().

#define SICSLOWPAN_IPHC_TTL_I   0x00

Referenced by uncompress_hdr_hc06().

#define SICSLOWPAN_IPV6_HDR_LEN   1 /*one byte*/
#define sicslowpan_is_iid_16_bit_compressable (   a)
Value:
((((a)->u16[4]) == 0) && \
(((a)->u8[10]) == 0)&& \
(((a)->u8[11]) == 0xff)&& \
(((a)->u8[12]) == 0xfe)&& \
(((a)->u8[13]) == 0))

check whether we can compress the IID in address 'a' to 16 bits.

This is used for unicast addresses only, and is true if the address is on the format <PREFIX>::0000:00ff:fe00:XXXX NOTE: we currently assume 64-bits prefixes

Referenced by compress_addr_64().

#define sicslowpan_is_mcast_addr_compressable (   a)
Value:
((((a)->u16[1]) == 0) && \
(((a)->u16[2]) == 0) && \
(((a)->u16[3]) == 0) && \
(((a)->u16[4]) == 0) && \
(((a)->u16[5]) == 0) && \
(((a)->u16[6]) == 0) && \
(((a)->u8[14]) == 0) && \
((((a)->u8[15]) == 1) || (((a)->u8[15]) == 2)))

check whether the 112-bit group-id of the multicast address is mappable to a 9-bit group-id It is true if the group is the all nodes or all routers group.

#define sicslowpan_is_mcast_addr_compressable32 (   a)
Value:
((((a)->u16[1]) == 0) && \
(((a)->u16[2]) == 0) && \
(((a)->u16[3]) == 0) && \
(((a)->u16[4]) == 0) && \
(((a)->u16[5]) == 0) && \
(((a)->u8[12]) == 0))

Referenced by compress_hdr_hc06().

#define sicslowpan_is_mcast_addr_compressable48 (   a)
Value:
((((a)->u16[1]) == 0) && \
(((a)->u16[2]) == 0) && \
(((a)->u16[3]) == 0) && \
(((a)->u16[4]) == 0) && \
(((a)->u8[10]) == 0))

Referenced by compress_hdr_hc06().

#define sicslowpan_is_mcast_addr_compressable8 (   a)
Value:
((((a)->u8[1]) == 2) && \
(((a)->u16[1]) == 0) && \
(((a)->u16[2]) == 0) && \
(((a)->u16[3]) == 0) && \
(((a)->u16[4]) == 0) && \
(((a)->u16[5]) == 0) && \
(((a)->u16[6]) == 0) && \
(((a)->u8[14]) == 0))

Referenced by compress_hdr_hc06().

#define sicslowpan_is_mcast_addr_decompressable (   a)
Value:
(((*a & 0x01) == 0) && \
((*(a + 1) == 0x01) || (*(a + 1) == 0x02)))

check whether the 9-bit group-id of the compressed multicast address is known.

It is true if the 9-bit group is the all nodes or all routers group.

Parameters
ais typed uint8_t *
#define sicslowpan_len   uip_len

Referenced by input().

#define SICSLOWPAN_MAX_MAC_TRANSMISSIONS   4

Referenced by output().

#define SICSLOWPAN_NHC_EXT_HDR   0xE0
#define SICSLOWPAN_NHC_MASK   0xF0
#define SICSLOWPAN_NHC_UDP_CHECKSUMC   0x04

Referenced by uncompress_hdr_hc06().

#define SICSLOWPAN_NHC_UDP_CHECKSUMI   0x00
#define SICSLOWPAN_NHC_UDP_CS_P_00   0xF0 /* all inline */
#define SICSLOWPAN_NHC_UDP_CS_P_01   0xF1 /* source 16bit inline, dest = 0xF0 + 8 bit inline */
#define SICSLOWPAN_NHC_UDP_CS_P_10   0xF2 /* source = 0xF0 + 8bit inline, dest = 16 bit inline */
#define SICSLOWPAN_NHC_UDP_CS_P_11   0xF3 /* source & dest = 0xF0B + 4bit inline */
#define SICSLOWPAN_NHC_UDP_ID   0xF0

Referenced by uncompress_hdr_hc06().

#define SICSLOWPAN_NHC_UDP_MASK   0xF8

Referenced by uncompress_hdr_hc06().

#define SICSLOWPAN_UDP_4_BIT_PORT_MAX   0xF0BF /* F0B0 + 15 */
#define SICSLOWPAN_UDP_4_BIT_PORT_MIN   0xF0B0
#define SICSLOWPAN_UDP_8_BIT_PORT_MAX   0xF0FF /* F000 + 255 */
#define SICSLOWPAN_UDP_8_BIT_PORT_MIN   0xF000
#define SICSLOWPAN_UDP_BUF   ((struct uip_udp_hdr *)&sicslowpan_buf[UIP_LLIPH_LEN])
#define UIP_ICMP_BUF   ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN])

Referenced by set_packet_attrs().

#define UIP_LOG (   m)
#define UIP_TCP_BUF   ((struct uip_tcp_hdr *)&uip_buf[UIP_LLIPH_LEN])

Referenced by output(), and set_packet_attrs().

#define UIP_UDP_BUF   ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN])
#define USE_FRAMER_HDRLEN   1

static struct sicslowpan_addr_context* addr_context_lookup_by_number ( uint8_t  number)
static

find the context with the given number

References i, NULL, SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS, and sicslowpan_addr_context::used.

Referenced by uncompress_hdr_hc06().

static struct sicslowpan_addr_context* addr_context_lookup_by_prefix ( uip_ipaddr_t ipaddr)
static

find the context corresponding to prefix ipaddr

References i, NULL, prefix, SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS, uip_ipaddr_prefixcmp, and sicslowpan_addr_context::used.

Referenced by compress_hdr_hc06().

static uint8_t compress_addr_64 ( uint8_t  bitpos,
uip_ipaddr_t ipaddr,
uip_lladdr_t lladdr 
)
static
static void compress_hdr_hc06 ( linkaddr_t link_destaddr,
uint8_t *  tx_hdr_len 
)
static

Compress IP/UDP header.

This function is called by the 6lowpan code to create a compressed 6lowpan packet in the packetbuf buffer from a full IPv6 packet in the uip_buf buffer.

HC-06 (draft-ietf-6lowpan-hc, version 6)
http://tools.ietf.org/html/draft-ietf-6lowpan-hc-06

Note
We do not support ISA100_UDP header compression

For LOWPAN_UDP compression, we either compress both ports or none. General format with LOWPAN_UDP compression is

*                      1                   2                   3
*  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |0|1|1|TF |N|HLI|C|S|SAM|M|D|DAM| SCI   | DCI   | comp. IPv6 hdr|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | compressed IPv6 fields .....                                  |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | LOWPAN_UDP    | non compressed UDP fields ...                 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | L4 data ...                                                   |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 
Note
The context number 00 is reserved for the link local prefix. For unicast addresses, if we cannot compress the prefix, we neither compress the IID.
Parameters
link_destaddrL2 destination address, needed to compress IP dest

References addr_context_lookup_by_prefix(), compress_addr_64(), data, NULL, sicslowpan_addr_context::number, packetbuf_ptr, PRINTF, SICSLOWPAN_DISPATCH_IPHC, SICSLOWPAN_IPHC_CID, SICSLOWPAN_IPHC_DAC, SICSLOWPAN_IPHC_DAM_00, SICSLOWPAN_IPHC_DAM_01, SICSLOWPAN_IPHC_DAM_10, SICSLOWPAN_IPHC_DAM_11, SICSLOWPAN_IPHC_DAM_BIT, SICSLOWPAN_IPHC_FL_C, SICSLOWPAN_IPHC_M, SICSLOWPAN_IPHC_NH_C, SICSLOWPAN_IPHC_SAC, SICSLOWPAN_IPHC_SAM_00, SICSLOWPAN_IPHC_SAM_BIT, SICSLOWPAN_IPHC_TC_C, SICSLOWPAN_IPHC_TTL_1, SICSLOWPAN_IPHC_TTL_255, SICSLOWPAN_IPHC_TTL_64, sicslowpan_is_mcast_addr_compressable32, sicslowpan_is_mcast_addr_compressable48, sicslowpan_is_mcast_addr_compressable8, SICSLOWPAN_NHC_UDP_CS_P_00, SICSLOWPAN_NHC_UDP_CS_P_01, SICSLOWPAN_NHC_UDP_CS_P_10, SICSLOWPAN_NHC_UDP_CS_P_11, SICSLOWPAN_UDP_4_BIT_PORT_MIN, SICSLOWPAN_UDP_8_BIT_PORT_MIN, UIP_HTONS, UIP_IP_BUF, UIP_IPH_LEN, uip_is_addr_link_local, uip_is_addr_mcast, uip_is_addr_unspecified, uip_lladdr, UIP_PROTO_UDP, UIP_UDP_BUF, UIP_UDPH_LEN, and uncomp_hdr_len.

Referenced by output().

static void compress_hdr_hc1 ( linkaddr_t link_destaddr,
uint8_t *  tx_hdr_len 
)
static

Compress IP/UDP header using HC1 and HC_UDP.

This function is called by the 6lowpan code to create a compressed 6lowpan packet in the packetbuf buffer from a full IPv6 packet in the uip_buf buffer.

If we can compress everything, we use HC1 dispatch, if not we use IPv6 dispatch.
We can compress everything if:

  • IP version is
  • Flow label and traffic class are 0
  • Both src and dest ip addresses are link local
  • Both src and dest interface ID are recoverable from lower layer header
  • Next header is either ICMP, UDP or TCP Moreover, if next header is UDP, we try to compress it using HC_UDP. This is feasible is both ports are between F0B0 and F0B0 + 15

    Resulting header structure:

For ICMP, TCP, non compressed UDP
HC1 encoding = 11111010 (UDP) 11111110 (TCP) 11111100 (ICMP)

*                      1                   2                   3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | LoWPAN HC1 Dsp | HC1 encoding  | IPv6 Hop limit| L4 hdr + data|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 
  • For compressed UDP HC1 encoding = 11111011, HC_UDP encoding = 11100000
    *                      1                   2                   3
    * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * | LoWPAN HC1 Dsp| HC1 encoding  |  HC_UDP encod.| IPv6 Hop limit|
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * | src p.| dst p.| UDP checksum                  | L4 data...
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * 
Parameters
link_destaddrL2 destination address, needed to compress the IP destination field

References PACKETBUF_HC1_DISPATCH, PACKETBUF_HC1_ENCODING, PACKETBUF_HC1_HC_UDP_CHKSUM, PACKETBUF_HC1_HC_UDP_HC1_ENCODING, PACKETBUF_HC1_HC_UDP_PORTS, PACKETBUF_HC1_HC_UDP_TTL, PACKETBUF_HC1_HC_UDP_UDP_ENCODING, PACKETBUF_HC1_TTL, packetbuf_ptr, PRINTF, SICSLOWPAN_DISPATCH_HC1, SICSLOWPAN_DISPATCH_IPV6, SICSLOWPAN_HC1_HC_UDP_HDR_LEN, SICSLOWPAN_HC1_HDR_LEN, SICSLOWPAN_IPV6_HDR_LEN, UIP_HTONS, UIP_IP_BUF, UIP_IPH_LEN, uip_is_addr_link_local, uip_is_addr_mac_addr_based, uip_lladdr, UIP_PROTO_ICMP6, UIP_PROTO_TCP, UIP_PROTO_UDP, UIP_UDP_BUF, UIP_UDPH_LEN, and uncomp_hdr_len.

Referenced by output().

static void compress_hdr_ipv6 ( linkaddr_t link_destaddr,
uint8_t *  tx_hdr_len 
)
static
static void input ( void  )
static

Process a received 6lowpan packet.

Parameters
rThe MAC layer

The 6lowpan packet is put in packetbuf by the MAC. If its a frag1 or a non-fragmented packet we first uncompress the IP header. The 6lowpan payload and possibly the uncompressed IP header are then copied in siclowpan_buf. If the IP packet is complete it is copied to uip_buf and the IP layer is called.

Note
We do not check for overlapping sicslowpan fragments (it is a SHALL in the RFC 4944 and should never happen)

References data, GET16, i, rime_sniffer::input_callback, linkaddr_copy(), LINKADDR_SIZE, packetbuf_addr(), PACKETBUF_ADDR_SENDER, packetbuf_attr(), PACKETBUF_ATTR_RSSI, packetbuf_datalen(), packetbuf_dataptr(), PACKETBUF_FRAG_DISPATCH_SIZE, PACKETBUF_FRAG_OFFSET, PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_TAG, PACKETBUF_HC1_DISPATCH, packetbuf_ptr, printf, PRINTF, PRINTFI, RIMESTATS_ADD, set_packet_attrs(), sicslowpan_buf, SICSLOWPAN_DISPATCH_FRAG1, SICSLOWPAN_DISPATCH_FRAGN, SICSLOWPAN_DISPATCH_HC1, SICSLOWPAN_DISPATCH_IPHC, SICSLOWPAN_DISPATCH_IPV6, SICSLOWPAN_FRAG1_HDR_LEN, SICSLOWPAN_FRAGN_HDR_LEN, SICSLOWPAN_IP_BUF, SICSLOWPAN_IPV6_HDR_LEN, sicslowpan_len, tcpip_input(), timer_expired(), timer_set(), linkaddr_t::u8, uip_buf_t::u8, UIP_IP_BUF, UIP_IPH_LEN, uip_len, UIP_LLH_LEN, uncomp_hdr_len, uncompress_hdr_hc06(), and uncompress_hdr_hc1().

Referenced by netif_add().

static void packet_sent ( void *  ptr,
int  status,
int  transmissions 
)
static

Callback function for the MAC packet sent callback.

References last_tx_status, NULL, rime_sniffer::output_callback, PRINTF, status, and uip_ds6_link_neighbor_callback().

Referenced by send_packet().

void rime_sniffer_add ( struct rime_sniffer s)

References s.

void rime_sniffer_remove ( struct rime_sniffer s)

References NULL.

static void send_packet ( linkaddr_t dest)
static

This function is called by the 6lowpan code to send out a packet.

Parameters
destthe link layer destination address of the packet

References NETSTACK_MAC, NULL, packet_sent(), PACKETBUF_ADDR_RECEIVER, PACKETBUF_ADDR_SENDER, PACKETBUF_ATTR_RELIABLE, packetbuf_set_addr(), packetbuf_set_attr(), mac_driver::send, uip_lladdr, and wdt_reset_count().

Referenced by output().

int sicslowpan_get_last_rssi ( void  )
void sicslowpan_init ( void  )
static void uncompress_addr ( uip_ipaddr_t ipaddr,
uint8_t const  prefix[],
uint8_t  pref_post_count,
uip_lladdr_t lladdr 
)
static
static void uncompress_hdr_hc06 ( uint16_t  ip_len,
uint8_t *  uip_buff,
uint8_t *  rx_hdr_len 
)
static

Uncompress HC06 (i.e., IPHC and LOWPAN_UDP) headers and put them in sicslowpan_buf.

This function is called by the input function when the dispatch is HC06. We process the packet in the packetbuf buffer, uncompress the header fields, and copy the result in the sicslowpan buffer. At the end of the decompression, packetbuf_hdr_len and uncompressed_hdr_len are set to the appropriate values

Parameters
ip_lenEqual to 0 if the packet is not a fragment (IP length is then inferred from the L2 length), non 0 if the packet is a 1st fragment.

References addr_context_lookup_by_number(), uip_ip_hdr::destipaddr, uip_udp_hdr::destport, uip_ip_hdr::flow, hc06_ptr, len, uip_ip_hdr::len, NULL, PACKETBUF_ADDR_RECEIVER, PACKETBUF_ADDR_SENDER, packetbuf_datalen(), packetbuf_ptr, prefix, sicslowpan_addr_context::prefix, PRINTF, uip_ip_hdr::proto, sicslowpan_buf, SICSLOWPAN_IP_BUF, SICSLOWPAN_IPHC_CID, SICSLOWPAN_IPHC_DAC, SICSLOWPAN_IPHC_DAM_11, SICSLOWPAN_IPHC_DAM_BIT, SICSLOWPAN_IPHC_FL_C, SICSLOWPAN_IPHC_M, SICSLOWPAN_IPHC_NH_C, SICSLOWPAN_IPHC_SAC, SICSLOWPAN_IPHC_SAM_11, SICSLOWPAN_IPHC_SAM_BIT, SICSLOWPAN_IPHC_TC_C, SICSLOWPAN_IPHC_TTL_I, SICSLOWPAN_NHC_UDP_CHECKSUMC, SICSLOWPAN_NHC_UDP_CS_P_00, SICSLOWPAN_NHC_UDP_CS_P_01, SICSLOWPAN_NHC_UDP_CS_P_10, SICSLOWPAN_NHC_UDP_CS_P_11, SICSLOWPAN_NHC_UDP_ID, SICSLOWPAN_NHC_UDP_MASK, SICSLOWPAN_UDP_4_BIT_PORT_MIN, SICSLOWPAN_UDP_8_BIT_PORT_MIN, uip_ip_hdr::srcipaddr, uip_udp_hdr::srcport, uip_ip_hdr::tcflow, uip_ip_hdr::ttl, uip_udp_hdr::udpchksum, uip_udp_hdr::udplen, UIP_HTONS, UIP_IPH_LEN, UIP_LLH_LEN, UIP_LLIPH_LEN, UIP_PROTO_UDP, UIP_UDPH_LEN, uncomp_hdr_len, uncompress_addr(), and uip_ip_hdr::vtc.

Referenced by input().

static void uncompress_hdr_hc1 ( uint16_t  ip_len,
uint8_t *  uip_buff,
uint8_t **  rx_hdr_len 
)
static

Uncompress HC1 (and HC_UDP) headers and put them in sicslowpan_buf.

This function is called by the input function when the dispatch is HC1. We process the packet in the packetbuf buffer, uncompress the header fields, and copy the result in the sicslowpan buffer. At the end of the decompression, packetbuf_hdr_len and uncompressed_hdr_len are set to the appropriate values

Parameters
ip_lenEqual to 0 if the packet is not a fragment (IP length is then inferred from the L2 length), non 0 if the packet is a 1st fragment.

References uip_ip_hdr::destipaddr, uip_udp_hdr::destport, uip_ip_hdr::flow, len, uip_ip_hdr::len, PACKETBUF_ADDR_RECEIVER, PACKETBUF_ADDR_SENDER, packetbuf_datalen(), PACKETBUF_HC1_ENCODING, PACKETBUF_HC1_HC_UDP_CHKSUM, PACKETBUF_HC1_HC_UDP_HC1_ENCODING, PACKETBUF_HC1_HC_UDP_PORTS, PACKETBUF_HC1_HC_UDP_TTL, PACKETBUF_HC1_HC_UDP_UDP_ENCODING, PACKETBUF_HC1_TTL, PRINTF, uip_ip_hdr::proto, SICSLOWPAN_HC1_HC_UDP_HDR_LEN, SICSLOWPAN_HC1_HDR_LEN, SICSLOWPAN_HC1_NH_ICMP6, SICSLOWPAN_HC1_NH_TCP, SICSLOWPAN_HC1_NH_UDP, SICSLOWPAN_HC_UDP_ALL_C, uip_ip_hdr::srcipaddr, uip_udp_hdr::srcport, uip_ip_hdr::tcflow, uip_ip_hdr::ttl, uip_udp_hdr::udpchksum, uip_udp_hdr::udplen, uip_ds6_set_addr_iid(), UIP_HTONS, uip_ip6addr, UIP_IPH_LEN, UIP_LLH_LEN, UIP_LLIPH_LEN, UIP_PROTO_ICMP6, UIP_PROTO_TCP, UIP_PROTO_UDP, UIP_UDPH_LEN, uncomp_hdr_len, and uip_ip_hdr::vtc.

Referenced by input().

struct rime_sniffer* callback = NULL
static
struct sicslowpan_addr_context* context
static

Addresses contexts for IPHC.

pointer to an address context.

Referenced by sw_timer_register_callback().

uint8_t* hc06_ptr
static

pointer to the byte where to write next inline field.

Referenced by uncompress_hdr_hc06().

int last_rssi
static
int last_tx_status
static

the result of the last transmitted fragment

Referenced by output(), and packet_sent().

const uint8_t llprefix[] = {0xfe, 0x80}
uint8_t* packetbuf_ptr
static

A pointer to the packetbuf buffer.

We initialize it to the beginning of the packetbuf buffer, then access different fields by updating the offset packetbuf_hdr_len.

Referenced by compress_hdr_hc06(), compress_hdr_hc1(), compress_hdr_ipv6(), input(), output(), and uncompress_hdr_hc06().

const uint8_t ttl_values[] = {0, 1, 64, 255}
static
const uint8_t unc_ctxconf[] = {0x00,0x88,0x82,0x80}
const uint8_t unc_llconf[] = {0x0f,0x28,0x22,0x20}
const uint8_t unc_mxconf[] = {0x0f, 0x25, 0x23, 0x21}
uint8_t uncomp_hdr_len
static

uncomp_hdr_len is the length of the headers before compression (if HC2 is used this includes the UDP header in addition to the IP header).

Referenced by compress_hdr_hc06(), compress_hdr_hc1(), compress_hdr_ipv6(), input(), output(), uncompress_hdr_hc06(), and uncompress_hdr_hc1().