Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
3fa14d3cd5
2 changed files with 31 additions and 28 deletions
|
@ -169,6 +169,8 @@ dio_input(void)
|
||||||
uip_ipaddr_t from;
|
uip_ipaddr_t from;
|
||||||
uip_ds6_nbr_t *nbr;
|
uip_ds6_nbr_t *nbr;
|
||||||
|
|
||||||
|
memset(&dio, 0, sizeof(dio));
|
||||||
|
|
||||||
dio.dag_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
|
dio.dag_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
|
||||||
dio.dag_intmin = DEFAULT_DIO_INTERVAL_MIN;
|
dio.dag_intmin = DEFAULT_DIO_INTERVAL_MIN;
|
||||||
dio.dag_redund = DEFAULT_DIO_REDUNDANCY;
|
dio.dag_redund = DEFAULT_DIO_REDUNDANCY;
|
||||||
|
@ -227,7 +229,7 @@ dio_input(void)
|
||||||
/* Check if there are any DIO suboptions. */
|
/* Check if there are any DIO suboptions. */
|
||||||
for(; i < buffer_length; i += len) {
|
for(; i < buffer_length; i += len) {
|
||||||
subopt_type = buffer[i];
|
subopt_type = buffer[i];
|
||||||
if(subopt_type == RPL_DIO_SUBOPT_PAD1) {
|
if(subopt_type == RPL_OPTION_PAD1) {
|
||||||
len = 1;
|
len = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Suboption with a two-byte header + payload */
|
/* Suboption with a two-byte header + payload */
|
||||||
|
@ -240,10 +242,10 @@ dio_input(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("RPL: DIO suboption %u, length: %u\n", subopt_type, len - 2);
|
PRINTF("RPL: DIO option %u, length: %u\n", subopt_type, len - 2);
|
||||||
|
|
||||||
switch(subopt_type) {
|
switch(subopt_type) {
|
||||||
case RPL_DIO_SUBOPT_DAG_METRIC_CONTAINER:
|
case RPL_OPTION_DAG_METRIC_CONTAINER:
|
||||||
if(len < 6) {
|
if(len < 6) {
|
||||||
PRINTF("RPL: Invalid DAG MC, len = %d\n", len);
|
PRINTF("RPL: Invalid DAG MC, len = %d\n", len);
|
||||||
RPL_STAT(rpl_stats.malformed_msgs++);
|
RPL_STAT(rpl_stats.malformed_msgs++);
|
||||||
|
@ -276,7 +278,7 @@ dio_input(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RPL_DIO_SUBOPT_ROUTE_INFO:
|
case RPL_OPTION_ROUTE_INFO:
|
||||||
if(len < 9) {
|
if(len < 9) {
|
||||||
PRINTF("RPL: Invalid destination prefix option, len = %d\n", len);
|
PRINTF("RPL: Invalid destination prefix option, len = %d\n", len);
|
||||||
RPL_STAT(rpl_stats.malformed_msgs++);
|
RPL_STAT(rpl_stats.malformed_msgs++);
|
||||||
|
@ -300,7 +302,7 @@ dio_input(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RPL_DIO_SUBOPT_DAG_CONF:
|
case RPL_OPTION_DAG_CONF:
|
||||||
if(len != 16) {
|
if(len != 16) {
|
||||||
PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len);
|
PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len);
|
||||||
RPL_STAT(rpl_stats.malformed_msgs++);
|
RPL_STAT(rpl_stats.malformed_msgs++);
|
||||||
|
@ -322,7 +324,7 @@ dio_input(void)
|
||||||
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
|
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
|
||||||
dio.default_lifetime, dio.lifetime_unit);
|
dio.default_lifetime, dio.lifetime_unit);
|
||||||
break;
|
break;
|
||||||
case RPL_DIO_SUBOPT_PREFIX_INFO:
|
case RPL_OPTION_PREFIX_INFO:
|
||||||
if(len != 32) {
|
if(len != 32) {
|
||||||
PRINTF("RPL: DAG Prefix info not ok, len != 32\n");
|
PRINTF("RPL: DAG Prefix info not ok, len != 32\n");
|
||||||
RPL_STAT(rpl_stats.malformed_msgs++);
|
RPL_STAT(rpl_stats.malformed_msgs++);
|
||||||
|
@ -382,7 +384,7 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
|
||||||
if(dag->mc.type != RPL_DAG_MC_NONE) {
|
if(dag->mc.type != RPL_DAG_MC_NONE) {
|
||||||
dag->of->update_metric_container(dag);
|
dag->of->update_metric_container(dag);
|
||||||
|
|
||||||
buffer[pos++] = RPL_DIO_SUBOPT_DAG_METRIC_CONTAINER;
|
buffer[pos++] = RPL_OPTION_DAG_METRIC_CONTAINER;
|
||||||
buffer[pos++] = 6;
|
buffer[pos++] = 6;
|
||||||
buffer[pos++] = dag->mc.type;
|
buffer[pos++] = dag->mc.type;
|
||||||
buffer[pos++] = dag->mc.flags >> 1;
|
buffer[pos++] = dag->mc.flags >> 1;
|
||||||
|
@ -405,7 +407,7 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always add a sub-option for DAG configuration. */
|
/* Always add a sub-option for DAG configuration. */
|
||||||
buffer[pos++] = RPL_DIO_SUBOPT_DAG_CONF;
|
buffer[pos++] = RPL_OPTION_DAG_CONF;
|
||||||
buffer[pos++] = 14;
|
buffer[pos++] = 14;
|
||||||
buffer[pos++] = 0; /* No Auth, PCS = 0 */
|
buffer[pos++] = 0; /* No Auth, PCS = 0 */
|
||||||
buffer[pos++] = dag->dio_intdoubl;
|
buffer[pos++] = dag->dio_intdoubl;
|
||||||
|
@ -425,7 +427,7 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
|
||||||
|
|
||||||
/* Check if we have a prefix to send also. */
|
/* Check if we have a prefix to send also. */
|
||||||
if(dag->prefix_info.length > 0) {
|
if(dag->prefix_info.length > 0) {
|
||||||
buffer[pos++] = RPL_DIO_SUBOPT_PREFIX_INFO;
|
buffer[pos++] = RPL_OPTION_PREFIX_INFO;
|
||||||
buffer[pos++] = 30; /* always 30 bytes + 2 long */
|
buffer[pos++] = 30; /* always 30 bytes + 2 long */
|
||||||
buffer[pos++] = dag->prefix_info.length;
|
buffer[pos++] = dag->prefix_info.length;
|
||||||
buffer[pos++] = dag->prefix_info.flags;
|
buffer[pos++] = dag->prefix_info.flags;
|
||||||
|
@ -522,25 +524,25 @@ dao_input(void)
|
||||||
pos += 16;
|
pos += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if there are any DIO sub-options. */
|
/* Check if there are any RPL options present. */
|
||||||
i = pos;
|
i = pos;
|
||||||
for(; i < buffer_length; i += len) {
|
for(; i < buffer_length; i += len) {
|
||||||
subopt_type = buffer[i];
|
subopt_type = buffer[i];
|
||||||
if(subopt_type == RPL_DIO_SUBOPT_PAD1) {
|
if(subopt_type == RPL_OPTION_PAD1) {
|
||||||
len = 1;
|
len = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Sub-option with a two-byte header and payload */
|
/* The option consists of a two-byte header and a payload. */
|
||||||
len = 2 + buffer[i + 1];
|
len = 2 + buffer[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(subopt_type) {
|
switch(subopt_type) {
|
||||||
case RPL_DIO_SUBOPT_TARGET:
|
case RPL_OPTION_TARGET:
|
||||||
/* handle the target option */
|
/* handle the target option */
|
||||||
prefixlen = buffer[i + 3];
|
prefixlen = buffer[i + 3];
|
||||||
memset(&prefix, 0, sizeof(prefix));
|
memset(&prefix, 0, sizeof(prefix));
|
||||||
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
|
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
|
||||||
break;
|
break;
|
||||||
case RPL_DIO_SUBOPT_TRANSIT:
|
case RPL_OPTION_TRANSIT:
|
||||||
/* The path sequence and control are ignored. */
|
/* The path sequence and control are ignored. */
|
||||||
pathcontrol = buffer[i + 3];
|
pathcontrol = buffer[i + 3];
|
||||||
pathsequence = buffer[i + 4];
|
pathsequence = buffer[i + 4];
|
||||||
|
@ -651,7 +653,7 @@ dao_output(rpl_parent_t *n, rpl_lifetime_t lifetime)
|
||||||
|
|
||||||
/* create target subopt */
|
/* create target subopt */
|
||||||
prefixlen = sizeof(prefix) * CHAR_BIT;
|
prefixlen = sizeof(prefix) * CHAR_BIT;
|
||||||
buffer[pos++] = RPL_DIO_SUBOPT_TARGET;
|
buffer[pos++] = RPL_OPTION_TARGET;
|
||||||
buffer[pos++] = 2 + ((prefixlen + 7) / CHAR_BIT);
|
buffer[pos++] = 2 + ((prefixlen + 7) / CHAR_BIT);
|
||||||
buffer[pos++] = 0; /* reserved */
|
buffer[pos++] = 0; /* reserved */
|
||||||
buffer[pos++] = prefixlen;
|
buffer[pos++] = prefixlen;
|
||||||
|
@ -659,7 +661,7 @@ dao_output(rpl_parent_t *n, rpl_lifetime_t lifetime)
|
||||||
pos += ((prefixlen + 7) / CHAR_BIT);
|
pos += ((prefixlen + 7) / CHAR_BIT);
|
||||||
|
|
||||||
/* Create a transit information sub-option. */
|
/* Create a transit information sub-option. */
|
||||||
buffer[pos++] = RPL_DIO_SUBOPT_TRANSIT;
|
buffer[pos++] = RPL_OPTION_TRANSIT;
|
||||||
buffer[pos++] = 4;
|
buffer[pos++] = 4;
|
||||||
buffer[pos++] = 0; /* flags - ignored */
|
buffer[pos++] = 0; /* flags - ignored */
|
||||||
buffer[pos++] = 0; /* path control - ignored */
|
buffer[pos++] = 0; /* path control - ignored */
|
||||||
|
|
|
@ -79,19 +79,20 @@
|
||||||
#define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
|
#define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
|
||||||
#define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
|
#define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
|
||||||
|
|
||||||
/* RPL DIO/DAO suboption types */
|
/* RPL control message options. */
|
||||||
#define RPL_DIO_SUBOPT_PAD1 0
|
#define RPL_OPTION_PAD1 0
|
||||||
#define RPL_DIO_SUBOPT_PADN 1
|
#define RPL_OPTION_PADN 1
|
||||||
#define RPL_DIO_SUBOPT_DAG_METRIC_CONTAINER 2
|
#define RPL_OPTION_DAG_METRIC_CONTAINER 2
|
||||||
#define RPL_DIO_SUBOPT_ROUTE_INFO 3
|
#define RPL_OPTION_ROUTE_INFO 3
|
||||||
#define RPL_DIO_SUBOPT_DAG_CONF 4
|
#define RPL_OPTION_DAG_CONF 4
|
||||||
#define RPL_DIO_SUBOPT_TARGET 5
|
#define RPL_OPTION_TARGET 5
|
||||||
#define RPL_DIO_SUBOPT_TRANSIT 6
|
#define RPL_OPTION_TRANSIT 6
|
||||||
#define RPL_DIO_SUBOPT_SOLICITED_INFO 7
|
#define RPL_OPTION_SOLICITED_INFO 7
|
||||||
#define RPL_DIO_SUBOPT_PREFIX_INFO 8
|
#define RPL_OPTION_PREFIX_INFO 8
|
||||||
|
#define RPL_OPTION_TARGET_DESC 9
|
||||||
|
|
||||||
#define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
|
#define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
|
||||||
#define RPL_DAO_D_FLAG 0x40 /* DODAG ID Present */
|
#define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Default values for RPL constants and variables. */
|
/* Default values for RPL constants and variables. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue