1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2014 Lennart Poettering
12 # include <stringprep.h>
16 #include <netinet/in.h>
19 #include <sys/socket.h>
21 #include "alloc-util.h"
22 #include "dns-domain.h"
24 #include "hexdecoct.h"
25 #include "in-addr-util.h"
27 #include "parse-util.h"
28 #include "string-util.h"
32 int dns_label_unescape(const char **name
, char *dest
, size_t sz
) {
52 if (r
>= DNS_LABEL_MAX
)
59 /* Escaped character */
67 else if (IN_SET(*n
, '\\', '.')) {
68 /* Escaped backslash or dot */
76 } else if (n
[0] >= '0' && n
[0] <= '9') {
79 /* Escaped literal ASCII character */
81 if (!(n
[1] >= '0' && n
[1] <= '9') ||
82 !(n
[2] >= '0' && n
[2] <= '9'))
85 k
= ((unsigned) (n
[0] - '0') * 100) +
86 ((unsigned) (n
[1] - '0') * 10) +
87 ((unsigned) (n
[2] - '0'));
89 /* Don't allow anything that doesn't
90 * fit in 8bit. Note that we do allow
91 * control characters, as some servers
92 * (e.g. cloudflare) are happy to
93 * generate labels with them
107 } else if ((uint8_t) *n
>= (uint8_t) ' ' && *n
!= 127) {
109 /* Normal character */
120 /* Empty label that is not at the end? */
124 /* More than one trailing dot? */
135 /* @label_terminal: terminal character of a label, updated to point to the terminal character of
136 * the previous label (always skipping one dot) or to NULL if there are no more
138 int dns_label_unescape_suffix(const char *name
, const char **label_terminal
, char *dest
, size_t sz
) {
139 const char *terminal
;
143 assert(label_terminal
);
147 if (!*label_terminal
) {
154 terminal
= *label_terminal
;
155 assert(IN_SET(*terminal
, 0, '.'));
157 /* Skip current terminal character (and accept domain names ending it ".") */
160 if (terminal
>= name
&& *terminal
== '.')
163 /* Point name to the last label, and terminal to the preceding terminal symbol (or make it a NULL pointer) */
165 if (terminal
< name
) {
166 /* Reached the first label, so indicate that there are no more */
171 /* Find the start of the last label */
172 if (*terminal
== '.') {
174 unsigned slashes
= 0;
176 for (y
= terminal
- 1; y
>= name
&& *y
== '\\'; y
--)
179 if (slashes
% 2 == 0) {
180 /* The '.' was not escaped */
192 r
= dns_label_unescape(&name
, dest
, sz
);
196 *label_terminal
= terminal
;
201 int dns_label_escape(const char *p
, size_t l
, char *dest
, size_t sz
) {
204 /* DNS labels must be between 1 and 63 characters long. A
205 * zero-length label does not exist. See RFC 2182, Section
208 if (l
<= 0 || l
> DNS_LABEL_MAX
)
219 if (IN_SET(*p
, '.', '\\')) {
221 /* Dot or backslash */
231 } else if (IN_SET(*p
, '_', '-') ||
232 (*p
>= '0' && *p
<= '9') ||
233 (*p
>= 'a' && *p
<= 'z') ||
234 (*p
>= 'A' && *p
<= 'Z')) {
236 /* Proper character */
246 /* Everything else */
252 *(q
++) = '0' + (char) ((uint8_t) *p
/ 100);
253 *(q
++) = '0' + (char) (((uint8_t) *p
/ 10) % 10);
254 *(q
++) = '0' + (char) ((uint8_t) *p
% 10);
264 return (int) (q
- dest
);
267 int dns_label_escape_new(const char *p
, size_t l
, char **ret
) {
268 _cleanup_free_
char *s
= NULL
;
274 if (l
<= 0 || l
> DNS_LABEL_MAX
)
277 s
= new(char, DNS_LABEL_ESCAPED_MAX
);
281 r
= dns_label_escape(p
, l
, s
, DNS_LABEL_ESCAPED_MAX
);
291 int dns_label_apply_idna(const char *encoded
, size_t encoded_size
, char *decoded
, size_t decoded_max
) {
292 _cleanup_free_
uint32_t *input
= NULL
;
293 size_t input_size
, l
;
295 bool contains_8bit
= false;
296 char buffer
[DNS_LABEL_MAX
+1];
301 /* Converts an U-label into an A-label */
303 if (encoded_size
<= 0)
306 for (p
= encoded
; p
< encoded
+ encoded_size
; p
++)
307 if ((uint8_t) *p
> 127)
308 contains_8bit
= true;
310 if (!contains_8bit
) {
311 if (encoded_size
> DNS_LABEL_MAX
)
317 input
= stringprep_utf8_to_ucs4(encoded
, encoded_size
, &input_size
);
321 if (idna_to_ascii_4i(input
, input_size
, buffer
, 0) != 0)
326 /* Verify that the result is not longer than one DNS label. */
327 if (l
<= 0 || l
> DNS_LABEL_MAX
)
332 memcpy(decoded
, buffer
, l
);
334 /* If there's room, append a trailing NUL byte, but only then */
341 int dns_label_undo_idna(const char *encoded
, size_t encoded_size
, char *decoded
, size_t decoded_max
) {
342 size_t input_size
, output_size
;
343 _cleanup_free_
uint32_t *input
= NULL
;
344 _cleanup_free_
char *result
= NULL
;
345 uint32_t *output
= NULL
;
348 /* To be invoked after unescaping. Converts an A-label into an U-label. */
353 if (encoded_size
<= 0 || encoded_size
> DNS_LABEL_MAX
)
356 if (!memory_startswith(encoded
, encoded_size
, IDNA_ACE_PREFIX
))
359 input
= stringprep_utf8_to_ucs4(encoded
, encoded_size
, &input_size
);
363 output_size
= input_size
;
364 output
= newa(uint32_t, output_size
);
366 idna_to_unicode_44i(input
, input_size
, output
, &output_size
, 0);
368 result
= stringprep_ucs4_to_utf8(output
, output_size
, NULL
, &w
);
376 memcpy(decoded
, result
, w
);
378 /* Append trailing NUL byte if there's space, but only then. */
386 int dns_name_concat(const char *a
, const char *b
, char **_ret
) {
387 _cleanup_free_
char *ret
= NULL
;
388 size_t n
= 0, allocated
= 0;
401 char label
[DNS_LABEL_MAX
];
403 r
= dns_label_unescape(&p
, label
, sizeof(label
));
411 /* Now continue with the second string, if there is one */
420 if (!GREEDY_REALLOC(ret
, allocated
, n
+ !first
+ DNS_LABEL_ESCAPED_MAX
))
423 r
= dns_label_escape(label
, r
, ret
+ n
+ !first
, DNS_LABEL_ESCAPED_MAX
);
430 char escaped
[DNS_LABEL_ESCAPED_MAX
];
432 r
= dns_label_escape(label
, r
, escaped
, sizeof(escaped
));
446 if (n
> DNS_HOSTNAME_MAX
)
451 /* Nothing appended? If so, generate at least a single dot, to indicate the DNS root domain */
452 if (!GREEDY_REALLOC(ret
, allocated
, 2))
457 if (!GREEDY_REALLOC(ret
, allocated
, n
+ 1))
462 *_ret
= TAKE_PTR(ret
);
468 void dns_name_hash_func(const void *s
, struct siphash
*state
) {
475 char label
[DNS_LABEL_MAX
+1];
477 r
= dns_label_unescape(&p
, label
, sizeof(label
));
483 ascii_strlower_n(label
, r
);
484 siphash24_compress(label
, r
, state
);
485 siphash24_compress_byte(0, state
); /* make sure foobar and foo.bar result in different hashes */
488 /* enforce that all names are terminated by the empty label */
489 string_hash_func("", state
);
492 int dns_name_compare_func(const void *a
, const void *b
) {
499 x
= (const char *) a
+ strlen(a
);
500 y
= (const char *) b
+ strlen(b
);
503 char la
[DNS_LABEL_MAX
], lb
[DNS_LABEL_MAX
];
505 if (x
== NULL
&& y
== NULL
)
508 r
= dns_label_unescape_suffix(a
, &x
, la
, sizeof(la
));
509 q
= dns_label_unescape_suffix(b
, &y
, lb
, sizeof(lb
));
513 r
= ascii_strcasecmp_nn(la
, r
, lb
, q
);
519 const struct hash_ops dns_name_hash_ops
= {
520 .hash
= dns_name_hash_func
,
521 .compare
= dns_name_compare_func
524 int dns_name_equal(const char *x
, const char *y
) {
531 char la
[DNS_LABEL_MAX
], lb
[DNS_LABEL_MAX
];
533 r
= dns_label_unescape(&x
, la
, sizeof(la
));
537 q
= dns_label_unescape(&y
, lb
, sizeof(lb
));
546 if (ascii_strcasecmp_n(la
, lb
, r
) != 0)
551 int dns_name_endswith(const char *name
, const char *suffix
) {
552 const char *n
, *s
, *saved_n
= NULL
;
562 char ln
[DNS_LABEL_MAX
], ls
[DNS_LABEL_MAX
];
564 r
= dns_label_unescape(&n
, ln
, sizeof(ln
));
571 q
= dns_label_unescape(&s
, ls
, sizeof(ls
));
575 if (r
== 0 && q
== 0)
577 if (r
== 0 && saved_n
== n
)
580 if (r
!= q
|| ascii_strcasecmp_n(ln
, ls
, r
) != 0) {
582 /* Not the same, let's jump back, and try with the next label again */
584 n
= TAKE_PTR(saved_n
);
589 int dns_name_startswith(const char *name
, const char *prefix
) {
600 char ln
[DNS_LABEL_MAX
], lp
[DNS_LABEL_MAX
];
602 r
= dns_label_unescape(&p
, lp
, sizeof(lp
));
608 q
= dns_label_unescape(&n
, ln
, sizeof(ln
));
614 if (ascii_strcasecmp_n(ln
, lp
, r
) != 0)
619 int dns_name_change_suffix(const char *name
, const char *old_suffix
, const char *new_suffix
, char **ret
) {
620 const char *n
, *s
, *saved_before
= NULL
, *saved_after
= NULL
, *prefix
;
632 char ln
[DNS_LABEL_MAX
], ls
[DNS_LABEL_MAX
];
637 r
= dns_label_unescape(&n
, ln
, sizeof(ln
));
644 q
= dns_label_unescape(&s
, ls
, sizeof(ls
));
648 if (r
== 0 && q
== 0)
650 if (r
== 0 && saved_after
== n
) {
651 *ret
= NULL
; /* doesn't match */
655 if (r
!= q
|| ascii_strcasecmp_n(ln
, ls
, r
) != 0) {
657 /* Not the same, let's jump back, and try with the next label again */
659 n
= TAKE_PTR(saved_after
);
664 /* Found it! Now generate the new name */
665 prefix
= strndupa(name
, saved_before
- name
);
667 r
= dns_name_concat(prefix
, new_suffix
, ret
);
674 int dns_name_between(const char *a
, const char *b
, const char *c
) {
675 /* Determine if b is strictly greater than a and strictly smaller than c.
676 We consider the order of names to be circular, so that if a is
677 strictly greater than c, we consider b to be between them if it is
678 either greater than a or smaller than c. This is how the canonical
679 DNS name order used in NSEC records work. */
681 if (dns_name_compare_func(a
, c
) < 0)
683 a and c are properly ordered:
686 return dns_name_compare_func(a
, b
) < 0 &&
687 dns_name_compare_func(b
, c
) < 0;
690 a and c are equal or 'reversed':
695 return dns_name_compare_func(b
, c
) < 0 ||
696 dns_name_compare_func(a
, b
) < 0;
699 int dns_name_reverse(int family
, const union in_addr_union
*a
, char **ret
) {
706 p
= (const uint8_t*) a
;
708 if (family
== AF_INET
)
709 r
= asprintf(ret
, "%u.%u.%u.%u.in-addr.arpa", p
[3], p
[2], p
[1], p
[0]);
710 else if (family
== AF_INET6
)
711 r
= asprintf(ret
, "%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.%c.ip6.arpa",
712 hexchar(p
[15] & 0xF), hexchar(p
[15] >> 4), hexchar(p
[14] & 0xF), hexchar(p
[14] >> 4),
713 hexchar(p
[13] & 0xF), hexchar(p
[13] >> 4), hexchar(p
[12] & 0xF), hexchar(p
[12] >> 4),
714 hexchar(p
[11] & 0xF), hexchar(p
[11] >> 4), hexchar(p
[10] & 0xF), hexchar(p
[10] >> 4),
715 hexchar(p
[ 9] & 0xF), hexchar(p
[ 9] >> 4), hexchar(p
[ 8] & 0xF), hexchar(p
[ 8] >> 4),
716 hexchar(p
[ 7] & 0xF), hexchar(p
[ 7] >> 4), hexchar(p
[ 6] & 0xF), hexchar(p
[ 6] >> 4),
717 hexchar(p
[ 5] & 0xF), hexchar(p
[ 5] >> 4), hexchar(p
[ 4] & 0xF), hexchar(p
[ 4] >> 4),
718 hexchar(p
[ 3] & 0xF), hexchar(p
[ 3] >> 4), hexchar(p
[ 2] & 0xF), hexchar(p
[ 2] >> 4),
719 hexchar(p
[ 1] & 0xF), hexchar(p
[ 1] >> 4), hexchar(p
[ 0] & 0xF), hexchar(p
[ 0] >> 4));
721 return -EAFNOSUPPORT
;
728 int dns_name_address(const char *p
, int *family
, union in_addr_union
*address
) {
735 r
= dns_name_endswith(p
, "in-addr.arpa");
742 for (i
= 0; i
< ELEMENTSOF(a
); i
++) {
743 char label
[DNS_LABEL_MAX
+1];
745 r
= dns_label_unescape(&p
, label
, sizeof(label
));
753 r
= safe_atou8(label
, &a
[i
]);
758 r
= dns_name_equal(p
, "in-addr.arpa");
763 address
->in
.s_addr
= htobe32(((uint32_t) a
[3] << 24) |
764 ((uint32_t) a
[2] << 16) |
765 ((uint32_t) a
[1] << 8) |
771 r
= dns_name_endswith(p
, "ip6.arpa");
778 for (i
= 0; i
< ELEMENTSOF(a
.s6_addr
); i
++) {
779 char label
[DNS_LABEL_MAX
+1];
782 r
= dns_label_unescape(&p
, label
, sizeof(label
));
787 x
= unhexchar(label
[0]);
791 r
= dns_label_unescape(&p
, label
, sizeof(label
));
796 y
= unhexchar(label
[0]);
800 a
.s6_addr
[ELEMENTSOF(a
.s6_addr
) - i
- 1] = (uint8_t) y
<< 4 | (uint8_t) x
;
803 r
= dns_name_equal(p
, "ip6.arpa");
815 bool dns_name_is_root(const char *name
) {
819 /* There are exactly two ways to encode the root domain name:
820 * as empty string, or with a single dot. */
822 return STR_IN_SET(name
, "", ".");
825 bool dns_name_is_single_label(const char *name
) {
830 r
= dns_name_parent(&name
);
834 return dns_name_is_root(name
);
837 /* Encode a domain name according to RFC 1035 Section 3.1, without compression */
838 int dns_name_to_wire_format(const char *domain
, uint8_t *buffer
, size_t len
, bool canonical
) {
839 uint8_t *label_length
, *out
;
848 /* Reserve a byte for label length */
855 /* Convert and copy a single label. Note that
856 * dns_label_unescape() returns 0 when it hits the end
857 * of the domain name, which we rely on here to encode
858 * the trailing NUL byte. */
859 r
= dns_label_unescape(&domain
, (char *) out
, len
);
863 /* Optionally, output the name in DNSSEC canonical
864 * format, as described in RFC 4034, section 6.2. Or
865 * in other words: in lower-case. */
867 ascii_strlower_n((char*) out
, (size_t) r
);
869 /* Fill label length, move forward */
876 /* Verify the maximum size of the encoded name. The trailing
877 * dot + NUL byte account are included this time, hence
878 * compare against DNS_HOSTNAME_MAX + 2 (which is 255) this
880 if (out
- buffer
> DNS_HOSTNAME_MAX
+ 2)
886 static bool srv_type_label_is_valid(const char *label
, size_t n
) {
891 if (n
< 2) /* Label needs to be at least 2 chars long */
894 if (label
[0] != '_') /* First label char needs to be underscore */
897 /* Second char must be a letter */
898 if (!(label
[1] >= 'A' && label
[1] <= 'Z') &&
899 !(label
[1] >= 'a' && label
[1] <= 'z'))
902 /* Third and further chars must be alphanumeric or a hyphen */
903 for (k
= 2; k
< n
; k
++) {
904 if (!(label
[k
] >= 'A' && label
[k
] <= 'Z') &&
905 !(label
[k
] >= 'a' && label
[k
] <= 'z') &&
906 !(label
[k
] >= '0' && label
[k
] <= '9') &&
914 bool dns_srv_type_is_valid(const char *name
) {
922 char label
[DNS_LABEL_MAX
];
924 /* This more or less implements RFC 6335, Section 5.1 */
926 r
= dns_label_unescape(&name
, label
, sizeof(label
));
935 if (!srv_type_label_is_valid(label
, r
))
941 return c
== 2; /* exactly two labels */
944 bool dnssd_srv_type_is_valid(const char *name
) {
945 return dns_srv_type_is_valid(name
) &&
946 ((dns_name_endswith(name
, "_tcp") > 0) ||
947 (dns_name_endswith(name
, "_udp") > 0)); /* Specific to DNS-SD. RFC 6763, Section 7 */
950 bool dns_service_name_is_valid(const char *name
) {
953 /* This more or less implements RFC 6763, Section 4.1.1 */
958 if (!utf8_is_valid(name
))
961 if (string_has_cc(name
, NULL
))
973 int dns_service_join(const char *name
, const char *type
, const char *domain
, char **ret
) {
974 char escaped
[DNS_LABEL_ESCAPED_MAX
];
975 _cleanup_free_
char *n
= NULL
;
982 if (!dns_srv_type_is_valid(type
))
986 return dns_name_concat(type
, domain
, ret
);
988 if (!dns_service_name_is_valid(name
))
991 r
= dns_label_escape(name
, strlen(name
), escaped
, sizeof(escaped
));
995 r
= dns_name_concat(type
, domain
, &n
);
999 return dns_name_concat(escaped
, n
, ret
);
1002 static bool dns_service_name_label_is_valid(const char *label
, size_t n
) {
1007 if (memchr(label
, 0, n
))
1010 s
= strndupa(label
, n
);
1011 return dns_service_name_is_valid(s
);
1014 int dns_service_split(const char *joined
, char **_name
, char **_type
, char **_domain
) {
1015 _cleanup_free_
char *name
= NULL
, *type
= NULL
, *domain
= NULL
;
1016 const char *p
= joined
, *q
= NULL
, *d
= NULL
;
1017 char a
[DNS_LABEL_MAX
], b
[DNS_LABEL_MAX
], c
[DNS_LABEL_MAX
];
1023 /* Get first label from the full name */
1024 an
= dns_label_unescape(&p
, a
, sizeof(a
));
1031 /* If there was a first label, try to get the second one */
1032 bn
= dns_label_unescape(&p
, b
, sizeof(b
));
1039 /* If there was a second label, try to get the third one */
1041 cn
= dns_label_unescape(&p
, c
, sizeof(c
));
1052 if (x
>= 2 && srv_type_label_is_valid(b
, bn
)) {
1054 if (x
>= 3 && srv_type_label_is_valid(c
, cn
)) {
1056 if (dns_service_name_label_is_valid(a
, an
)) {
1057 /* OK, got <name> . <type> . <type2> . <domain> */
1059 name
= strndup(a
, an
);
1063 type
= strjoin(b
, ".", c
);
1071 } else if (srv_type_label_is_valid(a
, an
)) {
1073 /* OK, got <type> . <type2> . <domain> */
1077 type
= strjoin(a
, ".", b
);
1091 r
= dns_name_normalize(d
, &domain
);
1096 *_domain
= TAKE_PTR(domain
);
1099 *_type
= TAKE_PTR(type
);
1102 *_name
= TAKE_PTR(name
);
1107 static int dns_name_build_suffix_table(const char *name
, const char*table
[]) {
1117 if (n
> DNS_N_LABELS_MAX
)
1121 r
= dns_name_parent(&p
);
1133 int dns_name_suffix(const char *name
, unsigned n_labels
, const char **ret
) {
1134 const char* labels
[DNS_N_LABELS_MAX
+1];
1140 n
= dns_name_build_suffix_table(name
, labels
);
1144 if ((unsigned) n
< n_labels
)
1147 *ret
= labels
[n
- n_labels
];
1148 return (int) (n
- n_labels
);
1151 int dns_name_skip(const char *a
, unsigned n_labels
, const char **ret
) {
1157 for (; n_labels
> 0; n_labels
--) {
1158 r
= dns_name_parent(&a
);
1171 int dns_name_count_labels(const char *name
) {
1180 r
= dns_name_parent(&p
);
1186 if (n
>= DNS_N_LABELS_MAX
)
1195 int dns_name_equal_skip(const char *a
, unsigned n_labels
, const char *b
) {
1201 r
= dns_name_skip(a
, n_labels
, &a
);
1205 return dns_name_equal(a
, b
);
1208 int dns_name_common_suffix(const char *a
, const char *b
, const char **ret
) {
1209 const char *a_labels
[DNS_N_LABELS_MAX
+1], *b_labels
[DNS_N_LABELS_MAX
+1];
1210 int n
= 0, m
= 0, k
= 0, r
, q
;
1216 /* Determines the common suffix of domain names a and b */
1218 n
= dns_name_build_suffix_table(a
, a_labels
);
1222 m
= dns_name_build_suffix_table(b
, b_labels
);
1227 char la
[DNS_LABEL_MAX
], lb
[DNS_LABEL_MAX
];
1230 if (k
>= n
|| k
>= m
) {
1231 *ret
= a_labels
[n
- k
];
1235 x
= a_labels
[n
- 1 - k
];
1236 r
= dns_label_unescape(&x
, la
, sizeof(la
));
1240 y
= b_labels
[m
- 1 - k
];
1241 q
= dns_label_unescape(&y
, lb
, sizeof(lb
));
1245 if (r
!= q
|| ascii_strcasecmp_n(la
, lb
, r
) != 0) {
1246 *ret
= a_labels
[n
- k
];
1254 int dns_name_apply_idna(const char *name
, char **ret
) {
1255 /* Return negative on error, 0 if not implemented, positive on success. */
1259 _cleanup_free_
char *t
= NULL
;
1264 r
= idn2_lookup_u8((uint8_t*) name
, (uint8_t**) &t
,
1265 IDN2_NFC_INPUT
| IDN2_NONTRANSITIONAL
);
1266 log_debug("idn2_lookup_u8: %s → %s", name
, t
);
1268 if (!startswith(name
, "xn--")) {
1269 _cleanup_free_
char *s
= NULL
;
1271 r
= idn2_to_unicode_8z8z(t
, &s
, 0);
1273 log_debug("idn2_to_unicode_8z8z(\"%s\") failed: %d/%s",
1274 t
, r
, idn2_strerror(r
));
1278 if (!streq_ptr(name
, s
)) {
1279 log_debug("idn2 roundtrip failed: \"%s\" → \"%s\" → \"%s\", ignoring.",
1287 return 1; /* *ret has been written */
1290 log_debug("idn2_lookup_u8(\"%s\") failed: %d/%s", name
, r
, idn2_strerror(r
));
1291 if (r
== IDN2_2HYPHEN
)
1292 /* The name has two hypens — forbidden by IDNA2008 in some cases */
1294 if (IN_SET(r
, IDN2_TOO_BIG_DOMAIN
, IDN2_TOO_BIG_LABEL
))
1298 _cleanup_free_
char *buf
= NULL
;
1299 size_t n
= 0, allocated
= 0;
1307 char label
[DNS_LABEL_MAX
];
1309 r
= dns_label_unescape(&name
, label
, sizeof(label
));
1315 q
= dns_label_apply_idna(label
, r
, label
, sizeof(label
));
1321 if (!GREEDY_REALLOC(buf
, allocated
, n
+ !first
+ DNS_LABEL_ESCAPED_MAX
))
1324 r
= dns_label_escape(label
, r
, buf
+ n
+ !first
, DNS_LABEL_ESCAPED_MAX
);
1336 if (n
> DNS_HOSTNAME_MAX
)
1339 if (!GREEDY_REALLOC(buf
, allocated
, n
+ 1))
1343 *ret
= TAKE_PTR(buf
);
1351 int dns_name_is_valid_or_address(const char *name
) {
1352 /* Returns > 0 if the specified name is either a valid IP address formatted as string or a valid DNS name */
1357 if (in_addr_from_string_auto(name
, NULL
, NULL
) >= 0)
1360 return dns_name_is_valid(name
);