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 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");
76 set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
78 static uip_ipaddr_t root_ipaddr;
85 uip_ip6addr(&root_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
87 memcpy(&root_ipaddr, prefix, 8);
92 memcpy(((uint8_t*)&root_ipaddr) + 8, ((uint8_t*)iid) + 8, 8);
97 LOG_INFO(
"IPv6 addresses:\n");
98 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
103 LOG_INFO_6ADDR(&
uip_ds6_if.addr_list[i].ipaddr);
112 static uint8_t initialized = 0;
115 set_global_address(prefix, iid);
126 uip_ipaddr_t *
ipaddr = NULL;
130 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
133 state == ADDR_PREFERRED &&
139 root_if = uip_ds6_addr_lookup(ipaddr);
140 if(ipaddr != NULL || root_if != NULL) {
146 LOG_INFO(
"created a new RPL DAG\n");
149 LOG_ERR(
"failed to create a new RPL DAG\n");
157 return curr_instance.used && curr_instance.dag.rank ==
ROOT_RANK;
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.
int uip_sr_num_nodes(void)
Tells how many nodes are currently stored in the graph.
#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
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.
void rpl_dag_root_print_links(const char *str)
Prints a summary of all routing links.
int rpl_dag_root_is_root(void)
Tells whether we are DAG root or not.
uip_sr_node_t * uip_sr_node_next(uip_sr_node_t *item)
Returns the next element of the non-storing node list.
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.
uip_sr_node_t * uip_sr_node_head(void)
Returns the head of the non-storing node list.
Unicast address structure.
#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.
int uip_sr_link_snprint(char *buf, int buflen, uip_sr_node_t *link)
Print a textual description of a source routing link.
const uip_ipaddr_t * rpl_get_global_address(void)
Get one of the node's global addresses.
uip_ds6_netif_t uip_ds6_if
The single interface.
void rpl_dag_update_state(void)
Updates RPL internal state: selects preferred parent, updates rank & metreic container, triggers control traffic accordingly and updates uIP6 internal state.
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
A node in a source routing graph, stored at the root and representing all child-parent relationship...