Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpl: logic to switch between dodags #2631

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sys/net/routing/rpl/rpl_control_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@ void rpl_recv_DIO(void)
/* handle packet content... */
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if ((my_dodag != NULL) && (my_dodag->node_status != ROOT_NODE)
&& memcmp(&my_dodag->dodag_id, &dio_dodag.dodag_id, sizeof(ipv6_addr_t))) {
/* create a temporary parent and assign it to the incoming DIO's dodag */
rpl_parent_t tmp_parent = { .rank = byteorder_ntohs(rpl_dio_buf->rank), .dodag = &dio_dodag };
dio_dodag.my_preferred_parent = &tmp_parent;

/* calculate the incoming DIO's dodag rank and check wheter my rank would be better in the new dodag */
dio_dodag.my_rank = dio_dodag.of->calc_rank(&tmp_parent, tmp_parent.rank);
if (my_dodag != my_dodag->of->which_dodag(my_dodag, &dio_dodag)) {
/* my rank would be better in the incoming DIO's dodag. leave old dodag */
rpl_leave_dodag(my_dodag);
my_dodag = NULL;
}
}

if (my_dodag == NULL) {
if (!has_dodag_conf_opt) {
DEBUGF("send DIS\n");
Expand Down