6lowpan implementation (RFC4944 and draft-ietf-6lowpan-hc-06)
#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"
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 | 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 | |
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) |
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... | |
Variables | |
static struct rime_sniffer * | callback = NULL |
static int | last_rssi |
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} |
#define TCP_ACK 0x10 |
Referenced by output().
#define TCP_CTL 0x3f |
Referenced by output().
#define TCP_FIN 0x01 |
Referenced by output().