44#include "net/routing/rpl-lite/rpl.h"
49#define LOG_MODULE "RPL"
50#define LOG_LEVEL LOG_LEVEL_RPL
52uip_ipaddr_t rpl_multicast_addr;
53static uint8_t rpl_leaf_only = RPL_DEFAULT_LEAF_ONLY;
60 if(a > RPL_LOLLIPOP_CIRCULAR_REGION && b <= RPL_LOLLIPOP_CIRCULAR_REGION) {
61 return (RPL_LOLLIPOP_MAX_VALUE + 1 + b - a) > RPL_LOLLIPOP_SEQUENCE_WINDOWS;
65 return (a > b && (a - b) < RPL_LOLLIPOP_SEQUENCE_WINDOWS) ||
66 (a < b && (b - a) > (RPL_LOLLIPOP_CIRCULAR_REGION + 1-
67 RPL_LOLLIPOP_SEQUENCE_WINDOWS));
75 uip_ipaddr_t *
ipaddr = NULL;
76 uip_ipaddr_t *prefix = NULL;
77 uint8_t prefix_length = 0;
79 if(curr_instance.used && curr_instance.dag.prefix_info.length != 0) {
80 prefix = &curr_instance.dag.prefix_info.prefix;
81 prefix_length = curr_instance.dag.prefix_info.length;
84 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
87 state == ADDR_PREFERRED &&
89 (prefix == NULL || uip_ipaddr_prefixcmp(prefix, &
uip_ds6_if.addr_list[i].ipaddr, prefix_length))) {
99 if(curr_instance.used == 1 ) {
105 if(curr_instance.dag.urgent_probing_target ==
nbr) {
106 curr_instance.dag.urgent_probing_target = NULL;
111 LOG_INFO(
"packet sent to ");
112 LOG_INFO_LLADDR(
addr);
113 LOG_INFO_(
", status %u, tx %u, new link metric %u\n",
123 return curr_instance.used && curr_instance.dag.state >= DAG_JOINED;
129 return curr_instance.used && curr_instance.dag.state == DAG_REACHABLE;
135 memset(
ipaddr, 0,
sizeof(uip_ipaddr_t));
136 memcpy(
ipaddr, &prefix->prefix, (prefix->length + 7) / 8);
145 set_ip_from_prefix(&
ipaddr, last_prefix);
146 rep = uip_ds6_addr_lookup(&
ipaddr);
148 LOG_INFO(
"removing global IP address ");
151 uip_ds6_addr_rm(rep);
153 curr_instance.dag.prefix_info.length = 0;
161 if(
addr == NULL || len == 0 || len > 128 || !(flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {
162 LOG_WARN(
"prefix not included, not-supported or invalid\n");
167 memset(&curr_instance.dag.prefix_info.prefix, 0,
sizeof(uip_ipaddr_t));
168 memcpy(&curr_instance.dag.prefix_info.prefix,
addr, (len + 7) / 8);
169 curr_instance.dag.prefix_info.length = len;
170 curr_instance.dag.prefix_info.lifetime = RPL_ROUTE_INFINITE_LIFETIME;
171 curr_instance.dag.prefix_info.flags = flags;
174 set_ip_from_prefix(&
ipaddr, &curr_instance.dag.prefix_info);
175 if(uip_ds6_addr_lookup(&
ipaddr) == NULL) {
176 LOG_INFO(
"adding global IP address ");
188 curr_instance.dag.prefix_info.lifetime = prefix->lifetime;
197 LOG_INFO(
"initializing\n");
200 uip_create_linklocal_rplnodes_mcast(&rpl_multicast_addr);
201 uip_ds6_maddr_add(&rpl_multicast_addr);
214 if(
addr != NULL && node != NULL) {
215 memcpy(
addr, &curr_instance.dag.dag_id, 8);
216 memcpy(((
unsigned char *)
addr) + 8, &node->link_identifier, 8);
238 rpl_leaf_only = value;
244 return rpl_leaf_only;
250 rpl_dag_root_set_prefix,
252 rpl_dag_root_is_root,
260 rpl_ext_header_remove,
261 rpl_ext_header_update,
262 rpl_ext_header_hbh_update,
263 rpl_ext_header_srh_update,
264 rpl_ext_header_srh_get_next_hop,
void rpl_neighbor_init(void)
Initialize rpl-dag-neighbor module.
rpl_nbr_t * rpl_neighbor_get_from_lladdr(uip_lladdr_t *addr)
Returns a neighbor from its link-layer address.
int rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr)
Returns the IPv6 address of the RPL DAG root, if any.
int rpl_set_prefix(rpl_prefix_t *prefix)
Set prefix from an prefix data structure (from DIO)
int rpl_is_reachable(void)
Get the RPL's best guess on if we are reachable via have downward route or not.
void rpl_set_leaf_only(uint8_t value)
Changes the value of the rpl_leaf_only flag, which determines if a node acts only as a leaf in the ne...
uint8_t rpl_get_leaf_only(void)
Get the value of the rpl_leaf_only flag.
int rpl_lollipop_greater_than(int a, int b)
Greater-than function for a lollipop counter.
uint16_t rpl_neighbor_get_link_metric(rpl_nbr_t *nbr)
Returns a neighbor's link metric.
void rpl_reset_prefix(rpl_prefix_t *last_prefix)
Removes current prefx.
int rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags)
Set prefix from an IPv6 address.
void rpl_dag_poison_and_leave(void)
Start poisoning and leave the DAG after a delay.
void rpl_timers_init(void)
Initialize rpl-timers module.
void rpl_icmp6_init()
Initializes rpl-icmp6 module, registers ICMPv6 handlers for all RPL ICMPv6 messages: DIO,...
const uip_ipaddr_t * rpl_get_global_address(void)
Get one of the node's global addresses.
void rpl_global_repair(const char *str)
Triggers a RPL global repair.
void rpl_timers_schedule_state_update(void)
Schedule a state update ASAP.
int rpl_has_joined(void)
Tells whether the node has joined a network or not.
uip_lladdr_t uip_lladdr
Host L2 address.
void uip_sr_init(void)
Initialize this module.
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.
#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
void rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
Called by lower layers after every packet transmission.
uip_ds6_netif_t uip_ds6_if
The single interface.
Header file for the logging system.
Routing driver header file.
The structure of a routing protocol driver.
void(* init)(void)
Initialize the routing protocol.
void(* neighbor_state_changed)(uip_ds6_nbr_t *nbr)
Called by uIP to notify addition/removal of IPv6 neighbor entries.
int(* get_sr_node_ipaddr)(uip_ipaddr_t *ipaddr, const uip_sr_node_t *node)
Returns the global IPv6 address of a source routing node.
void(* drop_route)(uip_ds6_route_t *route)
Called by uIP if it has decided to drop a route because.
All information related to a RPL neighbor.
Unicast address structure.
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...
An entry in the routing table.
A node in a source routing graph, stored at the root and representing all child-parent relationship.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.