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