Contiki-NG
rpl-icmp6.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Inria.
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  * Header file for rpl-ext-header
38  *
39  * \author Simon Duquennoy <simon.duquennoy@inria.fr>
40  */
41 
42  #ifndef RPL_ICMP6_H_
43  #define RPL_ICMP6_H_
44 
45 #include "uip.h"
46 #include "uip-ds6.h"
47 #include "uip-ds6-nbr.h"
48 
49 /********** Data structures **********/
50 
51 /* Logical representation of a DAG Information Object (DIO.) */
52 struct rpl_dio {
53  uip_ipaddr_t dag_id;
54  rpl_ocp_t ocp;
55  rpl_rank_t rank;
56  uint8_t grounded;
57  uint8_t mop;
58  uint8_t preference;
59  uint8_t version;
60  uint8_t instance_id;
61  uint8_t dtsn;
62  uint8_t dag_intdoubl;
63  uint8_t dag_intmin;
64  uint8_t dag_redund;
65  uint8_t default_lifetime;
66  uint16_t lifetime_unit;
67  rpl_rank_t dag_max_rankinc;
68  rpl_rank_t dag_min_hoprankinc;
69  rpl_prefix_t destination_prefix;
70  rpl_prefix_t prefix_info;
71  struct rpl_metric_container mc;
72 };
73 typedef struct rpl_dio rpl_dio_t;
74 
75 /* Logical representation of a Destination Advertisement Object (DAO.) */
76 struct rpl_dao {
77  uip_ipaddr_t parent_addr;
78  uip_ipaddr_t prefix;
79  uint16_t sequence;
80  uint8_t instance_id;
81  uint8_t lifetime;
82  uint8_t prefixlen;
83  uint8_t flags;
84 };
85 typedef struct rpl_dao rpl_dao_t;
86 
87 /********** Public functions **********/
88 
89 /**
90  * Updates IPv6 neighbor cache on incoming link-local RPL ICMPv6 messages.
91  *
92  * \param from The source link-local IPv6 address
93  * \param reason What triggered the update (maps to RPL packet types)
94  * \param data Generic pointer, used for instance to store parsed DIO data
95  * \return A pointer to the new neighbor cache entry, NULL if there was no space left.
96 */
97 uip_ds6_nbr_t *rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void *data);
98 
99 /**
100  * Creates an ICMPv6 DIS packet and sends it. Can be unicast or multicast.
101  *
102  * \param addr The link-local address of the target host, if any.
103  * Else, a multicast DIS will be sent.
104 */
105 void rpl_icmp6_dis_output(uip_ipaddr_t *addr);
106 
107 /**
108  * Creates an ICMPv6 DIO packet and sends it. Can be unicast or multicast
109  *
110  * \param uc_addr The link-local address of the target host, if any.
111  * Else, a multicast DIO will be sent.
112 */
113 void rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr);
114 
115 /**
116  * Creates an ICMPv6 DAO packet and sends it to the root, advertising the
117  * current preferred parent, and with our global address as prefix.
118  *
119  * \param lifetime The DAO lifetime. Use 0 to send a No-path DAO
120 */
121 void rpl_icmp6_dao_output(uint8_t lifetime);
122 
123 /**
124  * Creates an ICMPv6 DAO-ACK packet and sends it to the originator
125  * of the ACK.
126  *
127  * \param dest The DAO-ACK destination (was source of the DAO)
128  * \param sequence The sequence number of the DAO being ACKed
129  * \param status The status of the DAO-ACK (see RPL_DAO_ACK_* defines)
130 */
131 void rpl_icmp6_dao_ack_output(uip_ipaddr_t *dest, uint8_t sequence, uint8_t status);
132 
133 /**
134  * Initializes rpl-icmp6 module, registers ICMPv6 handlers for all
135  * RPL ICMPv6 messages: DIO, DIS, DAO and DAO-ACK
136 */
137 void rpl_icmp6_init(void);
138 
139  /** @} */
140 
141 #endif /* RPL_ICMP6_H_ */
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:107
IPv6 Neighbor cache (link-layer/IPv6 address mapping)
RPL prefix information.
Definition: rpl.h:126
void rpl_icmp6_dao_output(uint8_t lifetime)
Creates an ICMPv6 DAO packet and sends it to the root, advertising the current preferred parent...
Definition: rpl-icmp6.c:543
Header file for IPv6-related data structures.
uip_ds6_nbr_t * rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void *data)
Updates IPv6 neighbor cache on incoming link-local RPL ICMPv6 messages.
Definition: rpl-icmp6.c:194
Logical representation of a DAG Metric Container.
Definition: rpl.h:95
Header file for the uIP TCP/IP stack.
void rpl_icmp6_dao_ack_output(uip_ipaddr_t *dest, uint8_t sequence, uint8_t status)
Creates an ICMPv6 DAO-ACK packet and sends it to the originator of the ACK.
void rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
Creates an ICMPv6 DIO packet and sends it.
Definition: rpl-icmp6.c:332
void rpl_icmp6_init()
Initializes rpl-icmp6 module, registers ICMPv6 handlers for all RPL ICMPv6 messages: DIO...
Definition: rpl-icmp6.c:677
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...
Definition: uip-ds6-nbr.h:105
void rpl_icmp6_dis_output(uip_ipaddr_t *addr)
Creates an ICMPv6 DIS packet and sends it.
Definition: rpl-icmp6.c:150