Bugfix: out-of-order fragments were not handled correctly. minor style fixes
This commit is contained in:
parent
2a885a476d
commit
1b5001b226
|
@ -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.47 2010/10/26 13:25:32 joxe Exp $
|
* $Id: sicslowpan.c,v 1.48 2010/11/02 10:56:57 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
|
@ -300,7 +300,8 @@ static const uint8_t ttl_values[] = {0, 1, 64, 255};
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/** \brief find the context corresponding to prefix ipaddr */
|
/** \brief find the context corresponding to prefix ipaddr */
|
||||||
static struct sicslowpan_addr_context*
|
static struct sicslowpan_addr_context*
|
||||||
addr_context_lookup_by_prefix(uip_ipaddr_t *ipaddr) {
|
addr_context_lookup_by_prefix(uip_ipaddr_t *ipaddr)
|
||||||
|
{
|
||||||
/* Remove code to avoid warnings and save flash if no context is used */
|
/* Remove code to avoid warnings and save flash if no context is used */
|
||||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||||
int i;
|
int i;
|
||||||
|
@ -316,7 +317,8 @@ addr_context_lookup_by_prefix(uip_ipaddr_t *ipaddr) {
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/** \brief find the context with the given number */
|
/** \brief find the context with the given number */
|
||||||
static struct sicslowpan_addr_context*
|
static struct sicslowpan_addr_context*
|
||||||
addr_context_lookup_by_number(u8_t number) {
|
addr_context_lookup_by_number(u8_t number)
|
||||||
|
{
|
||||||
/* Remove code to avoid warnings and save flash if no context is used */
|
/* Remove code to avoid warnings and save flash if no context is used */
|
||||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||||
int i;
|
int i;
|
||||||
|
@ -331,7 +333,8 @@ addr_context_lookup_by_number(u8_t number) {
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static uint8_t
|
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)) {
|
||||||
return 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)) {
|
||||||
|
@ -356,7 +359,8 @@ compress_addr_64(uint8_t bitpos, uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) {
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
|
uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
|
||||||
uint8_t pref_post_count, uip_lladdr_t *lladdr) {
|
uint8_t pref_post_count, uip_lladdr_t *lladdr)
|
||||||
|
{
|
||||||
uint8_t prefcount = pref_post_count >> 4;
|
uint8_t prefcount = pref_post_count >> 4;
|
||||||
uint8_t postcount = pref_post_count & 0x0f;
|
uint8_t postcount = pref_post_count & 0x0f;
|
||||||
/* full nibble 15 => 16 */
|
/* full nibble 15 => 16 */
|
||||||
|
@ -703,9 +707,9 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
|
||||||
* is then inferred from the L2 length), non 0 if the packet is a 1st
|
* is then inferred from the L2 length), non 0 if the packet is a 1st
|
||||||
* fragment.
|
* fragment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uncompress_hdr_hc06(u16_t ip_len) {
|
uncompress_hdr_hc06(u16_t ip_len)
|
||||||
|
{
|
||||||
uint8_t tmp, iphc0, iphc1;
|
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;
|
||||||
|
@ -1106,7 +1110,8 @@ compress_hdr_hc1(rimeaddr_t *rime_destaddr)
|
||||||
* fragment.
|
* fragment.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
uncompress_hdr_hc1(u16_t ip_len) {
|
uncompress_hdr_hc1(u16_t ip_len)
|
||||||
|
{
|
||||||
/* version, traffic class, flow label */
|
/* version, traffic class, flow label */
|
||||||
SICSLOWPAN_IP_BUF->vtc = 0x60;
|
SICSLOWPAN_IP_BUF->vtc = 0x60;
|
||||||
SICSLOWPAN_IP_BUF->tcflow = 0;
|
SICSLOWPAN_IP_BUF->tcflow = 0;
|
||||||
|
@ -1206,7 +1211,8 @@ uncompress_hdr_hc1(u16_t ip_len) {
|
||||||
* \endverbatim
|
* \endverbatim
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
compress_hdr_ipv6(rimeaddr_t *rime_destaddr) {
|
compress_hdr_ipv6(rimeaddr_t *rime_destaddr)
|
||||||
|
{
|
||||||
*rime_ptr = SICSLOWPAN_DISPATCH_IPV6;
|
*rime_ptr = SICSLOWPAN_DISPATCH_IPV6;
|
||||||
rime_hdr_len += SICSLOWPAN_IPV6_HDR_LEN;
|
rime_hdr_len += SICSLOWPAN_IPV6_HDR_LEN;
|
||||||
memcpy(rime_ptr + rime_hdr_len, UIP_IP_BUF, UIP_IPH_LEN);
|
memcpy(rime_ptr + rime_hdr_len, UIP_IP_BUF, UIP_IPH_LEN);
|
||||||
|
@ -1329,6 +1335,9 @@ output(uip_lladdr_t *localdest)
|
||||||
* The following fragments contain only the fragn dispatch.
|
* The following fragments contain only the fragn dispatch.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
printf("Fragmentation sending packet len %d\n", uip_len);
|
||||||
|
|
||||||
/* Create 1st Fragment */
|
/* Create 1st Fragment */
|
||||||
PRINTFO("sicslowpan output: 1rst fragment ");
|
PRINTFO("sicslowpan output: 1rst fragment ");
|
||||||
|
|
||||||
|
@ -1446,6 +1455,7 @@ input(void)
|
||||||
#if SICSLOWPAN_CONF_FRAG
|
#if SICSLOWPAN_CONF_FRAG
|
||||||
/* tag of the fragment */
|
/* tag of the fragment */
|
||||||
u16_t frag_tag = 0;
|
u16_t frag_tag = 0;
|
||||||
|
uint8_t first_fragment = 0;
|
||||||
#endif /*SICSLOWPAN_CONF_FRAG*/
|
#endif /*SICSLOWPAN_CONF_FRAG*/
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
|
@ -1477,6 +1487,7 @@ input(void)
|
||||||
frag_size, frag_tag, frag_offset);
|
frag_size, frag_tag, frag_offset);
|
||||||
rime_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
|
rime_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
|
||||||
/* printf("frag1 %d %d\n", reass_tag, frag_tag);*/
|
/* printf("frag1 %d %d\n", reass_tag, frag_tag);*/
|
||||||
|
first_fragment = 1;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_DISPATCH_FRAGN:
|
case SICSLOWPAN_DISPATCH_FRAGN:
|
||||||
/*
|
/*
|
||||||
|
@ -1585,7 +1596,8 @@ input(void)
|
||||||
|
|
||||||
#if SICSLOWPAN_CONF_FRAG
|
#if SICSLOWPAN_CONF_FRAG
|
||||||
if(frag_size > 0) {
|
if(frag_size > 0) {
|
||||||
if(processed_ip_len == 0) {
|
/* Add the size of the header only for the first fragment. */
|
||||||
|
if(first_fragment != 0) {
|
||||||
processed_ip_len += uncomp_hdr_len;
|
processed_ip_len += uncomp_hdr_len;
|
||||||
}
|
}
|
||||||
processed_ip_len += rime_payload_len;
|
processed_ip_len += rime_payload_len;
|
||||||
|
|
Loading…
Reference in a new issue