summaryrefslogtreecommitdiff
path: root/src/shared/dns-domain.h
diff options
context:
space:
mode:
authorNick Owens <nick.owens@coreos.com>2015-06-02 16:29:39 -0700
committerNick Owens <nick.owens@coreos.com>2015-06-10 11:15:46 -0700
commitdf6cfeeff7b66856dd20956efe97d87faf8ce1c3 (patch)
treee92e694873171b6c618508ee71057a3d5362e638 /src/shared/dns-domain.h
parent4ad7f2761da661853dcc29d542efb4727abb1101 (diff)
shared: add convenience function for validating dns names
Diffstat (limited to 'src/shared/dns-domain.h')
-rw-r--r--src/shared/dns-domain.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shared/dns-domain.h b/src/shared/dns-domain.h
index 516d244f7a..00caf5d700 100644
--- a/src/shared/dns-domain.h
+++ b/src/shared/dns-domain.h
@@ -35,6 +35,15 @@ int dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded
int dns_label_undo_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max);
int dns_name_normalize(const char *s, char **_ret);
+static inline int dns_name_is_valid(const char *s) {
+ int r;
+ r = dns_name_normalize(s, NULL);
+ if (r == -EINVAL)
+ return 0;
+ if (r < 0)
+ return r;
+ return 1;
+}
unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]);
int dns_name_compare_func(const void *a, const void *b);