Merge branch 'develop' into fix-native-clock

This commit is contained in:
George Oikonomou 2017-12-12 21:46:33 +00:00 committed by GitHub
commit bd5d6470d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 33 deletions

View File

@ -238,12 +238,8 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) {
return;
}
} else {
#if UIP_CONF_ROUTER
/* need to pick a source that corresponds to this node */
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &tmp_ipaddr);
#else
uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &tmp_ipaddr);
#endif
}
UIP_ICMP_BUF->type = type;

View File

@ -523,14 +523,16 @@ rpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, unsigned len)
dag->prefix_info.length = len;
dag->prefix_info.flags = UIP_ND6_RA_FLAG_AUTONOMOUS;
PRINTF("RPL: Prefix set - will announce this in DIOs\n");
/* Autoconfigure an address if this node does not already have an address
with this prefix. Otherwise, update the prefix */
if(last_len == 0) {
PRINTF("rpl_set_prefix - prefix NULL\n");
check_prefix(NULL, &dag->prefix_info);
} else {
PRINTF("rpl_set_prefix - prefix NON-NULL\n");
check_prefix(&last_prefix, &dag->prefix_info);
if(dag->rank != ROOT_RANK(dag->instance)) {
/* Autoconfigure an address if this node does not already have an address
with this prefix. Otherwise, update the prefix */
if(last_len == 0) {
PRINTF("rpl_set_prefix - prefix NULL\n");
check_prefix(NULL, &dag->prefix_info);
} else {
PRINTF("rpl_set_prefix - prefix NON-NULL\n");
check_prefix(&last_prefix, &dag->prefix_info);
}
}
return 1;
}

View File

@ -592,9 +592,11 @@ rpl_ext_header_remove(void)
{
uint8_t temp_len;
uint8_t rpl_ext_hdr_len;
int uip_ext_opt_offset;
uint8_t *uip_next_hdr;
uip_ext_len = 0;
uip_ext_opt_offset = 2;
uip_next_hdr = &UIP_IP_BUF->proto;
/* Look for hop-by-hop and routing headers */
@ -602,17 +604,22 @@ rpl_ext_header_remove(void)
switch(*uip_next_hdr) {
case UIP_PROTO_HBHO:
case UIP_PROTO_ROUTING:
/* Remove hop-by-hop and routing headers */
*uip_next_hdr = UIP_EXT_BUF->next;
rpl_ext_hdr_len = (UIP_EXT_BUF->len * 8) + 8;
temp_len = UIP_IP_BUF->len[1];
uip_len -= rpl_ext_hdr_len;
UIP_IP_BUF->len[1] -= rpl_ext_hdr_len;
if(UIP_IP_BUF->len[1] > temp_len) {
UIP_IP_BUF->len[0]--;
if((*uip_next_hdr != UIP_PROTO_HBHO || UIP_EXT_HDR_OPT_RPL_BUF->opt_type == UIP_EXT_HDR_OPT_RPL)) {
/* Remove hop-by-hop and routing headers */
*uip_next_hdr = UIP_EXT_BUF->next;
rpl_ext_hdr_len = (UIP_EXT_BUF->len * 8) + 8;
temp_len = UIP_IP_BUF->len[1];
uip_len -= rpl_ext_hdr_len;
UIP_IP_BUF->len[1] -= rpl_ext_hdr_len;
if(UIP_IP_BUF->len[1] > temp_len) {
UIP_IP_BUF->len[0]--;
}
PRINTF("RPL: Removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
} else {
uip_next_hdr = &UIP_EXT_BUF->next;
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
}
PRINTF("RPL: Removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
break;
case UIP_PROTO_DESTO:
/*
@ -626,6 +633,7 @@ rpl_ext_header_remove(void)
/* Move to next header */
uip_next_hdr = &UIP_EXT_BUF->next;
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
break;
default:
return;
}

View File

@ -56,6 +56,7 @@
typedef struct rpl_ns_node {
struct rpl_ns_node *next;
uint32_t lifetime;
rpl_dag_t *dag;
/* Store only IPv6 link identifiers as all nodes in the DAG share the same prefix */
unsigned char link_identifier[8];
struct rpl_ns_node *parent;

View File

@ -457,11 +457,29 @@ get_probing_target(rpl_dag_t *dag)
return probing_target;
}
/*---------------------------------------------------------------------------*/
static rpl_dag_t *
get_next_dag(rpl_instance_t *instance)
{
rpl_dag_t *dag = NULL;
int new_dag = instance->last_dag;
do {
new_dag++;
if(new_dag >= RPL_MAX_DAG_PER_INSTANCE) {
new_dag = 0;
}
if(instance->dag_table[new_dag].used) {
dag = &instance->dag_table[new_dag];
}
} while(new_dag != instance->last_dag && dag == NULL);
instance->last_dag = new_dag;
return dag;
}
/*---------------------------------------------------------------------------*/
static void
handle_probing_timer(void *ptr)
{
rpl_instance_t *instance = (rpl_instance_t *)ptr;
rpl_parent_t *probing_target = RPL_PROBING_SELECT_FUNC(instance->current_dag);
rpl_parent_t *probing_target = RPL_PROBING_SELECT_FUNC(get_next_dag(instance));
uip_ipaddr_t *target_ipaddr = rpl_parent_get_ipaddr(probing_target);
/* Perform probing */

View File

@ -252,6 +252,7 @@ struct rpl_instance {
#if RPL_WITH_PROBING
struct ctimer probing_timer;
rpl_parent_t *urgent_probing_target;
int last_dag;
#endif /* RPL_WITH_PROBING */
struct ctimer dio_timer;
struct ctimer dao_timer;

View File

@ -531,9 +531,11 @@ rpl_ext_header_remove(void)
{
uint8_t temp_len;
uint8_t rpl_ext_hdr_len;
int uip_ext_opt_offset;
uint8_t *uip_next_hdr;
uip_ext_len = 0;
uip_ext_opt_offset = 2;
uip_next_hdr = &UIP_IP_BUF->proto;
/* Look for hop-by-hop and routing headers */
@ -541,17 +543,22 @@ rpl_ext_header_remove(void)
switch(*uip_next_hdr) {
case UIP_PROTO_HBHO:
case UIP_PROTO_ROUTING:
/* Remove hop-by-hop and routing headers */
*uip_next_hdr = UIP_EXT_BUF->next;
rpl_ext_hdr_len = (UIP_EXT_BUF->len * 8) + 8;
temp_len = UIP_IP_BUF->len[1];
uip_len -= rpl_ext_hdr_len;
UIP_IP_BUF->len[1] -= rpl_ext_hdr_len;
if(UIP_IP_BUF->len[1] > temp_len) {
UIP_IP_BUF->len[0]--;
if((*uip_next_hdr != UIP_PROTO_HBHO || UIP_EXT_HDR_OPT_RPL_BUF->opt_type == UIP_EXT_HDR_OPT_RPL)) {
/* Remove hop-by-hop and routing headers */
*uip_next_hdr = UIP_EXT_BUF->next;
rpl_ext_hdr_len = (UIP_EXT_BUF->len * 8) + 8;
temp_len = UIP_IP_BUF->len[1];
uip_len -= rpl_ext_hdr_len;
UIP_IP_BUF->len[1] -= rpl_ext_hdr_len;
if(UIP_IP_BUF->len[1] > temp_len) {
UIP_IP_BUF->len[0]--;
}
LOG_INFO("removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
} else {
uip_next_hdr = &UIP_EXT_BUF->next;
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
}
LOG_INFO("removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
break;
case UIP_PROTO_DESTO:
/*
@ -565,6 +572,7 @@ rpl_ext_header_remove(void)
/* Move to next header */
uip_next_hdr = &UIP_EXT_BUF->next;
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
break;
default:
return;
}