Parcourir la source

Add PXE-required DHCP options to DHCPDISCOVER and DHCPREQUEST packets.

tags/v0.9.3
Michael Brown il y a 17 ans
Parent
révision
8d18338ae7
2 fichiers modifiés avec 31 ajouts et 10 suppressions
  1. 6
    0
      src/include/gpxe/dhcp.h
  2. 25
    10
      src/net/udp/dhcp.c

+ 6
- 0
src/include/gpxe/dhcp.h Voir le fichier

@@ -135,6 +135,12 @@ struct job_interface;
135 135
  */
136 136
 #define DHCP_BOOTFILE_NAME 67
137 137
 
138
+/** Client system architecture */
139
+#define DHCP_CLIENT_ARCHITECTURE 93
140
+
141
+/** Client network device interface */
142
+#define DHCP_CLIENT_NDI 94
143
+
138 144
 /** UUID client identifier */
139 145
 #define DHCP_CLIENT_UUID 97
140 146
 

+ 25
- 10
src/net/udp/dhcp.c Voir le fichier

@@ -61,13 +61,17 @@ static const uint8_t dhcp_op[] = {
61 61
 static uint8_t dhcp_request_options_data[] = {
62 62
 	DHCP_MAX_MESSAGE_SIZE, DHCP_WORD ( ETH_MAX_MTU ),
63 63
 	DHCP_VENDOR_CLASS_ID,
64
-	DHCP_STRING (  'E', 't', 'h', 'e', 'r', 'b', 'o', 'o', 't' ),
64
+	DHCP_STRING (  'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',
65
+		       'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':',
66
+		       'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1' ),
67
+	DHCP_CLIENT_ARCHITECTURE, DHCP_WORD ( 0 ),
68
+	DHCP_CLIENT_NDI, DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ ),
65 69
 	DHCP_PARAMETER_REQUEST_LIST,
66
-	DHCP_OPTION ( DHCP_SUBNET_MASK, DHCP_ROUTERS, DHCP_DNS_SERVERS, DHCP_LOG_SERVERS,
67
-		      DHCP_HOST_NAME, DHCP_DOMAIN_NAME, DHCP_ROOT_PATH,
68
-		      DHCP_VENDOR_ENCAP, DHCP_TFTP_SERVER_NAME,
69
-		      DHCP_BOOTFILE_NAME, DHCP_EB_ENCAP,
70
-		      DHCP_ISCSI_INITIATOR_IQN ),
70
+	DHCP_OPTION ( DHCP_SUBNET_MASK, DHCP_ROUTERS, DHCP_DNS_SERVERS,
71
+		      DHCP_LOG_SERVERS, DHCP_HOST_NAME, DHCP_DOMAIN_NAME,
72
+		      DHCP_ROOT_PATH, DHCP_VENDOR_ENCAP, DHCP_VENDOR_CLASS_ID,
73
+		      DHCP_TFTP_SERVER_NAME, DHCP_BOOTFILE_NAME,
74
+		      DHCP_EB_ENCAP, DHCP_ISCSI_INITIATOR_IQN ),
71 75
 	DHCP_END
72 76
 };
73 77
 
@@ -512,6 +516,16 @@ struct dhcp_client_id {
512 516
 	uint8_t ll_addr[MAX_LL_ADDR_LEN];
513 517
 } __attribute__ (( packed ));
514 518
 
519
+/** DHCP client UUID */
520
+struct dhcp_client_uuid {
521
+	/** Identifier type */
522
+	uint8_t type;
523
+	/** UUID */
524
+	union uuid uuid;
525
+} __attribute__ (( packed ));
526
+
527
+#define DHCP_CLIENT_UUID_TYPE 0
528
+
515 529
 /**
516 530
  * Create DHCP request
517 531
  *
@@ -530,7 +544,7 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
530 544
 	struct device_description *desc = &netdev->dev->desc;
531 545
 	struct dhcp_netdev_desc dhcp_desc;
532 546
 	struct dhcp_client_id client_id;
533
-	union uuid uuid;
547
+	struct dhcp_client_uuid client_uuid;
534 548
 	size_t dhcp_features_len;
535 549
 	size_t ll_addr_len;
536 550
 	int rc;
@@ -607,10 +621,11 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
607 621
 	}
608 622
 
609 623
 	/* Add client UUID, if we have one.  Required for PXE. */
610
-	if ( ( rc = get_uuid ( &uuid ) ) == 0 ) {
624
+	client_uuid.type = DHCP_CLIENT_UUID_TYPE;
625
+	if ( ( rc = get_uuid ( &client_uuid.uuid ) ) == 0 ) {
611 626
 		if ( ( rc = set_dhcp_packet_option ( dhcppkt,
612
-						     DHCP_CLIENT_UUID, &uuid,
613
-						     sizeof ( uuid ) ) ) !=0){
627
+					   DHCP_CLIENT_UUID, &client_uuid,
628
+					   sizeof ( client_uuid ) ) ) != 0 ) {
614 629
 			DBG ( "DHCP could not set client UUID: %s\n",
615 630
 			      strerror ( rc ) );
616 631
 			return rc;

Chargement…
Annuler
Enregistrer