41#include "contiki-net.h"
43#include "net/routing/rpl-lite/rpl.h"
49#define LOG_MODULE "RPL"
50#define LOG_LEVEL LOG_LEVEL_RPL
56 if(rpl_dag_root_is_root()) {
60 LOG_INFO(
"links: %u routing links in total (%s)\n",
uip_sr_num_nodes(), str);
65 LOG_INFO(
"links: %s\n", buf);
68 LOG_INFO(
"links: end of list\n");
70 LOG_INFO(
"No routing links\n");
76set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
78 static uip_ipaddr_t root_ipaddr;
79 const uip_ipaddr_t *default_prefix;
88 uip_ip6addr_copy(&root_ipaddr, default_prefix);
90 memcpy(&root_ipaddr, prefix, 8);
95 memcpy(((uint8_t*)&root_ipaddr) + 8, ((uint8_t*)iid) + 8, 8);
100 LOG_INFO(
"IPv6 addresses:\n");
101 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
106 LOG_INFO_6ADDR(&
uip_ds6_if.addr_list[i].ipaddr);
113rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
115 static uint8_t initialized = 0;
118 set_global_address(prefix, iid);
124rpl_dag_root_start(
void)
129 uip_ipaddr_t *
ipaddr = NULL;
131 rpl_dag_root_set_prefix(NULL, NULL);
133 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
136 state == ADDR_PREFERRED &&
142 root_if = uip_ds6_addr_lookup(
ipaddr);
143 if(
ipaddr != NULL || root_if != NULL) {
149 LOG_INFO(
"created a new RPL DAG\n");
152 LOG_ERR(
"failed to create a new RPL DAG\n");
158rpl_dag_root_is_root(
void)
160 return curr_instance.used && curr_instance.dag.rank == ROOT_RANK;
void rpl_dag_root_print_links(const char *str)
Prints a summary of all routing links.
void rpl_dag_update_state(void)
Updates RPL internal state: selects preferred parent, updates rank & metreic container,...
void rpl_dag_init_root(uint8_t instance_id, uip_ipaddr_t *dag_id, uip_ipaddr_t *prefix, unsigned prefix_len, uint8_t prefix_flags)
Initializes DAG internal structure for a root node.
const uip_ipaddr_t * rpl_get_global_address(void)
Get one of the node's global addresses.
const uip_ip6addr_t * uip_ds6_default_prefix()
Retrieve the Default IPv6 prefix.
uip_lladdr_t uip_lladdr
Host L2 address.
uip_sr_node_t * uip_sr_node_head(void)
Returns the head of the non-storing node list.
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.
int uip_sr_link_snprint(char *buf, int buflen, const uip_sr_node_t *link)
Print a textual description of a source routing link.
#define uip_is_addr_linklocal(a)
is addr (a) a link local unicast address, see RFC 4291 i.e.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
int uip_sr_num_nodes(void)
Tells how many nodes are currently stored in the graph.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
uip_ds6_netif_t uip_ds6_if
The single interface.
uip_sr_node_t * uip_sr_node_next(const uip_sr_node_t *item)
Returns the next element of the non-storing node list.
Header file for the logging system.
Unicast address structure.
A node in a source routing graph, stored at the root and representing all child-parent relationship.
Header file for routing table manipulation.
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.