Browse Source

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

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
8d18338ae7
2 changed files with 31 additions and 10 deletions
  1. 6
    0
      src/include/gpxe/dhcp.h
  2. 25
    10
      src/net/udp/dhcp.c

+ 6
- 0
src/include/gpxe/dhcp.h View File

135
  */
135
  */
136
 #define DHCP_BOOTFILE_NAME 67
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
 /** UUID client identifier */
144
 /** UUID client identifier */
139
 #define DHCP_CLIENT_UUID 97
145
 #define DHCP_CLIENT_UUID 97
140
 
146
 

+ 25
- 10
src/net/udp/dhcp.c View File

61
 static uint8_t dhcp_request_options_data[] = {
61
 static uint8_t dhcp_request_options_data[] = {
62
 	DHCP_MAX_MESSAGE_SIZE, DHCP_WORD ( ETH_MAX_MTU ),
62
 	DHCP_MAX_MESSAGE_SIZE, DHCP_WORD ( ETH_MAX_MTU ),
63
 	DHCP_VENDOR_CLASS_ID,
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
 	DHCP_PARAMETER_REQUEST_LIST,
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
 	DHCP_END
75
 	DHCP_END
72
 };
76
 };
73
 
77
 
512
 	uint8_t ll_addr[MAX_LL_ADDR_LEN];
516
 	uint8_t ll_addr[MAX_LL_ADDR_LEN];
513
 } __attribute__ (( packed ));
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
  * Create DHCP request
530
  * Create DHCP request
517
  *
531
  *
530
 	struct device_description *desc = &netdev->dev->desc;
544
 	struct device_description *desc = &netdev->dev->desc;
531
 	struct dhcp_netdev_desc dhcp_desc;
545
 	struct dhcp_netdev_desc dhcp_desc;
532
 	struct dhcp_client_id client_id;
546
 	struct dhcp_client_id client_id;
533
-	union uuid uuid;
547
+	struct dhcp_client_uuid client_uuid;
534
 	size_t dhcp_features_len;
548
 	size_t dhcp_features_len;
535
 	size_t ll_addr_len;
549
 	size_t ll_addr_len;
536
 	int rc;
550
 	int rc;
607
 	}
621
 	}
608
 
622
 
609
 	/* Add client UUID, if we have one.  Required for PXE. */
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
 		if ( ( rc = set_dhcp_packet_option ( dhcppkt,
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
 			DBG ( "DHCP could not set client UUID: %s\n",
629
 			DBG ( "DHCP could not set client UUID: %s\n",
615
 			      strerror ( rc ) );
630
 			      strerror ( rc ) );
616
 			return rc;
631
 			return rc;

Loading…
Cancel
Save