iPXE
ndp.h
Go to the documentation of this file.
1#ifndef _IPXE_NDP_H
2#define _IPXE_NDP_H
3
4/** @file
5 *
6 * Neighbour discovery protocol
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/in.h>
15#include <ipxe/ipv6.h>
16#include <ipxe/icmpv6.h>
17#include <ipxe/neighbour.h>
18
19/** An NDP option header */
21 /** Type */
23 /** Length (in blocks of 8 bytes) */
25} __attribute__ (( packed ));
26
27/** NDP option block size */
28#define NDP_OPTION_BLKSZ 8U
29
30/** NDP source link-layer address option */
31#define NDP_OPT_LL_SOURCE 1
32
33/** NDP target link-layer address option */
34#define NDP_OPT_LL_TARGET 2
35
36/** NDP source or target link-layer address option */
38 /** NDP option header */
40 /** Link-layer address */
42} __attribute__ (( packed ));
43
44/** NDP prefix information option */
45#define NDP_OPT_PREFIX 3
46
47/** NDP prefix information */
49 /** NDP option header */
51 /** Prefix length */
53 /** Flags */
55 /** Valid lifetime */
57 /** Preferred lifetime */
59 /** Reserved */
61 /** Prefix */
63} __attribute__ (( packed ));
64
65/** NDP on-link flag */
66#define NDP_PREFIX_ON_LINK 0x80
67
68/** NDP autonomous address configuration flag */
69#define NDP_PREFIX_AUTONOMOUS 0x40
70
71/** NDP MTU option */
72#define NDP_OPT_MTU 5
73
74/** NDP MTU */
76 /** NDP option header */
78 /** Reserved */
80 /** MTU */
82} __attribute__ (( packed ));
83
84/** NDP recursive DNS server option */
85#define NDP_OPT_RDNSS 25
86
87/** NDP recursive DNS server */
89 /** NDP option header */
91 /** Reserved */
93 /** Lifetime */
95 /** Addresses */
97} __attribute__ (( packed ));
98
99/** NDP DNS search list option */
100#define NDP_OPT_DNSSL 31
101
102/** NDP DNS search list */
104 /** NDP option header */
106 /** Reserved */
108 /** Lifetime */
110 /** Domain names */
112} __attribute__ (( packed ));
113
114/** An NDP option */
116 /** Option header */
118 /** Source or target link-layer address option */
120 /** Prefix information option */
122 /** MTU option */
124 /** Recursive DNS server option */
126 /** DNS search list option */
128} __attribute__ (( packed ));
129
130/** An NDP neighbour solicitation or advertisement header */
132 /** ICMPv6 header */
134 /** Flags */
136 /** Reserved */
138 /** Target address */
140 /** Options */
142} __attribute__ (( packed ));
143
144/** NDP router flag */
145#define NDP_NEIGHBOUR_ROUTER 0x80
146
147/** NDP solicited flag */
148#define NDP_NEIGHBOUR_SOLICITED 0x40
149
150/** NDP override flag */
151#define NDP_NEIGHBOUR_OVERRIDE 0x20
152
153/** An NDP router advertisement header */
155 /** ICMPv6 header */
157 /** Current hop limit */
159 /** Flags */
161 /** Router lifetime */
163 /** Reachable time */
165 /** Retransmission timer */
167 /** Options */
169} __attribute__ (( packed ));
170
171/** NDP managed address configuration */
172#define NDP_ROUTER_MANAGED 0x80
173
174/** NDP other configuration */
175#define NDP_ROUTER_OTHER 0x40
176
177/** An NDP router solicitation header */
179 /** ICMPv6 header */
181 /** Reserved */
183 /** Options */
185} __attribute__ (( packed ));
186
187/** An NDP header */
189 /** ICMPv6 header */
191 /** Neighbour solicitation or advertisement header */
193 /** Router solicitation header */
195 /** Router advertisement header */
197} __attribute__ (( packed ));
198
200
201/**
202 * Transmit packet, determining link-layer address via NDP
203 *
204 * @v iobuf I/O buffer
205 * @v netdev Network device
206 * @v net_dest Destination network-layer address
207 * @v net_source Source network-layer address
208 * @ret rc Return status code
209 */
210static inline int ndp_tx ( struct io_buffer *iobuf, struct net_device *netdev,
211 const void *net_dest, const void *net_source ) {
212
213 return neighbour_tx ( iobuf, netdev, &ipv6_protocol, net_dest,
214 &ndp_discovery, net_source );
215}
216
217/** NDP settings block name */
218#define NDP_SETTINGS_NAME "ndp"
219
220#endif /* _IPXE_NDP_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
static struct net_device * netdev
Definition gdbudp.c:53
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
ICMPv6 protocol.
#define __attribute__(x)
Definition compiler.h:10
IPv6 protocol.
struct neighbour_discovery ndp_discovery
NDP neighbour discovery protocol.
Definition ndp.c:162
static int ndp_tx(struct io_buffer *iobuf, struct net_device *netdev, const void *net_dest, const void *net_source)
Transmit packet, determining link-layer address via NDP.
Definition ndp.h:210
int neighbour_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, struct neighbour_discovery *discovery, const void *net_source)
Transmit packet, determining link-layer address via neighbour discovery.
Definition neighbour.c:377
Neighbour discovery.
An ICMP header.
Definition icmp.h:20
IP6 address structure.
Definition in.h:51
A persistent I/O buffer.
Definition iobuf.h:38
NDP DNS search list.
Definition ndp.h:103
uint16_t reserved
Reserved.
Definition ndp.h:107
uint32_t lifetime
Lifetime.
Definition ndp.h:109
struct ndp_option_header header
NDP option header.
Definition ndp.h:105
uint8_t names[0]
Domain names.
Definition ndp.h:111
NDP source or target link-layer address option.
Definition ndp.h:37
struct ndp_option_header header
NDP option header.
Definition ndp.h:39
uint8_t ll_addr[0]
Link-layer address.
Definition ndp.h:41
NDP MTU.
Definition ndp.h:75
struct ndp_option_header header
NDP option header.
Definition ndp.h:77
uint16_t reserved
Reserved.
Definition ndp.h:79
uint32_t mtu
MTU.
Definition ndp.h:81
An NDP neighbour solicitation or advertisement header.
Definition ndp.h:131
uint8_t reserved[3]
Reserved.
Definition ndp.h:137
struct icmp_header icmp
ICMPv6 header.
Definition ndp.h:133
uint8_t flags
Flags.
Definition ndp.h:135
union ndp_option option[0]
Options.
Definition ndp.h:141
struct in6_addr target
Target address.
Definition ndp.h:139
An NDP option header.
Definition ndp.h:20
uint8_t blocks
Length (in blocks of 8 bytes)
Definition ndp.h:24
uint8_t type
Type.
Definition ndp.h:22
NDP prefix information.
Definition ndp.h:48
uint8_t flags
Flags.
Definition ndp.h:54
uint8_t prefix_len
Prefix length.
Definition ndp.h:52
uint32_t valid
Valid lifetime.
Definition ndp.h:56
uint32_t reserved
Reserved.
Definition ndp.h:60
struct in6_addr prefix
Prefix.
Definition ndp.h:62
uint32_t preferred
Preferred lifetime.
Definition ndp.h:58
struct ndp_option_header header
NDP option header.
Definition ndp.h:50
NDP recursive DNS server.
Definition ndp.h:88
uint32_t lifetime
Lifetime.
Definition ndp.h:94
struct in6_addr addresses[0]
Addresses.
Definition ndp.h:96
struct ndp_option_header header
NDP option header.
Definition ndp.h:90
uint16_t reserved
Reserved.
Definition ndp.h:92
An NDP router advertisement header.
Definition ndp.h:154
union ndp_option option[0]
Options.
Definition ndp.h:168
uint16_t lifetime
Router lifetime.
Definition ndp.h:162
uint32_t retransmit
Retransmission timer.
Definition ndp.h:166
uint8_t hop_limit
Current hop limit.
Definition ndp.h:158
struct icmp_header icmp
ICMPv6 header.
Definition ndp.h:156
uint32_t reachable
Reachable time.
Definition ndp.h:164
An NDP router solicitation header.
Definition ndp.h:178
uint32_t reserved
Reserved.
Definition ndp.h:182
struct icmp_header icmp
ICMPv6 header.
Definition ndp.h:180
union ndp_option option[0]
Options.
Definition ndp.h:184
A neighbour discovery protocol.
Definition neighbour.h:20
A network device.
Definition netdevice.h:353
An NDP header.
Definition ndp.h:188
struct ndp_router_advertisement_header radv
Router advertisement header.
Definition ndp.h:196
struct ndp_router_solicitation_header rsol
Router solicitation header.
Definition ndp.h:194
struct ndp_neighbour_header neigh
Neighbour solicitation or advertisement header.
Definition ndp.h:192
struct icmp_header icmp
ICMPv6 header.
Definition ndp.h:190
An NDP option.
Definition ndp.h:115
struct ndp_dnssl_option dnssl
DNS search list option.
Definition ndp.h:127
struct ndp_prefix_information_option prefix
Prefix information option.
Definition ndp.h:121
struct ndp_rdnss_option rdnss
Recursive DNS server option.
Definition ndp.h:125
struct ndp_mtu_option mtu
MTU option.
Definition ndp.h:123
struct ndp_option_header header
Option header.
Definition ndp.h:117
struct ndp_ll_addr_option ll_addr
Source or target link-layer address option.
Definition ndp.h:119