From a4acfef3aad2edd4cc47c9594efc3110b1563322 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 19 Jul 2021 15:14:29 +0200 Subject: [PATCH] n-dhcp4: fix n_dhcp4_client_lease_get_server_identifier() N_DHCP4_E_MALFORMED is an internal error code, replace it with N_DHCP4_E_INTERNAL. Also, remove extra spaces. (cherry picked from commit be6997d1279c01e215383fe2022422c920372a18) --- src/n-dhcp4/src/n-dhcp4-c-lease.c | 8 +++++--- src/n-dhcp4/src/n-dhcp4.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/n-dhcp4/src/n-dhcp4-c-lease.c b/src/n-dhcp4/src/n-dhcp4-c-lease.c index 515814d4e6..6564dbe811 100644 --- a/src/n-dhcp4/src/n-dhcp4-c-lease.c +++ b/src/n-dhcp4/src/n-dhcp4-c-lease.c @@ -249,9 +249,11 @@ _c_public_ void n_dhcp4_client_lease_get_lifetime(NDhcp4ClientLease *lease, uint * Gets the address contained in the server-identifier DHCP option, in network * byte order. * - * Return: 0 on success, negative error code on failure. + * Return: 0 on success, + * N_DHCP4_E_UNSET if the lease doesn't contain a server-identifier, or + * N_DCHP4_E_INTERNAL if the server-identifier is not valid. */ -_c_public_ int n_dhcp4_client_lease_get_server_identifier (NDhcp4ClientLease *lease, struct in_addr *addr) { +_c_public_ int n_dhcp4_client_lease_get_server_identifier(NDhcp4ClientLease *lease, struct in_addr *addr) { uint8_t *data; size_t n_data; int r; @@ -260,7 +262,7 @@ _c_public_ int n_dhcp4_client_lease_get_server_identifier (NDhcp4ClientLease *le if (r) return r; if (n_data < sizeof(struct in_addr)) - return N_DHCP4_E_MALFORMED; + return N_DHCP4_E_INTERNAL; memcpy(addr, data, sizeof(struct in_addr)); diff --git a/src/n-dhcp4/src/n-dhcp4.h b/src/n-dhcp4/src/n-dhcp4.h index 435c5600d8..0be86e9fab 100644 --- a/src/n-dhcp4/src/n-dhcp4.h +++ b/src/n-dhcp4/src/n-dhcp4.h @@ -171,7 +171,7 @@ void n_dhcp4_client_lease_get_siaddr(NDhcp4ClientLease *lease, struct in_addr *s void n_dhcp4_client_lease_get_basetime(NDhcp4ClientLease *lease, uint64_t *ns_basetimep); void n_dhcp4_client_lease_get_lifetime(NDhcp4ClientLease *lease, uint64_t *ns_lifetimep); int n_dhcp4_client_lease_query(NDhcp4ClientLease *lease, uint8_t option, uint8_t **datap, size_t *n_datap); -int n_dhcp4_client_lease_get_server_identifier (NDhcp4ClientLease *lease, struct in_addr *addr); +int n_dhcp4_client_lease_get_server_identifier(NDhcp4ClientLease *lease, struct in_addr *addr); int n_dhcp4_client_lease_select(NDhcp4ClientLease *lease); int n_dhcp4_client_lease_accept(NDhcp4ClientLease *lease);