ndp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef NET_NDP_H
21 #define NET_NDP_H
22 
23 #include <stdint.h>
24 
25 #include "byteorder.h"
26 #include "net/ipv6/addr.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 #define NDP_RTR_ADV_FLAGS_MASK (0xc0)
38 #define NDP_RTR_ADV_FLAGS_M (0x80)
39 #define NDP_RTR_ADV_FLAGS_O (0x40)
49 #define NDP_RTR_ADV_CUR_HL_UNSPEC (0)
55 #define NDP_RTR_ADV_LTIME_SEC_MAX (9000)
56 
61 #define NDP_NBR_ADV_LTIME_NOT_DR (0)
62 
63 #define NDP_NBR_ADV_REACH_TIME (0)
64 #define NDP_NBR_ADV_RETRANS_TIMER (0)
72 #define NDP_NBR_ADV_FLAGS_MASK (0xe0)
73 #define NDP_NBR_ADV_FLAGS_R (0x80)
74 #define NDP_NBR_ADV_FLAGS_S (0x40)
75 #define NDP_NBR_ADV_FLAGS_O (0x20)
86 #define NDP_OPT_SL2A (1)
87 #define NDP_OPT_TL2A (2)
88 #define NDP_OPT_PI (3)
89 #define NDP_OPT_RH (4)
90 #define NDP_OPT_MTU (5)
91 #define NDP_OPT_RDNSS (25)
92 #define NDP_OPT_AR (33)
93 #define NDP_OPT_6CTX (34)
94 #define NDP_OPT_ABR (35)
101 #define NDP_OPT_PI_FLAGS_MASK (0xc0)
102 #define NDP_OPT_PI_FLAGS_L (0x80)
103 #define NDP_OPT_PI_FLAGS_A (0x40)
111 #define NDP_OPT_PI_VALID_LTIME_INF (UINT32_MAX)
112 #define NDP_OPT_PI_PREF_LTIME_INF (UINT32_MAX)
120 #define NDP_OPT_PI_LEN (4U)
121 #define NDP_OPT_MTU_LEN (1U)
122 
128 #define NDP_OPT_RDNSS_MIN_LEN (3U)
129 
136 #define NDP_MAX_INIT_RA_INTERVAL (16000U)
137 #define NDP_MAX_INIT_RA_NUMOF (3U)
138 #define NDP_MAX_FIN_RA_NUMOF (3U)
139 #define NDP_MIN_MS_DELAY_BETWEEN_RAS (3000U)
140 #define NDP_MAX_RA_DELAY (500U)
141 #define NDP_MAX_RA_INTERVAL_MS (600000U)
142 #define NDP_MIN_RA_INTERVAL_MS (198000U)
143 #define NDP_RTR_LTIME_SEC (1800U)
151 #define NDP_MAX_RS_MS_DELAY (1000U)
152 #define NDP_RS_MS_INTERVAL (4000U)
153 #define NDP_MAX_RS_NUMOF (3U)
161 #define NDP_MAX_MC_SOL_NUMOF (3U)
162 #define NDP_MAX_UC_SOL_NUMOF (3U)
171 #define NDP_DAD_TRANSMIT_NUMOF (1U)
172 #define NDP_MAX_ANYCAST_MS_DELAY (1000U)
173 #define NDP_MAX_NA_NUMOF (3U)
174 #define NDP_REACH_MS (30000U)
175 #define NDP_RETRANS_TIMER_MS (1000U)
181 #define NDP_MAX_RETRANS_TIMER_MS (60000U)
182 
190 #define NDP_MAX_NS_NUMOF (17U)
191 #define NDP_DELAY_FIRST_PROBE_MS (5000U)
192 #define NDP_MIN_RANDOM_FACTOR (500U)
193 #define NDP_MAX_RANDOM_FACTOR (1500U)
206 #define NDP_HOP_LIMIT (255U)
207 
214 typedef struct __attribute__((packed)) {
215  uint8_t type;
216  uint8_t code;
219 } ndp_rtr_sol_t;
220 
227 typedef struct __attribute__((packed)) {
228  uint8_t type;
229  uint8_t code;
231  uint8_t cur_hl;
232  uint8_t flags;
236 } ndp_rtr_adv_t;
237 
244 typedef struct __attribute__((packed)) {
245  uint8_t type;
246  uint8_t code;
250 } ndp_nbr_sol_t;
251 
258 typedef struct __attribute__((packed)) {
259  uint8_t type;
260  uint8_t code;
262  uint8_t flags;
263  uint8_t resv[3];
265 } ndp_nbr_adv_t;
266 
273 typedef struct __attribute__((packed)) {
274  uint8_t type;
275  uint8_t code;
281 
286 typedef struct __attribute__((packed)) {
287  uint8_t type;
288  uint8_t len;
289 } ndp_opt_t;
290 
291 /* XXX: slla and tlla are just ndp_opt_t with variable link layer address
292  * appended */
293 
300 typedef struct __attribute__((packed)) {
301  uint8_t type;
302  uint8_t len;
303  uint8_t prefix_len;
304  uint8_t flags;
309 } ndp_opt_pi_t;
310 
317 typedef struct __attribute__((packed)) {
318  uint8_t type;
319  uint8_t len;
320  uint8_t resv[6];
321 } ndp_opt_rh_t;
322 
329 typedef struct __attribute__((packed)) {
330  uint8_t type;
331  uint8_t len;
334 } ndp_opt_mtu_t;
335 
343 typedef struct __attribute__((packed)) {
344  uint8_t type;
345  uint8_t len;
349 
350 #ifndef __cplusplus
351 
359 typedef struct __attribute__((packed)) {
360  uint8_t type;
361  uint8_t len;
364  ipv6_addr_t addrs[];
366 #endif
367 
368 #ifdef __cplusplus
369 }
370 #endif
371 
372 #endif /* NET_NDP_H */
373 
ndp_opt_pi_t
Prefix information option format.
Definition: ndp.h:300
ndp_redirect_t
Redirect message format.
Definition: ndp.h:273
ndp_opt_rh_t
Redirected header option format.
Definition: ndp.h:317
ndp_opt_rh_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:319
ndp_opt_rdnss_t
Recursive DNS server option format without payload.
Definition: ndp.h:343
ndp_rtr_adv_t::csum
network_uint16_t csum
checksum
Definition: ndp.h:230
be_uint32_t
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:87
ndp_nbr_adv_t::type
uint8_t type
message type
Definition: ndp.h:259
ndp_redirect_t::code
uint8_t code
message code
Definition: ndp.h:275
ndp_opt_pi_t::pref_ltime
network_uint32_t pref_ltime
preferred lifetime
Definition: ndp.h:306
ndp_opt_mtu_t::type
uint8_t type
option type
Definition: ndp.h:330
ndp_rtr_sol_t::type
uint8_t type
message type
Definition: ndp.h:215
ndp_opt_rdnss_impl_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:361
byteorder.h
Functions to work with different byte orders.
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
ndp_opt_rdnss_impl_t
Recursive DNS server option format with payload.
Definition: ndp.h:359
ipv6_addr_t
Data type to represent an IPv6 address.
Definition: addr.h:74
ndp_opt_t::type
uint8_t type
option type
Definition: ndp.h:287
ndp_opt_rdnss_impl_t::ltime
network_uint32_t ltime
lifetime in seconds
Definition: ndp.h:363
ndp_nbr_adv_t
Neighbor advertisement message format.
Definition: ndp.h:258
ndp_nbr_adv_t::flags
uint8_t flags
flags
Definition: ndp.h:262
ndp_nbr_sol_t::csum
network_uint16_t csum
checksum
Definition: ndp.h:247
addr.h
Definitions for IPv6 addresses.
ndp_opt_mtu_t::resv
network_uint16_t resv
reserved field
Definition: ndp.h:332
ndp_rtr_adv_t::cur_hl
uint8_t cur_hl
current hop limit
Definition: ndp.h:231
ndp_opt_rdnss_impl_t::resv
network_uint16_t resv
reserved field
Definition: ndp.h:362
ndp_rtr_sol_t
Router solicitation message format.
Definition: ndp.h:214
ndp_rtr_sol_t::resv
network_uint32_t resv
reserved field
Definition: ndp.h:218
ndp_rtr_adv_t::flags
uint8_t flags
flags
Definition: ndp.h:232
ndp_opt_rdnss_impl_t::type
uint8_t type
option type
Definition: ndp.h:360
ndp_redirect_t::type
uint8_t type
message type
Definition: ndp.h:274
ndp_opt_rh_t::type
uint8_t type
option type
Definition: ndp.h:318
ndp_opt_pi_t::type
uint8_t type
option type
Definition: ndp.h:301
ndp_redirect_t::tgt
ipv6_addr_t tgt
target address
Definition: ndp.h:278
ndp_redirect_t::csum
network_uint16_t csum
checksum
Definition: ndp.h:276
ndp_rtr_adv_t::type
uint8_t type
message type
Definition: ndp.h:228
ndp_opt_rdnss_t::type
uint8_t type
option type
Definition: ndp.h:344
ndp_redirect_t::dst
ipv6_addr_t dst
destination address
Definition: ndp.h:279
ndp_nbr_sol_t::tgt
ipv6_addr_t tgt
target address
Definition: ndp.h:249
ndp_opt_pi_t::prefix_len
uint8_t prefix_len
prefix length
Definition: ndp.h:303
ndp_nbr_sol_t
Neighbor solicitation message format.
Definition: ndp.h:244
ndp_opt_mtu_t
MTU option format.
Definition: ndp.h:329
ndp_rtr_adv_t::retrans_timer
network_uint32_t retrans_timer
retransmission timer
Definition: ndp.h:235
ndp_opt_pi_t::prefix
ipv6_addr_t prefix
prefix
Definition: ndp.h:308
ndp_nbr_adv_t::tgt
ipv6_addr_t tgt
target address
Definition: ndp.h:264
ndp_rtr_sol_t::code
uint8_t code
message code
Definition: ndp.h:216
ndp_opt_rdnss_t::ltime
network_uint32_t ltime
lifetime in seconds
Definition: ndp.h:347
ndp_rtr_adv_t
Router advertisement message format.
Definition: ndp.h:227
ndp_opt_pi_t::resv
network_uint32_t resv
reserved field
Definition: ndp.h:307
ndp_rtr_adv_t::reach_time
network_uint32_t reach_time
reachable time
Definition: ndp.h:234
ndp_rtr_adv_t::ltime
network_uint16_t ltime
router lifetime
Definition: ndp.h:233
ndp_opt_mtu_t::mtu
network_uint32_t mtu
MTU.
Definition: ndp.h:333
ndp_opt_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:288
ndp_opt_rdnss_t::resv
network_uint16_t resv
reserved field
Definition: ndp.h:346
ndp_opt_mtu_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:331
ndp_nbr_sol_t::code
uint8_t code
message code
Definition: ndp.h:246
ndp_redirect_t::resv
network_uint32_t resv
reserved field
Definition: ndp.h:277
ndp_opt_pi_t::valid_ltime
network_uint32_t valid_ltime
valid lifetime
Definition: ndp.h:305
ndp_rtr_adv_t::code
uint8_t code
message code
Definition: ndp.h:229
ndp_rtr_sol_t::csum
network_uint16_t csum
checksum
Definition: ndp.h:217
ndp_opt_rdnss_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:345
ndp_nbr_sol_t::type
uint8_t type
message type
Definition: ndp.h:245
ndp_opt_t
General NDP option format.
Definition: ndp.h:286
ndp_nbr_adv_t::csum
network_uint16_t csum
checksum
Definition: ndp.h:261
ndp_opt_pi_t::flags
uint8_t flags
flags
Definition: ndp.h:304
ndp_opt_pi_t::len
uint8_t len
length in units of 8 octets
Definition: ndp.h:302
ndp_nbr_sol_t::resv
network_uint32_t resv
reserved field
Definition: ndp.h:248
ndp_nbr_adv_t::code
uint8_t code
message code
Definition: ndp.h:260