33 #include "contiki-net.h" 35 #include "net/routing/rpl-classic/rpl.h" 36 #include "net/routing/rpl-classic/rpl-private.h" 43 #define LOG_MODULE "RPL" 44 #define LOG_LEVEL LOG_LEVEL_RPL 48 set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
50 static uip_ipaddr_t root_ipaddr;
56 uip_ip6addr(&root_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
58 memcpy(&root_ipaddr, prefix, 8);
63 memcpy(((uint8_t*)&root_ipaddr) + 8, ((uint8_t*)iid) + 8, 8);
71 LOG_DBG(
"IPv6 addresses: ");
72 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
76 LOG_DBG_6ADDR(&
uip_ds6_if.addr_list[i].ipaddr);
86 static uint8_t initialized = 0;
89 set_global_address(prefix, iid);
100 uip_ipaddr_t *
ipaddr = NULL;
104 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
107 state == ADDR_PREFERRED &&
114 root_if = uip_ds6_addr_lookup(ipaddr);
115 if(root_if != NULL) {
119 rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr);
124 if(RPL_IS_STORING(dag->instance)) {
125 rpl_remove_routes(dag);
127 if(dag->instance != NULL && dag->instance->def_route != NULL) {
128 uip_ds6_defrt_rm(dag->instance->def_route);
129 dag->instance->def_route = NULL;
132 uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
133 rpl_set_prefix(dag, &prefix, 64);
134 LOG_INFO(
"root_set_prefix: created a new RPL dag\n");
137 LOG_ERR(
"root_set_prefix: failed to create a new RPL DAG\n");
141 LOG_ERR(
"root_set_prefix_dag: failed to create a new RPL DAG, no preferred IP address found\n");
153 if(instance == NULL) {
157 if(instance->current_dag &&
158 instance->current_dag->rank ==
ROOT_RANK(instance)) {
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
uip_lladdr_t uip_lladdr
Host L2 address.
int rpl_dag_root_start(void)
Set the node as root and start a DAG.
#define ROOT_RANK
Rank of a root node.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
int rpl_dag_root_is_root(void)
Tells whether we are DAG root or not.
void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
Set a prefix in case the node is later set as dag root.
Unicast address structure.
rpl_dag_t * rpl_get_any_dag(void)
Returns pointer to any DAG (for compatibility with legagy RPL code)
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
uip_ds6_addr_t * uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type)
Add a unicast address to the interface.
uip_ds6_netif_t uip_ds6_if
The single interface.
Header file for routing table manipulation.
#define uip_is_addr_linklocal(a)
is addr (a) a link local unicast address, see RFC 4291 i.e.
Header file for the logging system
rpl_instance_t * rpl_get_default_instance(void)
Returns pointer to the default instance (for compatibility with legagy RPL code)