nsec.c revision 0cfbb9285a96f1355e5a3bd458624eaed2f16846
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Permission to use, copy, modify, and/or distribute this software for any
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * purpose with or without fee is hereby granted, provided that the above
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * copyright notice and this permission notice appear in all copies.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * PERFORMANCE OF THIS SOFTWARE.
110d1702731f42dd620879c1d765ebe91f3920ceMichael Graff/* $Id: nsec.c,v 1.13 2009/01/06 23:47:57 tbox Exp $ */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#define RETERR(x) do { \
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyset_bit(unsigned char *array, unsigned int index, unsigned int bit) {
078d49b63324f01d98301ee21671abee0c41fcdeBob Halleystatic unsigned int
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleybit_isset(unsigned char *array, unsigned int index) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley unsigned int i, window;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley unsigned int max_type;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Use the end of the space for a raw bitmap leaving enough
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * space for the window identifiers and length octets.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * At zone cuts, deny the existence of glue in the parent zone.
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley for (i = 0; i <= max_type; i++) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ! dns_rdatatype_iszonecutauth((dns_rdatatype_t)i))
95552051abdb3b6fc4f56b015da27c000742646bBob Halley * Note: potential overlapping move.
95552051abdb3b6fc4f56b015da27c000742646bBob Halley memmove(&nsec_bits[2], &bm[window * 32], octet + 1);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halleydns_nsec_build(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley RETERR(dns_nsec_buildrdata(db, version, node, target, data, &rdata));
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley RETERR(dns_rdatalist_tordataset(&rdatalist, &rdataset));
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_db_addrdataset(db, node, version, 0, &rdataset,
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halleydns_nsec_typepresent(dns_rdata_t *nsec, dns_rdatatype_t type) {
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley /* This should never fail */
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_rdata_tostruct(nsec, &nsecstruct, NULL);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley present = ISC_TF(bit_isset(&nsecstruct.typebits[i],
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halleydns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version,
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey,