|
@@ -99,6 +99,12 @@ static uint8_t dhcp_request_options_data[] = {
|
99
|
99
|
DHCP_END
|
100
|
100
|
};
|
101
|
101
|
|
|
102
|
+/** Settings copied in to all DHCP requests */
|
|
103
|
+static const struct setting * dhcp_request_settings[] = {
|
|
104
|
+ &user_class_setting,
|
|
105
|
+ &vendor_class_setting,
|
|
106
|
+};
|
|
107
|
+
|
102
|
108
|
/** DHCP server address setting */
|
103
|
109
|
const struct setting dhcp_server_setting __setting ( SETTING_MISC,
|
104
|
110
|
dhcp-server ) = {
|
|
@@ -975,11 +981,13 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
|
975
|
981
|
struct dhcp_netdev_desc dhcp_desc;
|
976
|
982
|
struct dhcp_client_id client_id;
|
977
|
983
|
struct dhcp_client_uuid client_uuid;
|
|
984
|
+ const struct setting *setting;
|
978
|
985
|
uint8_t *dhcp_features;
|
979
|
986
|
size_t dhcp_features_len;
|
980
|
987
|
size_t ll_addr_len;
|
981
|
|
- void *user_class;
|
|
988
|
+ void *raw;
|
982
|
989
|
ssize_t len;
|
|
990
|
+ unsigned int i;
|
983
|
991
|
int rc;
|
984
|
992
|
|
985
|
993
|
/* Create DHCP packet */
|
|
@@ -1047,19 +1055,23 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
|
1047
|
1055
|
}
|
1048
|
1056
|
}
|
1049
|
1057
|
|
1050
|
|
- /* Add user class, if we have one. */
|
1051
|
|
- if ( ( len = fetch_raw_setting_copy ( NULL, &user_class_setting,
|
1052
|
|
- &user_class ) ) >= 0 ) {
|
1053
|
|
- if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_USER_CLASS_ID,
|
1054
|
|
- user_class, len ) ) != 0 ) {
|
1055
|
|
- DBG ( "DHCP could not set user class: %s\n",
|
1056
|
|
- strerror ( rc ) );
|
1057
|
|
- goto err_store_user_class;
|
|
1058
|
+ /* Add request settings, if applicable */
|
|
1059
|
+ for ( i = 0 ; i < ( sizeof ( dhcp_request_settings ) /
|
|
1060
|
+ sizeof ( dhcp_request_settings[0] ) ) ; i++ ) {
|
|
1061
|
+ setting = dhcp_request_settings[i];
|
|
1062
|
+ if ( ( len = fetch_raw_setting_copy ( NULL, setting,
|
|
1063
|
+ &raw ) ) >= 0 ) {
|
|
1064
|
+ rc = dhcppkt_store ( dhcppkt, setting->tag, raw, len );
|
|
1065
|
+ free ( raw );
|
|
1066
|
+ if ( rc != 0 ) {
|
|
1067
|
+ DBG ( "DHCP could not set %s: %s\n",
|
|
1068
|
+ setting->name, strerror ( rc ) );
|
|
1069
|
+ goto err_store_raw;
|
|
1070
|
+ }
|
1058
|
1071
|
}
|
1059
|
1072
|
}
|
1060
|
1073
|
|
1061
|
|
- err_store_user_class:
|
1062
|
|
- free ( user_class );
|
|
1074
|
+ err_store_raw:
|
1063
|
1075
|
err_store_client_uuid:
|
1064
|
1076
|
err_store_client_id:
|
1065
|
1077
|
err_store_busid:
|