diff options
Diffstat (limited to 'lib/dns/name.c')
-rw-r--r-- | lib/dns/name.c | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/lib/dns/name.c b/lib/dns/name.c index 3b7ff3f962bf..6db373c03b0e 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -2114,11 +2114,9 @@ dns_name_split(dns_name_t *name, unsigned int suffixlabels, REQUIRE(prefix != NULL || suffix != NULL); REQUIRE(prefix == NULL || (VALID_NAME(prefix) && - prefix->buffer != NULL && BINDABLE(prefix))); REQUIRE(suffix == NULL || (VALID_NAME(suffix) && - suffix->buffer != NULL && BINDABLE(suffix))); splitlabel = name->labels - suffixlabels; @@ -2387,6 +2385,8 @@ dns_name_tostring(dns_name_t *name, char **target, isc_mem_t *mctx) { isc_buffer_usedregion(&buf, ®); p = isc_mem_allocate(mctx, reg.length + 1); + if (p == NULL) + return (ISC_R_NOMEMORY); memmove(p, (char *) reg.base, (int) reg.length); p[reg.length] = '\0'; @@ -2501,3 +2501,76 @@ dns_name_destroy(void) { #endif } + +/* + * Service Discovery Prefixes RFC 6763. + */ +static unsigned char b_dns_sd_udp_data[] = "\001b\007_dns-sd\004_udp"; +static unsigned char b_dns_sd_udp_offsets[] = { 0, 2, 10 }; +static unsigned char db_dns_sd_udp_data[] = "\002db\007_dns-sd\004_udp"; +static unsigned char db_dns_sd_udp_offsets[] = { 0, 3, 11 }; +static unsigned char r_dns_sd_udp_data[] = "\001r\007_dns-sd\004_udp"; +static unsigned char r_dns_sd_udp_offsets[] = { 0, 2, 10 }; +static unsigned char dr_dns_sd_udp_data[] = "\002dr\007_dns-sd\004_udp"; +static unsigned char dr_dns_sd_udp_offsets[] = { 0, 3, 11 }; +static unsigned char lb_dns_sd_udp_data[] = "\002lb\007_dns-sd\004_udp"; +static unsigned char lb_dns_sd_udp_offsets[] = { 0, 3, 11 }; + +static const dns_name_t dns_sd[] = { + { + DNS_NAME_MAGIC, + b_dns_sd_udp_data, 15, 3, + DNS_NAMEATTR_READONLY, + b_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + db_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + db_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + r_dns_sd_udp_data, 15, 3, + DNS_NAMEATTR_READONLY, + r_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + dr_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + dr_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + lb_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + lb_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + } +}; + +isc_boolean_t +dns_name_isdnssd(const dns_name_t *name) { + size_t i; + dns_name_t prefix; + + if (dns_name_countlabels(name) > 3U) { + dns_name_init(&prefix, NULL); + dns_name_getlabelsequence(name, 0, 3, &prefix); + for (i = 0; i < (sizeof(dns_sd)/sizeof(dns_sd[0])); i++) + if (dns_name_equal(&prefix, &dns_sd[i])) + return (ISC_TRUE); + } + + return (ISC_FALSE); +} |