Commit fe7ded07 authored by Simon Duquennoy's avatar Simon Duquennoy
Browse files

Routing API: add function node_has_joined

parent 177a68db
......@@ -82,6 +82,12 @@ leave_network(void)
}
/*---------------------------------------------------------------------------*/
static int
node_has_joined(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
node_is_reachable(void)
{
return 1;
......@@ -151,6 +157,7 @@ const struct routing_driver nullrouting_driver = {
get_root_ipaddr,
get_sr_node_ipaddr,
leave_network,
node_has_joined,
node_is_reachable,
global_repair,
local_repair,
......
......@@ -93,6 +93,12 @@ struct routing_driver {
*
*/
void (* leave_network)(void);
/**
* Tells whether the node is currently part of a network
*
* \return 1 if we have joined a network, 0 otherwise.
*/
int (* node_has_joined)(void);
/**
* Tells whether the node is currently reachable as part of the network
*
......
......@@ -1006,6 +1006,12 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent)
}
/*---------------------------------------------------------------------------*/
int
rpl_has_joined(void)
{
return rpl_get_any_dag() != NULL;
}
/*---------------------------------------------------------------------------*/
int
rpl_has_downward_route(void)
{
int i;
......
......@@ -423,6 +423,7 @@ const struct routing_driver rpl_classic_driver = {
get_root_ipaddr,
get_sr_node_ipaddr,
leave_network,
rpl_has_joined,
rpl_has_downward_route,
global_repair,
local_repair,
......
......@@ -327,6 +327,12 @@ enum rpl_mode rpl_set_mode(enum rpl_mode mode);
*/
enum rpl_mode rpl_get_mode(void);
/**
* Tells whether the node has joined a network or not
*
* \retval 1 if we have joined a network, 0 if not.
*/
int rpl_has_joined(void);
/**
* Get the RPL's best guess on if we have downward route or not.
......
......@@ -109,6 +109,12 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
}
/*---------------------------------------------------------------------------*/
int
rpl_has_joined(void)
{
return curr_instance.used && curr_instance.dag.state >= DAG_JOINED;
}
/*---------------------------------------------------------------------------*/
int
rpl_is_reachable(void)
{
return curr_instance.used && curr_instance.dag.state == DAG_REACHABLE;
......@@ -226,6 +232,7 @@ const struct routing_driver rpl_lite_driver = {
rpl_dag_get_root_ipaddr,
get_sr_node_ipaddr,
rpl_dag_poison_and_leave,
rpl_has_joined,
rpl_is_reachable,
rpl_global_repair,
rpl_local_repair,
......
......@@ -49,7 +49,7 @@ AUTOSTART_PROCESSES(&wait_for_dag);
static void
timeout_handler(void)
{
if(NETSTACK_ROUTING.node_is_reachable()) {
if(NETSTACK_ROUTING.node_has_joined()) {
PRINTF("DAG Found\n");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment