n-dhcp4: allow not to send the client-identifier

Sending the client-identifier (DHCP Option 61) is not mandatory,
although it's recommended, and there are some weird cases where
clients need not to send it.

Allow not to send it by leaving client_id unset.
This commit is contained in:
Íñigo Huguet 2023-09-29 14:24:08 +02:00
parent f78a18bf16
commit 320e386b09
2 changed files with 9 additions and 7 deletions

View file

@ -543,12 +543,14 @@ static int n_dhcp4_c_connection_new_message(NDhcp4CConnection *connection,
if (r)
return r;
r = n_dhcp4_outgoing_append(message,
N_DHCP4_OPTION_CLIENT_IDENTIFIER,
connection->client_config->client_id,
connection->client_config->n_client_id);
if (r)
return r;
if (connection->client_config->n_client_id > 0) {
r = n_dhcp4_outgoing_append(message,
N_DHCP4_OPTION_CLIENT_IDENTIFIER,
connection->client_config->client_id,
connection->client_config->n_client_id);
if (r)
return r;
}
switch (message_type) {
case N_DHCP4_MESSAGE_DISCOVER:

View file

@ -403,7 +403,7 @@ _c_public_ int n_dhcp4_client_new(NDhcp4Client **clientp, NDhcp4ClientConfig *co
return N_DHCP4_E_INVALID_TRANSPORT;
}
if (config->n_client_id < 1)
if (config->n_client_id != 0 && config->n_client_id < 2)
return N_DHCP4_E_INVALID_CLIENT_ID;
}