iPXE
dhcpv6.h
Go to the documentation of this file.
1 #ifndef _IPXE_DHCPV6_H
2 #define _IPXE_DHCPV6_H
3 
4 /** @file
5  *
6  * Dynamic Host Configuration Protocol for IPv6
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/in.h>
14 #include <ipxe/uuid.h>
15 
16 /** DHCPv6 server port */
17 #define DHCPV6_SERVER_PORT 547
18 
19 /** DHCPv6 client port */
20 #define DHCPV6_CLIENT_PORT 546
21 
22 /**
23  * A DHCPv6 option
24  *
25  */
26 struct dhcpv6_option {
27  /** Code */
29  /** Length of the data field */
31  /** Data */
33 } __attribute__ (( packed ));
34 
35 /** DHCP unique identifier based on UUID (DUID-UUID) */
37  /** Type */
39  /** UUID */
40  union uuid uuid;
41 } __attribute__ (( packed ));
42 
43 /** DHCP unique identifier based on UUID (DUID-UUID) */
44 #define DHCPV6_DUID_UUID 4
45 
46 /** DHCPv6 client or server identifier option */
48  /** Option header */
50  /** DHCP unique identifier (DUID) */
52 } __attribute__ (( packed ));
53 
54 /** DHCPv6 client identifier option */
55 #define DHCPV6_CLIENT_ID 1
56 
57 /** DHCPv6 server identifier option */
58 #define DHCPV6_SERVER_ID 2
59 
60 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
62  /** Option header */
64  /** Identity association identifier (IAID) */
66  /** Renew time (in seconds) */
68  /** Rebind time (in seconds) */
70  /** IA_NA options */
72 } __attribute__ (( packed ));
73 
74 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
75 #define DHCPV6_IA_NA 3
76 
77 /** DHCPv6 identity association address (IAADDR) option */
79  /** Option header */
81  /** IPv6 address */
82  struct in6_addr address;
83  /** Preferred lifetime (in seconds) */
85  /** Valid lifetime (in seconds) */
87  /** IAADDR options */
89 } __attribute__ (( packed ));
90 
91 /** DHCPv6 identity association address (IAADDR) option */
92 #define DHCPV6_IAADDR 5
93 
94 /** DHCPv6 option request option */
96  /** Option header */
98  /** Requested options */
100 } __attribute__ (( packed ));
101 
102 /** DHCPv6 option request option */
103 #define DHCPV6_OPTION_REQUEST 6
104 
105 /** DHCPv6 elapsed time option */
107  /** Option header */
109  /** Elapsed time, in centiseconds */
111 } __attribute__ (( packed ));
112 
113 /** DHCPv6 elapsed time option */
114 #define DHCPV6_ELAPSED_TIME 8
115 
116 /** DHCPv6 status code option */
118  /** Option header */
120  /** Status code */
122  /** Status message */
123  char message[0];
124 } __attribute__ (( packed ));
125 
126 /** DHCPv6 status code option */
127 #define DHCPV6_STATUS_CODE 13
128 
129 /** DHCPv6 user class */
131  /** Length */
133  /** User class string */
134  char string[0];
135 } __attribute__ (( packed ));
136 
137 /** DHCPv6 user class option */
139  /** Option header */
141  /** User class */
143 } __attribute__ (( packed ));
144 
145 /** DHCPv6 user class option */
146 #define DHCPV6_USER_CLASS 15
147 
148 /** DHCPv6 vendor class option */
149 #define DHCPV6_VENDOR_CLASS 16
150 
151 /** DHCPv6 PXE vendor class
152  *
153  * The DHCPv6 vendor class includes a field for an IANA enterprise
154  * number. The EDK2 codebase uses the value 343, with the comment:
155  *
156  * TODO: IANA TBD: temporarily using Intel's
157  *
158  * Since this "temporarily" has applied since at least 2010, we assume
159  * that it has become a de facto standard.
160  */
161 #define DHCPV6_VENDOR_CLASS_PXE 343
162 
163 /** DHCPv6 DNS recursive name server option */
164 #define DHCPV6_DNS_SERVERS 23
165 
166 /** DHCPv6 domain search list option */
167 #define DHCPV6_DOMAIN_LIST 24
168 
169 /** DHCPv6 bootfile URI option */
170 #define DHCPV6_BOOTFILE_URL 59
171 
172 /** DHCPv6 bootfile parameters option */
173 #define DHCPV6_BOOTFILE_PARAM 60
174 
175 /** DHCPv6 client system architecture option */
176 #define DHCPV6_CLIENT_ARCHITECTURE 61
177 
178 /** DHCPv6 client network interface identifier option */
179 #define DHCPV6_CLIENT_NDI 62
180 
181 /** DHCPv6 syslog server option
182  *
183  * This option code has not yet been assigned by IANA. Please update
184  * this definition once an option code has been assigned.
185  */
186 #define DHCPV6_LOG_SERVERS 0xffffffffUL
187 
188 /** Construct a DHCPv6 byte value */
189 #define DHCPV6_BYTE_VALUE( value ) ( (value) & 0xff )
190 
191 /** Construct a DHCPv6 word value */
192 #define DHCPV6_WORD_VALUE( value ) \
193  DHCPV6_BYTE_VALUE ( (value) >> 8 ), DHCPV6_BYTE_VALUE ( (value) >> 0 )
194 
195 /** Construct a DHCPv6 dword value */
196 #define DHCPV6_DWORD_VALUE( value ) \
197  DHCPV6_WORD_VALUE ( (value) >> 16 ), DHCPV6_WORD_VALUE ( (value) >> 0 )
198 
199 /** Construct a DHCPv6 option code */
200 #define DHCPV6_CODE( code ) DHCPV6_WORD_VALUE ( code )
201 
202 /** Construct a DHCPv6 option length */
203 #define DHCPV6_LEN( len ) DHCPV6_WORD_VALUE ( len )
204 
205 /** Construct a DHCPv6 option from a list of bytes */
206 #define DHCPV6_OPTION( ... ) \
207  DHCPV6_LEN ( VA_ARG_COUNT ( __VA_ARGS__ ) ), __VA_ARGS__
208 
209 /** Construct a DHCPv6 option from a list of characters */
210 #define DHCPV6_STRING( ... ) DHCPV6_OPTION ( __VA_ARGS__ )
211 
212 /** Construct a byte-valued DHCPv6 option */
213 #define DHCPV6_BYTE( value ) DHCPV6_OPTION ( DHCPV6_BYTE_VALUE ( value ) )
214 
215 /** Construct a word-valued DHCPv6 option */
216 #define DHCPV6_WORD( value ) DHCPV6_OPTION ( DHCPV6_WORD_VALUE ( value ) )
217 
218 /** Construct a dword-valued DHCPv6 option */
219 #define DHCPV6_DWORD( value ) DHCPV6_OPTION ( DHCPV6_DWORD_VALUE ( value ) )
220 
221 /**
222  * Any DHCPv6 option
223  *
224  */
234 };
235 
236 /**
237  * A DHCPv6 header
238  *
239  */
241  /** Message type */
243  /** Transaction ID */
245  /** Options */
247 } __attribute__ (( packed ));
248 
249 /** DHCPv6 solicitation */
250 #define DHCPV6_SOLICIT 1
251 
252 /** DHCPv6 advertisement */
253 #define DHCPV6_ADVERTISE 2
254 
255 /** DHCPv6 request */
256 #define DHCPV6_REQUEST 3
257 
258 /** DHCPv6 reply */
259 #define DHCPV6_REPLY 7
260 
261 /** DHCPv6 information request */
262 #define DHCPV6_INFORMATION_REQUEST 11
263 
264 /** DHCPv6 settings block name */
265 #define DHCPV6_SETTINGS_NAME "dhcpv6"
266 
267 /**
268  * Construct all-DHCP-relay-agents-and-servers multicast address
269  *
270  * @v addr Zeroed address to construct
271  */
272 static inline void ipv6_all_dhcp_relay_and_servers ( struct in6_addr *addr ) {
273  addr->s6_addr16[0] = htons ( 0xff02 );
274  addr->s6_addr[13] = 1;
275  addr->s6_addr[15] = 2;
276 }
277 
278 extern int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
279  int stateful );
280 
281 #endif /* _IPXE_DHCPV6_H */
#define __attribute__(x)
Definition: compiler.h:10
unsigned short uint16_t
Definition: stdint.h:11
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
DHCP unique identifier based on UUID (DUID-UUID)
Definition: dhcpv6.h:36
struct dhcpv6_user_class_option user_class
Definition: dhcpv6.h:233
A universally unique ID.
Definition: uuid.h:15
uint16_t len
Length.
Definition: dhcpv6.h:132
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:80
struct dhcpv6_duid_option duid
Definition: dhcpv6.h:227
uint8_t duid[0]
DHCP unique identifier (DUID)
Definition: dhcpv6.h:51
struct dhcpv6_option options[0]
IA_NA options.
Definition: dhcpv6.h:71
uint16_t status
Status code.
Definition: dhcpv6.h:121
uint32_t iaid
Identity association identifier (IAID)
Definition: dhcpv6.h:65
Universally unique IDs.
int start_dhcpv6(struct interface *job, struct net_device *netdev, int stateful)
Start DHCPv6.
Definition: dhcpv6.c:921
DHCPv6 user class option.
Definition: dhcpv6.h:138
A DHCPv6 header.
Definition: dhcpv6.h:240
Any DHCPv6 option.
Definition: dhcpv6.h:225
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:108
uint8_t xid[3]
Transaction ID.
Definition: dhcpv6.h:244
uint32_t valid
Valid lifetime (in seconds)
Definition: dhcpv6.h:86
struct dhcpv6_elapsed_time_option elapsed_time
Definition: dhcpv6.h:231
An object interface.
Definition: interface.h:109
struct dhcpv6_option options[0]
IAADDR options.
Definition: dhcpv6.h:88
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:119
static struct net_device * netdev
Definition: gdbudp.c:52
char message[0]
Status message.
Definition: dhcpv6.h:123
IP6 address structure.
Definition: in.h:48
uint16_t requested[0]
Requested options.
Definition: dhcpv6.h:99
uint32_t rebind
Rebind time (in seconds)
Definition: dhcpv6.h:69
A network device.
Definition: netdevice.h:348
u32 addr
Definition: sky2.h:8
struct in6_addr address
IPv6 address.
Definition: dhcpv6.h:82
unsigned char uint8_t
Definition: stdint.h:10
DHCPv6 client or server identifier option.
Definition: dhcpv6.h:47
DHCPv6 identity association address (IAADDR) option.
Definition: dhcpv6.h:78
unsigned int uint32_t
Definition: stdint.h:12
A DHCPv6 option.
Definition: dhcpv6.h:26
DHCPv6 status code option.
Definition: dhcpv6.h:117
struct dhcpv6_option header
Definition: dhcpv6.h:226
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:97
struct dhcpv6_option_request_option option_request
Definition: dhcpv6.h:230
uint32_t renew
Renew time (in seconds)
Definition: dhcpv6.h:67
uint8_t data[0]
Data.
Definition: dhcpv6.h:32
uint16_t type
Type.
Definition: dhcpv6.h:38
uint16_t len
Length of the data field.
Definition: dhcpv6.h:30
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:63
static void ipv6_all_dhcp_relay_and_servers(struct in6_addr *addr)
Construct all-DHCP-relay-agents-and-servers multicast address.
Definition: dhcpv6.h:272
uint8_t type
Message type.
Definition: dhcpv6.h:242
DHCPv6 option request option.
Definition: dhcpv6.h:95
struct dhcpv6_option options[0]
Options.
Definition: dhcpv6.h:246
uint16_t elapsed
Elapsed time, in centiseconds.
Definition: dhcpv6.h:110
uint32_t preferred
Preferred lifetime (in seconds)
Definition: dhcpv6.h:84
uint16_t code
Code.
Definition: dhcpv6.h:28
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:49
DHCPv6 identity association for non-temporary address (IA_NA) option.
Definition: dhcpv6.h:61
struct dhcpv6_ia_na_option ia_na
Definition: dhcpv6.h:228
DHCPv6 user class.
Definition: dhcpv6.h:130
#define htons(value)
Definition: byteswap.h:135
struct dhcpv6_iaaddr_option iaaddr
Definition: dhcpv6.h:229
struct dhcpv6_user_class user_class[0]
User class.
Definition: dhcpv6.h:142
struct dhcpv6_status_code_option status_code
Definition: dhcpv6.h:232
struct dhcpv6_option header
Option header.
Definition: dhcpv6.h:140
DHCPv6 elapsed time option.
Definition: dhcpv6.h:106