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 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_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 */
62  struct in6_addr 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 recursive DNS server option */
72 #define NDP_OPT_RDNSS 25
73 
74 /** NDP recursive DNS server */
76  /** NDP option header */
78  /** Reserved */
80  /** Lifetime */
82  /** Addresses */
83  struct in6_addr addresses[0];
84 } __attribute__ (( packed ));
85 
86 /** NDP DNS search list option */
87 #define NDP_OPT_DNSSL 31
88 
89 /** NDP DNS search list */
91  /** NDP option header */
93  /** Reserved */
95  /** Lifetime */
97  /** Domain names */
99 } __attribute__ (( packed ));
100 
101 /** An NDP option */
102 union ndp_option {
103  /** Option header */
105  /** Source or target link-layer address option */
107  /** Prefix information option */
109  /** Recursive DNS server option */
111  /** DNS search list option */
113 } __attribute__ (( packed ));
114 
115 /** An NDP neighbour solicitation or advertisement header */
117  /** ICMPv6 header */
119  /** Flags */
121  /** Reserved */
123  /** Target address */
124  struct in6_addr target;
125  /** Options */
126  union ndp_option option[0];
127 } __attribute__ (( packed ));
128 
129 /** NDP router flag */
130 #define NDP_NEIGHBOUR_ROUTER 0x80
131 
132 /** NDP solicited flag */
133 #define NDP_NEIGHBOUR_SOLICITED 0x40
134 
135 /** NDP override flag */
136 #define NDP_NEIGHBOUR_OVERRIDE 0x20
137 
138 /** An NDP router advertisement header */
140  /** ICMPv6 header */
142  /** Current hop limit */
144  /** Flags */
146  /** Router lifetime */
148  /** Reachable time */
150  /** Retransmission timer */
152  /** Options */
153  union ndp_option option[0];
154 } __attribute__ (( packed ));
155 
156 /** NDP managed address configuration */
157 #define NDP_ROUTER_MANAGED 0x80
158 
159 /** NDP other configuration */
160 #define NDP_ROUTER_OTHER 0x40
161 
162 /** An NDP router solicitation header */
164  /** ICMPv6 header */
166  /** Reserved */
168  /** Options */
169  union ndp_option option[0];
170 } __attribute__ (( packed ));
171 
172 /** An NDP header */
173 union ndp_header {
174  /** ICMPv6 header */
176  /** Neighbour solicitation or advertisement header */
178  /** Router solicitation header */
180  /** Router advertisement header */
182 } __attribute__ (( packed ));
183 
184 extern struct neighbour_discovery ndp_discovery;
185 
186 /**
187  * Transmit packet, determining link-layer address via NDP
188  *
189  * @v iobuf I/O buffer
190  * @v netdev Network device
191  * @v net_dest Destination network-layer address
192  * @v net_source Source network-layer address
193  * @ret rc Return status code
194  */
195 static inline int ndp_tx ( struct io_buffer *iobuf, struct net_device *netdev,
196  const void *net_dest, const void *net_source ) {
197 
198  return neighbour_tx ( iobuf, netdev, &ipv6_protocol, net_dest,
199  &ndp_discovery, net_source );
200 }
201 
202 /** NDP settings block name */
203 #define NDP_SETTINGS_NAME "ndp"
204 
205 #endif /* _IPXE_NDP_H */
uint32_t valid
Valid lifetime.
Definition: ndp.h:56
struct ndp_prefix_information_option prefix
Prefix information option.
Definition: ndp.h:108
struct ndp_option_header header
NDP option header.
Definition: ndp.h:50
unsigned short uint16_t
Definition: stdint.h:11
uint8_t blocks
Length (in blocks of 8 bytes)
Definition: ndp.h:24
struct in6_addr addresses[0]
Addresses.
Definition: ndp.h:83
uint8_t flags
Flags.
Definition: ndp.h:54
uint8_t type
Type.
Definition: ndp.h:22
struct neighbour_discovery ndp_discovery
NDP neighbour discovery protocol.
Definition: ndp.c:162
struct ndp_option_header header
NDP option header.
Definition: ndp.h:77
uint8_t ll_addr[0]
Link-layer address.
Definition: ndp.h:41
struct in6_addr target
Target address.
Definition: ndp.h:124
NDP recursive DNS server.
Definition: ndp.h:75
struct icmp_header icmp
ICMPv6 header.
Definition: ndp.h:175
uint16_t reserved
Reserved.
Definition: ndp.h:79
struct icmp_header icmp
ICMPv6 header.
Definition: ndp.h:165
A neighbour discovery protocol.
Definition: neighbour.h:20
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t reachable
Reachable time.
Definition: ndp.h:149
An NDP option header.
Definition: ndp.h:20
struct ndp_option_header header
NDP option header.
Definition: ndp.h:92
uint8_t hop_limit
Current hop limit.
Definition: ndp.h:143
NDP DNS search list.
Definition: ndp.h:90
NDP source or target link-layer address option.
Definition: ndp.h:37
struct ndp_option_header header
NDP option header.
Definition: ndp.h:39
FILE_SECBOOT(PERMITTED)
struct ndp_router_advertisement_header radv
Router advertisement header.
Definition: ndp.h:181
struct ndp_option_header __attribute__
uint32_t retransmit
Retransmission timer.
Definition: ndp.h:151
A long option, as used for getopt_long()
Definition: getopt.h:25
uint16_t reserved
Reserved.
Definition: ndp.h:94
NDP prefix information.
Definition: ndp.h:48
static struct net_device * netdev
Definition: gdbudp.c:52
struct ndp_rdnss_option rdnss
Recursive DNS server option.
Definition: ndp.h:110
uint32_t reserved
Reserved.
Definition: ndp.h:60
IP6 address structure.
Definition: in.h:51
uint32_t lifetime
Lifetime.
Definition: ndp.h:96
struct icmp_header icmp
ICMPv6 header.
Definition: ndp.h:118
uint32_t lifetime
Lifetime.
Definition: ndp.h:81
struct ndp_router_solicitation_header rsol
Router solicitation header.
Definition: ndp.h:179
A network device.
Definition: netdevice.h:353
struct ndp_ll_addr_option ll_addr
Source or target link-layer address option.
Definition: ndp.h:106
unsigned char uint8_t
Definition: stdint.h:10
struct ndp_dnssl_option dnssl
DNS search list option.
Definition: ndp.h:112
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:195
unsigned int uint32_t
Definition: stdint.h:12
An NDP router advertisement header.
Definition: ndp.h:139
IPv6 protocol.
uint8_t prefix_len
Prefix length.
Definition: ndp.h:52
An NDP neighbour solicitation or advertisement header.
Definition: ndp.h:116
struct ndp_option_header header
Option header.
Definition: ndp.h:104
uint8_t reserved[3]
Reserved.
Definition: ndp.h:122
An NDP header.
Definition: ndp.h:173
uint32_t preferred
Preferred lifetime.
Definition: ndp.h:58
ICMPv6 protocol.
Neighbour discovery.
An ICMP header.
Definition: icmp.h:20
An NDP router solicitation header.
Definition: ndp.h:163
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
uint8_t flags
Flags.
Definition: ndp.h:120
struct in6_addr prefix
Prefix.
Definition: ndp.h:62
An NDP option.
Definition: ndp.h:102
uint32_t reserved
Reserved.
Definition: ndp.h:167
struct ndp_neighbour_header neigh
Neighbour solicitation or advertisement header.
Definition: ndp.h:177
uint16_t lifetime
Router lifetime.
Definition: ndp.h:147
struct icmp_header icmp
ICMPv6 header.
Definition: ndp.h:141
A persistent I/O buffer.
Definition: iobuf.h:38
uint8_t names[0]
Domain names.
Definition: ndp.h:98