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_AR (33)
92 #define NDP_OPT_6CTX (34)
93 #define NDP_OPT_ABR (35)
100 #define NDP_OPT_PI_FLAGS_MASK (0xc0)
101 #define NDP_OPT_PI_FLAGS_L (0x80)
102 #define NDP_OPT_PI_FLAGS_A (0x40)
110 #define NDP_OPT_PI_VALID_LTIME_INF (UINT32_MAX)
111 #define NDP_OPT_PI_PREF_LTIME_INF (UINT32_MAX)
119 #define NDP_OPT_PI_LEN (4U)
120 #define NDP_OPT_MTU_LEN (1U)
121 
129 #define NDP_MAX_INIT_RA_INTERVAL (16000U)
130 #define NDP_MAX_INIT_RA_NUMOF (3U)
131 #define NDP_MAX_FIN_RA_NUMOF (3U)
132 #define NDP_MIN_MS_DELAY_BETWEEN_RAS (3000U)
133 #define NDP_MAX_RA_DELAY (500U)
134 #define NDP_MAX_RA_INTERVAL_MS (600000U)
135 #define NDP_MIN_RA_INTERVAL_MS (198000U)
136 #define NDP_RTR_LTIME_SEC (1800U)
144 #define NDP_MAX_RS_MS_DELAY (1000U)
145 #define NDP_RS_MS_INTERVAL (4000U)
146 #define NDP_MAX_RS_NUMOF (3U)
154 #define NDP_MAX_MC_SOL_NUMOF (3U)
155 #define NDP_MAX_UC_SOL_NUMOF (3U)
162 #define NDP_DAD_TRANSMIT_NUMOF (1U)
163 #define NDP_MAX_ANYCAST_MS_DELAY (1000U)
164 #define NDP_MAX_NA_NUMOF (3U)
165 #define NDP_REACH_MS (30000U)
166 #define NDP_RETRANS_TIMER_MS (1000U)
172 #define NDP_MAX_RETRANS_TIMER_MS (60000U)
173 
181 #define NDP_MAX_NS_NUMOF (17U)
182 #define NDP_DELAY_FIRST_PROBE_MS (5000U)
183 #define NDP_MIN_RANDOM_FACTOR (500U)
184 #define NDP_MAX_RANDOM_FACTOR (1500U)
193 typedef struct __attribute__((packed)) {
194  uint8_t type;
195  uint8_t code;
198 } ndp_rtr_sol_t;
199 
206 typedef struct __attribute__((packed)) {
207  uint8_t type;
208  uint8_t code;
210  uint8_t cur_hl;
211  uint8_t flags;
215 } ndp_rtr_adv_t;
216 
223 typedef struct __attribute__((packed)) {
224  uint8_t type;
225  uint8_t code;
229 } ndp_nbr_sol_t;
230 
237 typedef struct __attribute__((packed)) {
238  uint8_t type;
239  uint8_t code;
241  uint8_t flags;
242  uint8_t resv[3];
244 } ndp_nbr_adv_t;
245 
252 typedef struct __attribute__((packed)) {
253  uint8_t type;
254  uint8_t code;
260 
265 typedef struct __attribute__((packed)) {
266  uint8_t type;
267  uint8_t len;
268 } ndp_opt_t;
269 
270 /* XXX: slla and tlla are just ndp_opt_t with variable link layer address
271  * appended */
272 
279 typedef struct __attribute__((packed)) {
280  uint8_t type;
281  uint8_t len;
282  uint8_t prefix_len;
283  uint8_t flags;
288 } ndp_opt_pi_t;
289 
296 typedef struct __attribute__((packed)) {
297  uint8_t type;
298  uint8_t len;
299  uint8_t resv[6];
300 } ndp_opt_rh_t;
301 
308 typedef struct __attribute__((packed)) {
309  uint8_t type;
310  uint8_t len;
313 } ndp_opt_mtu_t;
314 
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 
320 #endif /* NET_NDP_H */
321 
network_uint32_t mtu
MTU.
Definition: ndp.h:312
uint8_t type
message type
Definition: ndp.h:194
Definitions for IPv6 addresses.
network_uint16_t csum
checksum
Definition: ndp.h:240
Prefix information option format.
Definition: ndp.h:279
Neighbor solicitation message format.
Definition: ndp.h:223
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:86
Neighbor advertisement message format.
Definition: ndp.h:237
uint8_t code
message code
Definition: ndp.h:225
MTU option format.
Definition: ndp.h:308
uint8_t type
option type
Definition: ndp.h:280
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:76
network_uint32_t pref_ltime
preferred lifetime
Definition: ndp.h:285
Redirected header option format.
Definition: ndp.h:296
uint8_t flags
flags
Definition: ndp.h:241
uint8_t cur_hl
current hop limit
Definition: ndp.h:210
uint8_t type
message type
Definition: ndp.h:253
network_uint16_t csum
checksum
Definition: ndp.h:255
General NDP option format.
Definition: ndp.h:265
network_uint32_t resv
reserved field
Definition: ndp.h:197
uint8_t flags
flags
Definition: ndp.h:211
uint8_t type
option type
Definition: ndp.h:309
uint8_t len
length in units of 8 octets
Definition: ndp.h:267
uint8_t type
option type
Definition: ndp.h:297
Router advertisement message format.
Definition: ndp.h:206
Redirect message format.
Definition: ndp.h:252
network_uint16_t csum
checksum
Definition: ndp.h:226
uint8_t prefix_len
prefix length
Definition: ndp.h:282
uint8_t type
message type
Definition: ndp.h:224
uint8_t type
message type
Definition: ndp.h:207
network_uint32_t resv
reserved field
Definition: ndp.h:286
ipv6_addr_t dst
destination address
Definition: ndp.h:258
network_uint32_t retrans_timer
retransmission timer
Definition: ndp.h:214
network_uint32_t reach_time
reachable time
Definition: ndp.h:213
ipv6_addr_t tgt
target address
Definition: ndp.h:257
network_uint32_t resv
reserved field
Definition: ndp.h:227
uint8_t code
message code
Definition: ndp.h:195
ipv6_addr_t tgt
target address
Definition: ndp.h:243
network_uint32_t valid_ltime
valid lifetime
Definition: ndp.h:284
Functions to work with different byte orders.
uint8_t type
option type
Definition: ndp.h:266
Router solicitation message format.
Definition: ndp.h:193
ipv6_addr_t prefix
prefix
Definition: ndp.h:287
uint8_t code
message code
Definition: ndp.h:208
uint8_t len
length in units of 8 octets
Definition: ndp.h:310
ipv6_addr_t tgt
target address
Definition: ndp.h:228
uint8_t type
message type
Definition: ndp.h:238
network_uint32_t resv
reserved field
Definition: ndp.h:256
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
network_uint16_t resv
reserved field
Definition: ndp.h:311
uint8_t code
message code
Definition: ndp.h:239
uint8_t flags
flags
Definition: ndp.h:283
network_uint16_t csum
checksum
Definition: ndp.h:196
network_uint16_t ltime
router lifetime
Definition: ndp.h:212
uint8_t code
message code
Definition: ndp.h:254
uint8_t len
length in units of 8 octets
Definition: ndp.h:298
uint8_t len
length in units of 8 octets
Definition: ndp.h:281
network_uint16_t csum
checksum
Definition: ndp.h:209