Microchip® Advanced Software Framework

sicslowpan.c File Reference

    6lowpan implementation (RFC4944 and draft-ietf-6lowpan-hc-06)
Author
Adam Dunkels adam@.nosp@m.sics.nosp@m..se
Nicolas Tsiftes nvt@s.nosp@m.ics..nosp@m.se
Niclas Finne nfi@s.nosp@m.ics..nosp@m.se
Mathilde Durvy mdurv.nosp@m.y@ci.nosp@m.sco.c.nosp@m.om
Julien Abeille jabei.nosp@m.lle@.nosp@m.cisco.nosp@m..com
Joakim Eriksson joaki.nosp@m.me@s.nosp@m.ics.s.nosp@m.e
Joel Hoglund joel@.nosp@m.sics.nosp@m..se
#include <string.h>
#include "contiki.h"
#include "dev/watchdog.h"
#include "net/ip/tcpip.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/rime/rime.h"
#include "net/ipv6/sicslowpan.h"
#include "net/netstack.h"
#include "delay.h"
#include <stdio.h>
#include "net/ip/uip-debug.h"

Data Structures

struct  _sics_frag
 

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   SICSLOWPAN_CONF_COMPRESSION_THRESHOLD
 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   SICSLOWPAN_CONF_MAC_MAX_PAYLOAD
 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 PRIORITIZE_NEW_PACKETS   1
 
#define SET16(ptr, index, value)
 
#define SICSLOWPAN_COMPRESSION   SICSLOWPAN_CONF_COMPRESSION
 
#define SICSLOWPAN_MAX_MAC_TRANSMISSIONS   SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS
 
#define TCP_ACK   0x10
 
#define TCP_CTL   0x3f
 
#define TCP_FIN   0x01
 
#define UIP_LOG(m)
 
#define USE_FRAMER_HDRLEN   1
 
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])
 

Functions

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)
 
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...
 
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...
 
static void input (void)
 Process a received 6lowpan packet. More...
 

Variables

static struct rime_sniffercallback = NULL
 
static int last_rssi
 
struct network_driver sicslowpan_driver
 
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 
addr_contexts [SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS]
 Addresses contexts for IPHC. More...
 
static struct
sicslowpan_addr_context
context
 pointer to an address context. 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}
 

Fragmentation related variables

#define sicslowpan_buf   (sicslowpan_aligned_buf.u8)
 
typedef struct _sics_frag sics_frag_t
 
static uip_buf_t sicslowpan_aligned_buf
 The buffer used for the 6lowpan reassembly. More...
 
static uint16_t sicslowpan_len
 The total length of the IPv6 packet in the sicslowpan_buf. More...
 
static uint16_t my_tag
 Datagram tag to be put in the fragments I send. More...
 
uip_buf_t sicslowpanbuf [NUM_REASM_BUFS]
 
uint8_t sics_used_buf [NUM_REASM_BUFS]
 
static sics_frag_t sics_frag_attr [NUM_REASM_BUFS]
 
static struct ctimer reasm_ct
 
static void sics_frag_buf_init (void)
 
static void reasm_timer_callback (void *ptr)
 

#define PRIORITIZE_NEW_PACKETS   1
#define TCP_ACK   0x10

Referenced by output().

#define TCP_CTL   0x3f

Referenced by output().

#define TCP_FIN   0x01

Referenced by output().