diff options
| author | Michael Brown | 2009-02-01 21:06:09 +0100 |
|---|---|---|
| committer | Michael Brown | 2009-02-01 21:06:09 +0100 |
| commit | 4502c04360c997c48b0b00e4bf4142cd63760306 (patch) | |
| tree | 93d55aa4948ff2c47f92f91f4008aee9c3b2a9f7 /src/net/udp/dhcp.c | |
| parent | [tftp] Guard against invalid data block numbers (diff) | |
| download | ipxe-4502c04360c997c48b0b00e4bf4142cd63760306.tar.gz ipxe-4502c04360c997c48b0b00e4bf4142cd63760306.tar.xz ipxe-4502c04360c997c48b0b00e4bf4142cd63760306.zip | |
[dhcp] Send user class in DHCP requests
Diffstat (limited to 'src/net/udp/dhcp.c')
| -rw-r--r-- | src/net/udp/dhcp.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 3554b4058..26c501727 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; } |
