Browse Source

[dhcpv6] Include vendor class identifier option in DHCPv6 requests

RFC3315 defines DHCPv6 option 16 (vendor class identifier) but does
not define any direct relationship with the roughly equivalent DHCPv4
option 60.

The PXE specification predates IPv6, and the UEFI specification is
expectedly vague on the subject.  Examination of the reference EDK2
codebase suggests that the DHCPv6 vendor class identifier will be
formatted in accordance with RFC3315, using a single vendor-class-data
item in which the opaque-data field is the string as would appear in
DHCPv4 option 60.

RFC3315 requires the vendor class identifier to specify an IANA
enterprise number, as a way of disambiguating the vendor-class-data
namespace.  The EDK2 code uses the value 343, described as:

    // TODO: IANA TBD: temporarily using Intel's

Since this "TODO" has been present since at least 2010, it is probably
safe to assume that it has now become a de facto standard.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
d7f1834b5e
2 changed files with 35 additions and 11 deletions
  1. 32
    11
      src/include/ipxe/dhcpv6.h
  2. 3
    0
      src/net/udp/dhcpv6.c

+ 32
- 11
src/include/ipxe/dhcpv6.h View File

@@ -145,6 +145,21 @@ struct dhcpv6_user_class_option {
145 145
 /** DHCPv6 user class option */
146 146
 #define DHCPV6_USER_CLASS 15
147 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
+
148 163
 /** DHCPv6 DNS recursive name server option */
149 164
 #define DHCPV6_DNS_SERVERS 23
150 165
 
@@ -170,13 +185,22 @@ struct dhcpv6_user_class_option {
170 185
  */
171 186
 #define DHCPV6_LOG_SERVERS 0xffffffffUL
172 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
+
173 199
 /** Construct a DHCPv6 option code */
174
-#define DHCPV6_CODE( code ) \
175
-	( ( (code) >> 8 ) & 0xff ), ( ( (code) >> 0 ) & 0xff )
200
+#define DHCPV6_CODE( code ) DHCPV6_WORD_VALUE ( code )
176 201
 
177 202
 /** Construct a DHCPv6 option length */
178
-#define DHCPV6_LEN( len ) \
179
-	( ( (len) >> 8 ) & 0xff ), ( ( (len) >> 0 ) & 0xff )
203
+#define DHCPV6_LEN( len ) DHCPV6_WORD_VALUE ( len )
180 204
 
181 205
 /** Construct a DHCPv6 option from a list of bytes */
182 206
 #define DHCPV6_OPTION( ... ) \
@@ -186,16 +210,13 @@ struct dhcpv6_user_class_option {
186 210
 #define DHCPV6_STRING( ... ) DHCPV6_OPTION ( __VA_ARGS__ )
187 211
 
188 212
 /** Construct a byte-valued DHCPv6 option */
189
-#define DHCPV6_BYTE( value ) DHCPV6_OPTION ( value )
213
+#define DHCPV6_BYTE( value ) DHCPV6_OPTION ( DHCPV6_BYTE_VALUE ( value ) )
190 214
 
191 215
 /** Construct a word-valued DHCPv6 option */
192
-#define DHCPV6_WORD( value ) DHCPV6_OPTION ( ( ( (value) >> 8 ) & 0xff ), \
193
-					     ( ( (value) >> 0 ) & 0xff ) )
216
+#define DHCPV6_WORD( value ) DHCPV6_OPTION ( DHCPV6_WORD_VALUE ( value ) )
217
+
194 218
 /** Construct a dword-valued DHCPv6 option */
195
-#define DHCPV6_DWORD( value ) DHCPV6_OPTION ( ( ( (value) >> 24 ) & 0xff ), \
196
-					      ( ( (value) >> 16 ) & 0xff ), \
197
-					      ( ( (value) >>  8 ) & 0xff ), \
198
-					      ( ( (value) >>  0 ) & 0xff ) )
219
+#define DHCPV6_DWORD( value ) DHCPV6_OPTION ( DHCPV6_DWORD_VALUE ( value ) )
199 220
 
200 221
 /**
201 222
  * Any DHCPv6 option

+ 3
- 0
src/net/udp/dhcpv6.c View File

@@ -372,6 +372,9 @@ static uint8_t dhcpv6_request_options_data[] = {
372 372
 			DHCPV6_CODE ( DHCPV6_DOMAIN_LIST ),
373 373
 			DHCPV6_CODE ( DHCPV6_BOOTFILE_URL ),
374 374
 			DHCPV6_CODE ( DHCPV6_BOOTFILE_PARAM ) ),
375
+	DHCPV6_CODE ( DHCPV6_VENDOR_CLASS ),
376
+	DHCPV6_OPTION ( DHCPV6_DWORD_VALUE ( DHCPV6_VENDOR_CLASS_PXE ),
377
+			DHCPV6_STRING ( DHCP_ARCH_VENDOR_CLASS_ID ) ),
375 378
 	DHCPV6_CODE ( DHCPV6_CLIENT_ARCHITECTURE ),
376 379
 	DHCPV6_WORD ( DHCP_ARCH_CLIENT_ARCHITECTURE ),
377 380
 	DHCPV6_CODE ( DHCPV6_CLIENT_NDI ),

Loading…
Cancel
Save