Procházet zdrojové kódy

Add identifier for the network device into the DHCP request.

tags/v0.9.3
Michael Brown před 17 roky
rodič
revize
79691961ba
2 změnil soubory, kde provedl 38 přidání a 0 odebrání
  1. 13
    0
      src/include/gpxe/dhcp.h
  2. 25
    0
      src/net/udp/dhcp.c

+ 13
- 0
src/include/gpxe/dhcp.h Zobrazit soubor

168
  */
168
  */
169
 #define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
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
 /** BIOS drive number
184
 /** BIOS drive number
172
  *
185
  *
173
  * This is the drive number for a drive emulated via INT 13.  0x80 is
186
  * This is the drive number for a drive emulated via INT 13.  0x80 is

+ 25
- 0
src/net/udp/dhcp.c Zobrazit soubor

24
 #include <byteswap.h>
24
 #include <byteswap.h>
25
 #include <gpxe/if_ether.h>
25
 #include <gpxe/if_ether.h>
26
 #include <gpxe/netdevice.h>
26
 #include <gpxe/netdevice.h>
27
+#include <gpxe/device.h>
27
 #include <gpxe/xfer.h>
28
 #include <gpxe/xfer.h>
28
 #include <gpxe/open.h>
29
 #include <gpxe/open.h>
29
 #include <gpxe/job.h>
30
 #include <gpxe/job.h>
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
  * Create DHCP request
495
  * Create DHCP request
485
  *
496
  *
495
 			  struct dhcp_option_block *options,
506
 			  struct dhcp_option_block *options,
496
 			  void *data, size_t max_len,
507
 			  void *data, size_t max_len,
497
 			  struct dhcp_packet *dhcppkt ) {
508
 			  struct dhcp_packet *dhcppkt ) {
509
+	struct device_description *desc = &netdev->dev->desc;
510
+	struct dhcp_netdev_desc dhcp_desc;
498
 	int rc;
511
 	int rc;
499
 
512
 
500
 	/* Create DHCP packet */
513
 	/* Create DHCP packet */
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
 	return 0;
559
 	return 0;
535
 }
560
 }
536
 
561
 

Načítá se…
Zrušit
Uložit