rpl_dag_root module simplification
This commit is contained in:
parent
3a39b51056
commit
14ccd337c9
|
@ -77,7 +77,7 @@ PROCESS_THREAD(node_process, ev, data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ PROCESS_THREAD(node_process, ev, data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ PROCESS_THREAD(node_process, ev, data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
|
|
|
@ -14,7 +14,7 @@ PROCESS_THREAD(router_node_process, ev, data)
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
/* Set us up as a RPL root node. */
|
/* Set us up as a RPL root node. */
|
||||||
rpl_dag_root_init_dag_delay();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
/* Initialize the IP64 module so we'll start translating packets */
|
/* Initialize the IP64 module so we'll start translating packets */
|
||||||
ip64_init();
|
ip64_init();
|
||||||
|
|
|
@ -236,8 +236,8 @@ setup_network(void)
|
||||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rpl_dag_root_init(&ipaddr, &ipaddr);
|
rpl_dag_root_set_prefix(&ipaddr, &ipaddr);
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
#endif /* UIP_CONF_ROUTER */
|
#endif /* UIP_CONF_ROUTER */
|
||||||
|
|
||||||
PRINTF("IPv6 addresses: ");
|
PRINTF("IPv6 addresses: ");
|
||||||
|
|
|
@ -111,7 +111,7 @@ PROCESS_THREAD(rpl_root_process, ev, data)
|
||||||
|
|
||||||
PRINTF("Multicast Engine: '%s'\n", UIP_MCAST6.name);
|
PRINTF("Multicast Engine: '%s'\n", UIP_MCAST6.name);
|
||||||
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
prepare_mcast();
|
prepare_mcast();
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ PROCESS_THREAD(start_app, ev, data)
|
||||||
|
|
||||||
/* Start net stack */
|
/* Start net stack */
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
printf("Starting RPL node\n");
|
printf("Starting RPL node\n");
|
||||||
|
|
|
@ -349,7 +349,7 @@ PROCESS_THREAD(start_app, ev, data)
|
||||||
|
|
||||||
/* Start net stack */
|
/* Start net stack */
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
printf("Starting RPL node\n");
|
printf("Starting RPL node\n");
|
||||||
|
|
|
@ -350,7 +350,7 @@ PROCESS_THREAD(start_app, ev, data)
|
||||||
|
|
||||||
/* Start net stack */
|
/* Start net stack */
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
printf("Starting RPL node\n");
|
printf("Starting RPL node\n");
|
||||||
|
|
|
@ -96,7 +96,7 @@ PROCESS_THREAD(node_process, ev, data)
|
||||||
|
|
||||||
is_coordinator = node_role > role_6ln;
|
is_coordinator = node_role > role_6ln;
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ PROCESS_THREAD(node_process, ev, data)
|
||||||
is_coordinator = node_role > role_6ln;
|
is_coordinator = node_role > role_6ln;
|
||||||
|
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ PROCESS_THREAD(start_app, ev, data)
|
||||||
|
|
||||||
/* Start network stack */
|
/* Start network stack */
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
printf("Starting RPL node\n");
|
printf("Starting RPL node\n");
|
||||||
|
|
|
@ -156,8 +156,8 @@ PROCESS_THREAD(border_router_process, ev, data)
|
||||||
uip_debug_ipaddr_print(&prefix);
|
uip_debug_ipaddr_print(&prefix);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
|
|
||||||
rpl_dag_root_init(&prefix, NULL);
|
rpl_dag_root_set_prefix(&prefix, NULL);
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
coap_engine_init();
|
coap_engine_init();
|
||||||
coap_activate_resource(&resource_get_rssi, "Get-RSSI");
|
coap_activate_resource(&resource_get_rssi, "Get-RSSI");
|
||||||
|
|
|
@ -145,7 +145,7 @@ PROCESS_THREAD(start_app, ev, data)
|
||||||
|
|
||||||
/* Start network stack */
|
/* Start network stack */
|
||||||
if(is_coordinator) {
|
if(is_coordinator) {
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
NETSTACK_MAC.on();
|
NETSTACK_MAC.on();
|
||||||
printf("Starting RPL node\n");
|
printf("Starting RPL node\n");
|
||||||
|
|
|
@ -307,7 +307,7 @@ PROCESS_THREAD(router_node_process, ev, data)
|
||||||
leds_off(LEDS_DHCP);
|
leds_off(LEDS_DHCP);
|
||||||
|
|
||||||
/* Set us up as a RPL root node. */
|
/* Set us up as a RPL root node. */
|
||||||
rpl_dag_root_init_dag_delay();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
/* ... and do nothing more. */
|
/* ... and do nothing more. */
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ PROCESS_THREAD(udp_server_process, ev, data)
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
/* Initialize DAG root */
|
/* Initialize DAG root */
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
/* Initialize UDP connection */
|
/* Initialize UDP connection */
|
||||||
simple_udp_register(&udp_conn, UDP_SERVER_PORT, NULL,
|
simple_udp_register(&udp_conn, UDP_SERVER_PORT, NULL,
|
||||||
|
|
|
@ -41,105 +41,6 @@
|
||||||
#define DEBUG DEBUG_NONE
|
#define DEBUG DEBUG_NONE
|
||||||
#include "net/ipv6/uip-debug.h"
|
#include "net/ipv6/uip-debug.h"
|
||||||
|
|
||||||
#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1)
|
|
||||||
|
|
||||||
#if (UIP_MAX_ROUTES != 0)
|
|
||||||
static struct uip_ds6_notification n;
|
|
||||||
#endif /* (UIP_MAX_ROUTES != 0) */
|
|
||||||
static uint8_t to_become_root;
|
|
||||||
static struct ctimer c;
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static const uip_ipaddr_t *
|
|
||||||
dag_root(void)
|
|
||||||
{
|
|
||||||
rpl_dag_t *dag;
|
|
||||||
|
|
||||||
dag = rpl_get_any_dag();
|
|
||||||
if(dag != NULL) {
|
|
||||||
return &dag->dag_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static const uip_ipaddr_t *
|
|
||||||
get_global_address(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
uint8_t state;
|
|
||||||
uip_ipaddr_t *ipaddr = NULL;
|
|
||||||
|
|
||||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
|
||||||
state = uip_ds6_if.addr_list[i].state;
|
|
||||||
if(uip_ds6_if.addr_list[i].isused &&
|
|
||||||
state == ADDR_PREFERRED &&
|
|
||||||
!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) {
|
|
||||||
ipaddr = &uip_ds6_if.addr_list[i].ipaddr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ipaddr;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
create_dag_callback(void *ptr)
|
|
||||||
{
|
|
||||||
const uip_ipaddr_t *root, *ipaddr;
|
|
||||||
|
|
||||||
root = dag_root();
|
|
||||||
ipaddr = get_global_address();
|
|
||||||
|
|
||||||
if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) {
|
|
||||||
/* The RPL network we are joining is one that we created, so we
|
|
||||||
become root. */
|
|
||||||
if(to_become_root) {
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
|
||||||
to_become_root = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rpl_dag_t *dag;
|
|
||||||
|
|
||||||
dag = rpl_get_any_dag();
|
|
||||||
#if DEBUG
|
|
||||||
printf("Found a network we did not create\n");
|
|
||||||
printf("version %d grounded %d preference %d used %d joined %d rank %d\n",
|
|
||||||
dag->version, dag->grounded,
|
|
||||||
dag->preference, dag->used,
|
|
||||||
dag->joined, dag->rank);
|
|
||||||
#endif /* DEBUG */
|
|
||||||
|
|
||||||
/* We found a RPL network that we did not create so we just join
|
|
||||||
it without becoming root. But if the network has an infinite
|
|
||||||
rank, we assume the network has broken, and we become the new
|
|
||||||
root of the network. */
|
|
||||||
|
|
||||||
if(dag->rank == RPL_INFINITE_RANK) {
|
|
||||||
if(to_become_root) {
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
|
||||||
to_become_root = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try again after the grace period */
|
|
||||||
ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if (UIP_MAX_ROUTES != 0)
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
route_callback(int event, uip_ipaddr_t *route, uip_ipaddr_t *ipaddr,
|
|
||||||
int numroutes)
|
|
||||||
{
|
|
||||||
if(event == UIP_DS6_NOTIFICATION_DEFRT_ADD) {
|
|
||||||
if(route != NULL && ipaddr != NULL &&
|
|
||||||
!uip_is_addr_unspecified(route) &&
|
|
||||||
!uip_is_addr_unspecified(ipaddr)) {
|
|
||||||
if(to_become_root) {
|
|
||||||
ctimer_set(&c, 0, create_dag_callback, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* (UIP_MAX_ROUTES != 0) */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
|
@ -175,29 +76,25 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
{
|
{
|
||||||
static uint8_t initialized = 0;
|
static uint8_t initialized = 0;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
to_become_root = 0;
|
|
||||||
set_global_address(prefix, iid);
|
set_global_address(prefix, iid);
|
||||||
#if (UIP_MAX_ROUTES != 0)
|
|
||||||
uip_ds6_notification_add(&n, route_callback);
|
|
||||||
#endif /* (UIP_MAX_ROUTES != 0) */
|
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
rpl_dag_root_init_dag_immediately(void)
|
rpl_dag_root_start(void)
|
||||||
{
|
{
|
||||||
struct uip_ds6_addr *root_if;
|
struct uip_ds6_addr *root_if;
|
||||||
int i;
|
int i;
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uip_ipaddr_t *ipaddr = NULL;
|
uip_ipaddr_t *ipaddr = NULL;
|
||||||
|
|
||||||
rpl_dag_root_init(NULL, NULL);
|
rpl_dag_root_set_prefix(NULL, NULL);
|
||||||
|
|
||||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||||
state = uip_ds6_if.addr_list[i].state;
|
state = uip_ds6_if.addr_list[i].state;
|
||||||
|
@ -222,38 +119,25 @@ rpl_dag_root_init_dag_immediately(void)
|
||||||
if(RPL_IS_STORING(dag->instance)) {
|
if(RPL_IS_STORING(dag->instance)) {
|
||||||
rpl_remove_routes(dag);
|
rpl_remove_routes(dag);
|
||||||
}
|
}
|
||||||
if(dag->instance != NULL &&
|
if(dag->instance != NULL && dag->instance->def_route != NULL) {
|
||||||
dag->instance->def_route != NULL) {
|
|
||||||
uip_ds6_defrt_rm(dag->instance->def_route);
|
uip_ds6_defrt_rm(dag->instance->def_route);
|
||||||
dag->instance->def_route = NULL;
|
dag->instance->def_route = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
|
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
|
||||||
rpl_set_prefix(dag, &prefix, 64);
|
rpl_set_prefix(dag, &prefix, 64);
|
||||||
PRINTF("rpl_dag_root_init_dag: created a new RPL dag\n");
|
PRINTF("rpl_dag_root_set_prefix_dag: created a new RPL dag\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG\n");
|
PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG, no preferred IP address found\n");
|
PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG, no preferred IP address found\n");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
|
||||||
rpl_dag_root_init_dag_delay(void)
|
|
||||||
{
|
|
||||||
rpl_dag_root_init(NULL, NULL);
|
|
||||||
|
|
||||||
ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
|
|
||||||
to_become_root = 1;
|
|
||||||
|
|
||||||
/* Send a DIS packet to request RPL info from neighbors. */
|
|
||||||
dis_output(NULL);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
int
|
||||||
rpl_dag_root_is_root(void)
|
rpl_dag_root_is_root(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,9 +32,8 @@
|
||||||
#ifndef RPL_DAG_ROOT_H_
|
#ifndef RPL_DAG_ROOT_H_
|
||||||
#define RPL_DAG_ROOT_H_
|
#define RPL_DAG_ROOT_H_
|
||||||
|
|
||||||
void rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid);
|
void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid);
|
||||||
void rpl_dag_root_init_dag_delay(void);
|
int rpl_dag_root_start(void);
|
||||||
int rpl_dag_root_init_dag_immediately(void);
|
|
||||||
|
|
||||||
int rpl_dag_root_is_root(void);
|
int rpl_dag_root_is_root(void);
|
||||||
|
|
||||||
|
|
|
@ -48,48 +48,6 @@
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL LOG_LEVEL_RPL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1)
|
|
||||||
|
|
||||||
static uint8_t to_become_root;
|
|
||||||
static struct ctimer c;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
create_dag_callback(void *ptr)
|
|
||||||
{
|
|
||||||
const uip_ipaddr_t *root, *ipaddr;
|
|
||||||
|
|
||||||
root = curr_instance.used ? &curr_instance.dag.dag_id : NULL;
|
|
||||||
ipaddr = rpl_get_global_address();
|
|
||||||
|
|
||||||
if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) {
|
|
||||||
/* The RPL network we are joining is one that we created, so we
|
|
||||||
become root. */
|
|
||||||
if(to_become_root) {
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
|
||||||
to_become_root = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOG_WARN("found a network we did not create: version %d grounded %d preference %d rank %d\n",
|
|
||||||
curr_instance.dag.version, curr_instance.dag.grounded,
|
|
||||||
curr_instance.dag.preference, curr_instance.dag.rank);
|
|
||||||
|
|
||||||
/* We found a RPL network that we did not create so we just join
|
|
||||||
it without becoming root. But if the network has an infinite
|
|
||||||
rank, we assume the network has broken, and we become the new
|
|
||||||
root of the network. */
|
|
||||||
|
|
||||||
if(curr_instance.dag.rank == RPL_INFINITE_RANK) {
|
|
||||||
if(to_become_root) {
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
|
||||||
to_become_root = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try again after the grace period */
|
|
||||||
ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
|
@ -125,26 +83,25 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||||
{
|
{
|
||||||
static uint8_t initialized = 0;
|
static uint8_t initialized = 0;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
to_become_root = 0;
|
|
||||||
set_global_address(prefix, iid);
|
set_global_address(prefix, iid);
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
rpl_dag_root_init_dag_immediately(void)
|
rpl_dag_root_start(void)
|
||||||
{
|
{
|
||||||
struct uip_ds6_addr *root_if;
|
struct uip_ds6_addr *root_if;
|
||||||
int i;
|
int i;
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uip_ipaddr_t *ipaddr = NULL;
|
uip_ipaddr_t *ipaddr = NULL;
|
||||||
|
|
||||||
rpl_dag_root_init(NULL, NULL);
|
rpl_dag_root_set_prefix(NULL, NULL);
|
||||||
|
|
||||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||||
state = uip_ds6_if.addr_list[i].state;
|
state = uip_ds6_if.addr_list[i].state;
|
||||||
|
@ -170,18 +127,6 @@ rpl_dag_root_init_dag_immediately(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
|
||||||
rpl_dag_root_init_dag_delay(void)
|
|
||||||
{
|
|
||||||
rpl_dag_root_init(NULL, NULL);
|
|
||||||
|
|
||||||
ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
|
|
||||||
to_become_root = 1;
|
|
||||||
|
|
||||||
/* Send a DIS packet to request RPL info from neighbors. */
|
|
||||||
rpl_icmp6_dis_output(NULL);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
int
|
||||||
rpl_dag_root_is_root(void)
|
rpl_dag_root_is_root(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,20 +49,14 @@
|
||||||
* \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead
|
* \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead
|
||||||
* \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid.
|
* \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid.
|
||||||
*/
|
*/
|
||||||
void rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid);
|
void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the node as DAG root after a delay. Until the delay, the node
|
* Set the node as root and start a DAG
|
||||||
* gets a chance to hear another DAG and join it instead.
|
|
||||||
*/
|
|
||||||
void rpl_dag_root_init_dag_delay(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the node as DAG root immediatly.
|
|
||||||
*
|
*
|
||||||
* \return 0 in case of success, -1 otherwise
|
* \return 0 in case of success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
int rpl_dag_root_init_dag_immediately(void);
|
int rpl_dag_root_start(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether we are DAG root or not
|
* Tells whether we are DAG root or not
|
||||||
|
|
|
@ -64,8 +64,8 @@ void
|
||||||
set_prefix_64(uip_ipaddr_t *prefix_64)
|
set_prefix_64(uip_ipaddr_t *prefix_64)
|
||||||
{
|
{
|
||||||
prefix_set = 1;
|
prefix_set = 1;
|
||||||
rpl_dag_root_init(prefix_64, NULL);
|
rpl_dag_root_set_prefix(prefix_64, NULL);
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
|
|
@ -324,8 +324,8 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
|
||||||
SHELL_OUTPUT(output, "Setting as DAG root with prefix ");
|
SHELL_OUTPUT(output, "Setting as DAG root with prefix ");
|
||||||
shell_output_6addr(output, &prefix);
|
shell_output_6addr(output, &prefix);
|
||||||
SHELL_OUTPUT(output, "/64\n");
|
SHELL_OUTPUT(output, "/64\n");
|
||||||
rpl_dag_root_init(&prefix, NULL);
|
rpl_dag_root_set_prefix(&prefix, NULL);
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
} else {
|
} else {
|
||||||
SHELL_OUTPUT(output, "Node is already a DAG root\n");
|
SHELL_OUTPUT(output, "Node is already a DAG root\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ PROCESS_THREAD(udp_process, ev, data)
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
simple_udp_register(&broadcast_connection, UDP_PORT,
|
simple_udp_register(&broadcast_connection, UDP_PORT,
|
||||||
NULL, UDP_PORT,
|
NULL, UDP_PORT,
|
||||||
|
|
|
@ -74,7 +74,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
simple_udp_register(&unicast_connection, UDP_PORT,
|
simple_udp_register(&unicast_connection, UDP_PORT,
|
||||||
NULL, UDP_PORT, receiver);
|
NULL, UDP_PORT, receiver);
|
||||||
|
|
|
@ -72,7 +72,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
rpl_dag_root_init_dag_immediately();
|
rpl_dag_root_start();
|
||||||
|
|
||||||
simple_udp_register(&unicast_connection, UDP_PORT,
|
simple_udp_register(&unicast_connection, UDP_PORT,
|
||||||
NULL, UDP_PORT, receiver);
|
NULL, UDP_PORT, receiver);
|
||||||
|
|
Loading…
Reference in New Issue