Loading...
Searching...
No Matches
ndp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <stdint.h>
21
22#include "byteorder.h"
23#include "net/ipv6/addr.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
34#define NDP_RTR_ADV_FLAGS_MASK (0xc0)
35#define NDP_RTR_ADV_FLAGS_M (0x80)
36#define NDP_RTR_ADV_FLAGS_O (0x40)
40
46#define NDP_RTR_ADV_CUR_HL_UNSPEC (0)
47
52#define NDP_RTR_ADV_LTIME_SEC_MAX (9000)
53
58#define NDP_NBR_ADV_LTIME_NOT_DR (0)
59
60#define NDP_NBR_ADV_REACH_TIME (0)
61#define NDP_NBR_ADV_RETRANS_TIMER (0)
63
69#define NDP_NBR_ADV_FLAGS_MASK (0xe0)
70#define NDP_NBR_ADV_FLAGS_R (0x80)
71#define NDP_NBR_ADV_FLAGS_S (0x40)
72#define NDP_NBR_ADV_FLAGS_O (0x20)
76
83#define NDP_OPT_SL2A (1)
84#define NDP_OPT_TL2A (2)
85#define NDP_OPT_PI (3)
86#define NDP_OPT_RH (4)
87#define NDP_OPT_MTU (5)
88#define NDP_OPT_RI (24)
89#define NDP_OPT_RDNSS (25)
90#define NDP_OPT_AR (33)
91#define NDP_OPT_6CTX (34)
92#define NDP_OPT_ABR (35)
94
99#define NDP_OPT_PI_FLAGS_MASK (0xc0)
100#define NDP_OPT_PI_FLAGS_L (0x80)
101#define NDP_OPT_PI_FLAGS_A (0x40)
103
108#define NDP_OPT_RI_FLAGS_MASK (0x18)
109#define NDP_OPT_RI_FLAGS_PRF_NONE (0x10)
110#define NDP_OPT_RI_FLAGS_PRF_NEG (0x18)
111#define NDP_OPT_RI_FLAGS_PRF_ZERO (0x0)
112#define NDP_OPT_RI_FLAGS_PRF_POS (0x8)
114
120#define NDP_OPT_PI_VALID_LTIME_INF (UINT32_MAX)
121#define NDP_OPT_PI_PREF_LTIME_INF (UINT32_MAX)
123
129#define NDP_OPT_PI_LEN (4U)
130#define NDP_OPT_MTU_LEN (1U)
132
137#define NDP_OPT_RDNSS_MIN_LEN (3U)
138
145#define NDP_MAX_INIT_RA_INTERVAL (16000U)
146#define NDP_MAX_INIT_RA_NUMOF (3U)
147#define NDP_MAX_FIN_RA_NUMOF (3U)
148#define NDP_MIN_MS_DELAY_BETWEEN_RAS (3000U)
149#define NDP_MAX_RA_DELAY (500U)
150#define NDP_MAX_RA_INTERVAL_MS (600000U)
151#define NDP_MIN_RA_INTERVAL_MS (198000U)
152#define NDP_RTR_LTIME_SEC (1800U)
154
160#define NDP_MAX_RS_MS_DELAY (1000U)
161#define NDP_RS_MS_INTERVAL (4000U)
162#define NDP_MAX_RS_NUMOF (3U)
164
170#define NDP_MAX_MC_SOL_NUMOF (3U)
171#define NDP_MAX_UC_SOL_NUMOF (3U)
172
180#define NDP_DAD_TRANSMIT_NUMOF (1U)
181#define NDP_MAX_ANYCAST_MS_DELAY (1000U)
182#define NDP_MAX_NA_NUMOF (3U)
183#define NDP_REACH_MS (30000U)
184#define NDP_RETRANS_TIMER_MS (1000U)
190#define NDP_MAX_RETRANS_TIMER_MS (60000U)
191
199#define NDP_MAX_NS_NUMOF (17U)
200#define NDP_DELAY_FIRST_PROBE_MS (5000U)
201#define NDP_MIN_RANDOM_FACTOR (500U)
202#define NDP_MAX_RANDOM_FACTOR (1500U)
204
215#define NDP_HOP_LIMIT (255U)
216
223typedef struct __attribute__((packed)) {
224 uint8_t type;
225 uint8_t code;
229
246
253typedef struct __attribute__((packed)) {
254 uint8_t type;
255 uint8_t code;
260
267typedef struct __attribute__((packed)) {
268 uint8_t type;
269 uint8_t code;
271 uint8_t flags;
272 uint8_t resv[3];
275
282typedef struct __attribute__((packed)) {
283 uint8_t type;
284 uint8_t code;
290
295typedef struct __attribute__((packed)) {
296 uint8_t type;
297 uint8_t len;
298} ndp_opt_t;
299
300/* XXX: slla and tlla are just ndp_opt_t with variable link layer address
301 * appended */
302
319
326typedef struct __attribute__((packed)) {
327 uint8_t type;
328 uint8_t len;
329 uint8_t prefix_len;
330 uint8_t flags;
334
341typedef struct __attribute__((packed)) {
342 uint8_t type;
343 uint8_t len;
344 uint8_t resv[6];
346
353typedef struct __attribute__((packed)) {
354 uint8_t type;
355 uint8_t len;
359
367typedef struct __attribute__((packed)) {
368 uint8_t type;
369 uint8_t len;
373
374#ifndef __cplusplus
383typedef struct __attribute__((packed)) {
384 uint8_t type;
385 uint8_t len;
390#endif
391
392#ifdef __cplusplus
393}
394#endif
395
Functions to work with different byte orders.
be_uint32_t network_uint32_t
A 32 bit integer in network byte order.
Definition byteorder.h:109
be_uint16_t network_uint16_t
A 16 bit integer in network byte order.
Definition byteorder.h:104
Definitions for IPv6 addresses.
Neighbor advertisement message format.
Definition ndp.h:267
uint8_t resv[3]
reserved fields
Definition ndp.h:272
network_uint16_t csum
checksum
Definition ndp.h:270
ipv6_addr_t tgt
target address
Definition ndp.h:273
uint8_t code
message code
Definition ndp.h:269
uint8_t flags
flags
Definition ndp.h:271
uint8_t type
message type
Definition ndp.h:268
Neighbor solicitation message format.
Definition ndp.h:253
uint8_t type
message type
Definition ndp.h:254
network_uint16_t csum
checksum
Definition ndp.h:256
network_uint32_t resv
reserved field
Definition ndp.h:257
uint8_t code
message code
Definition ndp.h:255
ipv6_addr_t tgt
target address
Definition ndp.h:258
MTU option format.
Definition ndp.h:353
uint8_t type
option type
Definition ndp.h:354
network_uint16_t resv
reserved field
Definition ndp.h:356
network_uint32_t mtu
MTU.
Definition ndp.h:357
uint8_t len
length in units of 8 octets
Definition ndp.h:355
Prefix information option format.
Definition ndp.h:309
uint8_t flags
flags
Definition ndp.h:313
uint8_t type
option type
Definition ndp.h:310
uint8_t prefix_len
prefix length
Definition ndp.h:312
network_uint32_t pref_ltime
preferred lifetime
Definition ndp.h:315
network_uint32_t resv
reserved field
Definition ndp.h:316
network_uint32_t valid_ltime
valid lifetime
Definition ndp.h:314
uint8_t len
length in units of 8 octets
Definition ndp.h:311
ipv6_addr_t prefix
prefix
Definition ndp.h:317
Recursive DNS server option format with payload.
Definition ndp.h:383
uint8_t type
option type
Definition ndp.h:384
ipv6_addr_t addrs[]
addresses of IPv6 recursive DNS servers
Definition ndp.h:388
network_uint16_t resv
reserved field
Definition ndp.h:386
uint8_t len
length in units of 8 octets
Definition ndp.h:385
network_uint32_t ltime
lifetime in seconds
Definition ndp.h:387
Recursive DNS server option format without payload.
Definition ndp.h:367
uint8_t type
option type
Definition ndp.h:368
network_uint16_t resv
reserved field
Definition ndp.h:370
uint8_t len
length in units of 8 octets
Definition ndp.h:369
network_uint32_t ltime
lifetime in seconds
Definition ndp.h:371
Redirected header option format.
Definition ndp.h:341
uint8_t len
length in units of 8 octets
Definition ndp.h:343
uint8_t type
option type
Definition ndp.h:342
uint8_t resv[6]
reserved field
Definition ndp.h:344
Route information option format.
Definition ndp.h:326
uint8_t prefix_len
prefix length
Definition ndp.h:329
network_uint32_t route_ltime
route lifetime
Definition ndp.h:331
uint8_t len
length in units of 8 octets
Definition ndp.h:328
uint8_t type
option type
Definition ndp.h:327
ipv6_addr_t prefix
prefix
Definition ndp.h:332
uint8_t flags
flags
Definition ndp.h:330
General NDP option format.
Definition ndp.h:295
uint8_t len
length in units of 8 octets
Definition ndp.h:297
uint8_t type
option type
Definition ndp.h:296
Redirect message format.
Definition ndp.h:282
ipv6_addr_t tgt
target address
Definition ndp.h:287
uint8_t code
message code
Definition ndp.h:284
uint8_t type
message type
Definition ndp.h:283
ipv6_addr_t dst
destination address
Definition ndp.h:288
network_uint32_t resv
reserved field
Definition ndp.h:286
network_uint16_t csum
checksum
Definition ndp.h:285
Router advertisement message format.
Definition ndp.h:236
uint8_t code
message code
Definition ndp.h:238
uint8_t flags
flags
Definition ndp.h:241
network_uint32_t reach_time
reachable time
Definition ndp.h:243
network_uint16_t csum
checksum
Definition ndp.h:239
uint8_t type
message type
Definition ndp.h:237
uint8_t cur_hl
current hop limit
Definition ndp.h:240
network_uint32_t retrans_timer
retransmission timer
Definition ndp.h:244
network_uint16_t ltime
router lifetime
Definition ndp.h:242
Router solicitation message format.
Definition ndp.h:223
network_uint16_t csum
checksum
Definition ndp.h:226
network_uint32_t resv
reserved field
Definition ndp.h:227
uint8_t type
message type
Definition ndp.h:224
uint8_t code
message code
Definition ndp.h:225
Data type to represent an IPv6 address.
Definition addr.h:64