cleanup of the code, removing dead core + adding local vars to save some space.

This commit is contained in:
joxe 2010-05-24 14:28:56 +00:00
parent 0d3c7edd6c
commit 16c212798f

View file

@ -32,7 +32,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sicslowpan.c,v 1.40 2010/05/24 10:07:34 joxe Exp $ * $Id: sicslowpan.c,v 1.41 2010/05/24 14:28:56 joxe Exp $
*/ */
/** /**
* \file * \file
@ -123,7 +123,6 @@ void uip_log(char *msg);
/** \name Pointers in the rime buffer /** \name Pointers in the rime buffer
* @{ * @{
*/ */
/* #define RIME_FRAG_BUF ((struct sicslowpan_frag_hdr *)rime_ptr) */
#define RIME_FRAG_PTR (rime_ptr) #define RIME_FRAG_PTR (rime_ptr)
#define RIME_FRAG_DISPATCH_SIZE 0 /* 16 bit */ #define RIME_FRAG_DISPATCH_SIZE 0 /* 16 bit */
#define RIME_FRAG_TAG 2 /* 16 bit */ #define RIME_FRAG_TAG 2 /* 16 bit */
@ -132,13 +131,11 @@ void uip_log(char *msg);
/* define the buffer as a byte array */ /* define the buffer as a byte array */
#define RIME_IPHC_BUF ((uint8_t *)(rime_ptr + rime_hdr_len)) #define RIME_IPHC_BUF ((uint8_t *)(rime_ptr + rime_hdr_len))
/* #define RIME_HC1_BUF ((struct sicslowpan_hc1_hdr *)(rime_ptr + rime_hdr_len)) */
#define RIME_HC1_PTR (rime_ptr + rime_hdr_len) #define RIME_HC1_PTR (rime_ptr + rime_hdr_len)
#define RIME_HC1_DISPATCH 0 /* 8 bit */ #define RIME_HC1_DISPATCH 0 /* 8 bit */
#define RIME_HC1_ENCODING 1 /* 8 bit */ #define RIME_HC1_ENCODING 1 /* 8 bit */
#define RIME_HC1_TTL 2 /* 8 bit */ #define RIME_HC1_TTL 2 /* 8 bit */
/* #define RIME_HC1_HC_UDP_BUF ((struct sicslowpan_hc1_hc_udp_hdr *)(rime_ptr + rime_hdr_len)) */
#define RIME_HC1_HC_UDP_PTR (rime_ptr + rime_hdr_len) #define RIME_HC1_HC_UDP_PTR (rime_ptr + rime_hdr_len)
#define RIME_HC1_HC_UDP_DISPATCH 0 /* 8 bit */ #define RIME_HC1_HC_UDP_DISPATCH 0 /* 8 bit */
#define RIME_HC1_HC_UDP_HC1_ENCODING 1 /* 8 bit */ #define RIME_HC1_HC_UDP_HC1_ENCODING 1 /* 8 bit */
@ -147,18 +144,11 @@ void uip_log(char *msg);
#define RIME_HC1_HC_UDP_PORTS 4 /* 8 bit */ #define RIME_HC1_HC_UDP_PORTS 4 /* 8 bit */
#define RIME_HC1_HC_UDP_CHKSUM 5 /* 16 bit */ #define RIME_HC1_HC_UDP_CHKSUM 5 /* 16 bit */
/* #define RIME_IPHC_DISPATCH 0 /\* 8 bit *\/ */
/* #define RIME_IPHC_ENCODING1 1 /\* 8 bit *\/ */
/* #define RIME_IPHC_ENCODING2 2 /\* 8 bit *\/ */
/* #define RIME_IP_BUF ((struct uip_ip_hdr *)(rime_ptr + rime_hdr_len)) */
/** @} */
/** \name Pointers in the sicslowpan and uip buffer /** \name Pointers in the sicslowpan and uip buffer
* @{ * @{
*/ */
#define SICSLOWPAN_IP_BUF ((struct uip_ip_hdr *)&sicslowpan_buf.u8[UIP_LLH_LEN]) #define SICSLOWPAN_IP_BUF ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN])
#define SICSLOWPAN_UDP_BUF ((struct uip_udp_hdr *)&sicslowpan_buf.u8[UIP_LLIPH_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_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_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN])
@ -215,13 +205,14 @@ static u8_t uncomp_hdr_len;
*/ */
static u16_t sicslowpan_len; static u16_t sicslowpan_len;
/** /**
* The buffer used for the 6lowpan reassembly. * The buffer used for the 6lowpan reassembly.
* This buffer contains only the IPv6 packet (no MAC header, 6lowpan, etc). * This buffer contains only the IPv6 packet (no MAC header, 6lowpan, etc).
* It has a fix size as we do not use dynamic memory allocation. * It has a fix size as we do not use dynamic memory allocation.
*/ */
static uip_buf_t sicslowpan_aligned_buf;
static uip_buf_t sicslowpan_buf; #define sicslowpan_buf (sicslowpan_aligned_buf.u8)
/** The total length of the IPv6 packet in the sicslowpan_buf. */ /** The total length of the IPv6 packet in the sicslowpan_buf. */
@ -269,7 +260,6 @@ static struct sicslowpan_addr_context *context;
/** pointer to the byte where to write next inline field. */ /** pointer to the byte where to write next inline field. */
static uint8_t *hc06_ptr; static uint8_t *hc06_ptr;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
/** \name HC06 related functions /** \name HC06 related functions
* @{ */ * @{ */
@ -306,24 +296,25 @@ addr_context_lookup_by_number(u8_t number) {
return NULL; return NULL;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static uint8_t
compress_addr_64(uint8_t bitpos, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) { compress_addr_64(uint8_t bitpos, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) {
if(uip_is_addr_mac_addr_based(ipaddr, lladdr)){ if(uip_is_addr_mac_addr_based(ipaddr, lladdr)){
RIME_IPHC_BUF[1] |= 3 << bitpos; /* 0-bits */ return 3 << bitpos; /* 0-bits */
} else if(sicslowpan_is_iid_16_bit_compressable(ipaddr)){ } else if(sicslowpan_is_iid_16_bit_compressable(ipaddr)){
/* compress IID to 16 bits xxxx::XXXX */ /* compress IID to 16 bits xxxx::XXXX */
RIME_IPHC_BUF[1] |= 2 << bitpos; /* 16-bits */
memcpy(hc06_ptr, &ipaddr->u16[7], 2); memcpy(hc06_ptr, &ipaddr->u16[7], 2);
hc06_ptr += 2; hc06_ptr += 2;
return 2 << bitpos; /* 16-bits */
} else { } else {
/* do not compress IID => xxxx::IID */ /* do not compress IID => xxxx::IID */
RIME_IPHC_BUF[1] |= 1 << bitpos; /* 64-bits */
memcpy(hc06_ptr, &ipaddr->u16[4], 8); memcpy(hc06_ptr, &ipaddr->u16[4], 8);
hc06_ptr += 8; hc06_ptr += 8;
return 1 << bitpos; /* 64-bits */
} }
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
uncompress_lladdr(uint8_t mode, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) { uncompress_lladdr(uint8_t mode, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) {
switch(mode) { switch(mode) {
@ -399,7 +390,7 @@ uncompress_lladdr(uint8_t mode, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) {
static void static void
compress_hdr_hc06(rimeaddr_t *rime_destaddr) compress_hdr_hc06(rimeaddr_t *rime_destaddr)
{ {
uint8_t tmp; uint8_t tmp, iphc0, iphc1;
#if DEBUG #if DEBUG
PRINTF("before compression: "); PRINTF("before compression: ");
for (tmp = 0; tmp < UIP_IP_BUF->len[1] + 40; tmp++) { for (tmp = 0; tmp < UIP_IP_BUF->len[1] + 40; tmp++) {
@ -417,8 +408,8 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
* this does not work. We therefore reset the IPHC encoding here * this does not work. We therefore reset the IPHC encoding here
*/ */
RIME_IPHC_BUF[0] = SICSLOWPAN_DISPATCH_IPHC; iphc0 = SICSLOWPAN_DISPATCH_IPHC;
RIME_IPHC_BUF[1] = 0; iphc1 = 0;
RIME_IPHC_BUF[2] = 0; /* might not be used - but needs to be cleared */ RIME_IPHC_BUF[2] = 0; /* might not be used - but needs to be cleared */
/* /*
@ -435,7 +426,7 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr) != NULL) { addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr) != NULL) {
/* set context flag and increase hc06_ptr */ /* set context flag and increase hc06_ptr */
PRINTF("IPHC: compressing dest or src ipaddr - setting CID\n"); PRINTF("IPHC: compressing dest or src ipaddr - setting CID\n");
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_CID; iphc1 |= SICSLOWPAN_IPHC_CID;
hc06_ptr++; hc06_ptr++;
} }
@ -453,11 +444,11 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
if(((UIP_IP_BUF->tcflow & 0x0F) == 0) && if(((UIP_IP_BUF->tcflow & 0x0F) == 0) &&
(UIP_IP_BUF->flow == 0)) { (UIP_IP_BUF->flow == 0)) {
/* flow label can be compressed */ /* flow label can be compressed */
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_FL_C; iphc0 |= SICSLOWPAN_IPHC_FL_C;
if(((UIP_IP_BUF->vtc & 0x0F) == 0) && if(((UIP_IP_BUF->vtc & 0x0F) == 0) &&
((UIP_IP_BUF->tcflow & 0xF0) == 0)) { ((UIP_IP_BUF->tcflow & 0xF0) == 0)) {
/* compress (elide) all */ /* compress (elide) all */
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_TC_C; iphc0 |= SICSLOWPAN_IPHC_TC_C;
} else { } else {
/* compress only the flow label */ /* compress only the flow label */
*hc06_ptr = tmp; *hc06_ptr = tmp;
@ -468,7 +459,7 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
if(((UIP_IP_BUF->vtc & 0x0F) == 0) && if(((UIP_IP_BUF->vtc & 0x0F) == 0) &&
((UIP_IP_BUF->tcflow & 0xF0) == 0)) { ((UIP_IP_BUF->tcflow & 0xF0) == 0)) {
/* compress only traffic class */ /* compress only traffic class */
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_TC_C; iphc0 |= SICSLOWPAN_IPHC_TC_C;
*hc06_ptr = (tmp & 0xc0) | *hc06_ptr = (tmp & 0xc0) |
(UIP_IP_BUF->tcflow & 0x0F); (UIP_IP_BUF->tcflow & 0x0F);
memcpy(hc06_ptr + 1, &UIP_IP_BUF->flow, 2); memcpy(hc06_ptr + 1, &UIP_IP_BUF->flow, 2);
@ -487,15 +478,15 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
/* Next header. We compress it if UDP */ /* Next header. We compress it if UDP */
#if UIP_CONF_UDP #if UIP_CONF_UDP
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) { if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_NH_C; iphc0 |= SICSLOWPAN_IPHC_NH_C;
} }
#endif /*UIP_CONF_UDP*/ #endif /*UIP_CONF_UDP*/
#ifdef SICSLOWPAN_NH_COMPRESSOR #ifdef SICSLOWPAN_NH_COMPRESSOR
if(SICSLOWPAN_NH_COMPRESSOR.is_compressable(UIP_IP_BUF->proto)) { if(SICSLOWPAN_NH_COMPRESSOR.is_compressable(UIP_IP_BUF->proto)) {
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_NH_C; iphc0 |= SICSLOWPAN_IPHC_NH_C;
} }
#endif #endif
if ((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_NH_C) == 0) { if ((iphc0 & SICSLOWPAN_IPHC_NH_C) == 0) {
*hc06_ptr = UIP_IP_BUF->proto; *hc06_ptr = UIP_IP_BUF->proto;
hc06_ptr += 1; hc06_ptr += 1;
} }
@ -509,13 +500,13 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
*/ */
switch(UIP_IP_BUF->ttl) { switch(UIP_IP_BUF->ttl) {
case 1: case 1:
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_TTL_1; iphc0 |= SICSLOWPAN_IPHC_TTL_1;
break; break;
case 64: case 64:
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_TTL_64; iphc0 |= SICSLOWPAN_IPHC_TTL_64;
break; break;
case 255: case 255:
RIME_IPHC_BUF[0] |= SICSLOWPAN_IPHC_TTL_255; iphc0 |= SICSLOWPAN_IPHC_TTL_255;
break; break;
default: default:
*hc06_ptr = UIP_IP_BUF->ttl; *hc06_ptr = UIP_IP_BUF->ttl;
@ -526,26 +517,26 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
/* source address - cannot be multicast */ /* source address - cannot be multicast */
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("IPHC: compressing unspecified - setting SAC\n"); PRINTF("IPHC: compressing unspecified - setting SAC\n");
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_SAC; iphc1 |= SICSLOWPAN_IPHC_SAC;
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_SAM_00; iphc1 |= SICSLOWPAN_IPHC_SAM_00;
} else if((context = addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr)) } else if((context = addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr))
!= NULL) { != NULL) {
/* elide the prefix - indicate by CID and set context + SAC */ /* elide the prefix - indicate by CID and set context + SAC */
PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n", PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n",
context->number); context->number);
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC; iphc1 |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC;
RIME_IPHC_BUF[2] |= context->number << 4; RIME_IPHC_BUF[2] |= context->number << 4;
/* compession compare with this nodes address (source) */ /* compession compare with this nodes address (source) */
compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_link_local(&UIP_IP_BUF->srcipaddr)) { } else if(uip_is_addr_link_local(&UIP_IP_BUF->srcipaddr)) {
compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
} else { } else {
/* send the full address => SAC = 0, SAM = 00 */ /* send the full address => SAC = 0, SAM = 00 */
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_SAM_00; /* 128-bits */ iphc1 |= SICSLOWPAN_IPHC_SAM_00; /* 128-bits */
memcpy(hc06_ptr, &UIP_IP_BUF->srcipaddr.u16[0], 16); memcpy(hc06_ptr, &UIP_IP_BUF->srcipaddr.u16[0], 16);
hc06_ptr += 16; hc06_ptr += 16;
} }
@ -553,26 +544,26 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
/* dest address*/ /* dest address*/
if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
/* Address is multicast, try to compress */ /* Address is multicast, try to compress */
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_M; iphc1 |= SICSLOWPAN_IPHC_M;
if(sicslowpan_is_mcast_addr_compressable8(&UIP_IP_BUF->destipaddr)) { if(sicslowpan_is_mcast_addr_compressable8(&UIP_IP_BUF->destipaddr)) {
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAM_11; iphc1 |= SICSLOWPAN_IPHC_DAM_11;
/* use last byte */ /* use last byte */
*hc06_ptr = UIP_IP_BUF->destipaddr.u8[15]; *hc06_ptr = UIP_IP_BUF->destipaddr.u8[15];
hc06_ptr += 1; hc06_ptr += 1;
} else if(sicslowpan_is_mcast_addr_compressable32(&UIP_IP_BUF->destipaddr)){ } else if(sicslowpan_is_mcast_addr_compressable32(&UIP_IP_BUF->destipaddr)){
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAM_10; iphc1 |= SICSLOWPAN_IPHC_DAM_10;
/* second byte + the last three */ /* second byte + the last three */
*hc06_ptr = UIP_IP_BUF->destipaddr.u8[1]; *hc06_ptr = UIP_IP_BUF->destipaddr.u8[1];
memcpy(hc06_ptr + 1, &UIP_IP_BUF->destipaddr.u8[13], 3); memcpy(hc06_ptr + 1, &UIP_IP_BUF->destipaddr.u8[13], 3);
hc06_ptr += 4; hc06_ptr += 4;
} else if(sicslowpan_is_mcast_addr_compressable48(&UIP_IP_BUF->destipaddr)){ } else if(sicslowpan_is_mcast_addr_compressable48(&UIP_IP_BUF->destipaddr)){
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAM_01; iphc1 |= SICSLOWPAN_IPHC_DAM_01;
/* second byte + the last five */ /* second byte + the last five */
*hc06_ptr = UIP_IP_BUF->destipaddr.u8[1]; *hc06_ptr = UIP_IP_BUF->destipaddr.u8[1];
memcpy(hc06_ptr + 1, &UIP_IP_BUF->destipaddr.u8[11], 5); memcpy(hc06_ptr + 1, &UIP_IP_BUF->destipaddr.u8[11], 5);
hc06_ptr += 6; hc06_ptr += 6;
} else { } else {
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAM_00; iphc1 |= SICSLOWPAN_IPHC_DAM_00;
/* full address */ /* full address */
memcpy(hc06_ptr, &UIP_IP_BUF->destipaddr.u8[0], 16); memcpy(hc06_ptr, &UIP_IP_BUF->destipaddr.u8[0], 16);
hc06_ptr += 16; hc06_ptr += 16;
@ -581,19 +572,19 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
/* Address is unicast, try to compress */ /* Address is unicast, try to compress */
if((context = addr_context_lookup_by_prefix(&UIP_IP_BUF->destipaddr)) != NULL) { if((context = addr_context_lookup_by_prefix(&UIP_IP_BUF->destipaddr)) != NULL) {
/* elide the prefix */ /* elide the prefix */
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAC; iphc1 |= SICSLOWPAN_IPHC_DAC;
RIME_IPHC_BUF[2] |= context->number; RIME_IPHC_BUF[2] |= context->number;
/* compession compare with link adress (destination) */ /* compession compare with link adress (destination) */
compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr); &UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_link_local(&UIP_IP_BUF->destipaddr)) { } else if(uip_is_addr_link_local(&UIP_IP_BUF->destipaddr)) {
compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr); &UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr);
} else { } else {
/* send the full address */ /* send the full address */
RIME_IPHC_BUF[1] |= SICSLOWPAN_IPHC_DAM_00; /* 128-bits */ iphc1 |= SICSLOWPAN_IPHC_DAM_00; /* 128-bits */
memcpy(hc06_ptr, &UIP_IP_BUF->destipaddr.u16[0], 16); memcpy(hc06_ptr, &UIP_IP_BUF->destipaddr.u16[0], 16);
hc06_ptr += 16; hc06_ptr += 16;
} }
@ -651,10 +642,16 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
uncomp_hdr_len += UIP_UDPH_LEN; uncomp_hdr_len += UIP_UDPH_LEN;
} }
#endif /*UIP_CONF_UDP*/ #endif /*UIP_CONF_UDP*/
#ifdef SICSLOWPAN_NH_COMPRESSOR #ifdef SICSLOWPAN_NH_COMPRESSOR
/* if nothing to compress just return zero */ /* if nothing to compress just return zero */
hc06_ptr += SICSLOWPAN_NH_COMPRESSOR.compress(hc06_ptr, &uncomp_hdr_len); hc06_ptr += SICSLOWPAN_NH_COMPRESSOR.compress(hc06_ptr, &uncomp_hdr_len);
#endif #endif
/* before the rime_hdr_len operation */
RIME_IPHC_BUF[0] = iphc0;
RIME_IPHC_BUF[1] = iphc1;
rime_hdr_len = hc06_ptr - rime_ptr; rime_hdr_len = hc06_ptr - rime_ptr;
return; return;
} }
@ -678,20 +675,23 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
static void static void
uncompress_hdr_hc06(u16_t ip_len) { uncompress_hdr_hc06(u16_t ip_len) {
uint8_t tmp; uint8_t tmp, iphc0, iphc1;
/* at least two byte will be used for the encoding */ /* at least two byte will be used for the encoding */
hc06_ptr = rime_ptr + rime_hdr_len + 2; hc06_ptr = rime_ptr + rime_hdr_len + 2;
iphc0 = RIME_IPHC_BUF[0];
iphc1 = RIME_IPHC_BUF[1];
/* another if the CID flag is set */ /* another if the CID flag is set */
if(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_CID) { if(iphc1 & SICSLOWPAN_IPHC_CID) {
PRINTF("IPHC: CID flag set - increase header with one\n"); PRINTF("IPHC: CID flag set - increase header with one\n");
hc06_ptr++; hc06_ptr++;
} }
/* Traffic class and flow label */ /* Traffic class and flow label */
if((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_FL_C) == 0) { if((iphc0 & SICSLOWPAN_IPHC_FL_C) == 0) {
/* Flow label are carried inline */ /* Flow label are carried inline */
if((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_TC_C) == 0) { if((iphc0 & SICSLOWPAN_IPHC_TC_C) == 0) {
/* Traffic class is carried inline */ /* Traffic class is carried inline */
memcpy(&SICSLOWPAN_IP_BUF->tcflow, hc06_ptr + 1, 3); memcpy(&SICSLOWPAN_IP_BUF->tcflow, hc06_ptr + 1, 3);
tmp = *hc06_ptr; tmp = *hc06_ptr;
@ -714,7 +714,7 @@ uncompress_hdr_hc06(u16_t ip_len) {
} else { } else {
/* Version is always 6! */ /* Version is always 6! */
/* Version and flow label are compressed */ /* Version and flow label are compressed */
if((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_TC_C) == 0) { if((iphc0 & SICSLOWPAN_IPHC_TC_C) == 0) {
/* Traffic class is inline */ /* Traffic class is inline */
SICSLOWPAN_IP_BUF->vtc = 0x60 | ((*hc06_ptr >> 2) & 0x0f); SICSLOWPAN_IP_BUF->vtc = 0x60 | ((*hc06_ptr >> 2) & 0x0f);
SICSLOWPAN_IP_BUF->tcflow = ((*hc06_ptr << 6) & 0xC0) | ((*hc06_ptr >> 2) & 0x30); SICSLOWPAN_IP_BUF->tcflow = ((*hc06_ptr << 6) & 0xC0) | ((*hc06_ptr >> 2) & 0x30);
@ -729,7 +729,7 @@ uncompress_hdr_hc06(u16_t ip_len) {
} }
/* Next Header */ /* Next Header */
if((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_NH_C) == 0) { if((iphc0 & SICSLOWPAN_IPHC_NH_C) == 0) {
/* Next header is carried inline */ /* Next header is carried inline */
SICSLOWPAN_IP_BUF->proto = *hc06_ptr; SICSLOWPAN_IP_BUF->proto = *hc06_ptr;
PRINTF("IPHC: next header inline: %d\n", SICSLOWPAN_IP_BUF->proto); PRINTF("IPHC: next header inline: %d\n", SICSLOWPAN_IP_BUF->proto);
@ -737,7 +737,7 @@ uncompress_hdr_hc06(u16_t ip_len) {
} }
/* Hop limit */ /* Hop limit */
switch(RIME_IPHC_BUF[0] & 0x03) { switch(iphc0 & 0x03) {
case SICSLOWPAN_IPHC_TTL_1: case SICSLOWPAN_IPHC_TTL_1:
SICSLOWPAN_IP_BUF->ttl = 1; SICSLOWPAN_IP_BUF->ttl = 1;
break; break;
@ -754,12 +754,12 @@ uncompress_hdr_hc06(u16_t ip_len) {
} }
/* context based compression */ /* context based compression */
if(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_SAC) { if(iphc1 & SICSLOWPAN_IPHC_SAC) {
uint8_t sci = (RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_CID) ? uint8_t sci = (iphc1 & SICSLOWPAN_IPHC_CID) ?
RIME_IPHC_BUF[2] >> 4 : 0; RIME_IPHC_BUF[2] >> 4 : 0;
/* Source address */ /* Source address */
if((RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_SAM_11) != SICSLOWPAN_IPHC_SAM_00) { if((iphc1 & SICSLOWPAN_IPHC_SAM_11) != SICSLOWPAN_IPHC_SAM_00) {
context = context =
addr_context_lookup_by_number(sci); addr_context_lookup_by_number(sci);
if(context == NULL) { if(context == NULL) {
@ -770,7 +770,7 @@ uncompress_hdr_hc06(u16_t ip_len) {
} }
} }
switch(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_SAM_11) { switch(iphc1 & SICSLOWPAN_IPHC_SAM_11) {
case SICSLOWPAN_IPHC_SAM_00: case SICSLOWPAN_IPHC_SAM_00:
/* copy the unspecificed address */ /* copy the unspecificed address */
PRINTF("IPHC: unspecified address\n"); PRINTF("IPHC: unspecified address\n");
@ -802,20 +802,20 @@ uncompress_hdr_hc06(u16_t ip_len) {
/* end context based compression */ /* end context based compression */
} else { } else {
/* no compression and link local */ /* no compression and link local */
uncompress_lladdr((RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_SAM_11) >> SICSLOWPAN_IPHC_SAM_BIT, uncompress_lladdr((iphc1 & SICSLOWPAN_IPHC_SAM_11) >> SICSLOWPAN_IPHC_SAM_BIT,
&SICSLOWPAN_IP_BUF->srcipaddr, (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); &SICSLOWPAN_IP_BUF->srcipaddr, (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
} }
/* Destination address */ /* Destination address */
/* multicast compression */ /* multicast compression */
if(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_M) { if(iphc1 & SICSLOWPAN_IPHC_M) {
/* context based multicast compression */ /* context based multicast compression */
if(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_DAC) { if(iphc1 & SICSLOWPAN_IPHC_DAC) {
/* TODO: implement this */ /* TODO: implement this */
} else { } else {
/* non-context based multicast compression */ /* non-context based multicast compression */
switch (RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_DAM_11) { switch (iphc1 & SICSLOWPAN_IPHC_DAM_11) {
case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */ case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */
/* copy whole address from packet */ /* copy whole address from packet */
memcpy(&SICSLOWPAN_IP_BUF->destipaddr.u8[0], hc06_ptr, 16); memcpy(&SICSLOWPAN_IP_BUF->destipaddr.u8[0], hc06_ptr, 16);
@ -847,8 +847,8 @@ uncompress_hdr_hc06(u16_t ip_len) {
} else { } else {
/* no multicast */ /* no multicast */
/* Context based */ /* Context based */
if(RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_DAC) { if(iphc1 & SICSLOWPAN_IPHC_DAC) {
uint8_t dci = (RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_CID) ? uint8_t dci = (iphc1 & SICSLOWPAN_IPHC_CID) ?
RIME_IPHC_BUF[2] & 0x0f : 0; RIME_IPHC_BUF[2] & 0x0f : 0;
context = addr_context_lookup_by_number(dci); context = addr_context_lookup_by_number(dci);
@ -858,7 +858,7 @@ uncompress_hdr_hc06(u16_t ip_len) {
return; return;
} }
switch (RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_DAM_11) { switch (iphc1 & SICSLOWPAN_IPHC_DAM_11) {
case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */ case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */
/* copy prefix from context - rest from packet */ /* copy prefix from context - rest from packet */
memcpy(&SICSLOWPAN_IP_BUF->destipaddr, context->prefix, 8); memcpy(&SICSLOWPAN_IP_BUF->destipaddr, context->prefix, 8);
@ -882,14 +882,14 @@ uncompress_hdr_hc06(u16_t ip_len) {
} }
} else { } else {
/* not context based => link local M = 0, DAC = 0 - same as SAC */ /* not context based => link local M = 0, DAC = 0 - same as SAC */
uncompress_lladdr((RIME_IPHC_BUF[1] & SICSLOWPAN_IPHC_DAM_11) >> SICSLOWPAN_IPHC_DAM_BIT, uncompress_lladdr((iphc1 & SICSLOWPAN_IPHC_DAM_11) >> SICSLOWPAN_IPHC_DAM_BIT,
&SICSLOWPAN_IP_BUF->destipaddr, (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER)); &SICSLOWPAN_IP_BUF->destipaddr, (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
} }
} }
uncomp_hdr_len += UIP_IPH_LEN; uncomp_hdr_len += UIP_IPH_LEN;
/* Next header processing - continued */ /* Next header processing - continued */
if((RIME_IPHC_BUF[0] & SICSLOWPAN_IPHC_NH_C)) { if((iphc0 & SICSLOWPAN_IPHC_NH_C)) {
/* The next header is compressed, NHC is following */ /* The next header is compressed, NHC is following */
if((*hc06_ptr & SICSLOWPAN_NHC_UDP_MASK) == SICSLOWPAN_NHC_UDP_ID) { if((*hc06_ptr & SICSLOWPAN_NHC_UDP_MASK) == SICSLOWPAN_NHC_UDP_ID) {
uint8_t checksum_compressed; uint8_t checksum_compressed;
@ -1071,24 +1071,19 @@ compress_hdr_hc1(rimeaddr_t *rime_destaddr)
* All fields in the IP header but Hop Limit are elided * All fields in the IP header but Hop Limit are elided
* If next header is UDP, we compress UDP header using HC2 * If next header is UDP, we compress UDP header using HC2
*/ */
/* RIME_HC1_BUF->dispatch = SICSLOWPAN_DISPATCH_HC1; */
RIME_HC1_PTR[RIME_HC1_DISPATCH] = SICSLOWPAN_DISPATCH_HC1; RIME_HC1_PTR[RIME_HC1_DISPATCH] = SICSLOWPAN_DISPATCH_HC1;
uncomp_hdr_len += UIP_IPH_LEN; uncomp_hdr_len += UIP_IPH_LEN;
switch(UIP_IP_BUF->proto) { switch(UIP_IP_BUF->proto) {
case UIP_PROTO_ICMP6: case UIP_PROTO_ICMP6:
/* HC1 encoding and ttl */ /* HC1 encoding and ttl */
/* RIME_HC1_BUF->encoding = 0xFC; */
RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFC; RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFC;
/* RIME_HC1_BUF->ttl = UIP_IP_BUF->ttl; */
RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl; RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl;
rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN;
break; break;
#if UIP_CONF_TCP #if UIP_CONF_TCP
case UIP_PROTO_TCP: case UIP_PROTO_TCP:
/* HC1 encoding and ttl */ /* HC1 encoding and ttl */
/* RIME_HC1_BUF->encoding = 0xFE; */
RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFE; RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFE;
/* RIME_HC1_BUF->ttl = UIP_IP_BUF->ttl; */
RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl; RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl;
rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN;
break; break;
@ -1106,30 +1101,22 @@ compress_hdr_hc1(rimeaddr_t *rime_destaddr)
HTONS(UIP_UDP_BUF->destport) >= SICSLOWPAN_UDP_PORT_MIN && HTONS(UIP_UDP_BUF->destport) >= SICSLOWPAN_UDP_PORT_MIN &&
HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) { HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) {
/* HC1 encoding */ /* HC1 encoding */
/* RIME_HC1_HC_UDP_BUF->hc1_encoding = 0xFB; */
RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_HC1_ENCODING] = 0xFB; RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_HC1_ENCODING] = 0xFB;
/* HC_UDP encoding, ttl, src and dest ports, checksum */ /* HC_UDP encoding, ttl, src and dest ports, checksum */
/* RIME_HC1_HC_UDP_BUF->hc_udp_encoding = 0xE0; */
RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_UDP_ENCODING] = 0xE0; RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_UDP_ENCODING] = 0xE0;
/* RIME_HC1_HC_UDP_BUF->ttl = UIP_IP_BUF->ttl; */
RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl; RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl;
/* RIME_HC1_HC_UDP_BUF->ports = (u8_t)((HTONS(UIP_UDP_BUF->srcport) - */
/* SICSLOWPAN_UDP_PORT_MIN) << 4) + */
/* (u8_t)((HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_PORT_MIN)); */
RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] = RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] =
(u8_t)((HTONS(UIP_UDP_BUF->srcport) - (u8_t)((HTONS(UIP_UDP_BUF->srcport) -
SICSLOWPAN_UDP_PORT_MIN) << 4) + SICSLOWPAN_UDP_PORT_MIN) << 4) +
(u8_t)((HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_PORT_MIN)); (u8_t)((HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_PORT_MIN));
/* RIME_HC1_HC_UDP_BUF->udpchksum = UIP_UDP_BUF->udpchksum; */
memcpy(&RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], &UIP_UDP_BUF->udpchksum, 2); memcpy(&RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], &UIP_UDP_BUF->udpchksum, 2);
rime_hdr_len += SICSLOWPAN_HC1_HC_UDP_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HC_UDP_HDR_LEN;
uncomp_hdr_len += UIP_UDPH_LEN; uncomp_hdr_len += UIP_UDPH_LEN;
} else { } else {
/* HC1 encoding and ttl */ /* HC1 encoding and ttl */
/* RIME_HC1_BUF->encoding = 0xFA; */
RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFA; RIME_HC1_PTR[RIME_HC1_ENCODING] = 0xFA;
/* RIME_HC1_BUF->ttl = UIP_IP_BUF->ttl; */
RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl; RIME_HC1_PTR[RIME_HC1_TTL] = UIP_IP_BUF->ttl;
rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN;
} }
@ -1174,18 +1161,15 @@ uncompress_hdr_hc1(u16_t ip_len) {
uncomp_hdr_len += UIP_IPH_LEN; uncomp_hdr_len += UIP_IPH_LEN;
/* Next header field */ /* Next header field */
/* switch(RIME_HC1_BUF->encoding & 0x06) { */
switch(RIME_HC1_PTR[RIME_HC1_ENCODING] & 0x06) { switch(RIME_HC1_PTR[RIME_HC1_ENCODING] & 0x06) {
case SICSLOWPAN_HC1_NH_ICMP6: case SICSLOWPAN_HC1_NH_ICMP6:
SICSLOWPAN_IP_BUF->proto = UIP_PROTO_ICMP6; SICSLOWPAN_IP_BUF->proto = UIP_PROTO_ICMP6;
/* SICSLOWPAN_IP_BUF->ttl = RIME_HC1_BUF->ttl; */
SICSLOWPAN_IP_BUF->ttl = RIME_HC1_PTR[RIME_HC1_TTL]; SICSLOWPAN_IP_BUF->ttl = RIME_HC1_PTR[RIME_HC1_TTL];
rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN;
break; break;
#if UIP_CONF_TCP #if UIP_CONF_TCP
case SICSLOWPAN_HC1_NH_TCP: case SICSLOWPAN_HC1_NH_TCP:
SICSLOWPAN_IP_BUF->proto = UIP_PROTO_TCP; SICSLOWPAN_IP_BUF->proto = UIP_PROTO_TCP;
/* SICSLOWPAN_IP_BUF->ttl = RIME_HC1_BUF->ttl; */
SICSLOWPAN_IP_BUF->ttl = RIME_HC1_PTR[RIME_HC1_TTL]; SICSLOWPAN_IP_BUF->ttl = RIME_HC1_PTR[RIME_HC1_TTL];
rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HDR_LEN;
break; break;
@ -1193,30 +1177,22 @@ uncompress_hdr_hc1(u16_t ip_len) {
#if UIP_CONF_UDP #if UIP_CONF_UDP
case SICSLOWPAN_HC1_NH_UDP: case SICSLOWPAN_HC1_NH_UDP:
SICSLOWPAN_IP_BUF->proto = UIP_PROTO_UDP; SICSLOWPAN_IP_BUF->proto = UIP_PROTO_UDP;
/* if(RIME_HC1_HC_UDP_BUF->hc1_encoding & 0x01) { */
if(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_HC1_ENCODING] & 0x01) { if(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_HC1_ENCODING] & 0x01) {
/* UDP header is compressed with HC_UDP */ /* UDP header is compressed with HC_UDP */
/* if(RIME_HC1_HC_UDP_BUF->hc_udp_encoding != */
if(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_UDP_ENCODING] != if(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_UDP_ENCODING] !=
SICSLOWPAN_HC_UDP_ALL_C) { SICSLOWPAN_HC_UDP_ALL_C) {
PRINTF("sicslowpan (uncompress_hdr), packet not supported"); PRINTF("sicslowpan (uncompress_hdr), packet not supported");
return; return;
} }
/* IP TTL */ /* IP TTL */
/* SICSLOWPAN_IP_BUF->ttl = RIME_HC1_HC_UDP_BUF->ttl; */
SICSLOWPAN_IP_BUF->ttl = RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL]; SICSLOWPAN_IP_BUF->ttl = RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL];
/* UDP ports, len, checksum */ /* UDP ports, len, checksum */
/* SICSLOWPAN_UDP_BUF->srcport = HTONS(SICSLOWPAN_UDP_PORT_MIN + */
/* (RIME_HC1_HC_UDP_BUF->ports >> 4)); */
SICSLOWPAN_UDP_BUF->srcport = SICSLOWPAN_UDP_BUF->srcport =
HTONS(SICSLOWPAN_UDP_PORT_MIN + HTONS(SICSLOWPAN_UDP_PORT_MIN +
(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] >> 4)); (RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] >> 4));
/* SICSLOWPAN_UDP_BUF->destport = HTONS(SICSLOWPAN_UDP_PORT_MIN + */
/* (RIME_HC1_HC_UDP_BUF->ports & 0x0F)); */
SICSLOWPAN_UDP_BUF->destport = SICSLOWPAN_UDP_BUF->destport =
HTONS(SICSLOWPAN_UDP_PORT_MIN + HTONS(SICSLOWPAN_UDP_PORT_MIN +
(RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] & 0x0F)); (RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] & 0x0F));
/* SICSLOWPAN_UDP_BUF->udpchksum = RIME_HC1_HC_UDP_BUF->udpchksum; */
memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, &RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], 2); memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, &RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], 2);
uncomp_hdr_len += UIP_UDPH_LEN; uncomp_hdr_len += UIP_UDPH_LEN;
rime_hdr_len += SICSLOWPAN_HC1_HC_UDP_HDR_LEN; rime_hdr_len += SICSLOWPAN_HC1_HC_UDP_HDR_LEN;
@ -1440,7 +1416,6 @@ output(uip_lladdr_t *localdest)
rime_payload_len = (MAC_MAX_PAYLOAD - rime_hdr_len) & 0xf8; rime_payload_len = (MAC_MAX_PAYLOAD - rime_hdr_len) & 0xf8;
while(processed_ip_len < uip_len){ while(processed_ip_len < uip_len){
PRINTFO("sicslowpan output: fragment "); PRINTFO("sicslowpan output: fragment ");
/* RIME_FRAG_BUF->offset = processed_ip_len >> 3; */
RIME_FRAG_PTR[RIME_FRAG_OFFSET] = processed_ip_len >> 3; RIME_FRAG_PTR[RIME_FRAG_OFFSET] = processed_ip_len >> 3;
/* Copy payload and send */ /* Copy payload and send */
@ -1527,7 +1502,6 @@ input(void)
* Since we don't support the mesh and broadcast header, the first header * Since we don't support the mesh and broadcast header, the first header
* we look for is the fragmentation header * we look for is the fragmentation header
*/ */
/* switch((ntohs(RIME_FRAG_BUF->dispatch_size) & 0xf800) >> 8) { */
switch((GET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE) & 0xf800) >> 8) { switch((GET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE) & 0xf800) >> 8) {
case SICSLOWPAN_DISPATCH_FRAG1: case SICSLOWPAN_DISPATCH_FRAG1:
PRINTFI("sicslowpan input: FRAG1 "); PRINTFI("sicslowpan input: FRAG1 ");
@ -1547,11 +1521,8 @@ input(void)
* Offset is in units of 8 bytes * Offset is in units of 8 bytes
*/ */
PRINTFI("sicslowpan input: FRAGN "); PRINTFI("sicslowpan input: FRAGN ");
/* frag_offset = RIME_FRAG_BUF->offset; */
frag_offset = RIME_FRAG_PTR[RIME_FRAG_OFFSET]; frag_offset = RIME_FRAG_PTR[RIME_FRAG_OFFSET];
/* frag_tag = ntohs(RIME_FRAG_BUF->tag); */
frag_tag = GET16(RIME_FRAG_PTR, RIME_FRAG_TAG); frag_tag = GET16(RIME_FRAG_PTR, RIME_FRAG_TAG);
/* frag_size = (ntohs(RIME_FRAG_BUF->dispatch_size) & 0x07ff); */
frag_size = GET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE) & 0x07ff; frag_size = GET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE) & 0x07ff;
PRINTFI("size %d, tag %d, offset %d)\n", PRINTFI("size %d, tag %d, offset %d)\n",
frag_size, frag_tag, frag_offset); frag_size, frag_tag, frag_offset);
@ -1598,7 +1569,6 @@ input(void)
#endif /* SICSLOWPAN_CONF_FRAG */ #endif /* SICSLOWPAN_CONF_FRAG */
/* Process next dispatch and headers */ /* Process next dispatch and headers */
/* switch(RIME_HC1_BUF->dispatch) { */
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06 #if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06
if((RIME_HC1_PTR[RIME_HC1_DISPATCH] & 0xe0) == SICSLOWPAN_DISPATCH_IPHC) { if((RIME_HC1_PTR[RIME_HC1_DISPATCH] & 0xe0) == SICSLOWPAN_DISPATCH_IPHC) {
PRINTFI("sicslowpan input: IPHC\n"); PRINTFI("sicslowpan input: IPHC\n");
@ -1625,7 +1595,6 @@ input(void)
break; break;
default: default:
/* unknown header */ /* unknown header */
/* PRINTF("sicslowpan input: unknown dispatch\n"); */
PRINTFI("sicslowpan input: unknown dispatch: %u\n", PRINTFI("sicslowpan input: unknown dispatch: %u\n",
RIME_HC1_PTR[RIME_HC1_DISPATCH]); RIME_HC1_PTR[RIME_HC1_DISPATCH]);
return; return;