void recv_rpl_dao(void) { rpl_dodag_t *my_dodag = rpl_get_my_dodag(); if(my_dodag == NULL) { printf("[Error] got DAO without beeing part of a Dodag\n"); return; } ipv6_buf = get_rpl_ipv6_buf(); rpl_dao_buf = get_rpl_dao_buf(); int len = DAO_BASE_LEN; uint8_t increment_seq = 0; while(len < (ipv6_buf->length - ICMPV6_HDR_LEN)) { rpl_opt_buf = get_rpl_opt_buf(len); switch(rpl_opt_buf->type) { case(RPL_OPT_PAD1): { len += 1; break; } case(RPL_OPT_PADN): { len += rpl_opt_buf->length + 2; break; } case(RPL_OPT_DAG_METRIC_CONTAINER): { len += rpl_opt_buf->length + 2; break; } case(RPL_OPT_TARGET): { rpl_opt_target_buf = get_rpl_opt_target_buf(len); if(rpl_opt_target_buf->prefix_length != RPL_DODAG_ID_LEN) { printf("prefixes are not supported yet"); break; } len += rpl_opt_target_buf->length + 2; rpl_opt_transit_buf = get_rpl_opt_transit_buf(len); if(rpl_opt_transit_buf->type != RPL_OPT_TRANSIT) { printf("[Error] - no Transit Inforamtion to Target Option, type = %d\n", rpl_opt_transit_buf->type); break; } len += rpl_opt_transit_buf->length + 2; /* Die eigentliche Lebenszeit einer Route errechnet sich aus (Lifetime aus DAO) * (Lifetime Unit) Sekunden */ rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr, rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit); /* puts("Updated route \n"); */ increment_seq = 1; break; } case(RPL_OPT_TRANSIT): { len += rpl_opt_buf->length + 2; break; } case(RPL_OPT_TARGET_DESC): { len += rpl_opt_buf->length + 2; break; } default: return; } } send_DAO_ACK(&ipv6_buf->srcaddr); if(increment_seq) { RPL_COUNTER_INCREMENT(my_dodag->dao_seq); delay_dao(); } }
void recv_rpl_dao(void) { rpl_dodag_t *my_dodag = rpl_get_my_dodag(); if (my_dodag == NULL) { DEBUG("[Error] got DAO although not a DODAG\n"); return; } ipv6_buf = get_rpl_ipv6_buf(); rpl_dao_buf = get_rpl_dao_buf(); int len = DAO_BASE_LEN; uint8_t increment_seq = 0; while (len < (ipv6_buf->length - ICMPV6_HDR_LEN)) { rpl_opt_buf = get_rpl_opt_buf(len); switch (rpl_opt_buf->type) { case (RPL_OPT_PAD1): { len += 1; break; } case (RPL_OPT_PADN): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_DAG_METRIC_CONTAINER): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_TARGET): { rpl_opt_target_buf = get_rpl_opt_target_buf(len); if (rpl_opt_target_buf->prefix_length != RPL_DODAG_ID_LEN) { DEBUG("prefixes are not supported yet"); break; } len += rpl_opt_target_buf->length + 2; rpl_opt_transit_buf = get_rpl_opt_transit_buf(len); if (rpl_opt_transit_buf->type != RPL_OPT_TRANSIT) { DEBUG("[Error] - no transit information for target option type = %d\n", rpl_opt_transit_buf->type); break; } len += rpl_opt_transit_buf->length + 2; /* route lifetime seconds = (DAO lifetime) * (Unit Lifetime) */ rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr, rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit); increment_seq = 1; break; } case (RPL_OPT_TRANSIT): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_TARGET_DESC): { len += rpl_opt_buf->length + 2; break; } default: return; } } send_DAO_ACK(&ipv6_buf->srcaddr); if (increment_seq) { RPL_COUNTER_INCREMENT(my_dodag->dao_seq); delay_dao(); } }
void recv_rpl_dao(void) { DEBUG("%s, %d: Received DAO with ", __FILE__, __LINE__); rpl_dodag_t *my_dodag = rpl_get_my_dodag(); if (my_dodag == NULL) { DEBUG("%s, %d: [Error] got DAO although not a DODAG\n", __FILE__, __LINE__); return; } ipv6_buf = get_rpl_ipv6_buf(); rpl_dao_buf = get_rpl_dao_buf(); DEBUG("instance %04X ", rpl_dao_buf->rpl_instanceid); DEBUG("sequence %04X\n", rpl_dao_buf->dao_sequence); int len = DAO_BASE_LEN; uint8_t increment_seq = 0; while (len < (NTOHS(ipv6_buf->length) - ICMPV6_HDR_LEN)) { rpl_opt_buf = get_rpl_opt_buf(len); switch (rpl_opt_buf->type) { case (RPL_OPT_PAD1): { len += 1; break; } case (RPL_OPT_PADN): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_DAG_METRIC_CONTAINER): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_TARGET): { rpl_opt_target_buf = get_rpl_opt_target_buf(len); if (rpl_opt_target_buf->prefix_length != RPL_DODAG_ID_LEN) { DEBUG("%s, %d: prefixes are not supported yet", __FILE__, __LINE__); break; } len += rpl_opt_target_buf->length + 2; rpl_opt_transit_buf = get_rpl_opt_transit_buf(len); if (rpl_opt_transit_buf->type != RPL_OPT_TRANSIT) { DEBUG("%s, %d: [Error] - no transit information for target option type = %d\n", __FILE__, __LINE__, rpl_opt_transit_buf->type); break; } len += rpl_opt_transit_buf->length + 2; /* route lifetime seconds = (DAO lifetime) * (Unit Lifetime) */ DEBUG("%s, %d: Adding routing information: Target: %s, Source: %s, Lifetime: %u\n", __FILE__, __LINE__, ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, &ipv6_buf->srcaddr), ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, &ipv6_buf->srcaddr), (rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit)); rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr, rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit); increment_seq = 1; break; } case (RPL_OPT_TRANSIT): { len += rpl_opt_buf->length + 2; break; } case (RPL_OPT_TARGET_DESC): { len += rpl_opt_buf->length + 2; break; } default: return; } } send_DAO_ACK(&ipv6_buf->srcaddr); if (increment_seq) { RPL_COUNTER_INCREMENT(my_dodag->dao_seq); delay_dao(); } }