summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2007-07-31 04:32:22 +0200
committerMichael Brown2007-07-31 04:32:22 +0200
commit79691961bae9a0eaf261615aeff472b5d186dfc0 (patch)
tree3f6c6a68144b837b668d1af2b5625828316f6ee1
parentCentralise construction of the DHCP request and response packets. (diff)
downloadipxe-79691961bae9a0eaf261615aeff472b5d186dfc0.tar.gz
ipxe-79691961bae9a0eaf261615aeff472b5d186dfc0.tar.xz
ipxe-79691961bae9a0eaf261615aeff472b5d186dfc0.zip
Add identifier for the network device into the DHCP request.
-rw-r--r--src/include/gpxe/dhcp.h13
-rw-r--r--src/net/udp/dhcp.c25
2 files changed, 38 insertions, 0 deletions
diff --git a/src/include/gpxe/dhcp.h b/src/include/gpxe/dhcp.h
index a7cac228d..863227867 100644
--- a/src/include/gpxe/dhcp.h
+++ b/src/include/gpxe/dhcp.h
@@ -168,6 +168,19 @@ struct job_interface;
*/
#define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
+/** Network device descriptor
+ *
+ * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
+ *
+ * PCI devices:
+ * Byte 0 : 1 (PCI)
+ * Byte 1 : PCI vendor ID MSB
+ * Byte 2 : PCI vendor ID LSB
+ * Byte 3 : PCI device ID MSB
+ * Byte 4 : PCI device ID LSB
+ */
+#define DHCP_EB_BUS_ID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb1 )
+
/** BIOS drive number
*
* This is the drive number for a drive emulated via INT 13. 0x80 is
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index b82db1a42..f8f59e2e4 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -24,6 +24,7 @@
#include <byteswap.h>
#include <gpxe/if_ether.h>
#include <gpxe/netdevice.h>
+#include <gpxe/device.h>
#include <gpxe/xfer.h>
#include <gpxe/open.h>
#include <gpxe/job.h>
@@ -480,6 +481,16 @@ static struct dhcp_option_block * dhcp_parse ( const struct dhcphdr *dhcphdr,
*
*/
+/** DHCP network device descriptor */
+struct dhcp_netdev_desc {
+ /** Bus type ID */
+ uint8_t type;
+ /** Vendor ID */
+ uint16_t vendor;
+ /** Device ID */
+ uint16_t device;
+} __attribute__ (( packed ));
+
/**
* Create DHCP request
*
@@ -495,6 +506,8 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
struct dhcp_option_block *options,
void *data, size_t max_len,
struct dhcp_packet *dhcppkt ) {
+ struct device_description *desc = &netdev->dev->desc;
+ struct dhcp_netdev_desc dhcp_desc;
int rc;
/* Create DHCP packet */
@@ -531,6 +544,18 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
}
}
+ /* Add options to identify the network device */
+ dhcp_desc.type = desc->bus_type;
+ dhcp_desc.vendor = htons ( desc->vendor );
+ dhcp_desc.device = htons ( desc->device );
+ if ( ( rc = set_dhcp_packet_option ( dhcppkt, DHCP_EB_BUS_ID,
+ &dhcp_desc,
+ sizeof ( dhcp_desc ) ) ) != 0 ) {
+ DBG ( "DHCP could not set bus ID option: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
return 0;
}