Example #1
0
uint8_t rpl_init(int if_id)
{
    rpl_instances_init();

    /* initialize routing table */
    rpl_clear_routing_table();
    init_trickle();
    rpl_process_pid = thread_create(rpl_process_buf, RPL_PROCESS_STACKSIZE,
                                    PRIORITY_MAIN - 1, CREATE_STACKTEST,
                                    rpl_process, NULL, "rpl_process");

    /* INSERT NEW OBJECTIVE FUNCTIONS HERE */
    rpl_objective_functions[0] = rpl_get_of0();
    rpl_objective_functions[1] = rpl_get_of_mrhof();

    sixlowpan_lowpan_init_interface(if_id);
    /* need link local prefix to query _our_ corresponding address  */
    ipv6_addr_t my_address;
    ipv6_addr_t ll_address;
    ipv6_addr_set_link_local_prefix(&ll_address);
    ipv6_net_if_get_best_src_addr(&my_address, &ll_address);
    ipv6_register_rpl_handler(rpl_process_pid);

    /* initialize ETX-calculation if needed */
    if (RPL_DEFAULT_OCP == 1) {
        DEBUGF("INIT ETX BEACONING\n");
        etx_init_beaconing(&my_address);
    }

    rpl_init_mode(&my_address);

    return SIXLOWERROR_SUCCESS;
}
Example #2
0
uint8_t rpl_init(int if_id)
{
    rpl_instances_init();

    /* initialize routing table */
    rpl_clear_routing_table();

    if (RPL_DEFAULT_MOP == RPL_STORING_MODE_NO_MC) {
        rpl_max_routing_entries = RPL_MAX_ROUTING_ENTRIES_STORING;
        rpl_clear_routing_table();
    }
    else {
        rpl_max_routing_entries = RPL_MAX_ROUTING_ENTRIES_NON_STORING;
        rpl_clear_routing_table();
    }

    if (rpl_routing_table == NULL) {
        DEBUGF("Routing table init failed!\n");
        return SIXLOWERROR_NULLPTR;
    }
    else {
        DEBUGF("Routing table init finished!\n");
    }

    init_trickle();
    rpl_process_pid = thread_create(rpl_process_buf, RPL_PROCESS_STACKSIZE,
                                    PRIORITY_MAIN - 1, CREATE_STACKTEST,
                                    rpl_process, NULL, "rpl_process");

    sixlowpan_lowpan_init_interface(if_id);
    /* need link local prefix to query _our_ corresponding address  */
    ipv6_addr_t ll_address;
    ipv6_addr_set_link_local_prefix(&ll_address);
    ipv6_net_if_get_best_src_addr(&my_address, &ll_address);
    ipv6_register_rpl_handler(rpl_process_pid);
    ipv6_iface_set_srh_indicator(rpl_is_root);
    ipv6_iface_set_routing_provider(rpl_get_next_hop);
    DEBUGF("All addresses set!\n");

    /* initialize objective function manager */
    rpl_of_manager_init(&my_address);
    rpl_init_mode(&my_address);
    return SIXLOWERROR_SUCCESS;
}