Contiki-NG
rpl-ext-header.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \addtogroup rpl-lite
34  * @{
35  *
36  * \file
37  * Management of extension headers for ContikiRPL.
38  *
39  * \author Vincent Brillault <vincent.brillault@imag.fr>,
40  * Joakim Eriksson <joakime@sics.se>,
41  * Niclas Finne <nfi@sics.se>,
42  * Nicolas Tsiftes <nvt@sics.se>,
43  * Simon Duquennoy <simon.duquennoy@inria.fr>
44  */
45 
46 #include "net/routing/routing.h"
47 #include "net/routing/rpl-lite/rpl.h"
48 #include "net/ipv6/uip-sr.h"
49 #include "net/packetbuf.h"
50 
51 /* Log configuration */
52 #include "sys/log.h"
53 #define LOG_MODULE "RPL"
54 #define LOG_LEVEL LOG_LEVEL_RPL
55 
56 /*---------------------------------------------------------------------------*/
57 int
59 {
60  struct uip_routing_hdr *rh_header;
61  uip_sr_node_t *dest_node;
62  uip_sr_node_t *root_node;
63 
64  /* Look for routing ext header */
65  rh_header = (struct uip_routing_hdr *)uipbuf_search_header(uip_buf, uip_len, UIP_PROTO_ROUTING);
66 
67  if(!rpl_is_addr_in_our_dag(&UIP_IP_BUF->destipaddr)) {
68  return 0;
69  }
70 
71  root_node = uip_sr_get_node(NULL, &curr_instance.dag.dag_id);
72  dest_node = uip_sr_get_node(NULL, &UIP_IP_BUF->destipaddr);
73 
74  if((rh_header != NULL && rh_header->routing_type == RPL_RH_TYPE_SRH) ||
75  (dest_node != NULL && root_node != NULL &&
76  dest_node->parent == root_node)) {
77  /* Routing header found or the packet destined for a direct child of the root.
78  * The next hop should be already copied as the IPv6 destination
79  * address, via rpl_ext_header_srh_update. We turn this address into a link-local to enable
80  * forwarding to next hop */
81  uip_ipaddr_copy(ipaddr, &UIP_IP_BUF->destipaddr);
82  uip_create_linklocal_prefix(ipaddr);
83  return 1;
84  }
85 
86  LOG_DBG("no SRH found\n");
87  return 0;
88 }
89 /*---------------------------------------------------------------------------*/
90 int
92 {
93  struct uip_routing_hdr *rh_header;
94  struct uip_rpl_srh_hdr *srh_header;
95  uint8_t cmpri, cmpre;
96  uint8_t ext_len;
97  uint8_t padding;
98  uint8_t path_len;
99  uint8_t segments_left;
100  uip_ipaddr_t current_dest_addr;
101 
102  /* Look for routing ext header */
103  rh_header = (struct uip_routing_hdr *)uipbuf_search_header(uip_buf, uip_len, UIP_PROTO_ROUTING);
104 
105  if(rh_header == NULL || rh_header->routing_type != RPL_RH_TYPE_SRH) {
106  LOG_INFO("SRH not found\n");
107  return 0;
108  }
109 
110  /* Parse SRH */
111  srh_header = (struct uip_rpl_srh_hdr *)(((uint8_t *)rh_header) + RPL_RH_LEN);
112  segments_left = rh_header->seg_left;
113  ext_len = rh_header->len * 8 + 8;
114  cmpri = srh_header->cmpr >> 4;
115  cmpre = srh_header->cmpr & 0x0f;
116  padding = srh_header->pad >> 4;
117  path_len = ((ext_len - padding - RPL_RH_LEN - RPL_SRH_LEN - (16 - cmpre)) / (16 - cmpri)) + 1;
118  (void)path_len;
119 
120  LOG_INFO("read SRH, path len %u, segments left %u, Cmpri %u, Cmpre %u, ext len %u (padding %u)\n",
121  path_len, segments_left, cmpri, cmpre, ext_len, padding);
122 
123  /* Update SRH in-place */
124  if(segments_left == 0) {
125  /* We are the final destination, do nothing */
126  } else if(segments_left > path_len) {
127  /* Discard the packet because of a parameter problem. */
128  LOG_ERR("SRH with too many segments left (%u > %u)\n",
129  segments_left, path_len);
130  return 0;
131  } else {
132  uint8_t i = path_len - segments_left; /* The index of the next address to be visited */
133  uint8_t *addr_ptr = ((uint8_t *)rh_header) + RPL_RH_LEN + RPL_SRH_LEN + (i * (16 - cmpri));
134  uint8_t cmpr = segments_left == 1 ? cmpre : cmpri;
135 
136  /* As per RFC6554: swap the IPv6 destination address with address[i] */
137 
138  /* First, copy the current IPv6 destination address */
139  uip_ipaddr_copy(&current_dest_addr, &UIP_IP_BUF->destipaddr);
140  /* Second, update the IPv6 destination address with addresses[i] */
141  memcpy(((uint8_t *)&UIP_IP_BUF->destipaddr) + cmpr, addr_ptr, 16 - cmpr);
142  /* Third, write current_dest_addr to addresses[i] */
143  memcpy(addr_ptr, ((uint8_t *)&current_dest_addr) + cmpr, 16 - cmpr);
144 
145  /* Update segments left field */
146  rh_header->seg_left--;
147 
148  LOG_INFO("SRH next hop ");
149  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
150  LOG_INFO_("\n");
151  }
152 
153  return 1;
154 }
155 /*---------------------------------------------------------------------------*/
156 /* Utility function for SRH. Counts the number of bytes in common between
157  * two addresses at p1 and p2. */
158 static int
159 count_matching_bytes(const void *p1, const void *p2, size_t n)
160 {
161  int i = 0;
162  for(i = 0; i < n; i++) {
163  if(((uint8_t *)p1)[i] != ((uint8_t *)p2)[i]) {
164  return i;
165  }
166  }
167  return n;
168 }
169 /*---------------------------------------------------------------------------*/
170 /* Used by rpl_ext_header_update to insert a RPL SRH extension header. This
171  * is used at the root, to initiate downward routing. Returns 1 on success,
172  * 0 on failure.
173 */
174 static int
175 insert_srh_header(void)
176 {
177  /* Implementation of RFC6554 */
178  uint8_t path_len;
179  uint8_t ext_len;
180  uint8_t cmpri, cmpre; /* ComprI and ComprE fields of the RPL Source Routing Header */
181  uint8_t *hop_ptr;
182  uint8_t padding;
183  uip_sr_node_t *dest_node;
184  uip_sr_node_t *root_node;
185  uip_sr_node_t *node;
186  uip_ipaddr_t node_addr;
187 
188  /* Always insest SRH as first extension header */
189  struct uip_routing_hdr *rh_hdr = (struct uip_routing_hdr *)UIP_IP_PAYLOAD(0);
190  struct uip_rpl_srh_hdr *srh_hdr = (struct uip_rpl_srh_hdr *)(UIP_IP_PAYLOAD(0) + RPL_RH_LEN);
191 
192  LOG_INFO("SRH creating source routing header with destination ");
193  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
194  LOG_INFO_(" \n");
195 
196  /* Construct source route. We do not do this recursively to keep the runtime stack usage constant. */
197 
198  /* Get link of the destination and root */
199 
200  if(!rpl_is_addr_in_our_dag(&UIP_IP_BUF->destipaddr)) {
201  /* The destination is not in our DAG, skip SRH insertion */
202  LOG_INFO("SRH destination not in our DAG, skip SRH insertion\n");
203  return 1;
204  }
205 
206  dest_node = uip_sr_get_node(NULL, &UIP_IP_BUF->destipaddr);
207  if(dest_node == NULL) {
208  /* The destination is not found, skip SRH insertion */
209  LOG_INFO("SRH node not found, skip SRH insertion\n");
210  return 1;
211  }
212 
213  root_node = uip_sr_get_node(NULL, &curr_instance.dag.dag_id);
214  if(root_node == NULL) {
215  LOG_ERR("SRH root node not found\n");
216  return 0;
217  }
218 
219  if(!uip_sr_is_addr_reachable(NULL, &UIP_IP_BUF->destipaddr)) {
220  LOG_ERR("SRH no path found to destination\n");
221  return 0;
222  }
223 
224  /* Compute path length and compression factors (we use cmpri == cmpre) */
225  path_len = 0;
226  node = dest_node->parent;
227  /* For simplicity, we use cmpri = cmpre */
228  cmpri = 15;
229  cmpre = 15;
230 
231  /* Note that in case of a direct child (node == root_node), we insert
232  SRH anyway, as RFC 6553 mandates that routed datagrams must include
233  SRH or the RPL option (or both) */
234 
235  while(node != NULL && node != root_node) {
236 
237  NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node);
238 
239  /* How many bytes in common between all nodes in the path? */
240  cmpri = MIN(cmpri, count_matching_bytes(&node_addr, &UIP_IP_BUF->destipaddr, 16));
241  cmpre = cmpri;
242 
243  LOG_INFO("SRH Hop ");
244  LOG_INFO_6ADDR(&node_addr);
245  LOG_INFO_("\n");
246  node = node->parent;
247  path_len++;
248  }
249 
250  /* Extension header length: fixed headers + (n-1) * (16-ComprI) + (16-ComprE)*/
251  ext_len = RPL_RH_LEN + RPL_SRH_LEN
252  + (path_len - 1) * (16 - cmpre)
253  + (16 - cmpri);
254 
255  padding = ext_len % 8 == 0 ? 0 : (8 - (ext_len % 8));
256  ext_len += padding;
257 
258  LOG_INFO("SRH path len: %u, ComprI %u, ComprE %u, ext len %u (padding %u)\n",
259  path_len, cmpri, cmpre, ext_len, padding);
260 
261  /* Check if there is enough space to store the extension header */
262  if(uip_len + ext_len > UIP_LINK_MTU) {
263  LOG_ERR("packet too long: impossible to add source routing header (%u bytes)\n", ext_len);
264  return 0;
265  }
266 
267  /* Move existing ext headers and payload ext_len further */
268  memmove(uip_buf + UIP_IPH_LEN + uip_ext_len + ext_len,
269  uip_buf + UIP_IPH_LEN + uip_ext_len, uip_len - UIP_IPH_LEN);
270  memset(uip_buf + UIP_IPH_LEN + uip_ext_len, 0, ext_len);
271 
272  /* Insert source routing header (as first ext header) */
273  rh_hdr->next = UIP_IP_BUF->proto;
274  UIP_IP_BUF->proto = UIP_PROTO_ROUTING;
275 
276  /* Initialize IPv6 Routing Header */
277  rh_hdr->len = (ext_len - 8) / 8;
278  rh_hdr->routing_type = RPL_RH_TYPE_SRH;
279  rh_hdr->seg_left = path_len;
280 
281  /* Initialize RPL Source Routing Header */
282  srh_hdr->cmpr = (cmpri << 4) + cmpre;
283  srh_hdr->pad = padding << 4;
284 
285  /* Initialize addresses field (the actual source route).
286  * From last to first. */
287  node = dest_node;
288  hop_ptr = ((uint8_t *)rh_hdr) + ext_len - padding; /* Pointer where to write the next hop compressed address */
289 
290  while(node != NULL && node->parent != root_node) {
291  NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node);
292 
293  hop_ptr -= (16 - cmpri);
294  memcpy(hop_ptr, ((uint8_t*)&node_addr) + cmpri, 16 - cmpri);
295 
296  node = node->parent;
297  }
298 
299  /* The next hop (i.e. node whose parent is the root) is placed as the current IPv6 destination */
300  NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node);
301  uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &node_addr);
302 
303  /* Update the IPv6 length field */
304  uipbuf_add_ext_hdr(ext_len);
305  uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
306 
307  return 1;
308 }
309 /*---------------------------------------------------------------------------*/
310 int
311 rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset)
312 {
313  int down;
314  int rank_error_signaled;
315  int loop_detected;
316  uint16_t sender_rank;
317  uint8_t sender_closer;
318  rpl_nbr_t *sender;
319  struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)ext_buf;
320  struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(ext_buf + opt_offset);
321 
322  if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
323  || rpl_opt->opt_type != UIP_EXT_HDR_OPT_RPL
324  || rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
325  LOG_ERR("hop-by-hop extension header has wrong size or type (%u %u %u)\n",
326  hbh_hdr->len, rpl_opt->opt_type, rpl_opt->opt_len);
327  return 0; /* Drop */
328  }
329 
330  if(!curr_instance.used || curr_instance.instance_id != rpl_opt->instance) {
331  LOG_ERR("unknown instance: %u\n", rpl_opt->instance);
332  return 0; /* Drop */
333  }
334 
335  if(rpl_opt->flags & RPL_HDR_OPT_FWD_ERR) {
336  LOG_ERR("forward error!\n");
337  return 0; /* Drop */
338  }
339 
340  down = (rpl_opt->flags & RPL_HDR_OPT_DOWN) ? 1 : 0;
341  sender_rank = UIP_HTONS(rpl_opt->senderrank);
342  sender = nbr_table_get_from_lladdr(rpl_neighbors, packetbuf_addr(PACKETBUF_ADDR_SENDER));
343  rank_error_signaled = (rpl_opt->flags & RPL_HDR_OPT_RANK_ERR) ? 1 : 0;
344  sender_closer = sender_rank < curr_instance.dag.rank;
345  loop_detected = (down && !sender_closer) || (!down && sender_closer);
346 
347  LOG_INFO("ext hdr: packet from ");
348  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
349  LOG_INFO_(" to ");
350  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
351  LOG_INFO_(" going %s, sender closer %d (%d < %d), rank error %u, loop detected %u\n",
352  down == 1 ? "down" : "up", sender_closer, sender_rank,
353  curr_instance.dag.rank, rank_error_signaled, loop_detected);
354 
355  if(loop_detected) {
356  /* Set forward error flag */
357  rpl_opt->flags |= RPL_HDR_OPT_RANK_ERR;
358  }
359 
360  return rpl_process_hbh(sender, sender_rank, loop_detected, rank_error_signaled);
361 }
362 /*---------------------------------------------------------------------------*/
363 /* In-place update of the RPL HBH extension header, when already present
364  * in the uIP packet. Used by insert_hbh_header and rpl_ext_header_update.
365  * Returns 1 on success, 0 on failure. */
366 static int
367 update_hbh_header(void)
368 {
369  struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
370  struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(2));
371 
372  if(UIP_IP_BUF->proto == UIP_PROTO_HBHO && rpl_opt->opt_type == UIP_EXT_HDR_OPT_RPL) {
373  if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
374  || rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
375 
376  LOG_ERR("hop-by-hop extension header has wrong size (%u)\n", rpl_opt->opt_len);
377  return 0; /* Drop */
378  }
379 
380  if(!curr_instance.used || curr_instance.instance_id != rpl_opt->instance) {
381  LOG_ERR("unable to add/update hop-by-hop extension header: incorrect instance\n");
382  return 0; /* Drop */
383  }
384 
385  /* Update sender rank and instance, will update flags next */
386  rpl_opt->senderrank = UIP_HTONS(curr_instance.dag.rank);
387  rpl_opt->instance = curr_instance.instance_id;
388  }
389 
390  return 1;
391 }
392 /*---------------------------------------------------------------------------*/
393 /* Used by rpl_ext_header_update on packets without an HBH extension header,
394  * for packets initated by non-root nodes.
395  * Inserts and initalizes (via update_hbh_header) a RPL HBH ext header.
396  * Returns 1 on success, 0 on failure. */
397 static int
398 insert_hbh_header(void)
399 {
400  struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
401  struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(2));
402 
403  /* Insert hop-by-hop header */
404  LOG_INFO("creating hop-by-hop option\n");
405  if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_LINK_MTU) {
406  LOG_ERR("packet too long: impossible to add hop-by-hop option\n");
407  return 0;
408  }
409 
410  /* Move existing ext headers and payload RPL_HOP_BY_HOP_LEN further */
411  memmove(UIP_IP_PAYLOAD(RPL_HOP_BY_HOP_LEN), UIP_IP_PAYLOAD(0), uip_len - UIP_IPH_LEN);
412  memset(UIP_IP_PAYLOAD(0), 0, RPL_HOP_BY_HOP_LEN);
413 
414  /* Insert HBH header (as first ext header) */
415  hbh_hdr->next = UIP_IP_BUF->proto;
416  UIP_IP_BUF->proto = UIP_PROTO_HBHO;
417 
418  /* Initialize HBH option */
419  hbh_hdr->len = (RPL_HOP_BY_HOP_LEN - 8) / 8;
420  rpl_opt->opt_type = UIP_EXT_HDR_OPT_RPL;
421  rpl_opt->opt_len = RPL_HDR_OPT_LEN;
422  rpl_opt->flags = 0;
423  rpl_opt->senderrank = UIP_HTONS(curr_instance.dag.rank);
424  rpl_opt->instance = curr_instance.instance_id;
425 
426  uipbuf_add_ext_hdr(RPL_HOP_BY_HOP_LEN);
427  uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
428 
429  /* Update header before returning */
430  return update_hbh_header();
431 }
432 /*---------------------------------------------------------------------------*/
433 int
435 {
436  if(!curr_instance.used
437  || uip_is_addr_linklocal(&UIP_IP_BUF->destipaddr)
438  || uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
439  return 1;
440  }
441 
442  if(rpl_dag_root_is_root()) {
443  /* At the root, remove headers if any, and insert SRH or HBH
444  * (SRH is inserted only if the destination is down the DODAG) */
446  /* Insert SRH (if needed) */
447  return insert_srh_header();
448  } else {
449  if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)
450  && UIP_IP_BUF->ttl == uip_ds6_if.cur_hop_limit) {
451  /* Insert HBH option at source. Checking the address is not sufficient because
452  * in non-storing mode, a packet may go up and then down the same path again */
453  return insert_hbh_header();
454  } else {
455  /* Update HBH option at forwarders */
456  return update_hbh_header();
457  }
458  }
459 }
460 /*---------------------------------------------------------------------------*/
461 bool
463 {
464  uint8_t *prev_proto_ptr;
465  uint8_t protocol;
466  uint16_t ext_len;
467  uint8_t *next_header;
468  struct uip_ext_hdr *ext_ptr;
469  struct uip_ext_hdr_opt *opt_ptr;
470 
471  next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true);
472  if(next_header == NULL) {
473  return true;
474  }
475  ext_ptr = (struct uip_ext_hdr *)next_header;
476  prev_proto_ptr = &UIP_IP_BUF->proto;
477 
478  while(uip_is_proto_ext_hdr(protocol)) {
479  opt_ptr = (struct uip_ext_hdr_opt *)(next_header + 2);
480  if(protocol == UIP_PROTO_ROUTING ||
481  (protocol == UIP_PROTO_HBHO && opt_ptr->type == UIP_EXT_HDR_OPT_RPL)) {
482  /* Remove ext header */
483  *prev_proto_ptr = ext_ptr->next;
484  ext_len = ext_ptr->len * 8 + 8;
485  if(uipbuf_add_ext_hdr(-ext_len) == false) {
486  return false;
487  }
488 
489  /* Update length field and move rest of packet to the "left" */
490  uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
491  if(uip_len <= next_header - uip_buf) {
492  /* No more data to move. */
493  return false;
494  }
495  memmove(next_header, next_header + ext_len,
496  uip_len - (next_header - uip_buf));
497 
498  /* Update loop variables */
499  protocol = *prev_proto_ptr;
500  } else {
501  /* move to the ext hdr */
502  next_header = uipbuf_get_next_header(next_header,
503  uip_len - (next_header - uip_buf),
504  &protocol, false);
505  if(next_header == NULL) {
506  /* Processing finished. */
507  break;
508  }
509  ext_ptr = (struct uip_ext_hdr *)next_header;
510  prev_proto_ptr = &ext_ptr->next;
511  }
512  }
513 
514  return true;
515 }
516 /** @}*/
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:116
#define UIP_IP_BUF
Direct access to IPv6 header.
Definition: uip.h:71
uint16_t uip_len
The length of the packet in the uip_buf buffer.
Definition: uip6.c:159
#define UIP_PROTO_HBHO
extension headers types
Definition: uip.h:1764
int rpl_is_addr_in_our_dag(const uip_ipaddr_t *addr)
Tells whether a given global IPv6 address is in our current DAG.
Definition: rpl-dag.c:158
int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr)
Look for next hop from SRH of current uIP packet.
int rpl_ext_header_update(void)
Adds/updates all RPL extension headers to current uIP packet.
#define UIP_LINK_MTU
The maximum transmission unit at the IP Layer.
Definition: uipopt.h:228
int rpl_dag_root_is_root(void)
Tells whether we are DAG root or not.
Definition: rpl-dag-root.c:153
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.
Source routing support.
uint16_t uip_ext_len
The length of the extension headers.
Definition: uip6.c:122
Routing driver header file
#define uip_buf
Macro to access uip_aligned_buf as an array of bytes.
Definition: uip.h:510
All information related to a RPL neighbor.
Definition: rpl-types.h:136
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Definition: uip.h:1015
uip_sr_node_t * uip_sr_get_node(void *graph, const uip_ipaddr_t *addr)
Looks up for a source routing node from its IPv6 global address.
Definition: uip-sr.c:81
#define uip_is_addr_mcast(a)
is address a multicast address, see RFC 4291 a is of type uip_ipaddr_t*
Definition: uip.h:1961
bool rpl_ext_header_remove(void)
Removes all RPL extension headers.
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
Definition: uip.h:1223
uip_ds6_netif_t uip_ds6_if
The single interface.
Definition: uip-ds6.c:75
int rpl_process_hbh(rpl_nbr_t *sender, uint16_t sender_rank, int loop_detected, int rank_error_signaled)
Processes Hop-by-Hop (HBH) Extension Header of a packet currently being forwrded. ...
Definition: rpl-dag.c:680
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.
Definition: routing.h:97
Header file for the Packet buffer (packetbuf) management
#define uip_is_addr_linklocal(a)
is addr (a) a link local unicast address, see RFC 4291 i.e.
Definition: uip.h:1877
Header file for the logging system
int uip_sr_is_addr_reachable(void *graph, const uip_ipaddr_t *addr)
Telle whether an address is reachable, i.e.
Definition: uip-sr.c:94
A node in a source routing graph, stored at the root and representing all child-parent relationship...
Definition: uip-sr.h:92
int rpl_ext_header_srh_update(void)
Process and update SRH in-place, i.e.