6 * Neighbour discovery protocol
10 FILE_LICENCE ( GPL2_OR_LATER );
14 #include <ipxe/ipv6.h>
15 #include <ipxe/icmpv6.h>
16 #include <ipxe/neighbour.h>
18 /** An NDP option header */
19 struct ndp_option_header {
22 /** Length (in blocks of 8 bytes) */
24 } __attribute__ (( packed ));
26 /** NDP option block size */
27 #define NDP_OPTION_BLKSZ 8U
29 /** NDP source link-layer address option */
30 #define NDP_OPT_LL_SOURCE 1
32 /** NDP target link-layer address option */
33 #define NDP_OPT_LL_TARGET 2
35 /** NDP source or target link-layer address option */
36 struct ndp_ll_addr_option {
37 /** NDP option header */
38 struct ndp_option_header header;
39 /** Link-layer address */
41 } __attribute__ (( packed ));
43 /** NDP prefix information option */
44 #define NDP_OPT_PREFIX 3
46 /** NDP prefix information */
47 struct ndp_prefix_information_option {
48 /** NDP option header */
49 struct ndp_option_header header;
56 /** Preferred lifetime */
61 struct in6_addr prefix;
62 } __attribute__ (( packed ));
64 /** NDP on-link flag */
65 #define NDP_PREFIX_ON_LINK 0x80
67 /** NDP autonomous address configuration flag */
68 #define NDP_PREFIX_AUTONOMOUS 0x40
70 /** NDP recursive DNS server option */
71 #define NDP_OPT_RDNSS 25
73 /** NDP recursive DNS server */
74 struct ndp_rdnss_option {
75 /** NDP option header */
76 struct ndp_option_header header;
82 struct in6_addr addresses[0];
83 } __attribute__ (( packed ));
85 /** NDP DNS search list option */
86 #define NDP_OPT_DNSSL 31
88 /** NDP DNS search list */
89 struct ndp_dnssl_option {
90 /** NDP option header */
91 struct ndp_option_header header;
98 } __attribute__ (( packed ));
103 struct ndp_option_header header;
104 /** Source or target link-layer address option */
105 struct ndp_ll_addr_option ll_addr;
106 /** Prefix information option */
107 struct ndp_prefix_information_option prefix;
108 /** Recursive DNS server option */
109 struct ndp_rdnss_option rdnss;
110 /** DNS search list option */
111 struct ndp_dnssl_option dnssl;
112 } __attribute__ (( packed ));
114 /** An NDP neighbour solicitation or advertisement header */
115 struct ndp_neighbour_header {
117 struct icmp_header icmp;
122 /** Target address */
123 struct in6_addr target;
125 union ndp_option option[0];
126 } __attribute__ (( packed ));
128 /** NDP router flag */
129 #define NDP_NEIGHBOUR_ROUTER 0x80
131 /** NDP solicited flag */
132 #define NDP_NEIGHBOUR_SOLICITED 0x40
134 /** NDP override flag */
135 #define NDP_NEIGHBOUR_OVERRIDE 0x20
137 /** An NDP router advertisement header */
138 struct ndp_router_advertisement_header {
140 struct icmp_header icmp;
141 /** Current hop limit */
145 /** Router lifetime */
147 /** Reachable time */
149 /** Retransmission timer */
152 union ndp_option option[0];
153 } __attribute__ (( packed ));
155 /** NDP managed address configuration */
156 #define NDP_ROUTER_MANAGED 0x80
158 /** NDP other configuration */
159 #define NDP_ROUTER_OTHER 0x40
161 /** An NDP router solicitation header */
162 struct ndp_router_solicitation_header {
164 struct icmp_header icmp;
168 union ndp_option option[0];
169 } __attribute__ (( packed ));
174 struct icmp_header icmp;
175 /** Neighbour solicitation or advertisement header */
176 struct ndp_neighbour_header neigh;
177 /** Router solicitation header */
178 struct ndp_router_solicitation_header rsol;
179 /** Router advertisement header */
180 struct ndp_router_advertisement_header radv;
181 } __attribute__ (( packed ));
183 extern struct neighbour_discovery ndp_discovery;
186 * Transmit packet, determining link-layer address via NDP
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
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 ) {
199 return neighbour_tx ( iobuf, netdev, &ipv6_protocol, net_dest,
200 &ndp_discovery, net_source, ll_source );
203 /** NDP settings block name */
204 #define NDP_SETTINGS_NAME "ndp"
206 #endif /* _IPXE_NDP_H */