name.c revision c80fef792a864f08453128230216fb079a69500b
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox User * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC")
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 1998-2003 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * purpose with or without fee is hereby granted, provided that the above
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews#define VALID_NAME(n) ISC_MAGIC_VALID(n, DNS_NAME_MAGIC)
364a82f7c25b62967678027043425201a5e5171aBob Halleytypedef enum {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*16*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*32*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*48*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /*64*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*80*/
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*96*/
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*112*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*128*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉static unsigned char maptolower[] = {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
785d1541b6ec7c6939ec8ebf409db367943bab5fAndreas Gustafsson 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
9d99e3fda11eb8549a2bc7d5af31b7630ed68162Mark Andrews 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews var = default; \
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * Note: If additional attributes are added that should not be set for
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellington * empty names, MAKE_EMPTY() must be changed so it clears them.
dcf8825fd74f3f83b1882af4793270083b125ee5David Lawrence * A name is "bindable" if it can be set to point to a new value, i.e.
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * name->ndata and name->length may be changed.
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley ((name->attributes & (DNS_NAMEATTR_READONLY|DNS_NAMEATTR_DYNAMIC)) \
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrence * Note that the name data must be a char array, not a string
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrence * literal, to avoid compiler warnings about discarding
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrence * the const attribute of a string.
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrewsstatic unsigned char root_offsets[] = { 0 };
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellington DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellington/* XXXDCL make const? */
64a84169d7eed05486b10be90afea58f4af146f9Brian WellingtonLIBDNS_EXTERNAL_DATA dns_name_t *dns_rootname = &root;
70c91849c3a3d808125d690a46af5fd225a4c291Andreas Gustafssonstatic unsigned char wild_ndata[] = { '\001', '*' };
2d67fbd786284ed570031fa82fc9807b0413aa3fBrian Wellingtonstatic unsigned char wild_offsets[] = { 0 };
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellington/* XXXDCL make const? */
64a84169d7eed05486b10be90afea58f4af146f9Brian WellingtonLIBDNS_EXTERNAL_DATA dns_name_t *dns_wildcardname = &wild;
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellingtondns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive);
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellington * dns_name_t to text post-conversion procedure.
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellingtonstatic isc_thread_key_t totext_filter_proc_key;
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellingtonstatic dns_name_totextfilter_t totext_filter_proc = NULL;
64a84169d7eed05486b10be90afea58f4af146f9Brian Wellingtonset_offsets(const dns_name_t *name, unsigned char *offsets,
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halleydns_name_init(dns_name_t *name, unsigned char *offsets) {
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * Initialize 'name'.
e08daafffce8fb74ffca8ecf5772e334299ccf76Bob Halley * Make 'name' invalid.
602274b30f17281b8af0608016eadd0816d3eca6Mark Andrews if (name->length > 255U || name->labels > 127U)
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews if (offsets != NULL && offsets[nlabels] != offset)
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews if (nlabels != name->labels || offset != name->length)
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrewsdns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) {
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews * Dedicate a buffer for use with 'name'.
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews REQUIRE((buffer != NULL && name->buffer == NULL) ||
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews * Does 'name' have a dedicated buffer?
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews * Does 'name' end in the root label?
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews if ((name->attributes & DNS_NAMEATTR_ABSOLUTE) != 0)
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
4f082b58b17ce39087930d5affc2ada90ef386e6Mark Andrews#define borderchar(c) (alphachar(c) || digitchar(c))
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews#define middlechar(c) (borderchar(c) || hyphenchar(c))
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews unsigned int n;
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE);
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews * Root label.
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews while (n--) {
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews while (n--) {
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews if (first || n == 0) {
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrewsdns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard) {
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews unsigned int n;
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE);
aa39170da817cae7b4c6c735cc832e05ec3d2351Mark Andrews * Root label.
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews * Skip wildcard if this is a ownername.
cc32d38366fa680fc29f9fb17bd3ebe515835445Mark Andrews if (wildcard && ndata[0] == 1 && ndata[1] == '*')
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox User while (n--) {
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox User if (first || n == 0) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned char *ndata;
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox User * Is 'name' a wildcard name?
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox Userdns_name_internalwildcard(const dns_name_t *name) {
313b0ea9f258edd8530f4454c69e6ba194280162Tinderbox User unsigned char *ndata;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int count;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int label;
d8c1e4eccf5bf88a3b4f8dc4a24391b5712bb3a3Mark Andrews * Does 'name' contain a internal wildcard?
0a00c3eb03464988821a0b6817b63ddb3c090890Tinderbox User * Skip first label.
0a00c3eb03464988821a0b6817b63ddb3c090890Tinderbox User * Check all but the last of the remaining labels.
0a00c3eb03464988821a0b6817b63ddb3c090890Tinderbox Userstatic inline unsigned int
0a00c3eb03464988821a0b6817b63ddb3c090890Tinderbox Username_hash(dns_name_t *name, isc_boolean_t case_sensitive) {
d8c1e4eccf5bf88a3b4f8dc4a24391b5712bb3a3Mark Andrews unsigned int length;
0a00c3eb03464988821a0b6817b63ddb3c090890Tinderbox User const unsigned char *s;
d8c1e4eccf5bf88a3b4f8dc4a24391b5712bb3a3Mark Andrews unsigned int h = 0;
d8c1e4eccf5bf88a3b4f8dc4a24391b5712bb3a3Mark Andrews unsigned char c;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * This hash function is similar to the one Ousterhout
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * uses in Tcl.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt while (length > 0) {
6f85ff3aac98187ff140bad192d01a6cfd31cf1cMark Andrews h += ( h << 3 ) + *s;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt while (length > 0) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt h += ( h << 3 ) + c;
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Provide a hash value for 'name'.
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_fullhash(dns_name_t *name, isc_boolean_t case_sensitive) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Provide a hash value for 'name'.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt return (isc_hash_calc((const unsigned char *)name->ndata,
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * This function was deprecated due to the breakage of the name space
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * convention. We only keep this internally to provide binary backward
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * compatibility.
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_hashbylabel(dns_name_t *name, isc_boolean_t case_sensitive) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned char *offsets;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int h = 0;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int i;
d8c1e4eccf5bf88a3b4f8dc4a24391b5712bb3a3Mark Andrews * Provide a hash value for 'name'.
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int l1, l2, l, count1, count2, count, nlabels;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Determine the relative ordering under the DNSSEC order relation of
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt * 'name1' and 'name2', and also determine the hierarchical
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * relationship of the names.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Note: It makes no sense for one of the names to be relative and the
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * other absolute. If both names are relative, then to be meaningfully
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * compared the caller must ensure that they are both relative to the
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * same domain.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Either name1 is absolute and name2 is absolute, or neither is.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt while (l > 0) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * We dropped bitstring labels, and we don't support any
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * other extended label types.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt while (count > 0) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt else if (ldiff > 0)
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_compare(const dns_name_t *name1, const dns_name_t *name2) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int nlabels;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Determine the relative ordering under the DNSSEC order relation of
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * 'name1' and 'name2'.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * Note: It makes no sense for one of the names to be relative and the
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * other absolute. If both names are relative, then to be meaningfully
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * compared the caller must ensure that they are both relative to the
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * same domain.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt (void)dns_name_fullcompare(name1, name2, &order, &nlabels);
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntdns_name_equal(const dns_name_t *name1, const dns_name_t *name2) {
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt unsigned int l, count;
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt unsigned char c;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Are 'name1' and 'name2' equal?
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Note: It makes no sense for one of the names to be relative and the
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * other absolute. If both names are relative, then to be meaningfully
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * compared the caller must ensure that they are both relative to the
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * same domain.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Either name1 is absolute and name2 is absolute, or neither is.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (name2->attributes & DNS_NAMEATTR_ABSOLUTE));
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt while (l > 0) {
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt while (count > 0) {
64ecc88345766e124e1fb053dbf4e36550471f83Evan Huntdns_name_caseequal(const dns_name_t *name1, const dns_name_t *name2) {
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * Are 'name1' and 'name2' equal?
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * Note: It makes no sense for one of the names to be relative and the
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * other absolute. If both names are relative, then to be meaningfully
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * compared the caller must ensure that they are both relative to the
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * same domain.
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt * Either name1 is absolute and name2 is absolute, or neither is.
64ecc88345766e124e1fb053dbf4e36550471f83Evan Hunt REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if (memcmp(name1->ndata, name2->ndata, name1->length) != 0)
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉dns_name_rdatacompare(const dns_name_t *name1, const dns_name_t *name2) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 unsigned int l1, l2, l, count1, count2, count;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Compare two absolute names as rdata.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews REQUIRE((name2->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews while (l > 0) {
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews /* no bitstring support */
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews while (count > 0) {
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews return (-1);
int order;
unsigned int nlabels;
return (ISC_TRUE);
return (ISC_FALSE);
int order;
#if defined(__clang__) && \
return (ISC_TRUE);
return (ISC_FALSE);
unsigned char *offsets;
unsigned int first, unsigned int n,
unsigned char *offsets;
unsigned char *offsets;
unsigned int len;
if (r->length > 0)
char *tdata;
unsigned char *offsets;
offsets[0] = 0;
tused = 0;
nused = 0;
labels = 0;
c = *tdata++;
tlen--;
tused++;
switch (state) {
case ft_init:
if (tlen != 0)
return (DNS_R_EMPTYLABEL);
labels++;
*ndata++ = 0;
nrem--;
nused++;
case ft_start:
ndata++;
nrem--;
nused++;
count = 0;
if (nrem == 0)
return (ISC_R_NOSPACE);
case ft_ordinary:
if (count == 0)
return (DNS_R_EMPTYLABEL);
labels++;
if (tlen == 0) {
labels++;
*ndata++ = 0;
nrem--;
nused++;
return (DNS_R_LABELTOOLONG);
count++;
CONVERTTOASCII(c);
if (downcase)
*ndata++ = c;
nrem--;
nused++;
case ft_initialescape:
return (DNS_R_BADLABELTYPE);
case ft_escape:
return (DNS_R_LABELTOOLONG);
count++;
CONVERTTOASCII(c);
if (downcase)
*ndata++ = c;
nrem--;
nused++;
digits = 0;
value = 0;
case ft_escdecimal:
return (DNS_R_BADESCAPE);
digits++;
return (DNS_R_BADESCAPE);
return (DNS_R_LABELTOOLONG);
count++;
if (downcase)
nrem--;
nused++;
if (!done) {
if (nrem == 0)
return (ISC_R_NOSPACE);
return (ISC_R_UNEXPECTEDEND);
labels++;
return (ISC_R_NOSPACE);
while (n1 > 0) {
while (n2 > 0) {
c = *label++;
if (downcase)
*ndata++ = c;
n2--;
labels++;
if (n1 > 0) {
return (ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
thread_key_mutex_init(void) {
static isc_result_t
totext_filter_proc_key_init(void) {
return (result);
if (!thread_key_initialized) {
goto unlock;
if (!thread_key_initialized &&
free_specific) != 0) {
return (result);
if (omit_final_dot)
unsigned char *ndata;
char *tdata;
unsigned int labels;
#ifdef ISC_PLATFORM_USETHREADS
#ifdef ISC_PLATFORM_USETHREADS
return (result);
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
labels--;
nlen--;
if (count == 0) {
while (count > 0) {
c = *ndata;
goto no_escape;
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
nlen--;
if (trem == 0)
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
trem--;
nlen--;
return (ISC_R_NOSPACE);
ndata++;
nlen--;
count--;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
return (ISC_R_NOSPACE);
trem++;
#ifdef ISC_PLATFORM_USETHREADS
return (ISC_R_SUCCESS);
unsigned char *ndata;
char *tdata;
unsigned int labels;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
labels--;
nlen--;
if (count == 0)
while (count > 0) {
c = *ndata;
if (trem == 0)
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
trem--;
nlen--;
return (ISC_R_NOSPACE);
ndata++;
nlen--;
count--;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
return (ISC_R_NOSPACE);
if (omit_final_dot)
trem++;
return (ISC_R_SUCCESS);
return (ISC_R_NOSPACE);
labels--;
nlen--;
while (count > 0) {
nlen--;
count--;
return (ISC_R_SUCCESS);
unsigned char *ndata;
offset = 0;
nlabels = 0;
offset++;
if (count == 0) {
if (absolute)
unsigned char *offsets;
new_current = 0;
labels = 0;
nused = 0;
cused = 0;
c = *cdata++;
current++;
if (!seen_pointer)
cused++;
switch (state) {
case fw_start:
labels++;
goto full;
*ndata++ = c;
return (DNS_R_BADLABELTYPE);
return (DNS_R_DISALLOWED);
return (DNS_R_BADLABELTYPE);
case fw_ordinary:
if (downcase)
c = maptolower[c];
case fw_copy:
*ndata++ = c;
case fw_newcurrent:
new_current += c;
return (DNS_R_BADPOINTER);
if (!done)
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
full:
return (DNS_R_NAMETOOLONG);
return (ISC_R_NOSPACE);
unsigned int methods;
#if defined(__clang__) && \
if (gf) {
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
if (copy_prefix &&
length = 0;
prefix_length = 0;
labels = 0;
if (copy_prefix) {
if (copy_suffix) {
return (DNS_R_NAMETOOLONG);
return (ISC_R_NOSPACE);
if (copy_suffix) {
if (absolute)
return (ISC_R_SUCCESS);
unsigned int splitlabel;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
isc_region_t r;
#if defined(__clang__) && \
return (result);
isc_buffer_t b;
isc_region_t r;
isc_buffer_init(&b, t, sizeof(t));
return (result);
isc_buffer_usedregion(&b, &r);
return (ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
int res;
return (result);
return (ISC_R_SUCCESS);
if (res != 0)
return (result);
return (ISC_R_NOMEMORY);
return (result);
return (ISC_R_SUCCESS);
isc_region_t r;
return (result);
*target = p;
return (ISC_R_SUCCESS);
return (result);
return (result);
unsigned char *ndata;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
dns_name_destroy(void) {
#ifdef ISC_PLATFORM_USETHREADS
== ISC_R_SUCCESS);
if (thread_key_initialized) {