From 17209e8fa4fd2e6e311761dd678ec9f1b23bc304 Mon Sep 17 00:00:00 2001 From: joxe Date: Thu, 3 Jun 2010 18:37:47 +0000 Subject: [PATCH] moved code for autoconfiguring global address into join_dag --- core/net/rpl/rpl-dag.c | 17 ++++++++++++++++- core/net/rpl/rpl-icmp6.c | 20 +------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 12dfa31d1..7b786c48e 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl-dag.c,v 1.17 2010/06/03 15:20:56 nvt-se Exp $ + * $Id: rpl-dag.c,v 1.18 2010/06/03 18:37:47 joxe Exp $ */ /** * \file @@ -398,6 +398,21 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio) return; } + /* Autoconfigure an address if this node does not already have an address + with this prefix. */ + if((dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) { + uip_ipaddr_t ipaddr; + /* assume that the prefix ends with zeros! */ + memcpy(&ipaddr, &dio->prefix_info.prefix, 16); + uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); + if(uip_ds6_addr_lookup(&ipaddr) == NULL) { + PRINTF("RPL: adding global IP address "); + PRINT6ADDR(&ipaddr); + PRINTF("\n"); + uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); + } + } + dag->joined = 1; dag->used = 1; dag->of = of; diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index cd2e403dd..37389fddb 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl-icmp6.c,v 1.15 2010/06/03 14:49:15 joxe Exp $ + * $Id: rpl-icmp6.c,v 1.16 2010/06/03 18:37:47 joxe Exp $ */ /** * \file @@ -286,24 +286,6 @@ dio_input(void) /* 32-bit reserved at i + 12 */ PRINTF("RPL: Copying prefix information\n"); memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16); - - /* NOTE: This is a test for adding autoconf prefix in RPL via */ - /* a destination prefix - this use one reserved flag bit */ - /* This should not be made until RPL decides to join the DAG */ - /* And not if there already is a global address configured for */ - /* the specific DAG */ - if((dio.prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) { - uip_ipaddr_t ipaddr; - /* assume that the prefix ends with zeros! */ - memcpy(&ipaddr, &dio.prefix_info.prefix, 16); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - if(uip_ds6_addr_lookup(&ipaddr) == NULL) { - PRINTF("RPL: adding global IP address "); - PRINT6ADDR(&ipaddr); - PRINTF("\n"); - uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); - } - } break; } }