44 #include "net/routing/rpl-lite/rpl.h" 49 #define LOG_MODULE "RPL" 50 #define LOG_LEVEL LOG_LEVEL_RPL 52 uip_ipaddr_t rpl_multicast_addr;
53 static 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);
122 return curr_instance.used && curr_instance.dag.state >= DAG_JOINED;
128 return curr_instance.used && curr_instance.dag.state == DAG_REACHABLE;
134 memset(
ipaddr, 0,
sizeof(uip_ipaddr_t));
135 memcpy(
ipaddr, &prefix->prefix, (prefix->length + 7) / 8);
144 set_ip_from_prefix(&ipaddr, last_prefix);
145 rep = uip_ds6_addr_lookup(&ipaddr);
147 LOG_INFO(
"removing global IP address ");
148 LOG_INFO_6ADDR(&ipaddr);
150 uip_ds6_addr_rm(rep);
152 curr_instance.dag.prefix_info.length = 0;
160 if(addr == NULL || len == 0 || len > 128 || !(flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {
161 LOG_WARN(
"prefix not included, not-supported or invalid\n");
166 memset(&curr_instance.dag.prefix_info.prefix, 0,
sizeof(
rpl_prefix_t));
167 memcpy(&curr_instance.dag.prefix_info.prefix, addr, (len + 7) / 8);
168 curr_instance.dag.prefix_info.length = len;
169 curr_instance.dag.prefix_info.lifetime = RPL_ROUTE_INFINITE_LIFETIME;
170 curr_instance.dag.prefix_info.flags = flags;
173 set_ip_from_prefix(&ipaddr, &curr_instance.dag.prefix_info);
174 if(uip_ds6_addr_lookup(&ipaddr) == NULL) {
175 LOG_INFO(
"adding global IP address ");
176 LOG_INFO_6ADDR(&ipaddr);
187 curr_instance.dag.prefix_info.lifetime = prefix->lifetime;
196 LOG_INFO(
"initializing\n");
200 uip_ds6_maddr_add(&rpl_multicast_addr);
213 if(
addr != NULL && node != NULL) {
214 memcpy(
addr, &curr_instance.dag.dag_id, 8);
215 memcpy(((
unsigned char *)
addr) + 8, &node->link_identifier, 8);
237 rpl_leaf_only = value;
243 return rpl_leaf_only;
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
void rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
Called by lower layers after every packet transmission.
uip_lladdr_t uip_lladdr
Host L2 address.
int rpl_dag_root_start(void)
Set the node as root and start a DAG.
void rpl_dag_poison_and_leave(void)
Start poisoning and leave the DAG after a delay.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
int rpl_lollipop_greater_than(int a, int b)
Greater-than function for a lollipop counter.
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...
void rpl_global_repair(const char *str)
Triggers a RPL global repair.
void(* drop_route)(uip_ds6_route_t *route)
Called by uIP if it has decided to drop a route because.
void rpl_timers_init(void)
Initialize rpl-timers module.
int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr)
Look for next hop from SRH of current uIP packet.
uint8_t rpl_get_leaf_only(void)
Get the value of the rpl_leaf_only flag.
void uip_sr_init(void)
Initialize this module.
uint16_t rpl_neighbor_get_link_metric(rpl_nbr_t *nbr)
Returns a neighbor's link metric.
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_ext_header_update(void)
Adds/updates all RPL extension headers to current uIP packet.
int rpl_dag_root_is_root(void)
Tells whether we are DAG root or not.
int rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset)
Process and update the RPL hop-by-hop extension headers of the current uIP packet.
void(* init)(void)
Initialize the routing protocol.
int rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags)
Set prefix from an IPv6 address.
void rpl_timers_schedule_state_update(void)
Schedule a state update ASAP.
int rpl_set_prefix(rpl_prefix_t *prefix)
Set prefix from an prefix data structure (from DIO)
An entry in the routing table.
void(* neighbor_state_changed)(uip_ds6_nbr_t *nbr)
Called by uIP to notify addition/removal of IPv6 neighbor entries.
int rpl_is_reachable(void)
Get the RPL's best guess on if we are reachable via have downward route or not.
void rpl_neighbor_init(void)
Initialize rpl-dag-neighbor module.
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.
Routing driver header file
All information related to a RPL neighbor.
Unicast address structure.
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.
const uip_ipaddr_t * rpl_get_global_address(void)
Get one of the node's global addresses.
bool rpl_ext_header_remove(void)
Removes all RPL extension headers.
uip_ds6_netif_t uip_ds6_if
The single interface.
int rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr)
Returns the IPv6 address of the RPL DAG root, if any.
int(* get_sr_node_ipaddr)(uip_ipaddr_t *addr, const uip_sr_node_t *node)
Returns the global IPv6 address of a source routing node.
#define uip_create_linklocal_rplnodes_mcast(addr)
Set IP address addr to the link-local, all-rpl-nodes multicast address.
void rpl_local_repair(const char *str)
Triggers a RPL local repair.
void rpl_reset_prefix(rpl_prefix_t *last_prefix)
Removes current prefx.
#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
int rpl_has_joined(void)
Tells whether the node has joined a network or not.
The structure of a routing protocol driver.
A node in a source routing graph, stored at the root and representing all child-parent relationship...
void rpl_icmp6_init()
Initializes rpl-icmp6 module, registers ICMPv6 handlers for all RPL ICMPv6 messages: DIO...
void rpl_dag_init(void)
Initializes rpl-dag module.
rpl_nbr_t * rpl_neighbor_get_from_lladdr(uip_lladdr_t *addr)
Returns a neighbor from its link-layer address.
int rpl_ext_header_srh_update(void)
Process and update SRH in-place, i.e.
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...