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