Contiki-NG
Loading...
Searching...
No Matches

Data Structures

struct  sicslowpan_addr_context
 An address context for IPHC address compression each context can have upto 8 bytes. More...
 
struct  sicslowpan_nh_compressor
 The structure of a next header compressor. More...
 

Macros

#define LOG_MODULE   "6LoWPAN"
 FOR RFC 6282 COMPLIANCE TODO: -Add compression options to UDP, currently only supports both ports compressed or both ports elided.
 

Functions

static void add_paging_dispatch (uint8_t page)
 Adds Paging dispatch byte.
 
static void add_6lorh_hdr (void)
 Adds 6lorh headers before IPHC.
 
static void digest_paging_dispatch (void)
 Digest 6lorh headers before IPHC.
 
static void digest_6lorh_hdr (void)
 Digest 6lorh headers before IPHC.
 

General variables

static uint8_t * packetbuf_ptr
 A pointer to the packetbuf buffer.
 
static uint8_t packetbuf_hdr_len
 packetbuf_hdr_len is the total length of (the processed) 6lowpan headers (fragment headers, IPV6 or HC1, HC2, and HC1 and HC2 non compressed fields).
 
static int packetbuf_payload_len
 The length of the payload in the Packetbuf buffer.
 
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).
 
static int mac_max_payload
 mac_max_payload is the maimum payload space on the MAC frame.
 
static uint8_t curr_page
 The current page (RFC 4944)
 
static int last_tx_status
 the result of the last transmitted fragment
 

variables specific to RFC 6282

static uint8_t * iphc_ptr
 Addresses contexts for IPHC.
 

IPHC related functions


static struct sicslowpan_addr_contextaddr_context_lookup_by_prefix (uip_ipaddr_t *ipaddr)
 find the context corresponding to prefix ipaddr
 
static struct sicslowpan_addr_contextaddr_context_lookup_by_number (uint8_t number)
 find the context with the given number
 
static int compress_hdr_iphc (void)
 Compress IP/UDP header.
 
static bool uncompress_hdr_iphc (uint8_t *buf, uint16_t buf_size, uint16_t ip_len)
 Uncompress IPHC (i.e., IPHC and LOWPAN_UDP) headers and put them in sicslowpan_buf.
 

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.
 
static void send_packet (void)
 This function is called by the 6lowpan code to send out a packet.
 
static uint8_t output (const linkaddr_t *localdest)
 Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.
 
static void input (void)
 Process a received 6lowpan packet.
 

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.
 
#define sicslowpan_is_mcast_addr_decompressable(a)
 check whether the 9-bit group-id of the compressed multicast address is known.
 
#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.
 

Detailed Description

Macro Definition Documentation

◆ LOG_MODULE

#define LOG_MODULE   "6LoWPAN"

FOR RFC 6282 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

Definition at line 81 of file sicslowpan.c.

◆ sicslowpan_is_iid_16_bit_compressable

#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

Definition at line 213 of file sicslowpan.h.

◆ sicslowpan_is_mcast_addr_decompressable

#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 *

Definition at line 227 of file sicslowpan.h.

Function Documentation

◆ compress_hdr_iphc()

static int compress_hdr_iphc ( void )
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.

IPHC (RFC 6282)
http://tools.ietf.org/html/

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.
Returns
1 if success, else 0

Definition at line 686 of file sicslowpan.c.

References addr_context_lookup_by_prefix(), iphc_ptr, packetbuf_hdr_len, packetbuf_ptr, UIP_HTONS, UIP_IP_BUF, uip_is_addr_linklocal, uip_is_addr_mcast, uip_is_addr_unspecified, uip_lladdr, UIP_PROTO_HBHO, and uncomp_hdr_len.

Referenced by output().

◆ input()

static void input ( void )
static

Process a received 6lowpan packet.

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)

Definition at line 1853 of file sicslowpan.c.

References curr_page, digest_6lorh_hdr(), digest_paging_dispatch(), packetbuf_datalen(), packetbuf_dataptr(), packetbuf_hdr_len, packetbuf_payload_len, packetbuf_ptr, SICSLOWPAN_COMPRESSION, tcpip_input(), uip_buf, UIP_BUFSIZE, UIP_IP_BUF, uip_len, uncomp_hdr_len, and uncompress_hdr_iphc().

◆ output()

static uint8_t output ( const linkaddr_t * localdest)
static

Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.

Parameters
localdestThe MAC address of the destination

The IP packet is initially in uip_buf. Its header is compressed and if necessary it is fragmented. The resulting packet/fragments are put in packetbuf and delivered to the 802.15.4 MAC.

Definition at line 1626 of file sicslowpan.c.

References add_6lorh_hdr(), add_paging_dispatch(), compress_hdr_iphc(), last_tx_status, linkaddr_null, mac_max_payload, MAC_TX_OK, mac_driver::max_payload, output(), packetbuf_clear(), packetbuf_dataptr(), packetbuf_hdr_len, packetbuf_payload_len, packetbuf_ptr, packetbuf_set_datalen(), send_packet(), UIP_IP_BUF, uip_is_addr_linklocal, uip_len, and uncomp_hdr_len.

Referenced by output().

◆ uncompress_hdr_iphc()

static bool uncompress_hdr_iphc ( uint8_t * buf,
uint16_t buf_size,
uint16_t ip_len )
static

Uncompress IPHC (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 IPHC. 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
bufPointer to the buffer to uncompress the packet into.
buf_sizeThe size of the buffer to uncompress the packet into.
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.
Returns
A boolean value indicating whether the uncompression succeeded.

Definition at line 1075 of file sicslowpan.c.

References addr_context_lookup_by_number(), iphc_ptr, packetbuf_datalen(), packetbuf_hdr_len, packetbuf_ptr, UIP_HTONS, UIP_PROTO_HBHO, and uncomp_hdr_len.

Referenced by input().

Variable Documentation

◆ iphc_ptr

uint8_t* iphc_ptr
static

Addresses contexts for IPHC.

pointer to the byte where to write next inline field.

Definition at line 514 of file sicslowpan.c.

Referenced by compress_hdr_iphc(), and uncompress_hdr_iphc().

◆ packetbuf_payload_len

int packetbuf_payload_len
static

The length of the payload in the Packetbuf buffer.

The payload is what comes after the compressed or uncompressed headers (can be the IP payload if the IP header only is compressed or the UDP payload if the UDP header is also compressed)

Definition at line 174 of file sicslowpan.c.

Referenced by input(), and output().

◆ packetbuf_ptr

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.

Definition at line 159 of file sicslowpan.c.

Referenced by compress_hdr_iphc(), input(), output(), and uncompress_hdr_iphc().