void trickle_reset_timer(trickle_t *trickle) { vtimer_remove(&trickle->msg_interval_timer); vtimer_remove(&trickle->msg_callback_timer); trickle_start(trickle->pid, trickle, trickle->interval_msg_type, trickle->callback_msg_type, trickle->Imin, trickle->Imax, trickle->k); }
gnrc_rpl_dodag_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id) { gnrc_rpl_dodag_t *dodag = _root_dodag_init(instance_id, dodag_id, GNRC_RPL_DEFAULT_MOP); if (!dodag) { return NULL; } dodag->dtsn = 1; dodag->prf = 0; dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS; dodag->dio_min = GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN; dodag->dio_redun = GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT; dodag->default_lifetime = GNRC_RPL_DEFAULT_LIFETIME; dodag->lifetime_unit = GNRC_RPL_LIFETIME_UNIT; dodag->version = GNRC_RPL_COUNTER_INIT; dodag->grounded = GNRC_RPL_GROUNDED; dodag->node_status = GNRC_RPL_ROOT_NODE; dodag->my_rank = GNRC_RPL_ROOT_RANK; trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->dio_redun); return dodag; }
gnrc_rpl_instance_t *gnrc_rpl_p2p_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id, ipv6_addr_t *target, bool gen_inst_id) { if (gen_inst_id) { instance_id = gnrc_rpl_gen_instance_id(true); } gnrc_rpl_dodag_t *dodag = NULL; gnrc_rpl_instance_t *instance = gnrc_rpl_root_instance_init(instance_id, dodag_id, GNRC_RPL_P2P_MOP); if (!instance) { return NULL; } dodag = &instance->dodag; instance->max_rank_inc = 0; dodag->dtsn = 0; dodag->prf = 0; dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS; dodag->dio_min = GNRC_RPL_P2P_DEFAULT_DIO_INTERVAL_MIN; dodag->dio_redun = GNRC_RPL_P2P_DEFAULT_DIO_REDUNDANCY_CONSTANT; dodag->default_lifetime = GNRC_RPL_P2P_DEFAULT_LIFETIME; dodag->lifetime_unit = GNRC_RPL_P2P_LIFETIME_UNIT; dodag->version = 0; dodag->grounded = 1; dodag->node_status = GNRC_RPL_ROOT_NODE; dodag->my_rank = GNRC_RPL_ROOT_RANK; dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_DODAG_CONF; dodag->dio_opts &= ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; gnrc_rpl_p2p_ext_t *p2p_ext = gnrc_rpl_p2p_ext_get(dodag); p2p_ext->target = *target; p2p_ext->compr = GNRC_RPL_P2P_COMPR; p2p_ext->routes_numof = 0; p2p_ext->hop_by_hop = true; p2p_ext->reply = true; p2p_ext->lifetime_enc = GNRC_RPL_P2P_LIFETIME; p2p_ext->lifetime_sec = gnrc_rpl_p2p_lifetime_lookup[p2p_ext->lifetime_enc]; p2p_ext->maxrank = GNRC_RPL_P2P_MAX_RANK; p2p_ext->dro_delay = -1; trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->dio_redun); return instance; }
void rpl_init_root_mode(void) { rpl_instance_t *inst; rpl_dodag_t *dodag; inst = rpl_new_instance(RPL_DEFAULT_INSTANCE); if (inst == NULL) { DEBUGF("Error - No memory for another RPL instance\n"); return; } inst->id = RPL_DEFAULT_INSTANCE; inst->joined = 1; dodag = rpl_new_dodag(RPL_DEFAULT_INSTANCE, &my_address); if (dodag != NULL) { dodag->of = (struct rpl_of_t *) rpl_get_of_for_ocp(RPL_DEFAULT_OCP); dodag->instance = inst; dodag->mop = RPL_DEFAULT_MOP; dodag->dtsn = 1; dodag->prf = 0; dodag->dio_interval_doubling = DEFAULT_DIO_INTERVAL_DOUBLINGS; dodag->dio_min = DEFAULT_DIO_INTERVAL_MIN; dodag->dio_redundancy = DEFAULT_DIO_REDUNDANCY_CONSTANT; dodag->maxrankincrease = 0; dodag->minhoprankincrease = (uint16_t)DEFAULT_MIN_HOP_RANK_INCREASE; dodag->default_lifetime = (uint8_t)RPL_DEFAULT_LIFETIME; dodag->lifetime_unit = RPL_LIFETIME_UNIT; dodag->version = RPL_COUNTER_INIT; dodag->grounded = RPL_GROUNDED; dodag->node_status = (uint8_t) ROOT_NODE; dodag->my_rank = RPL_ROOT_RANK; dodag->joined = 1; dodag->my_preferred_parent = NULL; } else { DEBUGF("Error - could not generate DODAG\n"); return; } i_am_root = 1; trickle_start(rpl_process_pid, &dodag->trickle, RPL_MSG_TYPE_TRICKLE_INTERVAL, RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubling, dodag->dio_redundancy); DEBUGF("ROOT INIT FINISHED\n"); }
gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id, bool gen_inst_id, bool local_inst_id) { if (gen_inst_id) { instance_id = gnrc_rpl_gen_instance_id(local_inst_id); } gnrc_rpl_dodag_t *dodag = NULL; gnrc_rpl_instance_t *inst = gnrc_rpl_root_instance_init(instance_id, dodag_id, GNRC_RPL_DEFAULT_MOP); if (!inst) { return NULL; } dodag = &inst->dodag; dodag->dtsn = 1; dodag->prf = 0; dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS; dodag->dio_min = GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN; dodag->dio_redun = GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT; dodag->default_lifetime = GNRC_RPL_DEFAULT_LIFETIME; dodag->lifetime_unit = GNRC_RPL_LIFETIME_UNIT; dodag->version = GNRC_RPL_COUNTER_INIT; dodag->grounded = GNRC_RPL_GROUNDED; dodag->node_status = GNRC_RPL_ROOT_NODE; dodag->my_rank = GNRC_RPL_ROOT_RANK; dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_DODAG_CONF; #ifndef GNRC_RPL_WITHOUT_PIO dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; #endif trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->dio_redun); return inst; }
void rpl_init_root(rpl_options_t *rpl_opts) { #if (RPL_DEFAULT_MOP == RPL_MOP_NON_STORING_MODE) #ifndef RPL_NODE_IS_ROOT puts("\n############################## ERROR ###############################"); puts("This configuration has NO ROUTING TABLE available for the root node!"); puts("The root will NOT be INITIALIZED."); puts("Please build the binary for root in non-storing MOP with:"); puts("\t\t'make RPL_NODE_IS_ROOT=1'"); puts("############################## ERROR ###############################\n"); return; #endif #endif rpl_instance_t *inst; rpl_dodag_t *dodag; inst = rpl_new_instance(rpl_opts ? rpl_opts->instance_id : RPL_DEFAULT_INSTANCE); if (inst == NULL) { DEBUGF("Error - No memory for another RPL instance\n"); return; } inst->joined = 1; dodag = rpl_new_dodag(inst, &my_address); if (dodag != NULL) { dodag->of = (struct rpl_of_t *) rpl_get_of_for_ocp(RPL_DEFAULT_OCP); dodag->instance = inst; dodag->mop = RPL_DEFAULT_MOP; dodag->dtsn = 1; dodag->prf = 0; dodag->dio_interval_doubling = DEFAULT_DIO_INTERVAL_DOUBLINGS; dodag->dio_min = DEFAULT_DIO_INTERVAL_MIN; dodag->dio_redundancy = DEFAULT_DIO_REDUNDANCY_CONSTANT; dodag->maxrankincrease = 0; dodag->minhoprankincrease = (uint16_t)DEFAULT_MIN_HOP_RANK_INCREASE; dodag->default_lifetime = (uint8_t)RPL_DEFAULT_LIFETIME; dodag->lifetime_unit = RPL_LIFETIME_UNIT; dodag->version = RPL_COUNTER_INIT; dodag->grounded = RPL_GROUNDED; dodag->node_status = (uint8_t) ROOT_NODE; dodag->my_rank = RPL_ROOT_RANK; dodag->joined = 1; dodag->my_preferred_parent = NULL; if (rpl_opts) { dodag->prefix = rpl_opts->prefix; dodag->prefix_length = rpl_opts->prefix_len; dodag->prefix_flags = rpl_opts->prefix_flags; dodag->prefix_preferred_lifetime = rpl_opts->prefix_valid_lifetime ? rpl_opts->prefix_preferred_lifetime : 0xffffffff; dodag->prefix_valid_lifetime = rpl_opts->prefix_valid_lifetime ? rpl_opts->prefix_valid_lifetime : 0xffffffff; } } else { DEBUGF("Error - could not generate DODAG\n"); return; } i_am_root = 1; trickle_start(rpl_process_pid, &dodag->trickle, RPL_MSG_TYPE_TRICKLE_INTERVAL, RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubling, dodag->dio_redundancy); DEBUGF("ROOT INIT FINISHED\n"); }
void sec_prot_timer_trickle_start(sec_prot_common_t *data, const trickle_params_t *trickle_params) { trickle_start(&data->trickle_timer, trickle_params); data->trickle_running = true; }
void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len) { gnrc_rpl_instance_t *inst = NULL; gnrc_rpl_dodag_t *dodag = NULL; if (!_gnrc_rpl_check_DIO_validity(dio, len)) { return; } len -= (sizeof(gnrc_rpl_dio_t) + sizeof(icmpv6_hdr_t)); if (gnrc_rpl_instance_add(dio->instance_id, &inst)) { /* new instance and DODAG */ if (byteorder_ntohs(dio->rank) == GNRC_RPL_INFINITE_RANK) { DEBUG("RPL: ignore INFINITE_RANK DIO when we are not yet part of this DODAG\n"); gnrc_rpl_instance_remove(inst); return; } inst->mop = (dio->g_mop_prf >> GNRC_RPL_MOP_SHIFT) & GNRC_RPL_SHIFTED_MOP_MASK; inst->of = gnrc_rpl_get_of_for_ocp(GNRC_RPL_DEFAULT_OCP); if (iface == KERNEL_PID_UNDEF) { iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes); assert(iface != KERNEL_PID_UNDEF); } gnrc_rpl_dodag_init(inst, &dio->dodag_id, iface, NULL); dodag = &inst->dodag; DEBUG("RPL: Joined DODAG (%s).\n", ipv6_addr_to_str(addr_str, &dio->dodag_id, sizeof(addr_str))); gnrc_rpl_parent_t *parent = NULL; if (!gnrc_rpl_parent_add_by_addr(dodag, src, &parent) && (parent == NULL)) { DEBUG("RPL: Could not allocate new parent.\n"); gnrc_rpl_instance_remove(inst); return; } dodag->version = dio->version_number; dodag->grounded = dio->g_mop_prf >> GNRC_RPL_GROUNDED_SHIFT; dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK; parent->rank = byteorder_ntohs(dio->rank); uint32_t included_opts = 0; if(!_parse_options(GNRC_RPL_ICMPV6_CODE_DIO, inst, (gnrc_rpl_opt_t *)(dio + 1), len, src, &included_opts)) { DEBUG("RPL: Error encountered during DIO option parsing - remove DODAG\n"); gnrc_rpl_instance_remove(inst); return; } if (!(included_opts & (((uint32_t) 1) << GNRC_RPL_OPT_DODAG_CONF))) { #ifndef GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN DEBUG("RPL: DIO without DODAG_CONF option - remove DODAG and request new DIO\n"); gnrc_rpl_instance_remove(inst); gnrc_rpl_send_DIS(NULL, src); return; #else DEBUG("RPL: DIO without DODAG_CONF option - use default trickle parameters\n"); gnrc_rpl_send_DIS(NULL, src); #endif } /* if there was no netif_addr created manually or by a PIO, then leave this DODAG */ if (!dodag->netif_addr) { ipv6_addr_t *configured_addr; if (!(configured_addr = gnrc_ipv6_netif_match_prefix(dodag->iface, &dodag->dodag_id))) { DEBUG("RPL: no IPv6 address configured to match the given dodag id: %s\n", ipv6_addr_to_str(addr_str, &(dodag->dodag_id), sizeof(addr_str))); gnrc_rpl_instance_remove(inst); return; } if (!(dodag->netif_addr = gnrc_ipv6_netif_addr_get(configured_addr))) { DEBUG("RPL: no netif address found for %s\n", ipv6_addr_to_str(addr_str, configured_addr, sizeof(addr_str))); gnrc_rpl_instance_remove(inst); return; } } gnrc_rpl_delay_dao(dodag); trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->dio_redun); gnrc_rpl_parent_update(dodag, parent); return; } else if (inst == NULL) {