Macros | Functions
sicslowpan.c File Reference

    6lowpan implementation (RFC4944 and draft-ietf-6lowpan-hc-06)

#include <string.h>
#include "contiki.h"
#include "dev/watchdog.h"
#include "net/link-stats.h"
#include "net/ipv6/uipopt.h"
#include "net/ipv6/tcpip.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ipv6/uipbuf.h"
#include "net/ipv6/sicslowpan.h"
#include "net/netstack.h"
#include "net/packetbuf.h"
#include "net/queuebuf.h"
#include "net/routing/routing.h"
#include "sys/log.h"

Go to the source code of this file.


#define LOG_MODULE   "6LoWPAN"
 FOR HC-06 COMPLIANCE TODO: -Add compression options to UDP, currently only supports both ports compressed or both ports elided. More...
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_IPHC_BUF   ((uint8_t *)(packetbuf_ptr + packetbuf_hdr_len))
#define PACKETBUF_PAYLOAD_END   ((uint8_t *)(packetbuf_ptr + mac_max_payload))
#define PACKETBUF_6LO_PTR   (packetbuf_ptr + packetbuf_hdr_len)
#define PACKETBUF_6LO_DISPATCH   0 /* 8 bit */
#define PACKETBUF_6LO_ENCODING   1 /* 8 bit */
#define PACKETBUF_6LO_TTL   2 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_PTR   (packetbuf_ptr + packetbuf_hdr_len)
#define PACKETBUF_6LO_HC_UDP_DISPATCH   0 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_HC1_ENCODING   1 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_UDP_ENCODING   2 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_TTL   3 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_PORTS   4 /* 8 bit */
#define PACKETBUF_6LO_HC_UDP_CHKSUM   5 /* 16 bit */
Pointers in the sicslowpan and uip buffer
#define SICSLOWPAN_IP_BUF(buf)   ((struct uip_ip_hdr *)buf)
#define SICSLOWPAN_UDP_BUF(buf)   ((struct uip_udp_hdr *)&buf[UIP_IPH_LEN])
#define UIP_IPPAYLOAD_BUF_POS(pos)   (&uip_buf[UIP_IPH_LEN + (pos)])
#define UIP_UDP_BUF_POS(pos)   ((struct uip_udp_hdr *)UIP_IPPAYLOAD_BUF_POS(pos))
#define UIP_EXT_HDR_LEN   2


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.
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 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 int compress_hdr_iphc (linkaddr_t *link_destaddr)
 Compress IP/UDP header. More...
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. More...
IPv6 dispatch "compression" function
static void compress_hdr_ipv6 (linkaddr_t *link_destaddr)
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 (linkaddr_t *dest)
 This function is called by the 6lowpan code to send out a packet. More...
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. More...
static void input (void)
 Process a received 6lowpan packet. More...


General variables
static uint8_t * packetbuf_ptr
 A pointer to the packetbuf buffer. More...
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. 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).
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 HC06 and more recent versions
static struct sicslowpan_addr_contextcontext
 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}

Detailed Description

    6lowpan implementation (RFC4944 and draft-ietf-6lowpan-hc-06)
Adam Dunkels
Nicolas Tsiftes
Niclas Finne
Mathilde Durvy
Julien Abeille
Joakim Eriksson
Joel Hoglund

Definition in file sicslowpan.c.