Переглянути джерело

Add identifier for the network device into the DHCP request.

tags/v0.9.3
Michael Brown 17 роки тому
джерело
коміт
79691961ba
2 змінених файлів з 38 додано та 0 видалено
  1. 13
    0
      src/include/gpxe/dhcp.h
  2. 25
    0
      src/net/udp/dhcp.c

+ 13
- 0
src/include/gpxe/dhcp.h Переглянути файл

@@ -168,6 +168,19 @@ struct job_interface;
168 168
  */
169 169
 #define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
170 170
 
171
+/** Network device descriptor
172
+ *
173
+ * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
174
+ *
175
+ * PCI devices:
176
+ * Byte 0 : 1 (PCI)
177
+ * Byte 1 : PCI vendor ID MSB
178
+ * Byte 2 : PCI vendor ID LSB
179
+ * Byte 3 : PCI device ID MSB
180
+ * Byte 4 : PCI device ID LSB
181
+ */
182
+#define DHCP_EB_BUS_ID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb1 )
183
+
171 184
 /** BIOS drive number
172 185
  *
173 186
  * This is the drive number for a drive emulated via INT 13.  0x80 is

+ 25
- 0
src/net/udp/dhcp.c Переглянути файл

@@ -24,6 +24,7 @@
24 24
 #include <byteswap.h>
25 25
 #include <gpxe/if_ether.h>
26 26
 #include <gpxe/netdevice.h>
27
+#include <gpxe/device.h>
27 28
 #include <gpxe/xfer.h>
28 29
 #include <gpxe/open.h>
29 30
 #include <gpxe/job.h>
@@ -480,6 +481,16 @@ static struct dhcp_option_block * dhcp_parse ( const struct dhcphdr *dhcphdr,
480 481
  *
481 482
  */
482 483
 
484
+/** DHCP network device descriptor */
485
+struct dhcp_netdev_desc {
486
+	/** Bus type ID */
487
+	uint8_t type;
488
+	/** Vendor ID */
489
+	uint16_t vendor;
490
+	/** Device ID */
491
+	uint16_t device;
492
+} __attribute__ (( packed ));
493
+
483 494
 /**
484 495
  * Create DHCP request
485 496
  *
@@ -495,6 +506,8 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
495 506
 			  struct dhcp_option_block *options,
496 507
 			  void *data, size_t max_len,
497 508
 			  struct dhcp_packet *dhcppkt ) {
509
+	struct device_description *desc = &netdev->dev->desc;
510
+	struct dhcp_netdev_desc dhcp_desc;
498 511
 	int rc;
499 512
 
500 513
 	/* Create DHCP packet */
@@ -531,6 +544,18 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
531 544
 		}
532 545
 	}
533 546
 
547
+	/* Add options to identify the network device */
548
+	dhcp_desc.type = desc->bus_type;
549
+	dhcp_desc.vendor = htons ( desc->vendor );
550
+	dhcp_desc.device = htons ( desc->device );
551
+	if ( ( rc = set_dhcp_packet_option ( dhcppkt, DHCP_EB_BUS_ID,
552
+					     &dhcp_desc,
553
+					     sizeof ( dhcp_desc ) ) ) != 0 ) {
554
+		DBG ( "DHCP could not set bus ID option: %s\n",
555
+		      strerror ( rc ) );
556
+		return rc;
557
+	}
558
+
534 559
 	return 0;
535 560
 }
536 561
 

Завантаження…
Відмінити
Зберегти