Cleaned up code style, comments, and print outs. Set default DAG parameters when the DIO configuration option is missing.
This commit is contained in:
parent
6e41f6fbe9
commit
d0e2d9b47e
7 changed files with 102 additions and 107 deletions
|
@ -92,6 +92,8 @@ void RPL_DEBUG_DIO_INPUT(uip_ipaddr_t *, rpl_dio_t *);
|
|||
void RPL_DEBUG_DAO_OUTPUT(rpl_parent_t *);
|
||||
#endif
|
||||
|
||||
extern rpl_of_t RPL_OF;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
get_global_addr(uip_ipaddr_t *addr)
|
||||
|
@ -209,9 +211,15 @@ dio_input(void)
|
|||
|
||||
memset(&dio, 0, sizeof(dio));
|
||||
|
||||
dio.dag_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
|
||||
dio.dag_intmin = DEFAULT_DIO_INTERVAL_MIN;
|
||||
dio.dag_redund = DEFAULT_DIO_REDUNDANCY;
|
||||
/* Set default values in case the DIO configuration option is missing. */
|
||||
dio.dag_intdoubl = RPL_DIO_INTERVAL_DOUBLINGS;
|
||||
dio.dag_intmin = RPL_DIO_INTERVAL_MIN;
|
||||
dio.dag_redund = RPL_DIO_REDUNDANCY;
|
||||
dio.dag_min_hoprankinc = RPL_MIN_HOPRANKINC;
|
||||
dio.dag_max_rankinc = RPL_MAX_RANKINC;
|
||||
dio.ocp = RPL_OF.ocp;
|
||||
dio.default_lifetime = RPL_DEFAULT_LIFETIME;
|
||||
dio.lifetime_unit = RPL_DEFAULT_LIFETIME_UNIT;
|
||||
|
||||
uip_ipaddr_copy(&from, &UIP_IP_BUF->srcipaddr);
|
||||
|
||||
|
@ -251,8 +259,10 @@ dio_input(void)
|
|||
dio.rank = get16(buffer, i);
|
||||
i += 2;
|
||||
|
||||
PRINTF("RPL: Incoming DIO InstanceID-Version %u-%u\n", (unsigned)dio.instance_id,(unsigned)dio.version);
|
||||
PRINTF("RPL: Incoming DIO rank %u\n", (unsigned)dio.rank);
|
||||
PRINTF("RPL: Incoming DIO (id, ver, rank) = (%u,%u,%u)\n",
|
||||
(unsigned)dio.instance_id,
|
||||
(unsigned)dio.version,
|
||||
(unsigned)dio.rank);
|
||||
|
||||
dio.grounded = buffer[i] & RPL_DIO_GROUNDED;
|
||||
dio.mop = (buffer[i]& RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT;
|
||||
|
@ -265,9 +275,9 @@ dio_input(void)
|
|||
memcpy(&dio.dag_id, buffer + i, sizeof(dio.dag_id));
|
||||
i += sizeof(dio.dag_id);
|
||||
|
||||
PRINTF("RPL: Incoming DIO DODAG ");
|
||||
PRINTF("RPL: Incoming DIO (dag_id, pref) = (");
|
||||
PRINT6ADDR(&dio.dag_id);
|
||||
PRINTF(", preference: %u\n", dio.preference);
|
||||
PRINTF(", %u)\n", dio.preference);
|
||||
|
||||
/* Check if there are any DIO suboptions. */
|
||||
for(; i < buffer_length; i += len) {
|
||||
|
@ -326,7 +336,7 @@ dio_input(void)
|
|||
return;
|
||||
}
|
||||
|
||||
/* flags is both preference and flags for now */
|
||||
/* The flags field includes the preference value. */
|
||||
dio.destination_prefix.length = buffer[i + 2];
|
||||
dio.destination_prefix.flags = buffer[i + 3];
|
||||
dio.destination_prefix.lifetime = get32(buffer, i + 4);
|
||||
|
@ -337,7 +347,7 @@ dio_input(void)
|
|||
memcpy(&dio.destination_prefix.prefix, &buffer[i + 8],
|
||||
(dio.destination_prefix.length + 7) / 8);
|
||||
} else {
|
||||
PRINTF("RPL: Invalid route infoprefix option, len = %d\n", len);
|
||||
PRINTF("RPL: Invalid route info option, len = %d\n", len);
|
||||
RPL_STAT(rpl_stats.malformed_msgs++);
|
||||
return;
|
||||
}
|
||||
|
@ -360,14 +370,14 @@ dio_input(void)
|
|||
/* buffer + 12 is reserved */
|
||||
dio.default_lifetime = buffer[i + 13];
|
||||
dio.lifetime_unit = get16(buffer, i + 14);
|
||||
PRINTF("RPL: DIO Conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
|
||||
PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
|
||||
dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund,
|
||||
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
|
||||
dio.default_lifetime, dio.lifetime_unit);
|
||||
break;
|
||||
case RPL_OPTION_PREFIX_INFO:
|
||||
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++);
|
||||
return;
|
||||
}
|
||||
|
@ -398,6 +408,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
|
|||
{
|
||||
unsigned char *buffer;
|
||||
int pos;
|
||||
rpl_dag_t *dag = instance->current_dag;
|
||||
#if !RPL_LEAF_ONLY
|
||||
uip_ipaddr_t addr;
|
||||
#endif /* !RPL_LEAF_ONLY */
|
||||
|
@ -409,8 +420,6 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
|
|||
}
|
||||
#endif /* RPL_LEAF_ONLY */
|
||||
|
||||
rpl_dag_t *dag = instance->current_dag;
|
||||
|
||||
/* DAG Information Object */
|
||||
pos = 0;
|
||||
|
||||
|
@ -597,7 +606,7 @@ dao_input(void)
|
|||
/* Is the DAGID present? */
|
||||
if(flags & RPL_DAO_D_FLAG) {
|
||||
if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) {
|
||||
PRINTF("RPL: Ignoring a DAO for a DODAG different from ours\n");
|
||||
PRINTF("RPL: Ignoring a DAO for a DAG different from ours\n");
|
||||
return;
|
||||
}
|
||||
pos += 16;
|
||||
|
@ -640,7 +649,7 @@ dao_input(void)
|
|||
|
||||
rep = uip_ds6_route_lookup(&prefix);
|
||||
|
||||
if(lifetime == ZERO_LIFETIME) {
|
||||
if(lifetime == RPL_ZERO_LIFETIME) {
|
||||
/* No-Path DAO received; invoke the route purging routine. */
|
||||
if(rep != NULL && rep->state.saved_lifetime == 0 && rep->length == prefixlen) {
|
||||
PRINTF("RPL: Setting expiration timer for prefix ");
|
||||
|
@ -733,19 +742,19 @@ dao_output(rpl_parent_t *n, uint8_t lifetime)
|
|||
|
||||
buffer[pos++] = instance->instance_id;
|
||||
buffer[pos] = 0;
|
||||
#if RPL_DAO_SPECIFY_DODAG
|
||||
#if RPL_DAO_SPECIFY_DAG
|
||||
buffer[pos] |= RPL_DAO_D_FLAG;
|
||||
#endif /* RPL_DAO_SPECIFY_DODAG */
|
||||
#endif /* RPL_DAO_SPECIFY_DAG */
|
||||
#if RPL_CONF_DAO_ACK
|
||||
buffer[pos] |= RPL_DAO_K_FLAG;
|
||||
#endif /* RPL_CONF_DAO_ACK */
|
||||
++pos;
|
||||
buffer[pos++] = 0; /* reserved */
|
||||
buffer[pos++] = dao_sequence;
|
||||
#if RPL_DAO_SPECIFY_DODAG
|
||||
#if RPL_DAO_SPECIFY_DAG
|
||||
memcpy(buffer + pos, &dag->dag_id, sizeof(dag->dag_id));
|
||||
pos+=sizeof(dag->dag_id);
|
||||
#endif /* RPL_DAO_SPECIFY_DODAG */
|
||||
#endif /* RPL_DAO_SPECIFY_DAG */
|
||||
|
||||
/* create target subopt */
|
||||
prefixlen = sizeof(prefix) * CHAR_BIT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue