diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-04-19 18:09:26 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-05-03 09:08:16 +0200 |
commit | 96d8637ceda382733f027615c36e0beb80abfca1 (patch) | |
tree | bc137815f4017b33b3d120f0aa4b7f3a6647cac7 | |
parent | 15a42113039994ca10bb97919319cb253a22e339 (diff) | |
download | NetworkManager-96d8637ceda382733f027615c36e0beb80abfca1.tar.gz |
core: add nm_dhcp_config_get_option_values()
Introduce a function to return an array of name-value tuples for DHCP
options.
-rw-r--r-- | src/core/nm-dhcp-config.c | 23 | ||||
-rw-r--r-- | src/core/nm-dhcp-config.h | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/core/nm-dhcp-config.c b/src/core/nm-dhcp-config.c index b32c9b7056..394a3a4924 100644 --- a/src/core/nm-dhcp-config.c +++ b/src/core/nm-dhcp-config.c @@ -125,6 +125,29 @@ nm_dhcp_config_set_lease(NMDhcpConfig *self, const NML3ConfigData *l3cd) _notify(self, PROP_OPTIONS); } +NMUtilsNamedValue * +nm_dhcp_config_get_option_values(NMDhcpConfig *self, guint *num) +{ + NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE(self); + NMDhcpLease *lease; + NMUtilsNamedValue *buffer = NULL; + + if (!priv->l3cd) { + NM_SET_OUT(num, 0); + return NULL; + } + + lease = nm_l3_config_data_get_dhcp_lease(priv->l3cd, nm_dhcp_config_get_addr_family(self)); + nm_utils_named_values_from_strdict_full(nm_dhcp_lease_get_options(lease), + num, + nm_strcmp_p_with_data, + NULL, + NULL, + 0, + &buffer); + return buffer; +} + const char * nm_dhcp_config_get_option(NMDhcpConfig *self, const char *key) { diff --git a/src/core/nm-dhcp-config.h b/src/core/nm-dhcp-config.h index cae0e11aa2..cdca4ef1fb 100644 --- a/src/core/nm-dhcp-config.h +++ b/src/core/nm-dhcp-config.h @@ -30,7 +30,8 @@ int nm_dhcp_config_get_addr_family(NMDhcpConfig *self); void nm_dhcp_config_set_lease(NMDhcpConfig *self, const NML3ConfigData *l3cd); -const char *nm_dhcp_config_get_option(NMDhcpConfig *self, const char *option); +NMUtilsNamedValue *nm_dhcp_config_get_option_values(NMDhcpConfig *self, guint *num); +const char *nm_dhcp_config_get_option(NMDhcpConfig *self, const char *option); GVariant *nm_dhcp_config_get_options(NMDhcpConfig *self); |