diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index ad05a4e29c..95f9f411e5 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -2076,3 +2076,8 @@ global: nm_setting_sriov_get_preserve_on_down; nm_sriov_preserve_on_down_get_type; } libnm_1_52_0; + +libnm_1_56_0 { +global: + nm_dns_server_validate; +} libnm_1_54_0; diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 959f457bb9..6c77d954b6 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -4221,6 +4221,25 @@ nm_setting_ip_config_clear_dns(NMSettingIPConfig *setting) } } +/** + * nm_dns_server_validate: + * @str: the string containing the DNS server + * @family: the IP address family (%AF_INET for IPv4, %AF_INET6 for IPv6, + * %AF_UNSPEC to accept both IPv4 and IPv6) + * @error: (nullable): a pointer to %NULL #GError, or %NULL + * + * Validates a DNS name server string. + * + * Return: %TRUE if the name server is valid, %FALSE otherwise + * + * Since: 1.56 + */ +gboolean +nm_dns_server_validate(const char *str, int family, GError **error) +{ + return nm_dns_uri_parse(family, str, NULL, error); +} + GPtrArray * _nm_setting_ip_config_get_dns_array(NMSettingIPConfig *setting) { diff --git a/src/libnm-core-public/nm-setting-ip-config.h b/src/libnm-core-public/nm-setting-ip-config.h index 625b941ff1..de05325f24 100644 --- a/src/libnm-core-public/nm-setting-ip-config.h +++ b/src/libnm-core-public/nm-setting-ip-config.h @@ -567,6 +567,9 @@ int nm_setting_ip_config_get_shared_dhcp_lease_time(NMSettingIPConfig *setting); NM_AVAILABLE_IN_1_54 NMSettingIPConfigForwarding nm_setting_ip_config_get_forwarding(NMSettingIPConfig *setting); +NM_AVAILABLE_IN_1_56 +gboolean nm_dns_server_validate(const char *str, int family, GError **error); + G_END_DECLS #endif /* NM_SETTING_IP_CONFIG_H */