Browse Source

[dhcp] Automatically generate vendor class identifier string

The vendor class identifier strings in DHCP_ARCH_VENDOR_CLASS_ID are
out of sync with the (correct) client architecture values in
DHCP_ARCH_CLIENT_ARCHITECTURE.

Fix by removing all definitions of DHCP_ARCH_VENDOR_CLASS_ID, and
instead generating the vendor class identifier string automatically
based on DHCP_ARCH_CLIENT_ARCHITECTURE and DHCP_ARCH_CLIENT_NDI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
aeb6203811

+ 0
- 5
src/arch/arm32/include/efi/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '7', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM32
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */

+ 0
- 5
src/arch/arm64/include/efi/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '7', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM64
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */

+ 0
- 5
src/arch/i386/include/efi/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '6', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_IA32
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */

+ 0
- 5
src/arch/i386/include/pcbios/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 2, 1 /* v2.1 */

+ 0
- 5
src/arch/x86_64/include/efi/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '9', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86_64
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */

+ 0
- 5
src/arch/x86_64/include/pcbios/ipxe/dhcp_arch.h View File

@@ -33,11 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 
34 34
 #include <ipxe/dhcp.h>
35 35
 
36
-#define DHCP_ARCH_VENDOR_CLASS_ID				\
37
-	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',	\
38
-	'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':',	\
39
-	'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1'
40
-
41 36
 #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86
42 37
 
43 38
 #define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 2, 1 /* v2.1 */

+ 23
- 0
src/include/ipxe/dhcp.h View File

@@ -210,6 +210,29 @@ struct dhcp_pxe_boot_menu_item {
210 210
 /** Vendor class identifier */
211 211
 #define DHCP_VENDOR_CLASS_ID 60
212 212
 
213
+/** Vendor class identifier for PXE clients */
214
+#define DHCP_VENDOR_PXECLIENT( arch, ndi )				\
215
+	'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',		\
216
+	'A', 'r', 'c', 'h', ':', DHCP_VENDOR_PXECLIENT_ARCH ( arch ),	\
217
+	':', 'U', 'N', 'D', 'I', ':', DHCP_VENDOR_PXECLIENT_UNDI ( ndi )
218
+
219
+/** Vendor class identifier architecture for PXE clients */
220
+#define DHCP_VENDOR_PXECLIENT_ARCH( arch )				\
221
+	( '0' + ( ( (arch) / 10000 ) % 10 ) ),				\
222
+	( '0' + ( ( (arch) /  1000 ) % 10 ) ),				\
223
+	( '0' + ( ( (arch) /   100 ) % 10 ) ),				\
224
+	( '0' + ( ( (arch) /    10 ) % 10 ) ),				\
225
+	( '0' + ( ( (arch) /     1 ) % 10 ) )
226
+
227
+/** Vendor class identifier UNDI version for PXE clients */
228
+#define DHCP_VENDOR_PXECLIENT_UNDI( type, major, minor )		\
229
+	DHCP_VENDOR_PXECLIENT_UNDI_VERSION ( major ),			\
230
+	DHCP_VENDOR_PXECLIENT_UNDI_VERSION ( minor )
231
+#define DHCP_VENDOR_PXECLIENT_UNDI_VERSION( version )			\
232
+	( '0' + ( ( (version) /   100 ) % 10 ) ),			\
233
+	( '0' + ( ( (version) /    10 ) % 10 ) ),			\
234
+	( '0' + ( ( (version) /     1 ) % 10 ) )
235
+
213 236
 /** Client identifier */
214 237
 #define DHCP_CLIENT_ID 61
215 238
 

+ 3
- 1
src/net/udp/dhcp.c View File

@@ -84,7 +84,9 @@ static uint8_t dhcp_request_options_data[] = {
84 84
 	DHCP_WORD ( ETH_MAX_MTU - 20 /* IP header */ - 8 /* UDP header */ ),
85 85
 	DHCP_CLIENT_ARCHITECTURE, DHCP_WORD ( DHCP_ARCH_CLIENT_ARCHITECTURE ),
86 86
 	DHCP_CLIENT_NDI, DHCP_OPTION ( DHCP_ARCH_CLIENT_NDI ),
87
-	DHCP_VENDOR_CLASS_ID, DHCP_STRING ( DHCP_ARCH_VENDOR_CLASS_ID ),
87
+	DHCP_VENDOR_CLASS_ID,
88
+	DHCP_STRING ( DHCP_VENDOR_PXECLIENT ( DHCP_ARCH_CLIENT_ARCHITECTURE,
89
+					      DHCP_ARCH_CLIENT_NDI ) ),
88 90
 	DHCP_USER_CLASS_ID, DHCP_STRING ( 'i', 'P', 'X', 'E' ),
89 91
 	DHCP_PARAMETER_REQUEST_LIST,
90 92
 	DHCP_OPTION ( DHCP_SUBNET_MASK, DHCP_ROUTERS, DHCP_DNS_SERVERS,

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

@@ -374,7 +374,9 @@ static uint8_t dhcpv6_request_options_data[] = {
374 374
 			DHCPV6_CODE ( DHCPV6_BOOTFILE_PARAM ) ),
375 375
 	DHCPV6_CODE ( DHCPV6_VENDOR_CLASS ),
376 376
 	DHCPV6_OPTION ( DHCPV6_DWORD_VALUE ( DHCPV6_VENDOR_CLASS_PXE ),
377
-			DHCPV6_STRING ( DHCP_ARCH_VENDOR_CLASS_ID ) ),
377
+			DHCPV6_STRING (
378
+			  DHCP_VENDOR_PXECLIENT ( DHCP_ARCH_CLIENT_ARCHITECTURE,
379
+						  DHCP_ARCH_CLIENT_NDI ) ) ),
378 380
 	DHCPV6_CODE ( DHCPV6_CLIENT_ARCHITECTURE ),
379 381
 	DHCPV6_WORD ( DHCP_ARCH_CLIENT_ARCHITECTURE ),
380 382
 	DHCPV6_CODE ( DHCPV6_CLIENT_NDI ),

Loading…
Cancel
Save