4269c3690697323b4c258ea279fbbe406dc356b3Tinderbox User * Copyright (C) 1999-2012, 2014-2017 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews "pending-additional",
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews "pending-answer",
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews "additional",
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews "authauthority",
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews "authanswer",
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews if (trust >= sizeof(trustnames)/sizeof(*trustnames))
4100ae5109c69d8269a8fa626f217a15a633cd7fMark Andrews return ("bad");
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Make 'rdataset' a valid, disassociated rdataset.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_invalidate(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Invalidate 'rdataset'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_disassociate(dns_rdataset_t *rdataset) {
2cd0c38115b1efb043ed3104c0d08e51ceade0d7Bob Halley * Disassociate 'rdataset' from its rdata, allowing it to be reused.
28640d1da26d561f4137122fe64e9e8cc08bf11eBob Halleydns_rdataset_isassociated(dns_rdataset_t *rdataset) {
28640d1da26d561f4137122fe64e9e8cc08bf11eBob Halley * Is 'rdataset' associated?
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halleyquestion_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halley * This routine should never be called.
1c724c986de1449e3b2f1eeae4c724dc0d97603cBob Halleyquestion_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
7837d146219db7a85a4b444a9cdf6602254a4f75Bob Halleystatic unsigned int
7837d146219db7a85a4b444a9cdf6602254a4f75Bob Halley * This routine should never be called.
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halleydns_rdataset_makequestion(dns_rdataset_t *rdataset, dns_rdataclass_t rdclass,
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halley * Make 'rdataset' a valid, associated, question rdataset, with a
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halley * question class of 'rdclass' and type 'type'.
bf345589ce0b0b64533d4566e4992a0e63aac6f5Bob Halley rdataset->attributes |= DNS_RDATASETATTR_QUESTION;
7837d146219db7a85a4b444a9cdf6602254a4f75Bob Halley * Return the number of records in 'rdataset'.
1c724c986de1449e3b2f1eeae4c724dc0d97603cBob Halleydns_rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
1c724c986de1449e3b2f1eeae4c724dc0d97603cBob Halley * Make 'target' refer to the same rdataset as 'source'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the first rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the next rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Make 'rdata' refer to the current rdata.
c3b708aaf1bb0a118e0e11befa1b732acfb1d079Bob Halley#define WANT_FIXED(r) (((r)->attributes & DNS_RDATASETATTR_FIXEDORDER) != 0)
2dd99c098ca162f985b7ef3c8142a964ad8281aeMark Andrews#define WANT_RANDOM(r) (((r)->attributes & DNS_RDATASETATTR_RANDOMIZE) != 0)
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafssontowire_compare(const void *av, const void *bv) {
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson const struct towire_sort *a = (const struct towire_sort *) av;
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson const struct towire_sort *b = (const struct towire_sort *) bv;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewstowiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews dns_rdatasetorderfunc_t order, const void *order_arg,
84185d19c7a9ef1ac23cc6236c8773697d4efeb1Brian Wellington isc_boolean_t partial, unsigned int options,
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews struct towire_sort *out = NULL, out_fixed[MAX_SHUFFLE];
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Convert 'rdataset' to wire format, compressing names as specified
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * in cctx, and storing the result in 'target'.
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson REQUIRE((order == NULL) == (order_arg == NULL));
89d8adb6663b13435ff9ae1eb53e45da7fa79275Bob Halley if ((rdataset->attributes & DNS_RDATASETATTR_QUESTION) != 0) {
6de9744cf9c64be2145f663e4051196a4eaa9d45Evan Hunt } else if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) {
8dfa9caeec8e68db0c937e347a3d6629e7627d54Bob Halley * This is a negative caching rdataset.
b2ca6fd3a8293440b4d263723525396059cf2400Brian Wellington if ((options & DNS_RDATASETTOWIRE_OMITDNSSEC) != 0)
b2ca6fd3a8293440b4d263723525396059cf2400Brian Wellington ncache_opts |= DNS_NCACHETOWIRE_OMITDNSSEC;
b2ca6fd3a8293440b4d263723525396059cf2400Brian Wellington return (dns_ncache_towire(rdataset, cctx, target, ncache_opts,
bdfaef63f576f810fab27f64395faccf2fcd9434Francis Dupont * Do we want to shuffle this answer?
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews in = isc_mem_get(cctx->mctx, count * sizeof(*in));
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews out = isc_mem_get(cctx->mctx, count * sizeof(*out));
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson * First we get handles to all of the rdata.
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson * Now we shuffle.
2dd99c098ca162f985b7ef3c8142a964ad8281aeMark Andrews * 'Fixed' order.
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson for (i = 0; i < count; i++) {
2dd99c098ca162f985b7ef3c8142a964ad8281aeMark Andrews * 'Random' order.
2dd99c098ca162f985b7ef3c8142a964ad8281aeMark Andrews for (i = 0; i < count; i++) {
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson * "Cyclic" order.
def8e47c688e2480a4539d69c3d1a0a28a7c0550Mark Andrews unsigned int j;
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson for (i = 0; i < count; i++) {
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson j = 0; /* Wrap around. */
2dd99c098ca162f985b7ef3c8142a964ad8281aeMark Andrews * Sorted order.
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews qsort(out, count, sizeof(out[0]), towire_compare);
836601ccc5e38b8104831f629f11fdb8e9d7238bMukund Sivaraman name->attributes |= owner_name->attributes &
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Copy out the name, type, class, ttl.
94a08e09db3dc844b6ee4841c368a2d7074a9c3fAndreas Gustafsson dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
69be7837c920fac5c71a73e8fad586f9a2711e96Michael Graff headlen = sizeof(dns_rdataclass_t) + sizeof(dns_rdatatype_t);
69be7837c920fac5c71a73e8fad586f9a2711e96Michael Graff * Save space for rdlen.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Copy out the rdata
69be7837c920fac5c71a73e8fad586f9a2711e96Michael Graff result = dns_rdata_towire(&rdata, cctx, target);
8af4b7042d84e0699f7c1de306526098030b74a9Mark Andrews dns_compress_rollback(cctx, (isc_uint16_t)rrbuffer.used);
13eaef2df27683658868c3828c18880d7419a16aDavid Lawrence dns_compress_rollback(cctx, (isc_uint16_t)savedbuffer.used);
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews isc_mem_put(cctx->mctx, out, count * sizeof(*out));
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews isc_mem_put(cctx->mctx, in, count * sizeof(*in));
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrewsdns_rdataset_towiresorted(dns_rdataset_t *rdataset,
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews unsigned int *countp)
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews return (towiresorted(rdataset, owner_name, cctx, target,
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrewsdns_rdataset_towirepartial(dns_rdataset_t *rdataset,
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews unsigned int *countp,
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews REQUIRE(state == NULL); /* XXX remove when implemented */
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews return (towiresorted(rdataset, owner_name, cctx, target,
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafssondns_rdataset_towire(dns_rdataset_t *rdataset,
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson unsigned int *countp)
03f91269f5453bcbd924910ef85a8f8496cf2661Mark Andrews return (towiresorted(rdataset, owner_name, cctx, target,
84185d19c7a9ef1ac23cc6236c8773697d4efeb1Brian Wellington NULL, NULL, ISC_FALSE, options, countp, NULL));
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdataset_additionaldata(dns_rdataset_t *rdataset,
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * For each rdata in rdataset, call 'add' for each name and type in the
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * rdata which is subject to additional section processing.
d981ca645597116d227a48bf37cc5edc061c854dBob Halley REQUIRE((rdataset->attributes & DNS_RDATASETATTR_QUESTION) == 0);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley result = dns_rdata_additionaldata(&rdata, add, arg);
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsdns_rdataset_addnoqname(dns_rdataset_t *rdataset, dns_name_t *name) {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews return((rdataset->methods->addnoqname)(rdataset, name));
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsdns_rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return((rdataset->methods->getnoqname)(rdataset, name, neg, negsig));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdns_rdataset_addclosest(dns_rdataset_t *rdataset, dns_name_t *name) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return((rdataset->methods->addclosest)(rdataset, name));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdns_rdataset_getclosest(dns_rdataset_t *rdataset, dns_name_t *name,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return((rdataset->methods->getclosest)(rdataset, name, neg, negsig));
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 * Additional cache stuff
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉dns_rdataset_getadditional(dns_rdataset_t *rdataset,
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 REQUIRE(zonep == NULL || *zonep == NULL);
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 REQUIRE(versionp != NULL && *versionp == NULL);
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 REQUIRE(nodep != NULL && *nodep == NULL);
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 if (acache != NULL && rdataset->methods->getadditional != NULL) {
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 return ((rdataset->methods->getadditional)(rdataset, type,
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉dns_rdataset_setadditional(dns_rdataset_t *rdataset,
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 if (acache != NULL && rdataset->methods->setadditional != NULL) {
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 return ((rdataset->methods->setadditional)(rdataset, type,
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉dns_rdataset_putadditional(dns_acache_t *acache,
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 if (acache != NULL && rdataset->methods->putadditional != NULL) {
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 return ((rdataset->methods->putadditional)(acache, rdataset,
0cae66577c69c89086cd065bb297690072b471b4Mark Andrewsdns_rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) {
0cae66577c69c89086cd065bb297690072b471b4Mark Andrews (rdataset->methods->settrust)(rdataset, trust);
092d3b76db6b93b8029bd7d083e74fc80fb41858Mark Andrewsdns_rdataset_clearprefetch(dns_rdataset_t *rdataset) {
a8da00ef95ba37b9d071c2b8db1a0c967e060106Mark Andrewsdns_rdataset_setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) {
a8da00ef95ba37b9d071c2b8db1a0c967e060106Mark Andrews (rdataset->methods->setownercase)(rdataset, name);
a8da00ef95ba37b9d071c2b8db1a0c967e060106Mark Andrewsdns_rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
a8da00ef95ba37b9d071c2b8db1a0c967e060106Mark Andrews (rdataset->methods->getownercase)(rdataset, name);
e7857b5ee05414961bb11f9e57f654163fae6acbckbdns_rdataset_trimttl(dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
e7857b5ee05414961bb11f9e57f654163fae6acbckb * If we accept expired RRsets keep them for no more than 120 seconds.
953692fa1e307b7325e383302d82b711d164a9d5Tinderbox User (isc_serial_le(rrsig->timeexpire, ((now + 120) & 0xffffffff)) ||
953692fa1e307b7325e383302d82b711d164a9d5Tinderbox User else if (isc_serial_ge(rrsig->timeexpire, now))