summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2009-02-01 21:06:09 +0100
committerMichael Brown2009-02-01 21:06:09 +0100
commit4502c04360c997c48b0b00e4bf4142cd63760306 (patch)
tree93d55aa4948ff2c47f92f91f4008aee9c3b2a9f7
parent[tftp] Guard against invalid data block numbers (diff)
downloadipxe-4502c04360c997c48b0b00e4bf4142cd63760306.tar.gz
ipxe-4502c04360c997c48b0b00e4bf4142cd63760306.tar.xz
ipxe-4502c04360c997c48b0b00e4bf4142cd63760306.zip
[dhcp] Send user class in DHCP requests
-rw-r--r--src/include/gpxe/dhcp.h3
-rw-r--r--src/include/gpxe/settings.h2
-rw-r--r--src/net/udp/dhcp.c27
3 files changed, 29 insertions, 3 deletions
diff --git a/src/include/gpxe/dhcp.h b/src/include/gpxe/dhcp.h
index 2fddb404..d84d55dd 100644
--- a/src/include/gpxe/dhcp.h
+++ b/src/include/gpxe/dhcp.h
@@ -203,6 +203,9 @@ struct dhcp_client_id {
*/
#define DHCP_BOOTFILE_NAME 67
+/** User class identifier */
+#define DHCP_USER_CLASS_ID 77
+
/** Client system architecture */
#define DHCP_CLIENT_ARCHITECTURE 93
diff --git a/src/include/gpxe/settings.h b/src/include/gpxe/settings.h
index bf80b1e1..9e62cdea 100644
--- a/src/include/gpxe/settings.h
+++ b/src/include/gpxe/settings.h
@@ -225,10 +225,10 @@ extern struct setting root_path_setting __setting;
extern struct setting username_setting __setting;
extern struct setting password_setting __setting;
extern struct setting priority_setting __setting;
-extern struct setting bios_drive_setting __setting;
extern struct setting uuid_setting __setting;
extern struct setting next_server_setting __setting;
extern struct setting mac_setting __setting;
+extern struct setting user_class_setting __setting;
/**
* Initialise a settings block
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index 3554b405..26c50172 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -101,6 +101,14 @@ struct setting dhcp_server_setting __setting = {
.type = &setting_type_ipv4,
};
+/** DHCP user class setting */
+struct setting user_class_setting __setting = {
+ .name = "user-class",
+ .description = "User class identifier",
+ .tag = DHCP_USER_CLASS_ID,
+ .type = &setting_type_string,
+};
+
/**
* Name a DHCP packet type
*
@@ -834,6 +842,7 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
struct dhcp_client_uuid client_uuid;
size_t dhcp_features_len;
size_t ll_addr_len;
+ ssize_t len;
int rc;
/* Create DHCP packet */
@@ -885,8 +894,8 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
/* Add client UUID, if we have one. Required for PXE. */
client_uuid.type = DHCP_CLIENT_UUID_TYPE;
- if ( ( rc = fetch_uuid_setting ( NULL, &uuid_setting,
- &client_uuid.uuid ) ) >= 0 ) {
+ if ( ( len = fetch_uuid_setting ( NULL, &uuid_setting,
+ &client_uuid.uuid ) ) >= 0 ) {
if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_CLIENT_UUID,
&client_uuid,
sizeof ( client_uuid ) ) ) != 0 ) {
@@ -896,6 +905,20 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
}
}
+ /* Add user class, if we have one. */
+ if ( ( len = fetch_setting_len ( NULL, &user_class_setting ) ) >= 0 ) {
+ char user_class[len];
+ fetch_setting ( NULL, &user_class_setting, user_class,
+ sizeof ( user_class ) );
+ if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_USER_CLASS_ID,
+ &user_class,
+ sizeof ( user_class ) ) ) != 0 ) {
+ DBG ( "DHCP could not set user class: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+ }
+
return 0;
}