version 1.2.2.2, 2018/09/06 06:55:00 |
version 1.2.2.3, 2019/01/18 08:49:53 |
|
|
#include <config.h> |
#include <config.h> |
|
|
#include <ctype.h> |
#include <ctype.h> |
|
#include <inttypes.h> |
|
#include <stdbool.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
#include <isc/buffer.h> |
#include <isc/buffer.h> |
Line 162 static dns_name_t const wild = |
|
Line 164 static dns_name_t const wild = |
|
|
|
LIBDNS_EXTERNAL_DATA const dns_name_t *dns_wildcardname = &wild; |
LIBDNS_EXTERNAL_DATA const dns_name_t *dns_wildcardname = &wild; |
|
|
unsigned int |
|
dns_fullname_hash(const dns_name_t *name, isc_boolean_t case_sensitive); |
|
|
|
/* |
/* |
* dns_name_t to text post-conversion procedure. |
* dns_name_t to text post-conversion procedure. |
*/ |
*/ |
#ifdef ISC_PLATFORM_USETHREADS |
|
static int thread_key_initialized = 0; |
static int thread_key_initialized = 0; |
static isc_mutex_t thread_key_mutex; |
static isc_mutex_t thread_key_mutex; |
static isc_mem_t *thread_key_mctx = NULL; |
static isc_mem_t *thread_key_mctx = NULL; |
static isc_thread_key_t totext_filter_proc_key; |
static isc_thread_key_t totext_filter_proc_key; |
static isc_once_t once = ISC_ONCE_INIT; |
static isc_once_t once = ISC_ONCE_INIT; |
#else |
|
static dns_name_totextfilter_t totext_filter_proc = NULL; |
|
#endif |
|
|
|
static void |
static void |
set_offsets(const dns_name_t *name, unsigned char *offsets, |
set_offsets(const dns_name_t *name, unsigned char *offsets, |
Line 216 dns_name_invalidate(dns_name_t *name) { |
|
Line 211 dns_name_invalidate(dns_name_t *name) { |
|
ISC_LINK_INIT(name, link); |
ISC_LINK_INIT(name, link); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_isvalid(const dns_name_t *name) { |
dns_name_isvalid(const dns_name_t *name) { |
unsigned char *ndata, *offsets; |
unsigned char *ndata, *offsets; |
unsigned int offset, count, length, nlabels; |
unsigned int offset, count, length, nlabels; |
|
|
if (!VALID_NAME(name)) |
if (!VALID_NAME(name)) |
return (ISC_FALSE); |
return (false); |
|
|
if (name->length > 255U || name->labels > 127U) |
if (name->length > 255U || name->labels > 127U) |
return (ISC_FALSE); |
return (false); |
|
|
ndata = name->ndata; |
ndata = name->ndata; |
length = name->length; |
length = name->length; |
Line 236 dns_name_isvalid(const dns_name_t *name) |
|
Line 231 dns_name_isvalid(const dns_name_t *name) |
|
while (offset != length) { |
while (offset != length) { |
count = *ndata; |
count = *ndata; |
if (count > 63U) |
if (count > 63U) |
return (ISC_FALSE); |
return (false); |
if (offsets != NULL && offsets[nlabels] != offset) |
if (offsets != NULL && offsets[nlabels] != offset) |
return (ISC_FALSE); |
return (false); |
|
|
nlabels++; |
nlabels++; |
offset += count + 1; |
offset += count + 1; |
ndata += count + 1; |
ndata += count + 1; |
if (offset > length) |
if (offset > length) |
return (ISC_FALSE); |
return (false); |
|
|
if (count == 0) |
if (count == 0) |
break; |
break; |
} |
} |
|
|
if (nlabels != name->labels || offset != name->length) |
if (nlabels != name->labels || offset != name->length) |
return (ISC_FALSE); |
return (false); |
|
|
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
void |
void |
Line 269 dns_name_setbuffer(dns_name_t *name, isc |
|
Line 264 dns_name_setbuffer(dns_name_t *name, isc |
|
name->buffer = buffer; |
name->buffer = buffer; |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_hasbuffer(const dns_name_t *name) { |
dns_name_hasbuffer(const dns_name_t *name) { |
/* |
/* |
* Does 'name' have a dedicated buffer? |
* Does 'name' have a dedicated buffer? |
Line 278 dns_name_hasbuffer(const dns_name_t *nam |
|
Line 273 dns_name_hasbuffer(const dns_name_t *nam |
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
|
|
if (name->buffer != NULL) |
if (name->buffer != NULL) |
return (ISC_TRUE); |
return (true); |
|
|
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_isabsolute(const dns_name_t *name) { |
dns_name_isabsolute(const dns_name_t *name) { |
|
|
/* |
/* |
Line 293 dns_name_isabsolute(const dns_name_t *na |
|
Line 288 dns_name_isabsolute(const dns_name_t *na |
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
|
|
if ((name->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) |
if ((name->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) |
return (ISC_TRUE); |
return (true); |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
#define hyphenchar(c) ((c) == 0x2d) |
#define hyphenchar(c) ((c) == 0x2d) |
Line 306 dns_name_isabsolute(const dns_name_t *na |
|
Line 301 dns_name_isabsolute(const dns_name_t *na |
|
#define middlechar(c) (borderchar(c) || hyphenchar(c)) |
#define middlechar(c) (borderchar(c) || hyphenchar(c)) |
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) |
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) |
|
|
isc_boolean_t |
bool |
dns_name_ismailbox(const dns_name_t *name) { |
dns_name_ismailbox(const dns_name_t *name) { |
unsigned char *ndata, ch; |
unsigned char *ndata, ch; |
unsigned int n; |
unsigned int n; |
isc_boolean_t first; |
bool first; |
|
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
REQUIRE(name->labels > 0); |
REQUIRE(name->labels > 0); |
Line 320 dns_name_ismailbox(const dns_name_t *nam |
|
Line 315 dns_name_ismailbox(const dns_name_t *nam |
|
* Root label. |
* Root label. |
*/ |
*/ |
if (name->length == 1) |
if (name->length == 1) |
return (ISC_TRUE); |
return (true); |
|
|
ndata = name->ndata; |
ndata = name->ndata; |
n = *ndata++; |
n = *ndata++; |
Line 328 dns_name_ismailbox(const dns_name_t *nam |
|
Line 323 dns_name_ismailbox(const dns_name_t *nam |
|
while (n--) { |
while (n--) { |
ch = *ndata++; |
ch = *ndata++; |
if (!domainchar(ch)) |
if (!domainchar(ch)) |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
if (ndata == name->ndata + name->length) |
if (ndata == name->ndata + name->length) |
return (ISC_FALSE); |
return (false); |
|
|
/* |
/* |
* RFC952/RFC1123 hostname. |
* RFC952/RFC1123 hostname. |
Line 340 dns_name_ismailbox(const dns_name_t *nam |
|
Line 335 dns_name_ismailbox(const dns_name_t *nam |
|
while (ndata < (name->ndata + name->length)) { |
while (ndata < (name->ndata + name->length)) { |
n = *ndata++; |
n = *ndata++; |
INSIST(n <= 63); |
INSIST(n <= 63); |
first = ISC_TRUE; |
first = true; |
while (n--) { |
while (n--) { |
ch = *ndata++; |
ch = *ndata++; |
if (first || n == 0) { |
if (first || n == 0) { |
if (!borderchar(ch)) |
if (!borderchar(ch)) |
return (ISC_FALSE); |
return (false); |
} else { |
} else { |
if (!middlechar(ch)) |
if (!middlechar(ch)) |
return (ISC_FALSE); |
return (false); |
} |
} |
first = ISC_FALSE; |
first = false; |
} |
} |
} |
} |
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard) { |
dns_name_ishostname(const dns_name_t *name, bool wildcard) { |
unsigned char *ndata, ch; |
unsigned char *ndata, ch; |
unsigned int n; |
unsigned int n; |
isc_boolean_t first; |
bool first; |
|
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
REQUIRE(name->labels > 0); |
REQUIRE(name->labels > 0); |
Line 370 dns_name_ishostname(const dns_name_t *na |
|
Line 365 dns_name_ishostname(const dns_name_t *na |
|
* Root label. |
* Root label. |
*/ |
*/ |
if (name->length == 1) |
if (name->length == 1) |
return (ISC_TRUE); |
return (true); |
|
|
/* |
/* |
* Skip wildcard if this is a ownername. |
* Skip wildcard if this is a ownername. |
Line 385 dns_name_ishostname(const dns_name_t *na |
|
Line 380 dns_name_ishostname(const dns_name_t *na |
|
while (ndata < (name->ndata + name->length)) { |
while (ndata < (name->ndata + name->length)) { |
n = *ndata++; |
n = *ndata++; |
INSIST(n <= 63); |
INSIST(n <= 63); |
first = ISC_TRUE; |
first = true; |
while (n--) { |
while (n--) { |
ch = *ndata++; |
ch = *ndata++; |
if (first || n == 0) { |
if (first || n == 0) { |
if (!borderchar(ch)) |
if (!borderchar(ch)) |
return (ISC_FALSE); |
return (false); |
} else { |
} else { |
if (!middlechar(ch)) |
if (!middlechar(ch)) |
return (ISC_FALSE); |
return (false); |
} |
} |
first = ISC_FALSE; |
first = false; |
} |
} |
} |
} |
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_iswildcard(const dns_name_t *name) { |
dns_name_iswildcard(const dns_name_t *name) { |
unsigned char *ndata; |
unsigned char *ndata; |
|
|
Line 415 dns_name_iswildcard(const dns_name_t *na |
|
Line 410 dns_name_iswildcard(const dns_name_t *na |
|
if (name->length >= 2) { |
if (name->length >= 2) { |
ndata = name->ndata; |
ndata = name->ndata; |
if (ndata[0] == 1 && ndata[1] == '*') |
if (ndata[0] == 1 && ndata[1] == '*') |
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_internalwildcard(const dns_name_t *name) { |
dns_name_internalwildcard(const dns_name_t *name) { |
unsigned char *ndata; |
unsigned char *ndata; |
unsigned int count; |
unsigned int count; |
Line 449 dns_name_internalwildcard(const dns_name |
|
Line 444 dns_name_internalwildcard(const dns_name |
|
count = *ndata++; |
count = *ndata++; |
INSIST(count <= 63); |
INSIST(count <= 63); |
if (count == 1 && *ndata == '*') |
if (count == 1 && *ndata == '*') |
return (ISC_TRUE); |
return (true); |
ndata += count; |
ndata += count; |
label++; |
label++; |
} |
} |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
unsigned int |
unsigned int |
dns_name_hash(const dns_name_t *name, isc_boolean_t case_sensitive) { |
dns_name_hash(const dns_name_t *name, bool case_sensitive) { |
unsigned int length; |
unsigned int length; |
|
|
/* |
/* |
Line 477 dns_name_hash(const dns_name_t *name, is |
|
Line 472 dns_name_hash(const dns_name_t *name, is |
|
} |
} |
|
|
unsigned int |
unsigned int |
dns_name_fullhash(const dns_name_t *name, isc_boolean_t case_sensitive) { |
dns_name_fullhash(const dns_name_t *name, bool case_sensitive) { |
/* |
/* |
* Provide a hash value for 'name'. |
* Provide a hash value for 'name'. |
*/ |
*/ |
Line 490 dns_name_fullhash(const dns_name_t *name |
|
Line 485 dns_name_fullhash(const dns_name_t *name |
|
case_sensitive, NULL)); |
case_sensitive, NULL)); |
} |
} |
|
|
unsigned int |
|
dns_fullname_hash(const dns_name_t *name, isc_boolean_t case_sensitive) { |
|
/* |
|
* This function was deprecated due to the breakage of the name space |
|
* convention. We only keep this internally to provide binary backward |
|
* compatibility. |
|
*/ |
|
return (dns_name_fullhash(name, case_sensitive)); |
|
} |
|
|
|
unsigned int |
|
dns_name_hashbylabel(const dns_name_t *name, isc_boolean_t case_sensitive) { |
|
unsigned char *offsets; |
|
dns_offsets_t odata; |
|
dns_name_t tname; |
|
unsigned int h = 0; |
|
unsigned int i; |
|
|
|
/* |
|
* Provide a hash value for 'name'. |
|
*/ |
|
REQUIRE(VALID_NAME(name)); |
|
|
|
if (name->labels == 0) |
|
return (0); |
|
else if (name->labels == 1) |
|
return (isc_hash_function_reverse(name->ndata, name->length, |
|
case_sensitive, NULL)); |
|
|
|
SETUP_OFFSETS(name, offsets, odata); |
|
DNS_NAME_INIT(&tname, NULL); |
|
tname.labels = 1; |
|
h = 0; |
|
for (i = 0; i < name->labels; i++) { |
|
tname.ndata = name->ndata + offsets[i]; |
|
if (i == name->labels - 1) |
|
tname.length = name->length - offsets[i]; |
|
else |
|
tname.length = offsets[i + 1] - offsets[i]; |
|
h += isc_hash_function_reverse(tname.ndata, tname.length, |
|
case_sensitive, NULL); |
|
} |
|
|
|
return (h); |
|
} |
|
|
|
dns_namereln_t |
dns_namereln_t |
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, |
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, |
int *orderp, unsigned int *nlabelsp) |
int *orderp, unsigned int *nlabelsp) |
Line 695 dns_name_compare(const dns_name_t *name1 |
|
Line 644 dns_name_compare(const dns_name_t *name1 |
|
return (order); |
return (order); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { |
dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { |
unsigned int l, count; |
unsigned int l, count; |
unsigned char c; |
unsigned char c; |
Line 719 dns_name_equal(const dns_name_t *name1, |
|
Line 668 dns_name_equal(const dns_name_t *name1, |
|
(name2->attributes & DNS_NAMEATTR_ABSOLUTE)); |
(name2->attributes & DNS_NAMEATTR_ABSOLUTE)); |
|
|
if (ISC_UNLIKELY(name1 == name2)) |
if (ISC_UNLIKELY(name1 == name2)) |
return (ISC_TRUE); |
return (true); |
|
|
if (name1->length != name2->length) |
if (name1->length != name2->length) |
return (ISC_FALSE); |
return (false); |
|
|
l = name1->labels; |
l = name1->labels; |
|
|
if (l != name2->labels) |
if (l != name2->labels) |
return (ISC_FALSE); |
return (false); |
|
|
label1 = name1->ndata; |
label1 = name1->ndata; |
label2 = name2->ndata; |
label2 = name2->ndata; |
while (ISC_LIKELY(l-- > 0)) { |
while (ISC_LIKELY(l-- > 0)) { |
count = *label1++; |
count = *label1++; |
if (count != *label2++) |
if (count != *label2++) |
return (ISC_FALSE); |
return (false); |
|
|
INSIST(count <= 63); /* no bitstring support */ |
INSIST(count <= 63); /* no bitstring support */ |
|
|
Line 742 dns_name_equal(const dns_name_t *name1, |
|
Line 691 dns_name_equal(const dns_name_t *name1, |
|
while (ISC_LIKELY(count > 3)) { |
while (ISC_LIKELY(count > 3)) { |
c = maptolower[label1[0]]; |
c = maptolower[label1[0]]; |
if (c != maptolower[label2[0]]) |
if (c != maptolower[label2[0]]) |
return (ISC_FALSE); |
return (false); |
c = maptolower[label1[1]]; |
c = maptolower[label1[1]]; |
if (c != maptolower[label2[1]]) |
if (c != maptolower[label2[1]]) |
return (ISC_FALSE); |
return (false); |
c = maptolower[label1[2]]; |
c = maptolower[label1[2]]; |
if (c != maptolower[label2[2]]) |
if (c != maptolower[label2[2]]) |
return (ISC_FALSE); |
return (false); |
c = maptolower[label1[3]]; |
c = maptolower[label1[3]]; |
if (c != maptolower[label2[3]]) |
if (c != maptolower[label2[3]]) |
return (ISC_FALSE); |
return (false); |
count -= 4; |
count -= 4; |
label1 += 4; |
label1 += 4; |
label2 += 4; |
label2 += 4; |
Line 759 dns_name_equal(const dns_name_t *name1, |
|
Line 708 dns_name_equal(const dns_name_t *name1, |
|
while (ISC_LIKELY(count-- > 0)) { |
while (ISC_LIKELY(count-- > 0)) { |
c = maptolower[*label1++]; |
c = maptolower[*label1++]; |
if (c != maptolower[*label2++]) |
if (c != maptolower[*label2++]) |
return (ISC_FALSE); |
return (false); |
} |
} |
} |
} |
|
|
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_caseequal(const dns_name_t *name1, const dns_name_t *name2) { |
dns_name_caseequal(const dns_name_t *name1, const dns_name_t *name2) { |
|
|
/* |
/* |
Line 787 dns_name_caseequal(const dns_name_t *nam |
|
Line 736 dns_name_caseequal(const dns_name_t *nam |
|
(name2->attributes & DNS_NAMEATTR_ABSOLUTE)); |
(name2->attributes & DNS_NAMEATTR_ABSOLUTE)); |
|
|
if (name1->length != name2->length) |
if (name1->length != name2->length) |
return (ISC_FALSE); |
return (false); |
|
|
if (memcmp(name1->ndata, name2->ndata, name1->length) != 0) |
if (memcmp(name1->ndata, name2->ndata, name1->length) != 0) |
return (ISC_FALSE); |
return (false); |
|
|
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
int |
int |
Line 853 dns_name_rdatacompare(const dns_name_t * |
|
Line 802 dns_name_rdatacompare(const dns_name_t * |
|
return (0); |
return (0); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) { |
dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) { |
int order; |
int order; |
unsigned int nlabels; |
unsigned int nlabels; |
Line 871 dns_name_issubdomain(const dns_name_t *n |
|
Line 820 dns_name_issubdomain(const dns_name_t *n |
|
namereln = dns_name_fullcompare(name1, name2, &order, &nlabels); |
namereln = dns_name_fullcompare(name1, name2, &order, &nlabels); |
if (namereln == dns_namereln_subdomain || |
if (namereln == dns_namereln_subdomain || |
namereln == dns_namereln_equal) |
namereln == dns_namereln_equal) |
return (ISC_TRUE); |
return (true); |
|
|
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) { |
dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) { |
int order; |
int order; |
unsigned int nlabels, labels; |
unsigned int nlabels, labels; |
Line 897 dns_name_matcheswildcard(const dns_name_ |
|
Line 846 dns_name_matcheswildcard(const dns_name_ |
|
dns_name_getlabelsequence(wname, 1, labels - 1, &tname); |
dns_name_getlabelsequence(wname, 1, labels - 1, &tname); |
if (dns_name_fullcompare(name, &tname, &order, &nlabels) == |
if (dns_name_fullcompare(name, &tname, &order, &nlabels) == |
dns_namereln_subdomain) |
dns_namereln_subdomain) |
return (ISC_TRUE); |
return (true); |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
unsigned int |
unsigned int |
Line 1093 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1042 dns_name_fromtext(dns_name_t *name, isc_ |
|
unsigned int value = 0, count = 0; |
unsigned int value = 0, count = 0; |
unsigned int n1 = 0, n2 = 0; |
unsigned int n1 = 0, n2 = 0; |
unsigned int tlen, nrem, nused, digits = 0, labels, tused; |
unsigned int tlen, nrem, nused, digits = 0, labels, tused; |
isc_boolean_t done; |
bool done; |
unsigned char *offsets; |
unsigned char *offsets; |
dns_offsets_t odata; |
dns_offsets_t odata; |
isc_boolean_t downcase; |
bool downcase; |
|
|
/* |
/* |
* Convert the textual representation of a DNS name at source |
* Convert the textual representation of a DNS name at source |
Line 1113 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1062 dns_name_fromtext(dns_name_t *name, isc_ |
|
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
(target == NULL && ISC_BUFFER_VALID(name->buffer))); |
(target == NULL && ISC_BUFFER_VALID(name->buffer))); |
|
|
downcase = ISC_TF((options & DNS_NAME_DOWNCASE) != 0); |
downcase = ((options & DNS_NAME_DOWNCASE) != 0); |
|
|
if (target == NULL && name->buffer != NULL) { |
if (target == NULL && name->buffer != NULL) { |
target = name->buffer; |
target = name->buffer; |
Line 1142 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1091 dns_name_fromtext(dns_name_t *name, isc_ |
|
nrem = 255; |
nrem = 255; |
nused = 0; |
nused = 0; |
labels = 0; |
labels = 0; |
done = ISC_FALSE; |
done = false; |
state = ft_init; |
state = ft_init; |
|
|
while (nrem > 0 && tlen > 0 && !done) { |
while (nrem > 0 && tlen > 0 && !done) { |
Line 1162 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1111 dns_name_fromtext(dns_name_t *name, isc_ |
|
*ndata++ = 0; |
*ndata++ = 0; |
nrem--; |
nrem--; |
nused++; |
nused++; |
done = ISC_TRUE; |
done = true; |
break; |
break; |
} |
} |
if (c == '@' && tlen == 0) { |
if (c == '@' && tlen == 0) { |
Line 1198 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1147 dns_name_fromtext(dns_name_t *name, isc_ |
|
*ndata++ = 0; |
*ndata++ = 0; |
nrem--; |
nrem--; |
nused++; |
nused++; |
done = ISC_TRUE; |
done = true; |
} |
} |
state = ft_start; |
state = ft_start; |
} else if (c == '\\') { |
} else if (c == '\\') { |
Line 1326 dns_name_fromtext(dns_name_t *name, isc_ |
|
Line 1275 dns_name_fromtext(dns_name_t *name, isc_ |
|
return (ISC_R_SUCCESS); |
return (ISC_R_SUCCESS); |
} |
} |
|
|
#ifdef ISC_PLATFORM_USETHREADS |
|
static void |
static void |
free_specific(void *arg) { |
free_specific(void *arg) { |
dns_name_totextfilter_t *mem = arg; |
dns_name_totextfilter_t *mem = arg; |
Line 1337 free_specific(void *arg) { |
|
Line 1285 free_specific(void *arg) { |
|
|
|
static void |
static void |
thread_key_mutex_init(void) { |
thread_key_mutex_init(void) { |
RUNTIME_CHECK(isc_mutex_init(&thread_key_mutex) == ISC_R_SUCCESS); |
isc_mutex_init(&thread_key_mutex); |
} |
} |
|
|
static isc_result_t |
static isc_result_t |
Line 1355 totext_filter_proc_key_init(void) { |
|
Line 1303 totext_filter_proc_key_init(void) { |
|
if (!thread_key_initialized) { |
if (!thread_key_initialized) { |
LOCK(&thread_key_mutex); |
LOCK(&thread_key_mutex); |
if (thread_key_mctx == NULL) |
if (thread_key_mctx == NULL) |
result = isc_mem_create2(0, 0, &thread_key_mctx, 0); |
result = isc_mem_create(0, 0, &thread_key_mctx); |
if (result != ISC_R_SUCCESS) |
if (result != ISC_R_SUCCESS) |
goto unlock; |
goto unlock; |
isc_mem_setname(thread_key_mctx, "threadkey", NULL); |
isc_mem_setname(thread_key_mctx, "threadkey", NULL); |
isc_mem_setdestroycheck(thread_key_mctx, ISC_FALSE); |
isc_mem_setdestroycheck(thread_key_mctx, false); |
|
|
if (!thread_key_initialized && |
if (!thread_key_initialized && |
isc_thread_key_create(&totext_filter_proc_key, |
isc_thread_key_create(&totext_filter_proc_key, |
Line 1373 totext_filter_proc_key_init(void) { |
|
Line 1321 totext_filter_proc_key_init(void) { |
|
} |
} |
return (result); |
return (result); |
} |
} |
#endif |
|
|
|
isc_result_t |
isc_result_t |
dns_name_totext(const dns_name_t *name, isc_boolean_t omit_final_dot, |
dns_name_totext(const dns_name_t *name, bool omit_final_dot, |
isc_buffer_t *target) |
isc_buffer_t *target) |
{ |
{ |
unsigned int options = DNS_NAME_MASTERFILE; |
unsigned int options = DNS_NAME_MASTERFILE; |
Line 1401 dns_name_totext2(const dns_name_t *name, |
|
Line 1348 dns_name_totext2(const dns_name_t *name, |
|
unsigned char c; |
unsigned char c; |
unsigned int trem, count; |
unsigned int trem, count; |
unsigned int labels; |
unsigned int labels; |
isc_boolean_t saw_root = ISC_FALSE; |
bool saw_root = false; |
unsigned int oused = target->used; |
unsigned int oused = target->used; |
#ifdef ISC_PLATFORM_USETHREADS |
|
dns_name_totextfilter_t *mem; |
dns_name_totextfilter_t *mem; |
dns_name_totextfilter_t totext_filter_proc = NULL; |
dns_name_totextfilter_t totext_filter_proc = NULL; |
isc_result_t result; |
isc_result_t result; |
#endif |
bool omit_final_dot = ((options & DNS_NAME_OMITFINALDOT) != 0); |
isc_boolean_t omit_final_dot = |
|
ISC_TF(options & DNS_NAME_OMITFINALDOT); |
|
|
|
/* |
/* |
* This function assumes the name is in proper uncompressed |
* This function assumes the name is in proper uncompressed |
Line 1418 dns_name_totext2(const dns_name_t *name, |
|
Line 1362 dns_name_totext2(const dns_name_t *name, |
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
REQUIRE(ISC_BUFFER_VALID(target)); |
REQUIRE(ISC_BUFFER_VALID(target)); |
|
|
#ifdef ISC_PLATFORM_USETHREADS |
|
result = totext_filter_proc_key_init(); |
result = totext_filter_proc_key_init(); |
if (result != ISC_R_SUCCESS) |
if (result != ISC_R_SUCCESS) |
return (result); |
return (result); |
#endif |
|
ndata = name->ndata; |
ndata = name->ndata; |
nlen = name->length; |
nlen = name->length; |
labels = name->labels; |
labels = name->labels; |
Line 1445 dns_name_totext2(const dns_name_t *name, |
|
Line 1387 dns_name_totext2(const dns_name_t *name, |
|
* They need to be set this way, though, to keep the "@" |
* They need to be set this way, though, to keep the "@" |
* from being trounced. |
* from being trounced. |
*/ |
*/ |
saw_root = ISC_TRUE; |
saw_root = true; |
omit_final_dot = ISC_FALSE; |
omit_final_dot = false; |
*tdata++ = '@'; |
*tdata++ = '@'; |
trem--; |
trem--; |
|
|
Line 1461 dns_name_totext2(const dns_name_t *name, |
|
Line 1403 dns_name_totext2(const dns_name_t *name, |
|
if (trem == 0) |
if (trem == 0) |
return (ISC_R_NOSPACE); |
return (ISC_R_NOSPACE); |
|
|
saw_root = ISC_TRUE; |
saw_root = true; |
omit_final_dot = ISC_FALSE; |
omit_final_dot = false; |
*tdata++ = '.'; |
*tdata++ = '.'; |
trem--; |
trem--; |
|
|
Line 1477 dns_name_totext2(const dns_name_t *name, |
|
Line 1419 dns_name_totext2(const dns_name_t *name, |
|
count = *ndata++; |
count = *ndata++; |
nlen--; |
nlen--; |
if (count == 0) { |
if (count == 0) { |
saw_root = ISC_TRUE; |
saw_root = true; |
break; |
break; |
} |
} |
if (count < 64) { |
if (count < 64) { |
Line 1562 dns_name_totext2(const dns_name_t *name, |
|
Line 1504 dns_name_totext2(const dns_name_t *name, |
|
} |
} |
isc_buffer_add(target, tlen - trem); |
isc_buffer_add(target, tlen - trem); |
|
|
#ifdef ISC_PLATFORM_USETHREADS |
|
mem = isc_thread_key_getspecific(totext_filter_proc_key); |
mem = isc_thread_key_getspecific(totext_filter_proc_key); |
if (mem != NULL) |
if (mem != NULL) |
totext_filter_proc = *mem; |
totext_filter_proc = *mem; |
#endif |
|
if (totext_filter_proc != NULL) |
if (totext_filter_proc != NULL) |
return ((*totext_filter_proc)(target, oused, saw_root)); |
return ((*totext_filter_proc)(target, oused)); |
|
|
return (ISC_R_SUCCESS); |
return (ISC_R_SUCCESS); |
} |
} |
|
|
isc_result_t |
isc_result_t |
dns_name_tofilenametext(const dns_name_t *name, isc_boolean_t omit_final_dot, |
dns_name_tofilenametext(const dns_name_t *name, bool omit_final_dot, |
isc_buffer_t *target) |
isc_buffer_t *target) |
{ |
{ |
unsigned char *ndata; |
unsigned char *ndata; |
Line 1607 dns_name_tofilenametext(const dns_name_t |
|
Line 1547 dns_name_tofilenametext(const dns_name_t |
|
if (trem == 0) |
if (trem == 0) |
return (ISC_R_NOSPACE); |
return (ISC_R_NOSPACE); |
|
|
omit_final_dot = ISC_FALSE; |
omit_final_dot = false; |
*tdata++ = '.'; |
*tdata++ = '.'; |
trem--; |
trem--; |
|
|
Line 1764 set_offsets(const dns_name_t *name, unsi |
|
Line 1704 set_offsets(const dns_name_t *name, unsi |
|
{ |
{ |
unsigned int offset, count, length, nlabels; |
unsigned int offset, count, length, nlabels; |
unsigned char *ndata; |
unsigned char *ndata; |
isc_boolean_t absolute; |
bool absolute; |
|
|
ndata = name->ndata; |
ndata = name->ndata; |
length = name->length; |
length = name->length; |
offset = 0; |
offset = 0; |
nlabels = 0; |
nlabels = 0; |
absolute = ISC_FALSE; |
absolute = false; |
while (ISC_LIKELY(offset != length)) { |
while (ISC_LIKELY(offset != length)) { |
INSIST(nlabels < 128); |
INSIST(nlabels < 128); |
offsets[nlabels++] = offset; |
offsets[nlabels++] = offset; |
Line 1780 set_offsets(const dns_name_t *name, unsi |
|
Line 1720 set_offsets(const dns_name_t *name, unsi |
|
ndata += count + 1; |
ndata += count + 1; |
INSIST(offset <= length); |
INSIST(offset <= length); |
if (ISC_UNLIKELY(count == 0)) { |
if (ISC_UNLIKELY(count == 0)) { |
absolute = ISC_TRUE; |
absolute = true; |
break; |
break; |
} |
} |
} |
} |
Line 1807 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1747 dns_name_fromwire(dns_name_t *name, isc_ |
|
unsigned int cused; /* Bytes of compressed name data used */ |
unsigned int cused; /* Bytes of compressed name data used */ |
unsigned int nused, labels, n, nmax; |
unsigned int nused, labels, n, nmax; |
unsigned int current, new_current, biggest_pointer; |
unsigned int current, new_current, biggest_pointer; |
isc_boolean_t done; |
bool done; |
fw_state state = fw_start; |
fw_state state = fw_start; |
unsigned int c; |
unsigned int c; |
unsigned char *offsets; |
unsigned char *offsets; |
dns_offsets_t odata; |
dns_offsets_t odata; |
isc_boolean_t downcase; |
bool downcase; |
isc_boolean_t seen_pointer; |
bool seen_pointer; |
|
|
/* |
/* |
* Copy the possibly-compressed name at source into target, |
* Copy the possibly-compressed name at source into target, |
Line 1825 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1765 dns_name_fromwire(dns_name_t *name, isc_ |
|
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
(target == NULL && ISC_BUFFER_VALID(name->buffer))); |
(target == NULL && ISC_BUFFER_VALID(name->buffer))); |
|
|
downcase = ISC_TF((options & DNS_NAME_DOWNCASE) != 0); |
downcase = ((options & DNS_NAME_DOWNCASE) != 0); |
|
|
if (target == NULL && name->buffer != NULL) { |
if (target == NULL && name->buffer != NULL) { |
target = name->buffer; |
target = name->buffer; |
Line 1852 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1792 dns_name_fromwire(dns_name_t *name, isc_ |
|
* Set up. |
* Set up. |
*/ |
*/ |
labels = 0; |
labels = 0; |
done = ISC_FALSE; |
done = false; |
|
|
ndata = isc_buffer_used(target); |
ndata = isc_buffer_used(target); |
nused = 0; |
nused = 0; |
seen_pointer = ISC_FALSE; |
seen_pointer = false; |
|
|
/* |
/* |
* Find the maximum number of uncompressed target name |
* Find the maximum number of uncompressed target name |
Line 1895 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1835 dns_name_fromwire(dns_name_t *name, isc_ |
|
nused += c + 1; |
nused += c + 1; |
*ndata++ = c; |
*ndata++ = c; |
if (c == 0) |
if (c == 0) |
done = ISC_TRUE; |
done = true; |
n = c; |
n = c; |
state = fw_ordinary; |
state = fw_ordinary; |
} else if (c >= 128 && c < 192) { |
} else if (c >= 128 && c < 192) { |
Line 1909 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1849 dns_name_fromwire(dns_name_t *name, isc_ |
|
/* |
/* |
* Ordinary 14-bit pointer. |
* Ordinary 14-bit pointer. |
*/ |
*/ |
if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == |
if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == 0) |
0) |
{ |
return (DNS_R_DISALLOWED); |
return (DNS_R_DISALLOWED); |
|
} |
new_current = c & 0x3F; |
new_current = c & 0x3F; |
state = fw_newcurrent; |
state = fw_newcurrent; |
} else |
} else |
Line 1933 dns_name_fromwire(dns_name_t *name, isc_ |
|
Line 1874 dns_name_fromwire(dns_name_t *name, isc_ |
|
biggest_pointer = new_current; |
biggest_pointer = new_current; |
current = new_current; |
current = new_current; |
cdata = (unsigned char *)source->base + current; |
cdata = (unsigned char *)source->base + current; |
seen_pointer = ISC_TRUE; |
seen_pointer = true; |
state = fw_start; |
state = fw_start; |
break; |
break; |
default: |
default: |
Line 1980 dns_name_towire(const dns_name_t *name, |
|
Line 1921 dns_name_towire(const dns_name_t *name, |
|
|
|
isc_result_t |
isc_result_t |
dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, |
dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, |
isc_buffer_t *target, isc_uint16_t *comp_offsetp) |
isc_buffer_t *target, uint16_t *comp_offsetp) |
{ |
{ |
unsigned int methods; |
unsigned int methods; |
isc_uint16_t offset; |
uint16_t offset; |
dns_name_t gp; /* Global compression prefix */ |
dns_name_t gp; /* Global compression prefix */ |
isc_boolean_t gf; /* Global compression target found */ |
bool gf; /* Global compression target found */ |
isc_uint16_t go; /* Global compression offset */ |
uint16_t go; /* Global compression offset */ |
dns_offsets_t clo; |
dns_offsets_t clo; |
dns_name_t clname; |
dns_name_t clname; |
|
|
Line 2037 dns_name_towire2(const dns_name_t *name, |
|
Line 1978 dns_name_towire2(const dns_name_t *name, |
|
(methods & DNS_COMPRESS_GLOBAL14) != 0) |
(methods & DNS_COMPRESS_GLOBAL14) != 0) |
gf = dns_compress_findglobal(cctx, name, &gp, &go); |
gf = dns_compress_findglobal(cctx, name, &gp, &go); |
else |
else |
gf = ISC_FALSE; |
gf = false; |
|
|
/* |
/* |
* If the offset is too high for 14 bit global compression, we're |
* If the offset is too high for 14 bit global compression, we're |
* out of luck. |
* out of luck. |
*/ |
*/ |
if (gf && ISC_UNLIKELY(go >= 0x4000)) |
if (gf && ISC_UNLIKELY(go >= 0x4000)) |
gf = ISC_FALSE; |
gf = false; |
|
|
/* |
/* |
* Will the compression pointer reduce the message size? |
* Will the compression pointer reduce the message size? |
*/ |
*/ |
if (gf && (gp.length + 2) >= name->length) |
if (gf && (gp.length + 2) >= name->length) |
gf = ISC_FALSE; |
gf = false; |
|
|
if (gf) { |
if (gf) { |
if (ISC_UNLIKELY(target->length - target->used < gp.length)) |
if (ISC_UNLIKELY(target->length - target->used < gp.length)) |
Line 2094 dns_name_concatenate(const dns_name_t *p |
|
Line 2035 dns_name_concatenate(const dns_name_t *p |
|
{ |
{ |
unsigned char *ndata, *offsets; |
unsigned char *ndata, *offsets; |
unsigned int nrem, labels, prefix_length, length; |
unsigned int nrem, labels, prefix_length, length; |
isc_boolean_t copy_prefix = ISC_TRUE; |
bool copy_prefix = true; |
isc_boolean_t copy_suffix = ISC_TRUE; |
bool copy_suffix = true; |
isc_boolean_t absolute = ISC_FALSE; |
bool absolute = false; |
dns_name_t tmp_name; |
dns_name_t tmp_name; |
dns_offsets_t odata; |
dns_offsets_t odata; |
|
|
Line 2110 dns_name_concatenate(const dns_name_t *p |
|
Line 2051 dns_name_concatenate(const dns_name_t *p |
|
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || |
(target == NULL && name != NULL && ISC_BUFFER_VALID(name->buffer))); |
(target == NULL && name != NULL && ISC_BUFFER_VALID(name->buffer))); |
if (prefix == NULL || prefix->labels == 0) |
if (prefix == NULL || prefix->labels == 0) |
copy_prefix = ISC_FALSE; |
copy_prefix = false; |
if (suffix == NULL || suffix->labels == 0) |
if (suffix == NULL || suffix->labels == 0) |
copy_suffix = ISC_FALSE; |
copy_suffix = false; |
if (copy_prefix && |
if (copy_prefix && |
(prefix->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) { |
(prefix->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) { |
absolute = ISC_TRUE; |
absolute = true; |
REQUIRE(!copy_suffix); |
REQUIRE(!copy_suffix); |
} |
} |
if (name == NULL) { |
if (name == NULL) { |
Line 2160 dns_name_concatenate(const dns_name_t *p |
|
Line 2101 dns_name_concatenate(const dns_name_t *p |
|
|
|
if (copy_suffix) { |
if (copy_suffix) { |
if ((suffix->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) |
if ((suffix->attributes & DNS_NAMEATTR_ABSOLUTE) != 0) |
absolute = ISC_TRUE; |
absolute = true; |
memmove(ndata + prefix_length, suffix->ndata, suffix->length); |
memmove(ndata + prefix_length, suffix->ndata, suffix->length); |
} |
} |
|
|
Line 2351 dns_name_digest(const dns_name_t *name, |
|
Line 2292 dns_name_digest(const dns_name_t *name, |
|
return ((digest)(arg, &r)); |
return ((digest)(arg, &r)); |
} |
} |
|
|
isc_boolean_t |
bool |
dns_name_dynamic(const dns_name_t *name) { |
dns_name_dynamic(const dns_name_t *name) { |
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
|
|
Line 2360 dns_name_dynamic(const dns_name_t *name) |
|
Line 2301 dns_name_dynamic(const dns_name_t *name) |
|
*/ |
*/ |
|
|
return ((name->attributes & DNS_NAMEATTR_DYNAMIC) != 0 ? |
return ((name->attributes & DNS_NAMEATTR_DYNAMIC) != 0 ? |
ISC_TRUE : ISC_FALSE); |
true : false); |
} |
} |
|
|
isc_result_t |
isc_result_t |
Line 2377 dns_name_print(const dns_name_t *name, F |
|
Line 2318 dns_name_print(const dns_name_t *name, F |
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
|
|
isc_buffer_init(&b, t, sizeof(t)); |
isc_buffer_init(&b, t, sizeof(t)); |
result = dns_name_totext(name, ISC_FALSE, &b); |
result = dns_name_totext(name, false, &b); |
if (result != ISC_R_SUCCESS) |
if (result != ISC_R_SUCCESS) |
return (result); |
return (result); |
isc_buffer_usedregion(&b, &r); |
isc_buffer_usedregion(&b, &r); |
Line 2388 dns_name_print(const dns_name_t *name, F |
|
Line 2329 dns_name_print(const dns_name_t *name, F |
|
|
|
isc_result_t |
isc_result_t |
dns_name_settotextfilter(dns_name_totextfilter_t proc) { |
dns_name_settotextfilter(dns_name_totextfilter_t proc) { |
#ifdef ISC_PLATFORM_USETHREADS |
|
isc_result_t result; |
isc_result_t result; |
dns_name_totextfilter_t *mem; |
dns_name_totextfilter_t *mem; |
int res; |
int res; |
Line 2424 dns_name_settotextfilter(dns_name_totext |
|
Line 2364 dns_name_settotextfilter(dns_name_totext |
|
result = ISC_R_UNEXPECTED; |
result = ISC_R_UNEXPECTED; |
} |
} |
return (result); |
return (result); |
#else |
|
totext_filter_proc = proc; |
|
return (ISC_R_SUCCESS); |
|
#endif |
|
} |
} |
|
|
void |
void |
Line 2441 dns_name_format(const dns_name_t *name, |
|
Line 2377 dns_name_format(const dns_name_t *name, |
|
* Leave room for null termination after buffer. |
* Leave room for null termination after buffer. |
*/ |
*/ |
isc_buffer_init(&buf, cp, size - 1); |
isc_buffer_init(&buf, cp, size - 1); |
result = dns_name_totext(name, ISC_TRUE, &buf); |
result = dns_name_totext(name, true, &buf); |
if (result == ISC_R_SUCCESS) { |
if (result == ISC_R_SUCCESS) { |
/* |
/* |
* Null terminate. |
* Null terminate. |
Line 2469 dns_name_tostring(const dns_name_t *name |
|
Line 2405 dns_name_tostring(const dns_name_t *name |
|
REQUIRE(target != NULL && *target == NULL); |
REQUIRE(target != NULL && *target == NULL); |
|
|
isc_buffer_init(&buf, txt, sizeof(txt)); |
isc_buffer_init(&buf, txt, sizeof(txt)); |
result = dns_name_totext(name, ISC_FALSE, &buf); |
result = dns_name_totext(name, false, &buf); |
if (result != ISC_R_SUCCESS) |
if (result != ISC_R_SUCCESS) |
return (result); |
return (result); |
|
|
Line 2577 dns_name_copy(const dns_name_t *source, |
|
Line 2513 dns_name_copy(const dns_name_t *source, |
|
|
|
void |
void |
dns_name_destroy(void) { |
dns_name_destroy(void) { |
#ifdef ISC_PLATFORM_USETHREADS |
|
RUNTIME_CHECK(isc_once_do(&once, thread_key_mutex_init) |
RUNTIME_CHECK(isc_once_do(&once, thread_key_mutex_init) |
== ISC_R_SUCCESS); |
== ISC_R_SUCCESS); |
|
|
Line 2589 dns_name_destroy(void) { |
|
Line 2524 dns_name_destroy(void) { |
|
} |
} |
UNLOCK(&thread_key_mutex); |
UNLOCK(&thread_key_mutex); |
|
|
#endif |
|
} |
} |
|
|
/* |
/* |
Line 2614 static dns_name_t const dns_sd[] = { |
|
Line 2548 static dns_name_t const dns_sd[] = { |
|
DNS_NAME_INITNONABSOLUTE(lb_dns_sd_udp_data, lb_dns_sd_udp_offsets) |
DNS_NAME_INITNONABSOLUTE(lb_dns_sd_udp_data, lb_dns_sd_udp_offsets) |
}; |
}; |
|
|
isc_boolean_t |
bool |
dns_name_isdnssd(const dns_name_t *name) { |
dns_name_isdnssd(const dns_name_t *name) { |
size_t i; |
size_t i; |
dns_name_t prefix; |
dns_name_t prefix; |
Line 2624 dns_name_isdnssd(const dns_name_t *name) |
|
Line 2558 dns_name_isdnssd(const dns_name_t *name) |
|
dns_name_getlabelsequence(name, 0, 3, &prefix); |
dns_name_getlabelsequence(name, 0, 3, &prefix); |
for (i = 0; i < (sizeof(dns_sd)/sizeof(dns_sd[0])); i++) |
for (i = 0; i < (sizeof(dns_sd)/sizeof(dns_sd[0])); i++) |
if (dns_name_equal(&prefix, &dns_sd[i])) |
if (dns_name_equal(&prefix, &dns_sd[i])) |
return (ISC_TRUE); |
return (true); |
} |
} |
|
|
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
static unsigned char inaddr10_offsets[] = { 0, 3, 11, 16 }; |
static unsigned char inaddr10_offsets[] = { 0, 3, 11, 16 }; |
Line 2676 static dns_name_t const rfc1918names[] = |
|
Line 2610 static dns_name_t const rfc1918names[] = |
|
DNS_NAME_INITABSOLUTE(inaddr168192, inaddr192_offsets) |
DNS_NAME_INITABSOLUTE(inaddr168192, inaddr192_offsets) |
}; |
}; |
|
|
isc_boolean_t |
bool |
dns_name_isrfc1918(const dns_name_t *name) { |
dns_name_isrfc1918(const dns_name_t *name) { |
size_t i; |
size_t i; |
|
|
for (i = 0; i < (sizeof(rfc1918names)/sizeof(*rfc1918names)); i++) |
for (i = 0; i < (sizeof(rfc1918names)/sizeof(*rfc1918names)); i++) |
if (dns_name_issubdomain(name, &rfc1918names[i])) |
if (dns_name_issubdomain(name, &rfc1918names[i])) |
return (ISC_TRUE); |
return (true); |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
static unsigned char ulaoffsets[] = { 0, 2, 4, 8, 13 }; |
static unsigned char ulaoffsets[] = { 0, 2, 4, 8, 13 }; |
Line 2695 static dns_name_t const ulanames[] = { |
|
Line 2629 static dns_name_t const ulanames[] = { |
|
DNS_NAME_INITABSOLUTE(ip6fd, ulaoffsets) |
DNS_NAME_INITABSOLUTE(ip6fd, ulaoffsets) |
}; |
}; |
|
|
isc_boolean_t |
bool |
dns_name_isula(const dns_name_t *name) { |
dns_name_isula(const dns_name_t *name) { |
size_t i; |
size_t i; |
|
|
for (i = 0; i < (sizeof(ulanames)/sizeof(*ulanames)); i++) |
for (i = 0; i < (sizeof(ulanames)/sizeof(*ulanames)); i++) |
if (dns_name_issubdomain(name, &ulanames[i])) |
if (dns_name_issubdomain(name, &ulanames[i])) |
return (ISC_TRUE); |
return (true); |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
/* |
/* |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
}; |
}; |
|
|
isc_boolean_t |
bool |
dns_name_istat(const dns_name_t *name) { |
dns_name_istat(const dns_name_t *name) { |
unsigned char len; |
unsigned char len; |
const unsigned char *ndata; |
const unsigned char *ndata; |
Line 2729 dns_name_istat(const dns_name_t *name) { |
|
Line 2663 dns_name_istat(const dns_name_t *name) { |
|
REQUIRE(VALID_NAME(name)); |
REQUIRE(VALID_NAME(name)); |
|
|
if (name->labels < 1) |
if (name->labels < 1) |
return (ISC_FALSE); |
return (false); |
|
|
ndata = name->ndata; |
ndata = name->ndata; |
len = ndata[0]; |
len = ndata[0]; |
Line 2738 dns_name_istat(const dns_name_t *name) { |
|
Line 2672 dns_name_istat(const dns_name_t *name) { |
|
|
|
/* |
/* |
* Is there at least one trust anchor reported and is the |
* Is there at least one trust anchor reported and is the |
* label length consistent with a trust-anchor-telementry label. |
* label length consistent with a trust-anchor-telemetry label. |
*/ |
*/ |
if ((len < 8) || (len - 3) % 5 != 0) { |
if ((len < 8) || (len - 3) % 5 != 0) { |
return (ISC_FALSE); |
return (false); |
} |
} |
|
|
if (ndata[0] != '_' || |
if (ndata[0] != '_' || |
maptolower[ndata[1]] != 't' || |
maptolower[ndata[1]] != 't' || |
maptolower[ndata[2]] != 'a') { |
maptolower[ndata[2]] != 'a') { |
return (ISC_FALSE); |
return (false); |
} |
} |
ndata += 3; |
ndata += 3; |
len -= 3; |
len -= 3; |
Line 2756 dns_name_istat(const dns_name_t *name) { |
|
Line 2690 dns_name_istat(const dns_name_t *name) { |
|
INSIST(len >= 5); |
INSIST(len >= 5); |
if (ndata[0] != '-' || !ishex[ndata[1]] || !ishex[ndata[2]] || |
if (ndata[0] != '-' || !ishex[ndata[1]] || !ishex[ndata[2]] || |
!ishex[ndata[3]] || !ishex[ndata[4]]) { |
!ishex[ndata[3]] || !ishex[ndata[4]]) { |
return (ISC_FALSE); |
return (false); |
} |
} |
ndata += 5; |
ndata += 5; |
len -= 5; |
len -= 5; |
} |
} |
return (ISC_TRUE); |
return (true); |
} |
} |