summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-22 23:22:04 -0500
committerGitHub <noreply@github.com>2016-11-22 23:22:04 -0500
commitee43050b40628368f938b6f366b4a6e94ea898a1 (patch)
treec2d2098c5dd0bb2f84b31153f0260e72d2a6d7c2 /src/shared
parent6d9e45e97fb1157d5670d533f55819a59e7ae336 (diff)
parentef8b0084552e05f28b9132d5dfc75edae164a991 (diff)
Merge pull request #4692 from poettering/networkd-dhcp
Various networkd/DHCP fixes.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/dns-domain.c12
-rw-r--r--src/shared/dns-domain.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index f9a6fd5f03..33debadb15 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -1324,3 +1324,15 @@ int dns_name_apply_idna(const char *name, char **ret) {
return (int) n;
}
+
+int dns_name_is_valid_or_address(const char *name) {
+ /* Returns > 0 if the specified name is either a valid IP address formatted as string or a valid DNS name */
+
+ if (isempty(name))
+ return 0;
+
+ if (in_addr_from_string_auto(name, NULL, NULL) >= 0)
+ return 1;
+
+ return dns_name_is_valid(name);
+}
diff --git a/src/shared/dns-domain.h b/src/shared/dns-domain.h
index af780f0b8b..03f160369c 100644
--- a/src/shared/dns-domain.h
+++ b/src/shared/dns-domain.h
@@ -107,3 +107,5 @@ int dns_name_equal_skip(const char *a, unsigned n_labels, const char *b);
int dns_name_common_suffix(const char *a, const char *b, const char **ret);
int dns_name_apply_idna(const char *name, char **ret);
+
+int dns_name_is_valid_or_address(const char *name);