Browse Source

[dhcp] Allow for variable encapsulation of architecture-specific options

DHCPv4 and DHCPv6 share some values in common for the architecture-
specific options (such as the client system architecture type), but
use different encapsulations: DHCPv4 has a single byte for the option
length while DHCPv6 has a 16-bit field for the option length.

Move the containing DHCP_OPTION() and related wrappers from the
individual dhcp_arch.h files to dhcp.c, thus allowing for the
architecture-specific values to be reused in dhcpv6.c.

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

+ 6
- 7
src/arch/arm32/include/efi/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_ARM32 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM32
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */
45 44
 
46 45
 #endif

+ 6
- 7
src/arch/arm64/include/efi/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_ARM64 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM64
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */
45 44
 
46 45
 #endif

+ 6
- 7
src/arch/i386/include/efi/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_IA32 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_IA32
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */
45 44
 
46 45
 #endif

+ 6
- 7
src/arch/i386/include/pcbios/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_X86 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 2, 1 /* v2.1 */
45 44
 
46 45
 #endif

+ 6
- 7
src/arch/x86_64/include/efi/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_X86_64 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86_64
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */
45 44
 
46 45
 #endif

+ 6
- 7
src/arch/x86_64/include/pcbios/ipxe/dhcp_arch.h View File

@@ -33,14 +33,13 @@ 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
-	DHCP_STRING ( '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' )
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 40
 
41
-#define DHCP_ARCH_CLIENT_ARCHITECTURE \
42
-	DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_X86 )
41
+#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_X86
43 42
 
44
-#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ )
43
+#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 2, 1 /* v2.1 */
45 44
 
46 45
 #endif

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

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

Loading…
Cancel
Save