From f50ae72ec3417cae55dd4e085991c01af9fdc5f1 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Wed, 11 Feb 2009 20:37:59 +0100 Subject: Initial commit --- bin/tests/Kchild.example.+003+04017.key | 1 + bin/tests/Kchild.example.+003+04017.private | 7 + bin/tests/Makefile.in | 306 + bin/tests/adb_test.c | 436 + bin/tests/b8t.mk | 63 + bin/tests/b9t.mk | 68 + bin/tests/byaddr_test.c | 267 + bin/tests/byname_test.c | 376 + bin/tests/cfg_test.c | 151 + bin/tests/compress_test.c | 194 + bin/tests/db/Makefile.in | 57 + bin/tests/db/dns_db_class_1.data | 11 + bin/tests/db/dns_db_class_data | 9 + bin/tests/db/dns_db_closeversion_1.data | 11 + bin/tests/db/dns_db_closeversion_1_data | 7 + bin/tests/db/dns_db_closeversion_2.data | 11 + bin/tests/db/dns_db_closeversion_2_data | 7 + bin/tests/db/dns_db_currentversion.data | 11 + bin/tests/db/dns_db_currentversion_data | 7 + bin/tests/db/dns_db_expirenode.data | 11 + bin/tests/db/dns_db_expirenode_data | 7 + bin/tests/db/dns_db_find_1.data | 12 + bin/tests/db/dns_db_find_10.data | 10 + bin/tests/db/dns_db_find_10_data | 8 + bin/tests/db/dns_db_find_1_data | 7 + bin/tests/db/dns_db_find_2.data | 9 + bin/tests/db/dns_db_find_2_data | 9 + bin/tests/db/dns_db_find_3.data | 10 + bin/tests/db/dns_db_find_3_data | 9 + bin/tests/db/dns_db_find_4.data | 9 + bin/tests/db/dns_db_find_4_data | 7 + bin/tests/db/dns_db_find_5.data | 10 + bin/tests/db/dns_db_find_5_data | 8 + bin/tests/db/dns_db_find_6.data | 10 + bin/tests/db/dns_db_find_6_data | 8 + bin/tests/db/dns_db_find_7.data | 12 + bin/tests/db/dns_db_find_7_data | 7 + bin/tests/db/dns_db_find_8.data | 13 + bin/tests/db/dns_db_find_8_data | 7 + bin/tests/db/dns_db_find_9.data | 13 + bin/tests/db/dns_db_find_9_data | 7 + bin/tests/db/dns_db_findnode_1.data | 11 + bin/tests/db/dns_db_findnode_1_data | 9 + bin/tests/db/dns_db_findnode_2.data | 11 + bin/tests/db/dns_db_findnode_2_data | 7 + bin/tests/db/dns_db_iscache_1.data | 11 + bin/tests/db/dns_db_iscache_1_data | 7 + bin/tests/db/dns_db_iscache_2.data | 11 + bin/tests/db/dns_db_iscache_2_data | 7 + bin/tests/db/dns_db_iszone_1.data | 11 + bin/tests/db/dns_db_iszone_1_data | 7 + bin/tests/db/dns_db_iszone_2.data | 11 + bin/tests/db/dns_db_iszone_2_data | 7 + bin/tests/db/dns_db_load_1.data | 11 + bin/tests/db/dns_db_load_25.data | 6 + bin/tests/db/dns_db_load_data | 7 + bin/tests/db/dns_db_load_soa_not_top | 7 + bin/tests/db/dns_db_newversion.data | 11 + bin/tests/db/dns_db_newversion_data | 7 + bin/tests/db/dns_db_origin_1.data | 11 + bin/tests/db/dns_db_origin_data | 8 + bin/tests/db/t_db.c | 3146 +++ bin/tests/db_test.c | 946 + bin/tests/dst/Kdh.+002+18602.key | 1 + bin/tests/dst/Kdh.+002+18602.private | 6 + bin/tests/dst/Kdh.+002+48957.key | 1 + bin/tests/dst/Kdh.+002+48957.private | 6 + bin/tests/dst/Ktest.+001+00002.key | 1 + bin/tests/dst/Ktest.+001+54622.key | 1 + bin/tests/dst/Ktest.+001+54622.private | 10 + bin/tests/dst/Ktest.+003+23616.key | 1 + bin/tests/dst/Ktest.+003+23616.private | 7 + bin/tests/dst/Ktest.+003+49667.key | 1 + bin/tests/dst/Makefile.in | 65 + bin/tests/dst/dst_2_data | 16 + bin/tests/dst/dst_test.c | 294 + bin/tests/dst/gsstest.c | 566 + bin/tests/dst/t2_data_1 | 3077 +++ bin/tests/dst/t2_data_2 | 3077 +++ bin/tests/dst/t2_dsasig | 3 + bin/tests/dst/t2_rsasig | 6 + bin/tests/dst/t_dst.c | 933 + bin/tests/entropy2_test.c | 175 + bin/tests/entropy_test.c | 140 + bin/tests/fsaccess_test.c | 60 + bin/tests/genrandom.c | 76 + bin/tests/gxba_test.c | 98 + bin/tests/gxbn_test.c | 86 + bin/tests/hash_test.c | 289 + bin/tests/headerdep_test.sh.in | 57 + bin/tests/inter_test.c | 137 + bin/tests/journalprint.c | 86 + bin/tests/keyboard_test.c | 75 + bin/tests/lex_test.c | 160 + bin/tests/lfsr_test.c | 95 + bin/tests/log_test.c | 338 + bin/tests/lwres_test.c | 304 + bin/tests/lwresconf_test.c | 98 + bin/tests/master/Makefile.in | 58 + bin/tests/master/dns_master_load_10_data | 12 + bin/tests/master/dns_master_load_11_data | 12 + bin/tests/master/dns_master_load_1_data | 12 + bin/tests/master/dns_master_load_2_data | 12 + bin/tests/master/dns_master_load_3_data | 12 + bin/tests/master/dns_master_load_4_data | 12 + bin/tests/master/dns_master_load_5_data | 12 + bin/tests/master/dns_master_load_6_data | 12 + bin/tests/master/dns_master_load_7_data | 12 + bin/tests/master/dns_master_load_8_data | 12 + bin/tests/master/dns_master_load_9_data | 12 + bin/tests/master/master1.data | 11 + bin/tests/master/master10.data | 7 + bin/tests/master/master11.data | 6 + bin/tests/master/master2.data | 11 + bin/tests/master/master3.data | 11 + bin/tests/master/master4.data | 11 + bin/tests/master/master5.data | 11 + bin/tests/master/master6.data | 33 + bin/tests/master/master7.data | 17 + bin/tests/master/master8.data | 4 + bin/tests/master/master9.data | 4 + bin/tests/master/t_master.c | 336 + bin/tests/master_test.c | 95 + bin/tests/mem/Makefile.in | 55 + bin/tests/mem/t_mem.c | 208 + bin/tests/mempool_test.c | 128 + bin/tests/name_test.c | 352 + bin/tests/named.conf | 624 + bin/tests/names/Makefile.in | 58 + bin/tests/names/dns_name_compare_data | 11 + bin/tests/names/dns_name_countlabels_data | 10 + bin/tests/names/dns_name_fromregion_data | 12 + bin/tests/names/dns_name_fromtext_data | 9 + bin/tests/names/dns_name_fromwire_1_data | 30 + bin/tests/names/dns_name_fromwire_2_data | 30 + bin/tests/names/dns_name_fromwire_3_data | 31 + bin/tests/names/dns_name_fromwire_4_data | 30 + bin/tests/names/dns_name_fromwire_5_data | 30 + bin/tests/names/dns_name_fromwire_6_data | 30 + bin/tests/names/dns_name_fromwire_7_data | 30 + bin/tests/names/dns_name_fromwire_8_data | 30 + bin/tests/names/dns_name_fullcompare_data | 10 + bin/tests/names/dns_name_getlabel_data | 10 + bin/tests/names/dns_name_getlabelsequence_data | 9 + bin/tests/names/dns_name_hash_data | 12 + bin/tests/names/dns_name_isabsolute_data | 8 + bin/tests/names/dns_name_issubdomain_data | 11 + bin/tests/names/dns_name_rdatacompare_data | 11 + bin/tests/names/dns_name_toregion_data | 8 + bin/tests/names/dns_name_totext_data | 9 + bin/tests/names/dns_name_towire_1_data | 17 + bin/tests/names/dns_name_towire_2_data | 17 + bin/tests/names/t_names.c | 2345 +++ bin/tests/names/wire_test1.data | 13 + bin/tests/names/wire_test2.data | 13 + bin/tests/names/wire_test3_1.data | 11 + bin/tests/names/wire_test3_2.data | 12 + bin/tests/names/wire_test4.data | 45 + bin/tests/names/wire_test5.data | 13 + bin/tests/names/wire_test6.data | 13 + bin/tests/names/wire_test7.data | 5 + bin/tests/names/wire_test8.data | 28 + bin/tests/ndc.conf | 36 + bin/tests/ndc.conf-include | 25 + bin/tests/net/Makefile.in | 53 + bin/tests/net/driver.c | 107 + bin/tests/net/driver.h | 48 + bin/tests/net/netaddr_multicast.c | 112 + bin/tests/net/sockaddr_multicast.c | 36 + bin/tests/net/testsuite.h | 33 + bin/tests/nsec3hash.c | 117 + bin/tests/nsecify.c | 216 + bin/tests/printmsg.c | 251 + bin/tests/printmsg.h | 27 + bin/tests/ratelimiter_test.c | 153 + bin/tests/rbt/Makefile.in | 58 + bin/tests/rbt/dns_rbt.data | 14 + bin/tests/rbt/dns_rbt_addname_1_data | 6 + bin/tests/rbt/dns_rbt_addname_2_data | 6 + bin/tests/rbt/dns_rbt_bitstring.data | 10 + bin/tests/rbt/dns_rbt_create_1_data | 7 + bin/tests/rbt/dns_rbt_deletename_1_data | 6 + bin/tests/rbt/dns_rbt_deletename_2_data | 6 + bin/tests/rbt/dns_rbt_findname_1_data | 6 + bin/tests/rbt/dns_rbt_findname_2_data | 6 + bin/tests/rbt/dns_rbt_findname_3_data | 6 + bin/tests/rbt/dns_rbtnodechain_first_1.data | 13 + bin/tests/rbt/dns_rbtnodechain_first_2.data | 9 + bin/tests/rbt/dns_rbtnodechain_first_data | 7 + bin/tests/rbt/dns_rbtnodechain_init.data | 13 + bin/tests/rbt/dns_rbtnodechain_init_data | 6 + bin/tests/rbt/dns_rbtnodechain_last_1.data | 13 + bin/tests/rbt/dns_rbtnodechain_last_2.data | 7 + bin/tests/rbt/dns_rbtnodechain_last_data | 7 + bin/tests/rbt/dns_rbtnodechain_next.data | 13 + bin/tests/rbt/dns_rbtnodechain_next_data | 6 + bin/tests/rbt/dns_rbtnodechain_prev.data | 13 + bin/tests/rbt/dns_rbtnodechain_prev_data | 6 + bin/tests/rbt/t_rbt.c | 1857 ++ bin/tests/rbt_test.c | 457 + bin/tests/rbt_test.out | 395 + bin/tests/rbt_test.txt | 93 + bin/tests/rdata_test.c | 1182 ++ bin/tests/resolv.conf.sample | 38 + bin/tests/rwlock_test.c | 142 + bin/tests/serial_test.c | 50 + bin/tests/shutdown_test.c | 232 + bin/tests/sig0_test.c | 305 + bin/tests/sock_test.c | 382 + bin/tests/sockaddr/Makefile.in | 55 + bin/tests/sockaddr/t_sockaddr.c | 137 + bin/tests/sym_test.c | 127 + bin/tests/system/Makefile.in | 45 + bin/tests/system/README | 54 + bin/tests/system/acl/clean.sh | 25 + bin/tests/system/acl/ns2/named1.conf | 61 + bin/tests/system/acl/ns2/named2.conf | 65 + bin/tests/system/acl/ns2/named3.conf | 74 + bin/tests/system/acl/ns2/named4.conf | 73 + bin/tests/system/acl/setup.sh | 21 + bin/tests/system/acl/tests.sh | 144 + bin/tests/system/cacheclean/clean.sh | 25 + bin/tests/system/cacheclean/dig.batch | 924 + bin/tests/system/cacheclean/knowngood.dig.out | 953 + bin/tests/system/cacheclean/ns1/example.db | 2950 +++ bin/tests/system/cacheclean/ns1/named.conf | 38 + bin/tests/system/cacheclean/ns2/named.conf | 38 + bin/tests/system/cacheclean/tests.sh | 32 + bin/tests/system/checkconf/bad.conf | 52 + bin/tests/system/checkconf/good.conf | 56 + bin/tests/system/checkconf/tests.sh | 37 + bin/tests/system/checknames/clean.sh | 24 + bin/tests/system/checknames/ns1/fail.example.db.in | 22 + bin/tests/system/checknames/ns1/fail.update.db.in | 21 + .../system/checknames/ns1/ignore.example.db.in | 23 + .../system/checknames/ns1/ignore.update.db.in | 21 + bin/tests/system/checknames/ns1/named.conf | 76 + bin/tests/system/checknames/ns1/root.db | 35 + bin/tests/system/checknames/ns1/warn.example.db.in | 22 + bin/tests/system/checknames/ns1/warn.update.db.in | 21 + bin/tests/system/checknames/ns2/named.conf | 38 + bin/tests/system/checknames/ns2/root.hints | 19 + bin/tests/system/checknames/ns3/named.conf | 38 + bin/tests/system/checknames/ns3/root.hints | 19 + bin/tests/system/checknames/setup.sh | 23 + bin/tests/system/checknames/tests.sh | 134 + bin/tests/system/cleanall.sh | 38 + bin/tests/system/common/controls.conf | 28 + bin/tests/system/common/rndc.conf | 27 + bin/tests/system/common/root.hint | 20 + bin/tests/system/conf.sh.in | 54 + bin/tests/system/dialup/ns1/example.db | 25 + bin/tests/system/dialup/ns1/named.conf | 45 + bin/tests/system/dialup/ns1/root.db | 26 + bin/tests/system/dialup/ns2/hint.db | 19 + bin/tests/system/dialup/ns2/named.conf | 45 + bin/tests/system/dialup/ns3/hint.db | 19 + bin/tests/system/dialup/ns3/named.conf | 45 + bin/tests/system/dialup/setup.sh | 19 + bin/tests/system/dialup/tests.sh | 71 + bin/tests/system/digcomp.pl | 111 + bin/tests/system/dlv/clean.sh | 28 + bin/tests/system/dlv/ns1/named.conf | 35 + bin/tests/system/dlv/ns1/root.db | 24 + bin/tests/system/dlv/ns1/rootservers.utld.db | 20 + bin/tests/system/dlv/ns2/hints | 18 + bin/tests/system/dlv/ns2/named.conf | 35 + bin/tests/system/dlv/ns2/utld.db | 56 + bin/tests/system/dlv/ns3/child.db.in | 22 + bin/tests/system/dlv/ns3/dlv.db.in | 20 + bin/tests/system/dlv/ns3/hints | 18 + bin/tests/system/dlv/ns3/named.conf | 43 + bin/tests/system/dlv/ns3/sign.sh | 174 + bin/tests/system/dlv/ns4/child.db | 41 + bin/tests/system/dlv/ns4/hints | 18 + bin/tests/system/dlv/ns4/named.conf | 36 + bin/tests/system/dlv/ns5/hints | 18 + bin/tests/system/dlv/ns5/named.conf | 66 + bin/tests/system/dlv/ns5/rndc.conf | 27 + bin/tests/system/dlv/setup.sh | 21 + bin/tests/system/dlv/tests.sh | 19 + bin/tests/system/dnssec/README | 17 + bin/tests/system/dnssec/clean.sh | 38 + bin/tests/system/dnssec/dnssec_update_test.pl | 105 + bin/tests/system/dnssec/ns1/named.conf | 43 + bin/tests/system/dnssec/ns1/root.db.in | 32 + bin/tests/system/dnssec/ns1/sign.sh | 56 + bin/tests/system/dnssec/ns2/child.nsec3.example.db | 25 + .../system/dnssec/ns2/child.optout.example.db | 25 + bin/tests/system/dnssec/ns2/dlv.db.in | 26 + bin/tests/system/dnssec/ns2/dst.example.db.in | 26 + bin/tests/system/dnssec/ns2/example.db.in | 97 + .../system/dnssec/ns2/insecure.secure.example.db | 32 + bin/tests/system/dnssec/ns2/named.conf | 83 + .../system/dnssec/ns2/private.secure.example.db.in | 34 + bin/tests/system/dnssec/ns2/rfc2335.example.db | 103 + bin/tests/system/dnssec/ns2/sign.sh | 68 + bin/tests/system/dnssec/ns3/bogus.example.db.in | 32 + bin/tests/system/dnssec/ns3/dynamic.example.db.in | 31 + bin/tests/system/dnssec/ns3/insecure.example.db | 32 + .../system/dnssec/ns3/insecure.nsec3.example.db | 31 + .../system/dnssec/ns3/insecure.optout.example.db | 31 + bin/tests/system/dnssec/ns3/keyless.example.db.in | 29 + bin/tests/system/dnssec/ns3/multiple.example.db.in | 34 + bin/tests/system/dnssec/ns3/named.conf | 159 + .../system/dnssec/ns3/nsec3-unknown.example.db.in | 34 + bin/tests/system/dnssec/ns3/nsec3.example.db.in | 43 + .../system/dnssec/ns3/nsec3.nsec3.example.db.in | 40 + .../system/dnssec/ns3/nsec3.optout.example.db.in | 40 + .../system/dnssec/ns3/optout-unknown.example.db.in | 34 + bin/tests/system/dnssec/ns3/optout.example.db.in | 45 + .../system/dnssec/ns3/optout.nsec3.example.db.in | 40 + .../system/dnssec/ns3/optout.optout.example.db.in | 40 + bin/tests/system/dnssec/ns3/secure.example.db.in | 41 + .../system/dnssec/ns3/secure.nsec3.example.db.in | 40 + .../system/dnssec/ns3/secure.optout.example.db.in | 40 + bin/tests/system/dnssec/ns3/sign.sh | 224 + bin/tests/system/dnssec/ns4/named.conf | 44 + bin/tests/system/dnssec/ns5/named.conf | 43 + bin/tests/system/dnssec/ns5/trusted.conf.bad | 22 + bin/tests/system/dnssec/ns6/named.conf | 45 + bin/tests/system/dnssec/ns7/named.conf | 72 + bin/tests/system/dnssec/prereq.sh | 28 + bin/tests/system/dnssec/setup.sh | 26 + bin/tests/system/dnssec/tests.sh | 834 + bin/tests/system/forward/clean.sh | 22 + bin/tests/system/forward/ns1/example.db | 12 + bin/tests/system/forward/ns1/named.conf | 61 + bin/tests/system/forward/ns1/root.db | 36 + bin/tests/system/forward/ns2/example.db | 12 + bin/tests/system/forward/ns2/named.conf | 56 + bin/tests/system/forward/ns2/root.db | 36 + bin/tests/system/forward/ns3/named.conf | 56 + bin/tests/system/forward/ns3/root.db | 36 + bin/tests/system/forward/ns4/named.conf | 52 + bin/tests/system/forward/ns4/root.db | 36 + bin/tests/system/forward/tests.sh | 92 + bin/tests/system/genzone.sh | 267 + bin/tests/system/glue/clean.sh | 25 + bin/tests/system/glue/fi.good | 27 + bin/tests/system/glue/noglue.good | 14 + bin/tests/system/glue/ns1/cache.in | 23 + bin/tests/system/glue/ns1/mil.db | 31 + bin/tests/system/glue/ns1/named.conf | 53 + bin/tests/system/glue/ns1/net.db | 40 + bin/tests/system/glue/ns1/root-servers.nil.db | 31 + bin/tests/system/glue/ns1/root.db | 76 + bin/tests/system/glue/setup.sh | 20 + bin/tests/system/glue/tests.sh | 46 + bin/tests/system/glue/xx.good | 16 + bin/tests/system/glue/yy.good | 17 + bin/tests/system/ifconfig.sh | 189 + bin/tests/system/ixfr/ans2/ans.pl | 157 + bin/tests/system/ixfr/clean.sh | 21 + bin/tests/system/ixfr/prereq.sh | 26 + bin/tests/system/ixfr/setup.sh | 43 + bin/tests/system/ixfr/tests.sh | 132 + bin/tests/system/limits/clean.sh | 24 + bin/tests/system/limits/knowngood.dig.out.1000 | 1023 + bin/tests/system/limits/knowngood.dig.out.2000 | 2023 ++ bin/tests/system/limits/knowngood.dig.out.3000 | 3023 +++ bin/tests/system/limits/knowngood.dig.out.4000 | 4023 ++++ .../limits/knowngood.dig.out.a-maximum-rrset | 4114 ++++ bin/tests/system/limits/ns1/example.db | 19118 +++++++++++++++++++ bin/tests/system/limits/ns1/named.conf | 42 + bin/tests/system/limits/ns1/root.db | 30 + bin/tests/system/limits/tests.sh | 60 + bin/tests/system/lwresd/Makefile.in | 56 + bin/tests/system/lwresd/clean.sh | 22 + bin/tests/system/lwresd/lwresd1/lwresd.conf | 34 + bin/tests/system/lwresd/lwresd1/resolv.conf | 21 + bin/tests/system/lwresd/lwtest.c | 773 + .../system/lwresd/ns1/10.10.10.in-addr.arpa.db | 29 + bin/tests/system/lwresd/ns1/e.example1.db | 54 + bin/tests/system/lwresd/ns1/example1.db | 35 + bin/tests/system/lwresd/ns1/example2.db | 30 + bin/tests/system/lwresd/ns1/ip6.arpa.db | 30 + bin/tests/system/lwresd/ns1/ip6.int.db | 29 + bin/tests/system/lwresd/ns1/named.conf | 69 + bin/tests/system/lwresd/ns1/root.db | 33 + bin/tests/system/lwresd/resolv.conf | 21 + bin/tests/system/lwresd/tests.sh | 46 + bin/tests/system/masterfile/clean.sh | 21 + bin/tests/system/masterfile/knowngood.dig.out | 33 + bin/tests/system/masterfile/ns1/include.db | 41 + bin/tests/system/masterfile/ns1/named.conf | 47 + bin/tests/system/masterfile/ns1/sub.db | 21 + bin/tests/system/masterfile/ns1/ttl1.db | 33 + bin/tests/system/masterfile/ns1/ttl2.db | 36 + bin/tests/system/masterfile/tests.sh | 37 + bin/tests/system/masterformat/clean.sh | 23 + bin/tests/system/masterformat/ns1/compile.sh | 17 + bin/tests/system/masterformat/ns1/example.db | 54 + bin/tests/system/masterformat/ns1/named.conf | 36 + bin/tests/system/masterformat/ns2/named.conf | 35 + bin/tests/system/masterformat/setup.sh | 20 + bin/tests/system/masterformat/tests.sh | 80 + bin/tests/system/notify/clean.sh | 26 + bin/tests/system/notify/ns1/named.conf | 37 + bin/tests/system/notify/ns1/root.db | 30 + bin/tests/system/notify/ns2/example1.db | 150 + bin/tests/system/notify/ns2/example2.db | 150 + bin/tests/system/notify/ns2/example3.db | 150 + bin/tests/system/notify/ns2/example4.db | 150 + bin/tests/system/notify/ns2/named.conf | 43 + bin/tests/system/notify/ns3/named.conf | 46 + bin/tests/system/notify/setup.sh | 20 + bin/tests/system/notify/tests.sh | 92 + bin/tests/system/nsupdate/clean.sh | 28 + bin/tests/system/nsupdate/knowngood.ns1.after | 99 + bin/tests/system/nsupdate/knowngood.ns1.afterstop | 3 + bin/tests/system/nsupdate/knowngood.ns1.before | 98 + bin/tests/system/nsupdate/ns1/example1.db | 152 + bin/tests/system/nsupdate/ns1/named.conf | 58 + bin/tests/system/nsupdate/ns2/named.conf | 49 + bin/tests/system/nsupdate/setup.sh | 42 + bin/tests/system/nsupdate/tests.sh | 161 + bin/tests/system/nsupdate/update_test.pl | 426 + bin/tests/system/resolver/ans2/ans.pl | 75 + bin/tests/system/resolver/ans3/ans.pl | 60 + bin/tests/system/resolver/clean.sh | 22 + bin/tests/system/resolver/ns1/named.conf | 38 + bin/tests/system/resolver/ns1/root.hint | 20 + bin/tests/system/resolver/prereq.sh | 26 + bin/tests/system/resolver/tests.sh | 39 + bin/tests/system/rrsetorder/clean.sh | 23 + bin/tests/system/rrsetorder/dig.out.fixed.good | 4 + bin/tests/system/rrsetorder/dig.out.random.good1 | 4 + bin/tests/system/rrsetorder/dig.out.random.good10 | 4 + bin/tests/system/rrsetorder/dig.out.random.good11 | 4 + bin/tests/system/rrsetorder/dig.out.random.good12 | 4 + bin/tests/system/rrsetorder/dig.out.random.good13 | 4 + bin/tests/system/rrsetorder/dig.out.random.good14 | 4 + bin/tests/system/rrsetorder/dig.out.random.good15 | 4 + bin/tests/system/rrsetorder/dig.out.random.good16 | 4 + bin/tests/system/rrsetorder/dig.out.random.good17 | 4 + bin/tests/system/rrsetorder/dig.out.random.good18 | 4 + bin/tests/system/rrsetorder/dig.out.random.good19 | 4 + bin/tests/system/rrsetorder/dig.out.random.good2 | 4 + bin/tests/system/rrsetorder/dig.out.random.good20 | 4 + bin/tests/system/rrsetorder/dig.out.random.good21 | 4 + bin/tests/system/rrsetorder/dig.out.random.good22 | 4 + bin/tests/system/rrsetorder/dig.out.random.good23 | 4 + bin/tests/system/rrsetorder/dig.out.random.good24 | 4 + bin/tests/system/rrsetorder/dig.out.random.good3 | 4 + bin/tests/system/rrsetorder/dig.out.random.good4 | 4 + bin/tests/system/rrsetorder/dig.out.random.good5 | 4 + bin/tests/system/rrsetorder/dig.out.random.good6 | 4 + bin/tests/system/rrsetorder/dig.out.random.good7 | 4 + bin/tests/system/rrsetorder/dig.out.random.good8 | 4 + bin/tests/system/rrsetorder/dig.out.random.good9 | 4 + bin/tests/system/rrsetorder/ns1/named.conf | 43 + bin/tests/system/rrsetorder/ns1/root.db | 40 + bin/tests/system/rrsetorder/ns2/named.conf | 45 + bin/tests/system/rrsetorder/ns3/named.conf | 45 + bin/tests/system/rrsetorder/tests.sh | 332 + bin/tests/system/run.sh | 115 + bin/tests/system/runall.sh | 46 + bin/tests/system/send.pl | 39 + bin/tests/system/setup.sh | 40 + bin/tests/system/sortlist/clean.sh | 21 + bin/tests/system/sortlist/ns1/example.db | 43 + bin/tests/system/sortlist/ns1/named.conf | 53 + bin/tests/system/sortlist/ns1/root.db | 30 + bin/tests/system/sortlist/tests.sh | 60 + bin/tests/system/start.pl | 209 + bin/tests/system/start.sh | 21 + bin/tests/system/stop.pl | 188 + bin/tests/system/stop.sh | 22 + bin/tests/system/stress/clean.sh | 29 + bin/tests/system/stress/ns1/named.conf | 37 + bin/tests/system/stress/ns2/named.conf | 39 + bin/tests/system/stress/ns3/named.conf | 56 + bin/tests/system/stress/ns4/named.conf | 41 + bin/tests/system/stress/setup.pl | 91 + bin/tests/system/stress/setup.sh | 24 + bin/tests/system/stress/tests.sh | 53 + bin/tests/system/stress/update.pl | 107 + bin/tests/system/stub/clean.sh | 24 + bin/tests/system/stub/knowngood.dig.out.norec | 21 + bin/tests/system/stub/knowngood.dig.out.rec | 24 + bin/tests/system/stub/ns1/named.conf | 37 + bin/tests/system/stub/ns1/root.db | 30 + bin/tests/system/stub/ns2/child.example.db | 28 + bin/tests/system/stub/ns2/named.conf | 42 + bin/tests/system/stub/ns3/example.db | 28 + bin/tests/system/stub/ns3/named.conf | 49 + bin/tests/system/stub/tests.sh | 39 + bin/tests/system/testsock.pl | 51 + bin/tests/system/tkey/Makefile.in | 60 + bin/tests/system/tkey/clean.sh | 22 + bin/tests/system/tkey/keycreate.c | 329 + bin/tests/system/tkey/keydelete.c | 267 + bin/tests/system/tkey/ns1/named.conf.in | 39 + bin/tests/system/tkey/ns1/setup.sh | 25 + bin/tests/system/tkey/prereq.sh | 28 + bin/tests/system/tkey/setup.sh | 24 + bin/tests/system/tkey/tests.sh | 83 + bin/tests/system/tsig/clean.sh | 24 + bin/tests/system/tsig/ns1/example.db | 151 + bin/tests/system/tsig/ns1/named.conf | 96 + bin/tests/system/tsig/tests.sh | 218 + bin/tests/system/unknown/clean.sh | 21 + bin/tests/system/unknown/ns1/broken1.db | 29 + bin/tests/system/unknown/ns1/broken2.db | 29 + bin/tests/system/unknown/ns1/broken3.db | 29 + bin/tests/system/unknown/ns1/broken4.db | 29 + bin/tests/system/unknown/ns1/broken5.db | 29 + bin/tests/system/unknown/ns1/class10.hints | 19 + bin/tests/system/unknown/ns1/example-class10.db | 37 + bin/tests/system/unknown/ns1/example-in.db | 52 + bin/tests/system/unknown/ns1/named.conf | 76 + bin/tests/system/unknown/tests.sh | 119 + bin/tests/system/upforwd/clean.sh | 26 + bin/tests/system/upforwd/knowngood.after1 | 10 + bin/tests/system/upforwd/knowngood.after2 | 11 + bin/tests/system/upforwd/knowngood.before | 8 + bin/tests/system/upforwd/knowngood.ns2.before | 6 + bin/tests/system/upforwd/ns1/example1.db | 24 + bin/tests/system/upforwd/ns1/named.conf | 44 + bin/tests/system/upforwd/ns2/named.conf | 39 + bin/tests/system/upforwd/ns3/named.conf | 40 + bin/tests/system/upforwd/setup.sh | 21 + bin/tests/system/upforwd/tests.sh | 103 + bin/tests/system/v6synth/clean.sh | 21 + bin/tests/system/v6synth/ns1/named.conf | 37 + bin/tests/system/v6synth/ns1/root.db | 33 + bin/tests/system/v6synth/ns2/example.db | 38 + bin/tests/system/v6synth/ns2/ip6.arpa.db | 24 + bin/tests/system/v6synth/ns2/ip6.int.db | 24 + bin/tests/system/v6synth/ns2/named.conf | 49 + bin/tests/system/v6synth/ns3/named.conf | 39 + bin/tests/system/v6synth/tests.sh | 71 + bin/tests/system/views/clean.sh | 26 + bin/tests/system/views/ns1/named.conf | 37 + bin/tests/system/views/ns1/root.db | 30 + bin/tests/system/views/ns2/example1.db | 34 + bin/tests/system/views/ns2/example2.db | 34 + bin/tests/system/views/ns2/internal.db | 36 + bin/tests/system/views/ns2/named1.conf | 45 + bin/tests/system/views/ns2/named2.conf | 65 + bin/tests/system/views/ns3/internal.db | 34 + bin/tests/system/views/ns3/named1.conf | 55 + bin/tests/system/views/ns3/named2.conf | 54 + bin/tests/system/views/setup.sh | 23 + bin/tests/system/views/tests.sh | 83 + bin/tests/system/xfer/clean.sh | 27 + bin/tests/system/xfer/dig1.good | 80 + bin/tests/system/xfer/dig2.good | 80 + bin/tests/system/xfer/ns1/named.conf | 37 + bin/tests/system/xfer/ns1/root.db | 33 + bin/tests/system/xfer/ns2/named.conf | 61 + bin/tests/system/xfer/ns3/named.conf | 71 + bin/tests/system/xfer/setup.sh | 21 + bin/tests/system/xfer/tests.sh | 102 + bin/tests/system/xferquota/clean.sh | 28 + bin/tests/system/xferquota/ns1/changing1.db | 33 + bin/tests/system/xferquota/ns1/changing2.db | 33 + bin/tests/system/xferquota/ns1/named.conf | 44 + bin/tests/system/xferquota/ns1/root.db | 35 + bin/tests/system/xferquota/ns2/example.db | 152 + bin/tests/system/xferquota/ns2/named.conf | 48 + bin/tests/system/xferquota/setup.pl | 46 + bin/tests/system/xferquota/setup.sh | 26 + bin/tests/system/xferquota/tests.sh | 71 + bin/tests/system/zonechecks/a.db | 19 + bin/tests/system/zonechecks/aaaa.db | 19 + bin/tests/system/zonechecks/clean.sh | 20 + bin/tests/system/zonechecks/cname.db | 19 + bin/tests/system/zonechecks/dname.db | 19 + bin/tests/system/zonechecks/noaddress.db | 19 + bin/tests/system/zonechecks/nxdomain.db | 19 + bin/tests/system/zonechecks/tests.sh | 164 + bin/tests/t_api.pl | 223 + bin/tests/task_test.c | 191 + bin/tests/tasks/Makefile.in | 55 + bin/tests/tasks/t_tasks.c | 2293 +++ bin/tests/timer_test.c | 172 + bin/tests/timers/Makefile.in | 55 + bin/tests/timers/t_timers.c | 1128 ++ bin/tests/wire_test.c | 284 + bin/tests/wire_test.data | 9 + bin/tests/wire_test.data2 | 14 + bin/tests/wire_test.data3 | 14 + bin/tests/wire_test.data4 | 31 + bin/tests/zone_test.c | 312 + 586 files changed, 90180 insertions(+) create mode 100644 bin/tests/Kchild.example.+003+04017.key create mode 100644 bin/tests/Kchild.example.+003+04017.private create mode 100644 bin/tests/Makefile.in create mode 100644 bin/tests/adb_test.c create mode 100644 bin/tests/b8t.mk create mode 100644 bin/tests/b9t.mk create mode 100644 bin/tests/byaddr_test.c create mode 100644 bin/tests/byname_test.c create mode 100644 bin/tests/cfg_test.c create mode 100644 bin/tests/compress_test.c create mode 100644 bin/tests/db/Makefile.in create mode 100644 bin/tests/db/dns_db_class_1.data create mode 100644 bin/tests/db/dns_db_class_data create mode 100644 bin/tests/db/dns_db_closeversion_1.data create mode 100644 bin/tests/db/dns_db_closeversion_1_data create mode 100644 bin/tests/db/dns_db_closeversion_2.data create mode 100644 bin/tests/db/dns_db_closeversion_2_data create mode 100644 bin/tests/db/dns_db_currentversion.data create mode 100644 bin/tests/db/dns_db_currentversion_data create mode 100644 bin/tests/db/dns_db_expirenode.data create mode 100644 bin/tests/db/dns_db_expirenode_data create mode 100644 bin/tests/db/dns_db_find_1.data create mode 100644 bin/tests/db/dns_db_find_10.data create mode 100644 bin/tests/db/dns_db_find_10_data create mode 100644 bin/tests/db/dns_db_find_1_data create mode 100644 bin/tests/db/dns_db_find_2.data create mode 100644 bin/tests/db/dns_db_find_2_data create mode 100644 bin/tests/db/dns_db_find_3.data create mode 100644 bin/tests/db/dns_db_find_3_data create mode 100644 bin/tests/db/dns_db_find_4.data create mode 100644 bin/tests/db/dns_db_find_4_data create mode 100644 bin/tests/db/dns_db_find_5.data create mode 100644 bin/tests/db/dns_db_find_5_data create mode 100644 bin/tests/db/dns_db_find_6.data create mode 100644 bin/tests/db/dns_db_find_6_data create mode 100644 bin/tests/db/dns_db_find_7.data create mode 100644 bin/tests/db/dns_db_find_7_data create mode 100644 bin/tests/db/dns_db_find_8.data create mode 100644 bin/tests/db/dns_db_find_8_data create mode 100644 bin/tests/db/dns_db_find_9.data create mode 100644 bin/tests/db/dns_db_find_9_data create mode 100644 bin/tests/db/dns_db_findnode_1.data create mode 100644 bin/tests/db/dns_db_findnode_1_data create mode 100644 bin/tests/db/dns_db_findnode_2.data create mode 100644 bin/tests/db/dns_db_findnode_2_data create mode 100644 bin/tests/db/dns_db_iscache_1.data create mode 100644 bin/tests/db/dns_db_iscache_1_data create mode 100644 bin/tests/db/dns_db_iscache_2.data create mode 100644 bin/tests/db/dns_db_iscache_2_data create mode 100644 bin/tests/db/dns_db_iszone_1.data create mode 100644 bin/tests/db/dns_db_iszone_1_data create mode 100644 bin/tests/db/dns_db_iszone_2.data create mode 100644 bin/tests/db/dns_db_iszone_2_data create mode 100644 bin/tests/db/dns_db_load_1.data create mode 100644 bin/tests/db/dns_db_load_25.data create mode 100644 bin/tests/db/dns_db_load_data create mode 100644 bin/tests/db/dns_db_load_soa_not_top create mode 100644 bin/tests/db/dns_db_newversion.data create mode 100644 bin/tests/db/dns_db_newversion_data create mode 100644 bin/tests/db/dns_db_origin_1.data create mode 100644 bin/tests/db/dns_db_origin_data create mode 100644 bin/tests/db/t_db.c create mode 100644 bin/tests/db_test.c create mode 100644 bin/tests/dst/Kdh.+002+18602.key create mode 100644 bin/tests/dst/Kdh.+002+18602.private create mode 100644 bin/tests/dst/Kdh.+002+48957.key create mode 100644 bin/tests/dst/Kdh.+002+48957.private create mode 100644 bin/tests/dst/Ktest.+001+00002.key create mode 100644 bin/tests/dst/Ktest.+001+54622.key create mode 100644 bin/tests/dst/Ktest.+001+54622.private create mode 100644 bin/tests/dst/Ktest.+003+23616.key create mode 100644 bin/tests/dst/Ktest.+003+23616.private create mode 100644 bin/tests/dst/Ktest.+003+49667.key create mode 100644 bin/tests/dst/Makefile.in create mode 100644 bin/tests/dst/dst_2_data create mode 100644 bin/tests/dst/dst_test.c create mode 100755 bin/tests/dst/gsstest.c create mode 100644 bin/tests/dst/t2_data_1 create mode 100644 bin/tests/dst/t2_data_2 create mode 100644 bin/tests/dst/t2_dsasig create mode 100644 bin/tests/dst/t2_rsasig create mode 100644 bin/tests/dst/t_dst.c create mode 100644 bin/tests/entropy2_test.c create mode 100644 bin/tests/entropy_test.c create mode 100644 bin/tests/fsaccess_test.c create mode 100644 bin/tests/genrandom.c create mode 100644 bin/tests/gxba_test.c create mode 100644 bin/tests/gxbn_test.c create mode 100644 bin/tests/hash_test.c create mode 100644 bin/tests/headerdep_test.sh.in create mode 100644 bin/tests/inter_test.c create mode 100644 bin/tests/journalprint.c create mode 100644 bin/tests/keyboard_test.c create mode 100644 bin/tests/lex_test.c create mode 100644 bin/tests/lfsr_test.c create mode 100644 bin/tests/log_test.c create mode 100644 bin/tests/lwres_test.c create mode 100644 bin/tests/lwresconf_test.c create mode 100644 bin/tests/master/Makefile.in create mode 100644 bin/tests/master/dns_master_load_10_data create mode 100644 bin/tests/master/dns_master_load_11_data create mode 100644 bin/tests/master/dns_master_load_1_data create mode 100644 bin/tests/master/dns_master_load_2_data create mode 100644 bin/tests/master/dns_master_load_3_data create mode 100644 bin/tests/master/dns_master_load_4_data create mode 100644 bin/tests/master/dns_master_load_5_data create mode 100644 bin/tests/master/dns_master_load_6_data create mode 100644 bin/tests/master/dns_master_load_7_data create mode 100644 bin/tests/master/dns_master_load_8_data create mode 100644 bin/tests/master/dns_master_load_9_data create mode 100644 bin/tests/master/master1.data create mode 100644 bin/tests/master/master10.data create mode 100644 bin/tests/master/master11.data create mode 100644 bin/tests/master/master2.data create mode 100644 bin/tests/master/master3.data create mode 100644 bin/tests/master/master4.data create mode 100644 bin/tests/master/master5.data create mode 100644 bin/tests/master/master6.data create mode 100644 bin/tests/master/master7.data create mode 100644 bin/tests/master/master8.data create mode 100644 bin/tests/master/master9.data create mode 100644 bin/tests/master/t_master.c create mode 100644 bin/tests/master_test.c create mode 100644 bin/tests/mem/Makefile.in create mode 100644 bin/tests/mem/t_mem.c create mode 100644 bin/tests/mempool_test.c create mode 100644 bin/tests/name_test.c create mode 100644 bin/tests/named.conf create mode 100644 bin/tests/names/Makefile.in create mode 100644 bin/tests/names/dns_name_compare_data create mode 100644 bin/tests/names/dns_name_countlabels_data create mode 100644 bin/tests/names/dns_name_fromregion_data create mode 100644 bin/tests/names/dns_name_fromtext_data create mode 100644 bin/tests/names/dns_name_fromwire_1_data create mode 100644 bin/tests/names/dns_name_fromwire_2_data create mode 100644 bin/tests/names/dns_name_fromwire_3_data create mode 100644 bin/tests/names/dns_name_fromwire_4_data create mode 100644 bin/tests/names/dns_name_fromwire_5_data create mode 100644 bin/tests/names/dns_name_fromwire_6_data create mode 100644 bin/tests/names/dns_name_fromwire_7_data create mode 100644 bin/tests/names/dns_name_fromwire_8_data create mode 100644 bin/tests/names/dns_name_fullcompare_data create mode 100644 bin/tests/names/dns_name_getlabel_data create mode 100644 bin/tests/names/dns_name_getlabelsequence_data create mode 100644 bin/tests/names/dns_name_hash_data create mode 100644 bin/tests/names/dns_name_isabsolute_data create mode 100644 bin/tests/names/dns_name_issubdomain_data create mode 100644 bin/tests/names/dns_name_rdatacompare_data create mode 100644 bin/tests/names/dns_name_toregion_data create mode 100644 bin/tests/names/dns_name_totext_data create mode 100644 bin/tests/names/dns_name_towire_1_data create mode 100644 bin/tests/names/dns_name_towire_2_data create mode 100644 bin/tests/names/t_names.c create mode 100644 bin/tests/names/wire_test1.data create mode 100644 bin/tests/names/wire_test2.data create mode 100644 bin/tests/names/wire_test3_1.data create mode 100644 bin/tests/names/wire_test3_2.data create mode 100644 bin/tests/names/wire_test4.data create mode 100644 bin/tests/names/wire_test5.data create mode 100644 bin/tests/names/wire_test6.data create mode 100644 bin/tests/names/wire_test7.data create mode 100644 bin/tests/names/wire_test8.data create mode 100644 bin/tests/ndc.conf create mode 100644 bin/tests/ndc.conf-include create mode 100644 bin/tests/net/Makefile.in create mode 100644 bin/tests/net/driver.c create mode 100644 bin/tests/net/driver.h create mode 100644 bin/tests/net/netaddr_multicast.c create mode 100644 bin/tests/net/sockaddr_multicast.c create mode 100644 bin/tests/net/testsuite.h create mode 100644 bin/tests/nsec3hash.c create mode 100644 bin/tests/nsecify.c create mode 100644 bin/tests/printmsg.c create mode 100644 bin/tests/printmsg.h create mode 100644 bin/tests/ratelimiter_test.c create mode 100644 bin/tests/rbt/Makefile.in create mode 100644 bin/tests/rbt/dns_rbt.data create mode 100644 bin/tests/rbt/dns_rbt_addname_1_data create mode 100644 bin/tests/rbt/dns_rbt_addname_2_data create mode 100644 bin/tests/rbt/dns_rbt_bitstring.data create mode 100644 bin/tests/rbt/dns_rbt_create_1_data create mode 100644 bin/tests/rbt/dns_rbt_deletename_1_data create mode 100644 bin/tests/rbt/dns_rbt_deletename_2_data create mode 100644 bin/tests/rbt/dns_rbt_findname_1_data create mode 100644 bin/tests/rbt/dns_rbt_findname_2_data create mode 100644 bin/tests/rbt/dns_rbt_findname_3_data create mode 100644 bin/tests/rbt/dns_rbtnodechain_first_1.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_first_2.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_first_data create mode 100644 bin/tests/rbt/dns_rbtnodechain_init.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_init_data create mode 100644 bin/tests/rbt/dns_rbtnodechain_last_1.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_last_2.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_last_data create mode 100644 bin/tests/rbt/dns_rbtnodechain_next.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_next_data create mode 100644 bin/tests/rbt/dns_rbtnodechain_prev.data create mode 100644 bin/tests/rbt/dns_rbtnodechain_prev_data create mode 100644 bin/tests/rbt/t_rbt.c create mode 100644 bin/tests/rbt_test.c create mode 100644 bin/tests/rbt_test.out create mode 100644 bin/tests/rbt_test.txt create mode 100644 bin/tests/rdata_test.c create mode 100644 bin/tests/resolv.conf.sample create mode 100644 bin/tests/rwlock_test.c create mode 100644 bin/tests/serial_test.c create mode 100644 bin/tests/shutdown_test.c create mode 100644 bin/tests/sig0_test.c create mode 100644 bin/tests/sock_test.c create mode 100644 bin/tests/sockaddr/Makefile.in create mode 100644 bin/tests/sockaddr/t_sockaddr.c create mode 100644 bin/tests/sym_test.c create mode 100644 bin/tests/system/Makefile.in create mode 100644 bin/tests/system/README create mode 100644 bin/tests/system/acl/clean.sh create mode 100644 bin/tests/system/acl/ns2/named1.conf create mode 100644 bin/tests/system/acl/ns2/named2.conf create mode 100644 bin/tests/system/acl/ns2/named3.conf create mode 100644 bin/tests/system/acl/ns2/named4.conf create mode 100644 bin/tests/system/acl/setup.sh create mode 100644 bin/tests/system/acl/tests.sh create mode 100644 bin/tests/system/cacheclean/clean.sh create mode 100644 bin/tests/system/cacheclean/dig.batch create mode 100644 bin/tests/system/cacheclean/knowngood.dig.out create mode 100644 bin/tests/system/cacheclean/ns1/example.db create mode 100644 bin/tests/system/cacheclean/ns1/named.conf create mode 100644 bin/tests/system/cacheclean/ns2/named.conf create mode 100644 bin/tests/system/cacheclean/tests.sh create mode 100644 bin/tests/system/checkconf/bad.conf create mode 100644 bin/tests/system/checkconf/good.conf create mode 100644 bin/tests/system/checkconf/tests.sh create mode 100644 bin/tests/system/checknames/clean.sh create mode 100644 bin/tests/system/checknames/ns1/fail.example.db.in create mode 100644 bin/tests/system/checknames/ns1/fail.update.db.in create mode 100644 bin/tests/system/checknames/ns1/ignore.example.db.in create mode 100644 bin/tests/system/checknames/ns1/ignore.update.db.in create mode 100644 bin/tests/system/checknames/ns1/named.conf create mode 100644 bin/tests/system/checknames/ns1/root.db create mode 100644 bin/tests/system/checknames/ns1/warn.example.db.in create mode 100644 bin/tests/system/checknames/ns1/warn.update.db.in create mode 100644 bin/tests/system/checknames/ns2/named.conf create mode 100644 bin/tests/system/checknames/ns2/root.hints create mode 100644 bin/tests/system/checknames/ns3/named.conf create mode 100644 bin/tests/system/checknames/ns3/root.hints create mode 100644 bin/tests/system/checknames/setup.sh create mode 100644 bin/tests/system/checknames/tests.sh create mode 100644 bin/tests/system/cleanall.sh create mode 100644 bin/tests/system/common/controls.conf create mode 100644 bin/tests/system/common/rndc.conf create mode 100644 bin/tests/system/common/root.hint create mode 100644 bin/tests/system/conf.sh.in create mode 100644 bin/tests/system/dialup/ns1/example.db create mode 100644 bin/tests/system/dialup/ns1/named.conf create mode 100644 bin/tests/system/dialup/ns1/root.db create mode 100644 bin/tests/system/dialup/ns2/hint.db create mode 100644 bin/tests/system/dialup/ns2/named.conf create mode 100644 bin/tests/system/dialup/ns3/hint.db create mode 100644 bin/tests/system/dialup/ns3/named.conf create mode 100644 bin/tests/system/dialup/setup.sh create mode 100644 bin/tests/system/dialup/tests.sh create mode 100644 bin/tests/system/digcomp.pl create mode 100644 bin/tests/system/dlv/clean.sh create mode 100644 bin/tests/system/dlv/ns1/named.conf create mode 100644 bin/tests/system/dlv/ns1/root.db create mode 100644 bin/tests/system/dlv/ns1/rootservers.utld.db create mode 100644 bin/tests/system/dlv/ns2/hints create mode 100644 bin/tests/system/dlv/ns2/named.conf create mode 100644 bin/tests/system/dlv/ns2/utld.db create mode 100644 bin/tests/system/dlv/ns3/child.db.in create mode 100644 bin/tests/system/dlv/ns3/dlv.db.in create mode 100644 bin/tests/system/dlv/ns3/hints create mode 100644 bin/tests/system/dlv/ns3/named.conf create mode 100755 bin/tests/system/dlv/ns3/sign.sh create mode 100644 bin/tests/system/dlv/ns4/child.db create mode 100644 bin/tests/system/dlv/ns4/hints create mode 100644 bin/tests/system/dlv/ns4/named.conf create mode 100644 bin/tests/system/dlv/ns5/hints create mode 100644 bin/tests/system/dlv/ns5/named.conf create mode 100644 bin/tests/system/dlv/ns5/rndc.conf create mode 100644 bin/tests/system/dlv/setup.sh create mode 100644 bin/tests/system/dlv/tests.sh create mode 100644 bin/tests/system/dnssec/README create mode 100644 bin/tests/system/dnssec/clean.sh create mode 100644 bin/tests/system/dnssec/dnssec_update_test.pl create mode 100644 bin/tests/system/dnssec/ns1/named.conf create mode 100644 bin/tests/system/dnssec/ns1/root.db.in create mode 100644 bin/tests/system/dnssec/ns1/sign.sh create mode 100644 bin/tests/system/dnssec/ns2/child.nsec3.example.db create mode 100644 bin/tests/system/dnssec/ns2/child.optout.example.db create mode 100644 bin/tests/system/dnssec/ns2/dlv.db.in create mode 100644 bin/tests/system/dnssec/ns2/dst.example.db.in create mode 100644 bin/tests/system/dnssec/ns2/example.db.in create mode 100644 bin/tests/system/dnssec/ns2/insecure.secure.example.db create mode 100644 bin/tests/system/dnssec/ns2/named.conf create mode 100644 bin/tests/system/dnssec/ns2/private.secure.example.db.in create mode 100644 bin/tests/system/dnssec/ns2/rfc2335.example.db create mode 100644 bin/tests/system/dnssec/ns2/sign.sh create mode 100644 bin/tests/system/dnssec/ns3/bogus.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/dynamic.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/insecure.example.db create mode 100644 bin/tests/system/dnssec/ns3/insecure.nsec3.example.db create mode 100644 bin/tests/system/dnssec/ns3/insecure.optout.example.db create mode 100644 bin/tests/system/dnssec/ns3/keyless.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/multiple.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/named.conf create mode 100644 bin/tests/system/dnssec/ns3/nsec3-unknown.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/nsec3.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/nsec3.nsec3.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/nsec3.optout.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/optout-unknown.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/optout.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/optout.nsec3.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/optout.optout.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/secure.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/secure.nsec3.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/secure.optout.example.db.in create mode 100644 bin/tests/system/dnssec/ns3/sign.sh create mode 100644 bin/tests/system/dnssec/ns4/named.conf create mode 100644 bin/tests/system/dnssec/ns5/named.conf create mode 100644 bin/tests/system/dnssec/ns5/trusted.conf.bad create mode 100644 bin/tests/system/dnssec/ns6/named.conf create mode 100644 bin/tests/system/dnssec/ns7/named.conf create mode 100644 bin/tests/system/dnssec/prereq.sh create mode 100644 bin/tests/system/dnssec/setup.sh create mode 100644 bin/tests/system/dnssec/tests.sh create mode 100644 bin/tests/system/forward/clean.sh create mode 100644 bin/tests/system/forward/ns1/example.db create mode 100644 bin/tests/system/forward/ns1/named.conf create mode 100644 bin/tests/system/forward/ns1/root.db create mode 100644 bin/tests/system/forward/ns2/example.db create mode 100644 bin/tests/system/forward/ns2/named.conf create mode 100644 bin/tests/system/forward/ns2/root.db create mode 100644 bin/tests/system/forward/ns3/named.conf create mode 100644 bin/tests/system/forward/ns3/root.db create mode 100644 bin/tests/system/forward/ns4/named.conf create mode 100644 bin/tests/system/forward/ns4/root.db create mode 100644 bin/tests/system/forward/tests.sh create mode 100644 bin/tests/system/genzone.sh create mode 100644 bin/tests/system/glue/clean.sh create mode 100644 bin/tests/system/glue/fi.good create mode 100644 bin/tests/system/glue/noglue.good create mode 100644 bin/tests/system/glue/ns1/cache.in create mode 100644 bin/tests/system/glue/ns1/mil.db create mode 100644 bin/tests/system/glue/ns1/named.conf create mode 100644 bin/tests/system/glue/ns1/net.db create mode 100644 bin/tests/system/glue/ns1/root-servers.nil.db create mode 100644 bin/tests/system/glue/ns1/root.db create mode 100644 bin/tests/system/glue/setup.sh create mode 100644 bin/tests/system/glue/tests.sh create mode 100644 bin/tests/system/glue/xx.good create mode 100644 bin/tests/system/glue/yy.good create mode 100755 bin/tests/system/ifconfig.sh create mode 100644 bin/tests/system/ixfr/ans2/ans.pl create mode 100644 bin/tests/system/ixfr/clean.sh create mode 100644 bin/tests/system/ixfr/prereq.sh create mode 100644 bin/tests/system/ixfr/setup.sh create mode 100644 bin/tests/system/ixfr/tests.sh create mode 100644 bin/tests/system/limits/clean.sh create mode 100644 bin/tests/system/limits/knowngood.dig.out.1000 create mode 100644 bin/tests/system/limits/knowngood.dig.out.2000 create mode 100644 bin/tests/system/limits/knowngood.dig.out.3000 create mode 100644 bin/tests/system/limits/knowngood.dig.out.4000 create mode 100644 bin/tests/system/limits/knowngood.dig.out.a-maximum-rrset create mode 100644 bin/tests/system/limits/ns1/example.db create mode 100644 bin/tests/system/limits/ns1/named.conf create mode 100644 bin/tests/system/limits/ns1/root.db create mode 100644 bin/tests/system/limits/tests.sh create mode 100644 bin/tests/system/lwresd/Makefile.in create mode 100644 bin/tests/system/lwresd/clean.sh create mode 100644 bin/tests/system/lwresd/lwresd1/lwresd.conf create mode 100644 bin/tests/system/lwresd/lwresd1/resolv.conf create mode 100644 bin/tests/system/lwresd/lwtest.c create mode 100644 bin/tests/system/lwresd/ns1/10.10.10.in-addr.arpa.db create mode 100644 bin/tests/system/lwresd/ns1/e.example1.db create mode 100644 bin/tests/system/lwresd/ns1/example1.db create mode 100644 bin/tests/system/lwresd/ns1/example2.db create mode 100644 bin/tests/system/lwresd/ns1/ip6.arpa.db create mode 100644 bin/tests/system/lwresd/ns1/ip6.int.db create mode 100644 bin/tests/system/lwresd/ns1/named.conf create mode 100644 bin/tests/system/lwresd/ns1/root.db create mode 100644 bin/tests/system/lwresd/resolv.conf create mode 100644 bin/tests/system/lwresd/tests.sh create mode 100644 bin/tests/system/masterfile/clean.sh create mode 100644 bin/tests/system/masterfile/knowngood.dig.out create mode 100644 bin/tests/system/masterfile/ns1/include.db create mode 100644 bin/tests/system/masterfile/ns1/named.conf create mode 100644 bin/tests/system/masterfile/ns1/sub.db create mode 100644 bin/tests/system/masterfile/ns1/ttl1.db create mode 100644 bin/tests/system/masterfile/ns1/ttl2.db create mode 100644 bin/tests/system/masterfile/tests.sh create mode 100755 bin/tests/system/masterformat/clean.sh create mode 100755 bin/tests/system/masterformat/ns1/compile.sh create mode 100644 bin/tests/system/masterformat/ns1/example.db create mode 100644 bin/tests/system/masterformat/ns1/named.conf create mode 100644 bin/tests/system/masterformat/ns2/named.conf create mode 100755 bin/tests/system/masterformat/setup.sh create mode 100755 bin/tests/system/masterformat/tests.sh create mode 100644 bin/tests/system/notify/clean.sh create mode 100644 bin/tests/system/notify/ns1/named.conf create mode 100644 bin/tests/system/notify/ns1/root.db create mode 100644 bin/tests/system/notify/ns2/example1.db create mode 100644 bin/tests/system/notify/ns2/example2.db create mode 100644 bin/tests/system/notify/ns2/example3.db create mode 100644 bin/tests/system/notify/ns2/example4.db create mode 100644 bin/tests/system/notify/ns2/named.conf create mode 100644 bin/tests/system/notify/ns3/named.conf create mode 100644 bin/tests/system/notify/setup.sh create mode 100644 bin/tests/system/notify/tests.sh create mode 100644 bin/tests/system/nsupdate/clean.sh create mode 100644 bin/tests/system/nsupdate/knowngood.ns1.after create mode 100644 bin/tests/system/nsupdate/knowngood.ns1.afterstop create mode 100644 bin/tests/system/nsupdate/knowngood.ns1.before create mode 100644 bin/tests/system/nsupdate/ns1/example1.db create mode 100644 bin/tests/system/nsupdate/ns1/named.conf create mode 100644 bin/tests/system/nsupdate/ns2/named.conf create mode 100644 bin/tests/system/nsupdate/setup.sh create mode 100644 bin/tests/system/nsupdate/tests.sh create mode 100644 bin/tests/system/nsupdate/update_test.pl create mode 100644 bin/tests/system/resolver/ans2/ans.pl create mode 100644 bin/tests/system/resolver/ans3/ans.pl create mode 100644 bin/tests/system/resolver/clean.sh create mode 100644 bin/tests/system/resolver/ns1/named.conf create mode 100644 bin/tests/system/resolver/ns1/root.hint create mode 100644 bin/tests/system/resolver/prereq.sh create mode 100644 bin/tests/system/resolver/tests.sh create mode 100644 bin/tests/system/rrsetorder/clean.sh create mode 100644 bin/tests/system/rrsetorder/dig.out.fixed.good create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good1 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good10 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good11 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good12 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good13 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good14 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good15 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good16 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good17 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good18 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good19 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good2 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good20 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good21 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good22 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good23 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good24 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good3 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good4 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good5 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good6 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good7 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good8 create mode 100644 bin/tests/system/rrsetorder/dig.out.random.good9 create mode 100644 bin/tests/system/rrsetorder/ns1/named.conf create mode 100644 bin/tests/system/rrsetorder/ns1/root.db create mode 100644 bin/tests/system/rrsetorder/ns2/named.conf create mode 100644 bin/tests/system/rrsetorder/ns3/named.conf create mode 100644 bin/tests/system/rrsetorder/tests.sh create mode 100644 bin/tests/system/run.sh create mode 100644 bin/tests/system/runall.sh create mode 100644 bin/tests/system/send.pl create mode 100644 bin/tests/system/setup.sh create mode 100644 bin/tests/system/sortlist/clean.sh create mode 100644 bin/tests/system/sortlist/ns1/example.db create mode 100644 bin/tests/system/sortlist/ns1/named.conf create mode 100644 bin/tests/system/sortlist/ns1/root.db create mode 100644 bin/tests/system/sortlist/tests.sh create mode 100644 bin/tests/system/start.pl create mode 100644 bin/tests/system/start.sh create mode 100644 bin/tests/system/stop.pl create mode 100644 bin/tests/system/stop.sh create mode 100644 bin/tests/system/stress/clean.sh create mode 100644 bin/tests/system/stress/ns1/named.conf create mode 100644 bin/tests/system/stress/ns2/named.conf create mode 100644 bin/tests/system/stress/ns3/named.conf create mode 100644 bin/tests/system/stress/ns4/named.conf create mode 100644 bin/tests/system/stress/setup.pl create mode 100644 bin/tests/system/stress/setup.sh create mode 100644 bin/tests/system/stress/tests.sh create mode 100644 bin/tests/system/stress/update.pl create mode 100644 bin/tests/system/stub/clean.sh create mode 100644 bin/tests/system/stub/knowngood.dig.out.norec create mode 100644 bin/tests/system/stub/knowngood.dig.out.rec create mode 100644 bin/tests/system/stub/ns1/named.conf create mode 100644 bin/tests/system/stub/ns1/root.db create mode 100644 bin/tests/system/stub/ns2/child.example.db create mode 100644 bin/tests/system/stub/ns2/named.conf create mode 100644 bin/tests/system/stub/ns3/example.db create mode 100644 bin/tests/system/stub/ns3/named.conf create mode 100644 bin/tests/system/stub/tests.sh create mode 100644 bin/tests/system/testsock.pl create mode 100644 bin/tests/system/tkey/Makefile.in create mode 100644 bin/tests/system/tkey/clean.sh create mode 100644 bin/tests/system/tkey/keycreate.c create mode 100644 bin/tests/system/tkey/keydelete.c create mode 100644 bin/tests/system/tkey/ns1/named.conf.in create mode 100644 bin/tests/system/tkey/ns1/setup.sh create mode 100644 bin/tests/system/tkey/prereq.sh create mode 100644 bin/tests/system/tkey/setup.sh create mode 100644 bin/tests/system/tkey/tests.sh create mode 100644 bin/tests/system/tsig/clean.sh create mode 100644 bin/tests/system/tsig/ns1/example.db create mode 100644 bin/tests/system/tsig/ns1/named.conf create mode 100644 bin/tests/system/tsig/tests.sh create mode 100644 bin/tests/system/unknown/clean.sh create mode 100644 bin/tests/system/unknown/ns1/broken1.db create mode 100644 bin/tests/system/unknown/ns1/broken2.db create mode 100644 bin/tests/system/unknown/ns1/broken3.db create mode 100644 bin/tests/system/unknown/ns1/broken4.db create mode 100644 bin/tests/system/unknown/ns1/broken5.db create mode 100644 bin/tests/system/unknown/ns1/class10.hints create mode 100644 bin/tests/system/unknown/ns1/example-class10.db create mode 100644 bin/tests/system/unknown/ns1/example-in.db create mode 100644 bin/tests/system/unknown/ns1/named.conf create mode 100644 bin/tests/system/unknown/tests.sh create mode 100644 bin/tests/system/upforwd/clean.sh create mode 100644 bin/tests/system/upforwd/knowngood.after1 create mode 100644 bin/tests/system/upforwd/knowngood.after2 create mode 100644 bin/tests/system/upforwd/knowngood.before create mode 100644 bin/tests/system/upforwd/knowngood.ns2.before create mode 100644 bin/tests/system/upforwd/ns1/example1.db create mode 100644 bin/tests/system/upforwd/ns1/named.conf create mode 100644 bin/tests/system/upforwd/ns2/named.conf create mode 100644 bin/tests/system/upforwd/ns3/named.conf create mode 100644 bin/tests/system/upforwd/setup.sh create mode 100644 bin/tests/system/upforwd/tests.sh create mode 100644 bin/tests/system/v6synth/clean.sh create mode 100644 bin/tests/system/v6synth/ns1/named.conf create mode 100644 bin/tests/system/v6synth/ns1/root.db create mode 100644 bin/tests/system/v6synth/ns2/example.db create mode 100644 bin/tests/system/v6synth/ns2/ip6.arpa.db create mode 100644 bin/tests/system/v6synth/ns2/ip6.int.db create mode 100644 bin/tests/system/v6synth/ns2/named.conf create mode 100644 bin/tests/system/v6synth/ns3/named.conf create mode 100644 bin/tests/system/v6synth/tests.sh create mode 100644 bin/tests/system/views/clean.sh create mode 100644 bin/tests/system/views/ns1/named.conf create mode 100644 bin/tests/system/views/ns1/root.db create mode 100644 bin/tests/system/views/ns2/example1.db create mode 100644 bin/tests/system/views/ns2/example2.db create mode 100644 bin/tests/system/views/ns2/internal.db create mode 100644 bin/tests/system/views/ns2/named1.conf create mode 100644 bin/tests/system/views/ns2/named2.conf create mode 100644 bin/tests/system/views/ns3/internal.db create mode 100644 bin/tests/system/views/ns3/named1.conf create mode 100644 bin/tests/system/views/ns3/named2.conf create mode 100644 bin/tests/system/views/setup.sh create mode 100644 bin/tests/system/views/tests.sh create mode 100644 bin/tests/system/xfer/clean.sh create mode 100644 bin/tests/system/xfer/dig1.good create mode 100644 bin/tests/system/xfer/dig2.good create mode 100644 bin/tests/system/xfer/ns1/named.conf create mode 100644 bin/tests/system/xfer/ns1/root.db create mode 100644 bin/tests/system/xfer/ns2/named.conf create mode 100644 bin/tests/system/xfer/ns3/named.conf create mode 100644 bin/tests/system/xfer/setup.sh create mode 100644 bin/tests/system/xfer/tests.sh create mode 100644 bin/tests/system/xferquota/clean.sh create mode 100644 bin/tests/system/xferquota/ns1/changing1.db create mode 100644 bin/tests/system/xferquota/ns1/changing2.db create mode 100644 bin/tests/system/xferquota/ns1/named.conf create mode 100644 bin/tests/system/xferquota/ns1/root.db create mode 100644 bin/tests/system/xferquota/ns2/example.db create mode 100644 bin/tests/system/xferquota/ns2/named.conf create mode 100644 bin/tests/system/xferquota/setup.pl create mode 100644 bin/tests/system/xferquota/setup.sh create mode 100644 bin/tests/system/xferquota/tests.sh create mode 100644 bin/tests/system/zonechecks/a.db create mode 100644 bin/tests/system/zonechecks/aaaa.db create mode 100644 bin/tests/system/zonechecks/clean.sh create mode 100644 bin/tests/system/zonechecks/cname.db create mode 100644 bin/tests/system/zonechecks/dname.db create mode 100644 bin/tests/system/zonechecks/noaddress.db create mode 100644 bin/tests/system/zonechecks/nxdomain.db create mode 100644 bin/tests/system/zonechecks/tests.sh create mode 100644 bin/tests/t_api.pl create mode 100644 bin/tests/task_test.c create mode 100644 bin/tests/tasks/Makefile.in create mode 100644 bin/tests/tasks/t_tasks.c create mode 100644 bin/tests/timer_test.c create mode 100644 bin/tests/timers/Makefile.in create mode 100644 bin/tests/timers/t_timers.c create mode 100644 bin/tests/wire_test.c create mode 100644 bin/tests/wire_test.data create mode 100644 bin/tests/wire_test.data2 create mode 100644 bin/tests/wire_test.data3 create mode 100644 bin/tests/wire_test.data4 create mode 100644 bin/tests/zone_test.c (limited to 'bin/tests') diff --git a/bin/tests/Kchild.example.+003+04017.key b/bin/tests/Kchild.example.+003+04017.key new file mode 100644 index 0000000..9f5cbac --- /dev/null +++ b/bin/tests/Kchild.example.+003+04017.key @@ -0,0 +1 @@ +child.example. IN KEY 256 3 3 ALeiYGFXbil6PgHnkm5ZE67ygEVDvGT/gqZmLH7tGboofcPSfyhh1hpw dxZgJ26d/gynWMGVSYzaXfzsxpPoNeYn+qeevQoJOaxXXlfcy8Ik52Rm eW0J9mWlf9hsD7ShIhh1+0kRYGCOCaU25wIe3SLVkN3HgqiCBDYnBY0u nMkqRadiUnoEa3Tcvc9kJx9r9gDstR2A9A5sBhFLI/XQ0gViHHLVpQ4x hz+rTLb/xrBoAb5sQJT3xUjhhdNo9HuL6kwdLdSu//PCl1QnY9NpYPVV SKUo diff --git a/bin/tests/Kchild.example.+003+04017.private b/bin/tests/Kchild.example.+003+04017.private new file mode 100644 index 0000000..176ff98 --- /dev/null +++ b/bin/tests/Kchild.example.+003+04017.private @@ -0,0 +1,7 @@ +Private-key-format: v1.2 +Algorithm: 3 (DSA) +Prime(p): vGT/gqZmLH7tGboofcPSfyhh1hpwdxZgJ26d/gynWMGVSYzaXfzsxpPoNeYn+qeevQoJOaxXXlfcy8Ik52RmeQ== +Subprime(q): t6JgYVduKXo+AeeSblkTrvKARUM= +Base(g): bQn2ZaV/2GwPtKEiGHX7SRFgYI4JpTbnAh7dItWQ3ceCqIIENicFjS6cySpFp2JSegRrdNy9z2QnH2v2AOy1HQ== +Private_value(x): J1Ctez8+w1PTR56Hze3pGoe0Wag= +Public_value(y): gPQObAYRSyP10NIFYhxy1aUOMYc/q0y2/8awaAG+bECU98VI4YXTaPR7i+pMHS3Urv/zwpdUJ2PTaWD1VUilKA== diff --git a/bin/tests/Makefile.in b/bin/tests/Makefile.in new file mode 100644 index 0000000..93b63f1 --- /dev/null +++ b/bin/tests/Makefile.in @@ -0,0 +1,306 @@ +# Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 1998-2003 Internet Software Consortium. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# $Id: Makefile.in,v 1.131 2008/09/25 04:02:38 tbox Exp $ + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +@BIND9_MAKE_INCLUDES@ + +CINCLUDES = ${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \ + ${LWRES_INCLUDES} ${OMAPI_INCLUDES} + +CDEFINES = +CWARNINGS = + +DNSLIBS = ../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +ISCLIBS = ../../lib/isc/libisc.@A@ +ISCCFGLIBS = ../../lib/isccfg/libisccfg.@A@ +LWRESLIBS = ../../lib/lwres/liblwres.@A@ + +DNSDEPLIBS = ../../lib/dns/libdns.@A@ +ISCDEPLIBS = ../../lib/isc/libisc.@A@ +ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@ +LWRESDEPLIBS = ../../lib/lwres/liblwres.@A@ + +LIBS = @LIBS@ + +SUBDIRS = db dst master mem names net rbt sockaddr tasks timers system + +# A few of the test programs are built by default: +# cfg_test is needed for regenerating doc/misc/options; +# genrandom is needed by the system tests + +# Alphabetically +TARGETS = cfg_test@EXEEXT@ \ + genrandom@EXEEXT@ + +# All the other tests are optional and not built by default. + +# Alphabetically +XTARGETS = adb_test@EXEEXT@ \ + byaddr_test@EXEEXT@ \ + byname_test@EXEEXT@ \ + compress_test@EXEEXT@ \ + db_test@EXEEXT@ \ + entropy_test@EXEEXT@ \ + entropy2_test@EXEEXT@ \ + gxba_test@EXEEXT@ \ + gxbn_test@EXEEXT@ \ + hash_test@EXEEXT@ \ + nsec3hash@EXEEXT@ \ + fsaccess_test@EXEEXT@ \ + inter_test@EXEEXT@ \ + journalprint@EXEEXT@ \ + keyboard_test@EXEEXT@ \ + lex_test@EXEEXT@ \ + lfsr_test@EXEEXT@ \ + log_test@EXEEXT@ \ + lwres_test@EXEEXT@ \ + lwresconf_test@EXEEXT@ \ + master_test@EXEEXT@ \ + mempool_test@EXEEXT@ \ + name_test@EXEEXT@ \ + nsecify@EXEEXT@ \ + ratelimiter_test@EXEEXT@ \ + rbt_test@EXEEXT@ \ + rdata_test@EXEEXT@ \ + rwlock_test@EXEEXT@ \ + serial_test@EXEEXT@ \ + shutdown_test@EXEEXT@ \ + sig0_test@EXEEXT@ \ + sock_test@EXEEXT@ \ + sym_test@EXEEXT@ \ + task_test@EXEEXT@ \ + timer_test@EXEEXT@ \ + wire_test@EXEEXT@ \ + zone_test@EXEEXT@ + +# Alphabetically +SRCS = cfg_test.c genrandom.c ${XSRCS} + +XSRCS = adb_test.c \ + byaddr_test.c \ + byname_test.c \ + compress_test.c \ + db_test.c \ + entropy_test.c \ + entropy2_test.c \ + gxba_test.c \ + gxbn_test.c \ + hash_test.c \ + fsaccess_test.c \ + inter_test.c \ + journalprint.c \ + keyboard_test.c \ + lex_test.c \ + lfsr_test.c \ + log_test.c \ + lwres_test.c \ + lwresconf_test.c \ + master_test.c \ + mempool_test.c \ + name_test.c \ + nsecify.c \ + printmsg.c \ + ratelimiter_test.c \ + rbt_test.c \ + rdata_test.c \ + rwlock_test.c \ + serial_test.c \ + shutdown_test.c \ + sig0_test.c \ + sock_test.c \ + sym_test.c \ + task_test.c \ + timer_test.c \ + wire_test.c \ + zone_test.c + +@BIND9_MAKE_RULES@ + +all_tests: ${XTARGETS} + +genrandom@EXEEXT@: genrandom.@O@ + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ genrandom.@O@ @GENRANDOMLIB@ ${LIBS} + +adb_test@EXEEXT@: adb_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ adb_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +nsecify@EXEEXT@: nsecify.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsecify.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +byaddr_test@EXEEXT@: byaddr_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byaddr_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +byname_test@EXEEXT@: byname_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byname_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lex_test.@O@ \ + ${ISCLIBS} ${LIBS} + +lfsr_test@EXEEXT@: lfsr_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lfsr_test.@O@ \ + ${ISCLIBS} ${LIBS} + +log_test@EXEEXT@: log_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ log_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +name_test@EXEEXT@: name_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ name_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +hash_test@EXEEXT@: hash_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ hash_test.@O@ \ + ${ISCLIBS} ${LIBS} + +entropy_test@EXEEXT@: entropy_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy_test.@O@ \ + ${ISCLIBS} ${LIBS} + +entropy2_test@EXEEXT@: entropy2_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy2_test.@O@ \ + ${ISCLIBS} ${LIBS} + +sock_test@EXEEXT@: sock_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sock_test.@O@ \ + ${ISCLIBS} ${LIBS} + +sym_test@EXEEXT@: sym_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sym_test.@O@ \ + ${ISCLIBS} ${LIBS} + +task_test@EXEEXT@: task_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ task_test.@O@ \ + ${ISCLIBS} ${LIBS} + +shutdown_test@EXEEXT@: shutdown_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ shutdown_test.@O@ \ + ${ISCLIBS} ${LIBS} + +timer_test@EXEEXT@: timer_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ timer_test.@O@ \ + ${ISCLIBS} ${LIBS} + +ratelimiter_test@EXEEXT@: ratelimiter_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ratelimiter_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +rbt_test@EXEEXT@: rbt_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rbt_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +rdata_test@EXEEXT@: rdata_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rdata_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +rwlock_test@EXEEXT@: rwlock_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rwlock_test.@O@ \ + ${ISCLIBS} ${LIBS} + +wire_test@EXEEXT@: wire_test.@O@ printmsg.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ wire_test.@O@ printmsg.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +master_test@EXEEXT@: master_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ master_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +db_test@EXEEXT@: db_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ db_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +compress_test@EXEEXT@: compress_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ compress_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +mempool_test@EXEEXT@: mempool_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ mempool_test.@O@ \ + ${ISCLIBS} ${LIBS} + +serial_test@EXEEXT@: serial_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ serial_test.@O@ \ + ${ISCLIBS} ${LIBS} + +zone_test@EXEEXT@: zone_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zone_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +fsaccess_test@EXEEXT@: fsaccess_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ fsaccess_test.@O@ \ + ${ISCLIBS} ${LIBS} + +inter_test@EXEEXT@: inter_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ inter_test.@O@ \ + ${ISCLIBS} ${LIBS} + +keyboard_test@EXEEXT@: keyboard_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ keyboard_test.@O@ \ + ${ISCLIBS} ${LIBS} + +lwresconf_test@EXEEXT@: lwresconf_test.@O@ ${ISCDEPLIBS} ${LWRESDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lwresconf_test.@O@ \ + ${LWRESLIBS} ${ISCLIBS} ${LIBS} + +lwres_test@EXEEXT@: lwres_test.@O@ ${ISCDEPLIBS} ${LWRESDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lwres_test.@O@ \ + ${LWRESLIBS} ${ISCLIBS} ${LIBS} + +gxbn_test@EXEEXT@: gxbn_test.@O@ ${LWRESDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ gxbn_test.@O@ \ + ${LWRESLIBS} ${ISCLIBS} ${LIBS} + +gxba_test@EXEEXT@: gxba_test.@O@ ${LWRESDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ gxba_test.@O@ \ + ${LWRESLIBS} ${ISCLIBS} ${LIBS} + +sig0_test@EXEEXT@: sig0_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sig0_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +journalprint@EXEEXT@: journalprint.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ journalprint.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +cfg_test@EXEEXT@: cfg_test.@O@ ${ISCCFGDEPLIBS} ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ cfg_test.@O@ \ + ${ISCCFGLIBS} ${DNSLIBS} ${ISCLIBS} ${LIBS} + +nsec3hash@EXEEXT@: nsec3hash.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsec3hash.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +distclean:: + rm -f headerdep_test.sh + +clean distclean:: + rm -f ${TARGETS} ${XTARGETS} + rm -f t_journal + +check: test + +test: + @for dir in $(SUBDIRS) ;\ + do \ + ( cd $$dir; $(MAKE) test ) ;\ + done diff --git a/bin/tests/adb_test.c b/bin/tests/adb_test.c new file mode 100644 index 0000000..2ef812d --- /dev/null +++ b/bin/tests/adb_test.c @@ -0,0 +1,436 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: adb_test.c,v 1.68 2007/06/19 23:46:59 tbox Exp $ */ + +/*! \file */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +typedef struct client client_t; +struct client { + dns_name_t name; + const char *target; + ISC_LINK(client_t) link; + dns_adbfind_t *find; +}; + +static isc_mem_t *mctx = NULL; +static isc_entropy_t *ectx = NULL; +static isc_mempool_t *cmp; +static isc_log_t *lctx; +static isc_logconfig_t *lcfg; +static isc_taskmgr_t *taskmgr; +static isc_socketmgr_t *socketmgr; +static isc_timermgr_t *timermgr; +static dns_dispatchmgr_t *dispatchmgr; +static isc_task_t *t1, *t2; +static dns_view_t *view; +static dns_db_t *rootdb; +static ISC_LIST(client_t) clients; +static isc_mutex_t client_lock; +static isc_stdtime_t now; +static dns_adb_t *adb; + +static void +check_result(isc_result_t result, const char *format, ...) + ISC_FORMAT_PRINTF(2, 3); + +static void +check_result(isc_result_t result, const char *format, ...) { + va_list args; + + if (result == ISC_R_SUCCESS) + return; + + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + fprintf(stderr, ": %s\n", isc_result_totext(result)); + exit(1); +} + +static client_t * +new_client(void) { + client_t *client; + + client = isc_mempool_get(cmp); + INSIST(client != NULL); + dns_name_init(&client->name, NULL); + ISC_LINK_INIT(client, link); + client->find = NULL; + + return (client); +} + +static void +free_client(client_t **c) { + client_t *client; + + INSIST(c != NULL); + client = *c; + *c = NULL; + INSIST(client != NULL); + dns_name_free(&client->name, mctx); + INSIST(!ISC_LINK_LINKED(client, link)); + INSIST(client->find == NULL); + + isc_mempool_put(cmp, client); +} + +static inline void +CLOCK(void) { + RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS); +} + +static inline void +CUNLOCK(void) { + RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS); +} + +static void +lookup_callback(isc_task_t *task, isc_event_t *ev) { + client_t *client; + + client = ev->ev_arg; + INSIST(client->find == ev->ev_sender); + + printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client %p\n\terr4: %s err6: %s\n", + client->target, + task, ev, ev->ev_type, client->find, client, + isc_result_totext(client->find->result_v4), + isc_result_totext(client->find->result_v6)); + + isc_event_free(&ev); + ev = NULL; + + CLOCK(); + + dns_adb_dumpfind(client->find, stderr); + dns_adb_destroyfind(&client->find); + + ISC_LIST_UNLINK(clients, client, link); + free_client(&client); + + CUNLOCK(); +} + +static void +create_managers(void) { + isc_result_t result; + + taskmgr = NULL; + result = isc_taskmgr_create(mctx, 5, 0, &taskmgr); + check_result(result, "isc_taskmgr_create"); + + timermgr = NULL; + result = isc_timermgr_create(mctx, &timermgr); + check_result(result, "isc_timermgr_create"); + + socketmgr = NULL; + result = isc_socketmgr_create(mctx, &socketmgr); + check_result(result, "isc_socketmgr_create"); + + dispatchmgr = NULL; + result = dns_dispatchmgr_create(mctx, NULL, &dispatchmgr); + check_result(result, "dns_dispatchmgr_create"); +} + +static void +create_view(void) { + dns_cache_t *cache; + isc_result_t result; + + /* + * View. + */ + view = NULL; + result = dns_view_create(mctx, dns_rdataclass_in, "_default", &view); + check_result(result, "dns_view_create"); + + /* + * Cache. + */ + cache = NULL; + result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in, + "rbt", 0, NULL, &cache); + check_result(result, "dns_cache_create"); + dns_view_setcache(view, cache); + dns_cache_detach(&cache); + + { + unsigned int attrs; + isc_sockaddr_t any4, any6; + dns_dispatch_t *disp4 = NULL; + dns_dispatch_t *disp6 = NULL; + + isc_sockaddr_any(&any4); + isc_sockaddr_any6(&any6); + + attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, + taskmgr, &any4, 512, 6, 1024, + 17, 19, attrs, attrs, &disp4) + == ISC_R_SUCCESS); + INSIST(disp4 != NULL); + + attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, + taskmgr, &any6, 512, 6, 1024, + 17, 19, attrs, attrs, &disp6) + == ISC_R_SUCCESS); + INSIST(disp6 != NULL); + + RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, + socketmgr, + timermgr, 0, + dispatchmgr, + disp4, disp6) == + ISC_R_SUCCESS); + } + + rootdb = NULL; + result = dns_rootns_create(mctx, dns_rdataclass_in, NULL, &rootdb); + check_result(result, "dns_rootns_create()"); + dns_view_sethints(view, rootdb); + dns_db_detach(&rootdb); + + dns_view_freeze(view); +} + +static void +lookup(const char *target) { + dns_name_t name; + unsigned char namedata[256]; + client_t *client; + isc_buffer_t t, namebuf; + isc_result_t result; + unsigned int options; + + INSIST(target != NULL); + + client = new_client(); + isc_buffer_init(&t, target, strlen(target)); + isc_buffer_add(&t, strlen(target)); + isc_buffer_init(&namebuf, namedata, sizeof(namedata)); + dns_name_init(&name, NULL); + result = dns_name_fromtext(&name, &t, dns_rootname, ISC_FALSE, + &namebuf); + check_result(result, "dns_name_fromtext %s", target); + + result = dns_name_dup(&name, mctx, &client->name); + check_result(result, "dns_name_dup %s", target); + + options = 0; + options |= DNS_ADBFIND_INET; + options |= DNS_ADBFIND_INET6; + options |= DNS_ADBFIND_WANTEVENT; + options |= DNS_ADBFIND_HINTOK; + options |= DNS_ADBFIND_GLUEOK; + result = dns_adb_createfind(adb, t2, lookup_callback, client, + &client->name, dns_rootname, 0, options, + now, NULL, view->dstport, &client->find); +#if 0 + check_result(result, "dns_adb_createfind()"); +#endif + dns_adb_dumpfind(client->find, stderr); + + if ((client->find->options & DNS_ADBFIND_WANTEVENT) != 0) { + client->target = target; + ISC_LIST_APPEND(clients, client, link); + } else { + printf("NAME %s: err4 %s, err6 %s\n", + target, isc_result_totext(client->find->result_v4), + isc_result_totext(client->find->result_v6)); + + dns_adb_destroyfind(&client->find); + free_client(&client); + } +} + +int +main(int argc, char **argv) { + isc_result_t result; + isc_logdestination_t destination; + + UNUSED(argc); + UNUSED(argv); + + dns_result_register(); + result = isc_app_start(); + check_result(result, "isc_app_start()"); + + isc_stdtime_get(&now); + + result = isc_mutex_init(&client_lock); + check_result(result, "isc_mutex_init(&client_lock)"); + ISC_LIST_INIT(clients); + + /* + * EVERYTHING needs a memory context. + */ + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + + cmp = NULL; + RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp) + == ISC_R_SUCCESS); + isc_mempool_setname(cmp, "adb test clients"); + + result = isc_entropy_create(mctx, &ectx); + check_result(result, "isc_entropy_create()"); + result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + check_result(result, "isc_hash_create()"); + + result = isc_log_create(mctx, &lctx, &lcfg); + check_result(result, "isc_log_create()"); + isc_log_setcontext(lctx); + dns_log_init(lctx); + dns_log_setcontext(lctx); + + /* + * Create and install the default channel. + */ + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + result = isc_log_createchannel(lcfg, "_default", + ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, + &destination, ISC_LOG_PRINTTIME); + check_result(result, "isc_log_createchannel()"); + result = isc_log_usechannel(lcfg, "_default", NULL, NULL); + check_result(result, "isc_log_usechannel()"); + + /* + * Set the initial debug level. + */ + isc_log_setdebuglevel(lctx, 2); + + create_managers(); + + t1 = NULL; + result = isc_task_create(taskmgr, 0, &t1); + check_result(result, "isc_task_create t1"); + t2 = NULL; + result = isc_task_create(taskmgr, 0, &t2); + check_result(result, "isc_task_create t2"); + + printf("task 1 = %p\n", t1); + printf("task 2 = %p\n", t2); + + create_view(); + + adb = view->adb; + + /* + * Lock the entire client list here. This will cause all events + * for found names to block as well. + */ + CLOCK(); + lookup("f.root-servers.net."); /* Should be in hints */ + lookup("www.iengines.com"); /* should fetch */ + lookup("www.isc.org"); /* should fetch */ + lookup("www.flame.org"); /* should fetch */ + lookup("kechara.flame.org."); /* should fetch */ + lookup("moghedien.flame.org."); /* should fetch */ + lookup("mailrelay.flame.org."); /* should fetch */ + lookup("ipv4v6.flame.org."); /* should fetch */ + lookup("nonexistant.flame.org."); /* should fail to be found */ + lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */ + lookup("i.root-servers.net."); /* Should be in hints */ + lookup("www.firstcard.com."); + lookup("dns04.flame.org."); + CUNLOCK(); + + sleep(10); + + dns_adb_dump(adb, stderr); + + sleep(10); + + CLOCK(); + lookup("f.root-servers.net."); /* Should be in hints */ + lookup("www.iengines.com"); /* should fetch */ + lookup("www.isc.org"); /* should fetch */ + lookup("www.flame.org"); /* should fetch */ + lookup("kechara.flame.org."); /* should fetch */ + lookup("moghedien.flame.org."); /* should fetch */ + lookup("mailrelay.flame.org."); /* should fetch */ + lookup("ipv4v6.flame.org."); /* should fetch */ + lookup("nonexistant.flame.org."); /* should fail to be found */ + lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */ + lookup("i.root-servers.net."); /* Should be in hints */ + CUNLOCK(); + + sleep(20); + + dns_adb_dump(adb, stderr); + + isc_task_detach(&t1); + isc_task_detach(&t2); + + isc_mem_stats(mctx, stdout); + dns_adb_dump(adb, stderr); + + isc_app_run(); + + dns_adb_dump(adb, stderr); + + dns_view_detach(&view); + adb = NULL; + + isc_socketmgr_destroy(&socketmgr); + isc_timermgr_destroy(&timermgr); + + fprintf(stderr, "Destroying task manager\n"); + isc_taskmgr_destroy(&taskmgr); + + isc_log_destroy(&lctx); + + isc_hash_destroy(); + isc_entropy_detach(&ectx); + + isc_mempool_destroy(&cmp); + isc_mem_stats(mctx, stdout); + isc_mem_destroy(&mctx); + + isc_app_finish(); + + return (0); +} diff --git a/bin/tests/b8t.mk b/bin/tests/b8t.mk new file mode 100644 index 0000000..55923dc --- /dev/null +++ b/bin/tests/b8t.mk @@ -0,0 +1,63 @@ +# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 1999-2001 Internet Software Consortium. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# $Id: b8t.mk,v 1.11 2007/06/19 23:46:59 tbox Exp $ + +# +# bind 8 multi-host make +# PLATFORM set in the environment by cron +# + +MODULE = bind +BASE = /build +BDIR = $(BASE)/$(MODULE) +RDIR = /proj/build-reports/bind8/hosts/$(PLATFORM) +SDIR = $(HOME)/b8t/src +CVSROOT = /proj/cvs/isc + +all: clobber populate config build + +clobber: + @echo "CLOBBBER `date`" + @if test ! -d $(BASE) ; then mkdir -p $(BASE) ; fi + @rm -fr $(BDIR) + @echo "DONE `date`" + +populate: + @echo "POPULATE `date`" + @( cd $(BASE) && tar -xvf $(SDIR)/$(MODULE).tar ) > $(RDIR)/.populate 2>&1 + @echo "DONE `date`" + +tarsrc: + @echo "TARSRC `date`" + @rm -fr $(SDIR)/$(MODULE) + @( cd $(SDIR) && cvs -d $(CVSROOT) checkout $(MODULE) ) + @( cd $(SDIR) && tar -cvf $(MODULE).tar $(MODULE) ) + @echo "DONE `date`" + +config: + @echo "CONFIG `date`" + @( cd $(BDIR)/src && make SRC=$(BDIR)/src DST=$(BDIR)/dst links ) > $(RDIR)/.config 2>&1 + @echo "DONE `date`" + +build: + @echo "BUILD `date`" + @( cd $(BDIR)/dst && make -k clean depend all ) > $(RDIR)/.build 2>&1 + @echo "DONE `date`" + +test: + @echo "TEST `date`" + @touch $(RDIR)/.test + @echo "DONE `date`" diff --git a/bin/tests/b9t.mk b/bin/tests/b9t.mk new file mode 100644 index 0000000..96f04fb --- /dev/null +++ b/bin/tests/b9t.mk @@ -0,0 +1,68 @@ +# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 1999-2001 Internet Software Consortium. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# $Id: b9t.mk,v 1.13 2007/06/19 23:46:59 tbox Exp $ + +# +# makefile to configure, build and test bind9 +# this is run by cron (user wpk) on aa, sol, irix, hp and aix +# $PLATFORM is set in the environment by cron +# + +BASE = /build +BDIR = $(BASE) +MODULE = bind9 +SDIR = $(HOME)/b9t/src + +# as it says +CVSROOT = /proj/cvs/isc + +# where the config, build and test output goes +RDIR = /proj/build-reports/$(MODULE)/hosts/$(PLATFORM) + +all: clobber populate config build test + +clobber: + @echo "CLOBBBER `date`" + @if test ! -d $(BDIR) ; then mkdir -p $(BDIR) > /dev/null 2>&1 ; fi + @( cd $(BDIR) && rm -fr $(MODULE) ) + @echo "DONE `date`" + +populate: + @echo "POPULATE `date`" + @( cd $(BDIR) && tar -xvf $(SDIR)/$(MODULE).tar ) > $(RDIR)/.populate 2>&1 + @echo "DONE `date`" + +config: + @echo "CONFIG `date`" + @( cd $(BDIR)/$(MODULE) && ./configure ) > $(RDIR)/.config 2>&1 + @echo "DONE `date`" + +build: + @echo "BUILD `date`" + @( cd $(BDIR)/$(MODULE) && $(MAKE) -k all ) > $(RDIR)/.build 2>&1 + @echo "DONE `date`" + +test: + @echo "TEST `date`" + -@( cd $(BDIR)/$(MODULE)/bin/tests && $(MAKE) test ) > $(RDIR)/.test 2>&1 + @echo "DONE `date`" + +tarsrc: + @echo "TARSRC `date`" + @rm -fr $(SDIR)/$(MODULE) + @( cd $(SDIR) && cvs -d $(CVSROOT) checkout $(MODULE) && tar -cvf $(MODULE).tar $(MODULE) ) + @echo "DONE `date`" + diff --git a/bin/tests/byaddr_test.c b/bin/tests/byaddr_test.c new file mode 100644 index 0000000..773b528 --- /dev/null +++ b/bin/tests/byaddr_test.c @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2000-2002 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: byaddr_test.c,v 1.28 2007/06/19 23:46:59 tbox Exp $ */ + +/*! \file + * \author + * Principal Author: Bob Halley + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +static void +done(isc_task_t *task, isc_event_t *event) { + dns_byaddrevent_t *bevent; + dns_byaddr_t *byaddr; + dns_name_t *name; + + REQUIRE(event->ev_type == DNS_EVENT_BYADDRDONE); + bevent = (dns_byaddrevent_t *)event; + + UNUSED(task); + + printf("byaddr event result = %s\n", + isc_result_totext(bevent->result)); + + if (bevent->result == ISC_R_SUCCESS) { + for (name = ISC_LIST_HEAD(bevent->names); + name != NULL; + name = ISC_LIST_NEXT(name, link)) { + char text[DNS_NAME_FORMATSIZE]; + dns_name_format(name, text, sizeof(text)); + printf("%s\n", text); + } + } + + byaddr = event->ev_sender; + dns_byaddr_destroy(&byaddr); + isc_event_free(&event); + + isc_app_shutdown(); +} + +int +main(int argc, char *argv[]) { + isc_mem_t *mctx; + isc_boolean_t verbose = ISC_FALSE; + unsigned int workers = 2; + isc_taskmgr_t *taskmgr; + isc_task_t *task; + isc_timermgr_t *timermgr; + dns_view_t *view; + int ch; + isc_socketmgr_t *socketmgr; + dns_dispatchmgr_t *dispatchmgr; + isc_netaddr_t na; + dns_byaddr_t *byaddr; + isc_result_t result; + unsigned int options = 0; + dns_cache_t *cache; + + RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS); + + dns_result_register(); + + mctx = NULL; + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + + while ((ch = isc_commandline_parse(argc, argv, "nvw:")) != -1) { + switch (ch) { + case 'n': + /* + * We only try nibbles, so do nothing for this option. + */ + break; + case 'v': + verbose = ISC_TRUE; + break; + case 'w': + workers = (unsigned int)atoi(isc_commandline_argument); + break; + } + } + + if (verbose) { + printf("%u workers\n", workers); + printf("IPv4: %s\n", isc_result_totext(isc_net_probeipv4())); + printf("IPv6: %s\n", isc_result_totext(isc_net_probeipv6())); + } + + taskmgr = NULL; + RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr) + == ISC_R_SUCCESS); + task = NULL; + RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) + == ISC_R_SUCCESS); + isc_task_setname(task, "byaddr", NULL); + + dispatchmgr = NULL; + RUNTIME_CHECK(dns_dispatchmgr_create(mctx, NULL, &dispatchmgr) + == ISC_R_SUCCESS); + + timermgr = NULL; + RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS); + socketmgr = NULL; + RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); + + cache = NULL; + RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, + dns_rdataclass_in, "rbt", 0, NULL, + &cache) == ISC_R_SUCCESS); + + view = NULL; + RUNTIME_CHECK(dns_view_create(mctx, dns_rdataclass_in, "default", + &view) == ISC_R_SUCCESS); + + { + unsigned int attrs; + dns_dispatch_t *disp4 = NULL; + dns_dispatch_t *disp6 = NULL; + + if (isc_net_probeipv4() == ISC_R_SUCCESS) { + isc_sockaddr_t any4; + + isc_sockaddr_any(&any4); + + attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, + socketmgr, + taskmgr, &any4, + 512, 6, 1024, + 17, 19, attrs, + attrs, &disp4) + == ISC_R_SUCCESS); + INSIST(disp4 != NULL); + } + + if (isc_net_probeipv6() == ISC_R_SUCCESS) { + isc_sockaddr_t any6; + + isc_sockaddr_any6(&any6); + + attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, + socketmgr, + taskmgr, &any6, + 512, 6, 1024, + 17, 19, attrs, + attrs, &disp6) + == ISC_R_SUCCESS); + INSIST(disp6 != NULL); + } + + RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, + socketmgr, + timermgr, 0, + dispatchmgr, + disp4, disp6) == + ISC_R_SUCCESS); + + if (disp4 != NULL) + dns_dispatch_detach(&disp4); + if (disp6 != NULL) + dns_dispatch_detach(&disp6); + } + + { + struct in_addr ina; + isc_sockaddr_t sa; + isc_sockaddrlist_t sal; + + ISC_LIST_INIT(sal); + ina.s_addr = inet_addr("127.0.0.1"); + isc_sockaddr_fromin(&sa, &ina, 53); + ISC_LIST_APPEND(sal, &sa, link); + + RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname, + &sal, dns_fwdpolicy_only) + == ISC_R_SUCCESS); + } + + dns_view_setcache(view, cache); + dns_view_freeze(view); + + dns_cache_detach(&cache); + + printf("address = %s\n", argv[isc_commandline_index]); + na.family = AF_INET; + if (inet_pton(AF_INET, argv[isc_commandline_index], + (char *)&na.type.in) != 1) { + na.family = AF_INET6; + if (inet_pton(AF_INET6, argv[isc_commandline_index], + (char *)&na.type.in6) != 1) { + printf("unknown address format\n"); + exit(1); + } + } + + result = dns_byaddr_create(mctx, &na, view, options, task, + done, NULL, &byaddr); + if (result != ISC_R_SUCCESS) { + printf("dns_byaddr_create() returned %s\n", + isc_result_totext(result)); + RUNTIME_CHECK(0); + } + + (void)isc_app_run(); + + /* + * XXXRTH if we get a control-C before we get to isc_app_run(), + * we're in trouble (because we might try to destroy things before + * they've been created. + */ + + dns_view_detach(&view); + + isc_task_shutdown(task); + isc_task_detach(&task); + + dns_dispatchmgr_destroy(&dispatchmgr); + + isc_taskmgr_destroy(&taskmgr); + + isc_socketmgr_destroy(&socketmgr); + isc_timermgr_destroy(&timermgr); + + if (verbose) + isc_mem_stats(mctx, stdout); + isc_mem_destroy(&mctx); + + isc_app_finish(); + + return (0); +} diff --git a/bin/tests/byname_test.c b/bin/tests/byname_test.c new file mode 100644 index 0000000..fdf45a9 --- /dev/null +++ b/bin/tests/byname_test.c @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: byname_test.c,v 1.31 2007/06/19 23:46:59 tbox Exp $ */ + +/*! \file + * \author + * Principal Author: Bob Halley + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +static isc_mem_t *mctx = NULL; +static isc_entropy_t *ectx = NULL; +static isc_taskmgr_t *taskmgr; +static dns_view_t *view = NULL; +static dns_adbfind_t *find = NULL; +static isc_task_t *task = NULL; +static dns_fixedname_t name; +static dns_fixedname_t target; +static isc_log_t *lctx; +static isc_logconfig_t *lcfg; +static unsigned int level = 0; + +static void adb_callback(isc_task_t *task, isc_event_t *event); + +static void +log_init(void) { + isc_logdestination_t destination; + unsigned int flags; + + /* + * Setup a logging context. + */ + RUNTIME_CHECK(isc_log_create(mctx, &lctx, &lcfg) == ISC_R_SUCCESS); + isc_log_setcontext(lctx); + dns_log_init(lctx); + dns_log_setcontext(lctx); + + /* + * Create and install the default channel. + */ + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + flags = ISC_LOG_PRINTTIME; + RUNTIME_CHECK(isc_log_createchannel(lcfg, "_default", + ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, + &destination, flags) == + ISC_R_SUCCESS); + RUNTIME_CHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL) == + ISC_R_SUCCESS); + isc_log_setdebuglevel(lctx, level); +} + +static void +print_addresses(dns_adbfind_t *find) { + dns_adbaddrinfo_t *address; + + for (address = ISC_LIST_HEAD(find->list); + address != NULL; + address = ISC_LIST_NEXT(address, publink)) { + isc_netaddr_t netaddr; + char text[ISC_NETADDR_FORMATSIZE]; + isc_netaddr_fromsockaddr(&netaddr, &address->sockaddr); + isc_netaddr_format(&netaddr, text, sizeof(text)); + printf("%s\n", text); + } +} + +static void +print_name(dns_name_t *name) { + char text[DNS_NAME_FORMATSIZE]; + + dns_name_format(name, text, sizeof(text)); + printf("%s\n", text); +} + +static void +do_find(isc_boolean_t want_event) { + isc_result_t result; + isc_boolean_t done = ISC_FALSE; + unsigned int options; + + options = DNS_ADBFIND_INET | DNS_ADBFIND_INET6; + if (want_event) + options |= DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_EMPTYEVENT; + dns_fixedname_init(&target); + result = dns_adb_createfind(view->adb, task, adb_callback, NULL, + dns_fixedname_name(&name), + dns_rootname, 0, options, 0, + dns_fixedname_name(&target), 0, + &find); + if (result == ISC_R_SUCCESS) { + if (!ISC_LIST_EMPTY(find->list)) { + /* + * We have at least some of the addresses for the + * name. + */ + INSIST((find->options & DNS_ADBFIND_WANTEVENT) == 0); + print_addresses(find); + done = ISC_TRUE; + } else { + /* + * We don't know any of the addresses for this + * name. + */ + if ((find->options & DNS_ADBFIND_WANTEVENT) == 0) { + /* + * And ADB isn't going to send us any events + * either. This query loses. + */ + done = ISC_TRUE; + } + /* + * If the DNS_ADBFIND_WANTEVENT flag was set, we'll + * get an event when something happens. + */ + } + } else if (result == DNS_R_ALIAS) { + print_name(dns_fixedname_name(&target)); + done = ISC_TRUE; + } else { + printf("dns_adb_createfind() returned %s\n", + isc_result_totext(result)); + done = ISC_TRUE; + } + + if (done) { + if (find != NULL) + dns_adb_destroyfind(&find); + isc_app_shutdown(); + } +} + +static void +adb_callback(isc_task_t *etask, isc_event_t *event) { + unsigned int type = event->ev_type; + + REQUIRE(etask == task); + + isc_event_free(&event); + dns_adb_destroyfind(&find); + + if (type == DNS_EVENT_ADBMOREADDRESSES) + do_find(ISC_FALSE); + else if (type == DNS_EVENT_ADBNOMOREADDRESSES) { + printf("no more addresses\n"); + isc_app_shutdown(); + } else { + printf("unexpected ADB event type %u\n", type); + isc_app_shutdown(); + } +} + +static void +run(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + do_find(ISC_TRUE); + isc_event_free(&event); +} + +int +main(int argc, char *argv[]) { + isc_boolean_t verbose = ISC_FALSE; + unsigned int workers = 2; + isc_timermgr_t *timermgr; + int ch; + isc_socketmgr_t *socketmgr; + dns_dispatchmgr_t *dispatchmgr; + dns_cache_t *cache; + isc_buffer_t b; + + RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS); + + dns_result_register(); + + mctx = NULL; + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + + RUNTIME_CHECK(isc_entropy_create(mctx, &ectx) == ISC_R_SUCCESS); + RUNTIME_CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE) + == ISC_R_SUCCESS); + + while ((ch = isc_commandline_parse(argc, argv, "d:vw:")) != -1) { + switch (ch) { + case 'd': + level = (unsigned int)atoi(isc_commandline_argument); + break; + case 'v': + verbose = ISC_TRUE; + break; + case 'w': + workers = (unsigned int)atoi(isc_commandline_argument); + break; + } + } + + log_init(); + + if (verbose) { + printf("%u workers\n", workers); + printf("IPv4: %s\n", isc_result_totext(isc_net_probeipv4())); + printf("IPv6: %s\n", isc_result_totext(isc_net_probeipv6())); + } + + taskmgr = NULL; + RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr) == + ISC_R_SUCCESS); + task = NULL; + RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == + ISC_R_SUCCESS); + isc_task_setname(task, "byname", NULL); + + dispatchmgr = NULL; + RUNTIME_CHECK(dns_dispatchmgr_create(mctx, NULL, &dispatchmgr) + == ISC_R_SUCCESS); + + timermgr = NULL; + RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS); + socketmgr = NULL; + RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); + + cache = NULL; + RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, + dns_rdataclass_in, "rbt", 0, NULL, + &cache) == ISC_R_SUCCESS); + + view = NULL; + RUNTIME_CHECK(dns_view_create(mctx, dns_rdataclass_in, "default", + &view) == ISC_R_SUCCESS); + + { + unsigned int attrs; + dns_dispatch_t *disp4 = NULL; + dns_dispatch_t *disp6 = NULL; + + if (isc_net_probeipv4() == ISC_R_SUCCESS) { + isc_sockaddr_t any4; + isc_sockaddr_any(&any4); + + attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, + socketmgr, + taskmgr, &any4, + 512, 6, 1024, + 17, 19, attrs, + attrs, &disp4) + == ISC_R_SUCCESS); + INSIST(disp4 != NULL); + } + + if (isc_net_probeipv6() == ISC_R_SUCCESS) { + isc_sockaddr_t any6; + + isc_sockaddr_any6(&any6); + + attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP; + RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, + socketmgr, + taskmgr, &any6, + 512, 6, 1024, + 17, 19, attrs, + attrs, &disp6) + == ISC_R_SUCCESS); + INSIST(disp6 != NULL); + } + + RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, + socketmgr, + timermgr, 0, + dispatchmgr, + disp4, disp6) == + ISC_R_SUCCESS); + + if (disp4 != NULL) + dns_dispatch_detach(&disp4); + if (disp6 != NULL) + dns_dispatch_detach(&disp6); + } + + { + struct in_addr ina; + isc_sockaddr_t sa; + isc_sockaddrlist_t sal; + + ISC_LIST_INIT(sal); + ina.s_addr = inet_addr("127.0.0.1"); + isc_sockaddr_fromin(&sa, &ina, 53); + ISC_LIST_APPEND(sal, &sa, link); + + RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname, + &sal, dns_fwdpolicy_only) + == ISC_R_SUCCESS); + } + + dns_view_setcache(view, cache); + dns_view_freeze(view); + + dns_cache_detach(&cache); + + printf("name = %s\n", argv[isc_commandline_index]); + isc_buffer_init(&b, argv[isc_commandline_index], + strlen(argv[isc_commandline_index])); + isc_buffer_add(&b, strlen(argv[isc_commandline_index])); + dns_fixedname_init(&name); + dns_fixedname_init(&target); + RUNTIME_CHECK(dns_name_fromtext(dns_fixedname_name(&name), &b, + dns_rootname, ISC_FALSE, NULL) == + ISC_R_SUCCESS); + + RUNTIME_CHECK(isc_app_onrun(mctx, task, run, NULL) == ISC_R_SUCCESS); + + (void)isc_app_run(); + + dns_view_detach(&view); + isc_task_shutdown(task); + isc_task_detach(&task); + + dns_dispatchmgr_destroy(&dispatchmgr); + + isc_taskmgr_destroy(&taskmgr); + + isc_socketmgr_destroy(&socketmgr); + isc_timermgr_destroy(&timermgr); + + isc_log_destroy(&lctx); + + isc_hash_destroy(); + isc_entropy_detach(&ectx); + + if (verbose) + isc_mem_stats(mctx, stdout); + isc_mem_destroy(&mctx); + + isc_app_finish(); + + return (0); +} diff --git a/bin/tests/cfg_test.c b/bin/tests/cfg_test.c new file mode 100644 index 0000000..77c9712 --- /dev/null +++ b/bin/tests/cfg_test.c @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2001, 2002 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: cfg_test.c,v 1.19 2007/06/19 23:46:59 tbox Exp $ */ + +/*! \file */ + +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +static void +check_result(isc_result_t result, const char *format, ...) { + va_list args; + + if (result == ISC_R_SUCCESS) + return; + + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + fprintf(stderr, ": %s\n", isc_result_totext(result)); + exit(1); +} + +static void +output(void *closure, const char *text, int textlen) { + UNUSED(closure); + (void) fwrite(text, 1, textlen, stdout); +} + +static void +usage(void) { + fprintf(stderr, "usage: cfg_test --rndc|--named " + "[--grammar] [--memstats] conffile\n"); + exit(1); +} + +int +main(int argc, char **argv) { + isc_result_t result; + isc_mem_t *mctx = NULL; + isc_log_t *lctx = NULL; + isc_logconfig_t *lcfg = NULL; + isc_logdestination_t destination; + cfg_parser_t *pctx = NULL; + cfg_obj_t *cfg = NULL; + cfg_type_t *type = NULL; + isc_boolean_t grammar = ISC_FALSE; + isc_boolean_t memstats = ISC_FALSE; + char *filename = NULL; + + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + + result = isc_log_create(mctx, &lctx, &lcfg); + check_result(result, "isc_log_create()"); + isc_log_setcontext(lctx); + + /* + * Create and install the default channel. + */ + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + result = isc_log_createchannel(lcfg, "_default", + ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, + &destination, ISC_LOG_PRINTTIME); + check_result(result, "isc_log_createchannel()"); + result = isc_log_usechannel(lcfg, "_default", NULL, NULL); + check_result(result, "isc_log_usechannel()"); + + /* + * Set the initial debug level. + */ + isc_log_setdebuglevel(lctx, 2); + + if (argc < 3) + usage(); + + while (argc > 1) { + if (strcmp(argv[1], "--grammar") == 0) { + grammar = ISC_TRUE; + } else if (strcmp(argv[1], "--memstats") == 0) { + memstats = ISC_TRUE; + } else if (strcmp(argv[1], "--named") == 0) { + type = &cfg_type_namedconf; + } else if (strcmp(argv[1], "--rndc") == 0) { + type = &cfg_type_rndcconf; + } else if (argv[1][0] == '-') { + usage(); + } else { + filename = argv[1]; + } + argv++, argc--; + } + + if (grammar) { + if (type == NULL) + usage(); + cfg_print_grammar(type, output, NULL); + } else { + if (type == NULL || filename == NULL) + usage(); + RUNTIME_CHECK(cfg_parser_create(mctx, lctx, &pctx) == ISC_R_SUCCESS); + + result = cfg_parse_file(pctx, filename, type, &cfg); + + fprintf(stderr, "read config: %s\n", isc_result_totext(result)); + + if (result != ISC_R_SUCCESS) + exit(1); + + cfg_print(cfg, output, NULL); + + cfg_obj_destroy(pctx, &cfg); + + cfg_parser_destroy(&pctx); + } + + isc_log_destroy(&lctx); + if (memstats) + isc_mem_stats(mctx, stderr); + isc_mem_destroy(&mctx); + + return (0); +} diff --git a/bin/tests/compress_test.c b/bin/tests/compress_test.c new file mode 100644 index 0000000..8284dc1 --- /dev/null +++ b/bin/tests/compress_test.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: compress_test.c,v 1.34 2007/06/18 23:47:26 tbox Exp $ */ + +/*! \file */ + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +unsigned char plain1[] = "\003yyy\003foo"; +unsigned char plain2[] = "\003bar\003yyy\003foo"; +unsigned char plain3[] = "\003xxx\003bar\003foo"; +unsigned char plain[] = "\003yyy\003foo\0\003bar\003yyy\003foo\0\003" + "bar\003yyy\003foo\0\003xxx\003bar\003foo"; + +/* + * Result concatenate (plain1, plain2, plain2, plain3). + */ +int raw = 0; +int verbose = 0; + +void +test(unsigned int, dns_name_t *, dns_name_t *, dns_name_t *, + unsigned char *, unsigned int); + +int +main(int argc, char *argv[]) { + dns_name_t name1; + dns_name_t name2; + dns_name_t name3; + isc_region_t region; + int c; + + while ((c = isc_commandline_parse(argc, argv, "rv")) != -1) { + switch (c) { + case 'r': + raw++; + break; + case 'v': + verbose++; + break; + } + } + + dns_name_init(&name1, NULL); + region.base = plain1; + region.length = sizeof(plain1); + dns_name_fromregion(&name1, ®ion); + + dns_name_init(&name2, NULL); + region.base = plain2; + region.length = sizeof(plain2); + dns_name_fromregion(&name2, ®ion); + + dns_name_init(&name3, NULL); + region.base = plain3; + region.length = sizeof(plain3); + dns_name_fromregion(&name3, ®ion); + + test(DNS_COMPRESS_NONE, &name1, &name2, &name3, plain, sizeof(plain)); + test(DNS_COMPRESS_GLOBAL14, &name1, &name2, &name3, plain, + sizeof(plain)); + test(DNS_COMPRESS_ALL, &name1, &name2, &name3, plain, sizeof(plain)); + + return (0); +} + +void +test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2, + dns_name_t *name3, unsigned char *result, unsigned int length) +{ + isc_mem_t *mctx = NULL; + dns_compress_t cctx; + dns_decompress_t dctx; + isc_buffer_t source; + isc_buffer_t target; + dns_name_t name; + unsigned char buf1[1024]; + unsigned char buf2[1024]; + + if (verbose) { + const char *s; + switch (allowed) { + case DNS_COMPRESS_NONE: s = "DNS_COMPRESS_NONE"; break; + case DNS_COMPRESS_GLOBAL14: s = "DNS_COMPRESS_GLOBAL14"; break; + /* case DNS_COMPRESS_ALL: s = "DNS_COMPRESS_ALL"; break; */ + default: s = "UNKNOWN"; break; + } + fprintf(stdout, "Allowed = %s\n", s); + } + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + isc_buffer_init(&source, buf1, sizeof(buf1)); + RUNTIME_CHECK(dns_compress_init(&cctx, -1, mctx) == ISC_R_SUCCESS); + + RUNTIME_CHECK(dns_name_towire(name1, &cctx, &source) == ISC_R_SUCCESS); + + /* + RUNTIME_CHECK(dns_compress_localinit(&cctx, name1, &source) == + ISC_R_SUCCESS); + */ + dns_compress_setmethods(&cctx, allowed); + RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_name_towire(name3, &cctx, &source) == ISC_R_SUCCESS); + + /* + dns_compress_localinvalidate(&cctx); + */ + dns_compress_rollback(&cctx, 0); /* testing only */ + dns_compress_invalidate(&cctx); + + if (raw) { + unsigned int i; + for (i = 0; i < source.used; /* */ ) { + fprintf(stdout, "%02x", + ((unsigned char *)source.base)[i]); + if ((++i % 20) == 0) + fputs("\n", stdout); + else + if (i == source.used) + fputs("\n", stdout); + else + fputs(" ", stdout); + } + } + + isc_buffer_setactive(&source, source.used); + isc_buffer_init(&target, buf2, sizeof(buf2)); + dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT); + + dns_name_init(&name, NULL); + RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE, + &target) == ISC_R_SUCCESS); + dns_decompress_setmethods(&dctx, allowed); + /* + dns_decompress_localinit(&dctx, &name, &source); + */ + RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE, + &target) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE, + &target) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE, + &target) == ISC_R_SUCCESS); + /* + dns_decompress_localinvalidate(&dctx); + */ + dns_decompress_invalidate(&dctx); + + if (raw) { + unsigned int i; + for (i = 0; i < target.used; /* */ ) { + fprintf(stdout, "%02x", + ((unsigned char *)target.base)[i]); + if ((++i % 20) == 0) + fputs("\n", stdout); + else + if (i == target.used) + fputs("\n", stdout); + else + fputs(" ", stdout); + } + fputs("\n", stdout); + fflush(stdout); + } + + RUNTIME_CHECK(target.used == length); + RUNTIME_CHECK(memcmp(target.base, result, target.used) == 0); + isc_mem_destroy(&mctx); +} diff --git a/bin/tests/db/Makefile.in b/bin/tests/db/Makefile.in new file mode 100644 index 0000000..13ebad2 --- /dev/null +++ b/bin/tests/db/Makefile.in @@ -0,0 +1,57 @@ +# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 1999-2002 Internet Software Consortium. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# $Id: Makefile.in,v 1.29 2007/06/19 23:46:59 tbox Exp $ + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +@BIND9_MAKE_INCLUDES@ + +CINCLUDES = ${TEST_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES} + +CDEFINES = +CWARNINGS = + +DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +ISCLIBS = ../../../lib/isc/libisc.@A@ + +DNSDEPLIBS = ../../../lib/dns/libdns.@A@ +ISCDEPLIBS = ../../../lib/isc/libisc.@A@ + +DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} + +LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ + +TLIB = ../../../lib/tests/libt_api.@A@ + +SRCS = t_db.c + +TARGETS = t_db@EXEEXT@ + +@BIND9_MAKE_RULES@ + +t_db@EXEEXT@: t_db.@O@ ${DEPLIBS} ${TLIB} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_db.@O@ ${TLIB} ${LIBS} + +test: t_db@EXEEXT@ + -@./t_db@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a + +testhelp: + @./t_db -h + +clean distclean:: + rm -f ${TARGETS} diff --git a/bin/tests/db/dns_db_class_1.data b/bin/tests/db/dns_db_class_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_class_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_class_data b/bin/tests/db/dns_db_class_data new file mode 100644 index 0000000..55a0cf8 --- /dev/null +++ b/bin/tests/db/dns_db_class_data @@ -0,0 +1,9 @@ +# +# test data for dns_db_class +# +# format: +# filename class +# +# +dns_db_class_1.data in +# dns_db_class_1.data any diff --git a/bin/tests/db/dns_db_closeversion_1.data b/bin/tests/db/dns_db_closeversion_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_closeversion_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_closeversion_1_data b/bin/tests/db/dns_db_closeversion_1_data new file mode 100644 index 0000000..7bfd5b0 --- /dev/null +++ b/bin/tests/db/dns_db_closeversion_1_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_closeversion test 1 +# +# format: +# filename type origin class cache new_name new_type existing_name existing_type +# +dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS diff --git a/bin/tests/db/dns_db_closeversion_2.data b/bin/tests/db/dns_db_closeversion_2.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_closeversion_2.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_closeversion_2_data b/bin/tests/db/dns_db_closeversion_2_data new file mode 100644 index 0000000..e5bcf4d --- /dev/null +++ b/bin/tests/db/dns_db_closeversion_2_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_closeversion test 2 +# +# format: +# filename type origin class cache new_name new_type existing_name existing_type +# +dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS diff --git a/bin/tests/db/dns_db_currentversion.data b/bin/tests/db/dns_db_currentversion.data new file mode 100644 index 0000000..b7cb868 --- /dev/null +++ b/bin/tests/db/dns_db_currentversion.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a.b.c.vix.com. a 1.2.3.4 +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_currentversion_data b/bin/tests/db/dns_db_currentversion_data new file mode 100644 index 0000000..e4a095e --- /dev/null +++ b/bin/tests/db/dns_db_currentversion_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_currentversion +# +# format: +# filename findname findtype +# +dns_db_currentversion.data rbt vix.com. IN zone a.b.c.vix.com. A diff --git a/bin/tests/db/dns_db_expirenode.data b/bin/tests/db/dns_db_expirenode.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_expirenode.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_expirenode_data b/bin/tests/db/dns_db_expirenode_data new file mode 100644 index 0000000..f51858a --- /dev/null +++ b/bin/tests/db/dns_db_expirenode_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_expirenode +# +# format: +# filename type origin class existing_name existing_type +# +dns_db_expirenode.data rbt vix.com. in a.vix.com. 10000 0 ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_find_1.data b/bin/tests/db/dns_db_find_1.data new file mode 100644 index 0000000..8cfc69c --- /dev/null +++ b/bin/tests/db/dns_db_find_1.data @@ -0,0 +1,12 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 +a.b.c in ns b diff --git a/bin/tests/db/dns_db_find_10.data b/bin/tests/db/dns_db_find_10.data new file mode 100644 index 0000000..ca1fc5e --- /dev/null +++ b/bin/tests/db/dns_db_find_10.data @@ -0,0 +1,10 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum + +a.b.c in NS ns1.vix.com. +a.b.c in A 1.2.3.4 diff --git a/bin/tests/db/dns_db_find_10_data b/bin/tests/db/dns_db_find_10_data new file mode 100644 index 0000000..d1ab1d3 --- /dev/null +++ b/bin/tests/db/dns_db_find_10_data @@ -0,0 +1,8 @@ +# +# test data for dns_db_find expiration time handling +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 1010 ISC_R_NOTFOUND +dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 ISC_R_SUCCESS diff --git a/bin/tests/db/dns_db_find_1_data b/bin/tests/db/dns_db_find_1_data new file mode 100644 index 0000000..e1664cf --- /dev/null +++ b/bin/tests/db/dns_db_find_1_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_find best match +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_1.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_2.data b/bin/tests/db/dns_db_find_2.data new file mode 100644 index 0000000..ab4b435 --- /dev/null +++ b/bin/tests/db/dns_db_find_2.data @@ -0,0 +1,9 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +fx in ns a.fx.vix.com. +a.fx in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_find_2_data b/bin/tests/db/dns_db_find_2_data new file mode 100644 index 0000000..0e3ffca --- /dev/null +++ b/bin/tests/db/dns_db_find_2_data @@ -0,0 +1,9 @@ +# +# test data for dns_db_find DNS_R_GLUE +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. A DNS_DBFIND_GLUEOK 0 DNS_R_GLUE +dns_db_find_2.data rbt vix.com. in zone fx.vix.com. NS DNS_DBFIND_GLUEOK 0 DNS_R_GLUE +dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. NS DNS_DBFIND_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_3.data b/bin/tests/db/dns_db_find_3.data new file mode 100644 index 0000000..d126e91 --- /dev/null +++ b/bin/tests/db/dns_db_find_3.data @@ -0,0 +1,10 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a.b.c in ns b +a.a.b.c in a 10.0.0.1 +b in a 10.0.0.2 diff --git a/bin/tests/db/dns_db_find_3_data b/bin/tests/db/dns_db_find_3_data new file mode 100644 index 0000000..a8e1223 --- /dev/null +++ b/bin/tests/db/dns_db_find_3_data @@ -0,0 +1,9 @@ +# +# test data for dns_db_find DNS_R_DELAGATION +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_3.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION +dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION +dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. A DNS_DB_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_4.data b/bin/tests/db/dns_db_find_4.data new file mode 100644 index 0000000..4c3b5e9 --- /dev/null +++ b/bin/tests/db/dns_db_find_4.data @@ -0,0 +1,9 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a.b.c in ns b +b.a.b.c in a 10.0.0.2 diff --git a/bin/tests/db/dns_db_find_4_data b/bin/tests/db/dns_db_find_4_data new file mode 100644 index 0000000..b0326a6 --- /dev/null +++ b/bin/tests/db/dns_db_find_4_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_find DNS_R_DELEGATION +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_4.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_5.data b/bin/tests/db/dns_db_find_5.data new file mode 100644 index 0000000..e33f631 --- /dev/null +++ b/bin/tests/db/dns_db_find_5.data @@ -0,0 +1,10 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a.b.c in DNAME x.y.z +a.x.y.z in A 1.2.3.4 + diff --git a/bin/tests/db/dns_db_find_5_data b/bin/tests/db/dns_db_find_5_data new file mode 100644 index 0000000..dab47c8 --- /dev/null +++ b/bin/tests/db/dns_db_find_5_data @@ -0,0 +1,8 @@ +# +# test data for dns_db_find DNS_R_DNAME +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_5.data rbt vix.com. in zone x.a.b.c.vix.com. ANY 0 0 DNS_R_DNAME +dns_db_find_5.data rbt vix.com. in zone a.a.b.c.vix.com. ANY 0 0 DNS_R_DNAME diff --git a/bin/tests/db/dns_db_find_6.data b/bin/tests/db/dns_db_find_6.data new file mode 100644 index 0000000..108f043 --- /dev/null +++ b/bin/tests/db/dns_db_find_6.data @@ -0,0 +1,10 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +exploder in CNAME mx +mx in A 1.2.3.4 + diff --git a/bin/tests/db/dns_db_find_6_data b/bin/tests/db/dns_db_find_6_data new file mode 100644 index 0000000..47de0e6 --- /dev/null +++ b/bin/tests/db/dns_db_find_6_data @@ -0,0 +1,8 @@ +# +# test data for dns_db_find DNS_R_CNAME +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. A 0 0 DNS_R_CNAME +dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. ANY 0 0 ISC_R_SUCCESS diff --git a/bin/tests/db/dns_db_find_7.data b/bin/tests/db/dns_db_find_7.data new file mode 100644 index 0000000..f0ec22b --- /dev/null +++ b/bin/tests/db/dns_db_find_7.data @@ -0,0 +1,12 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum + +a.b.c.d in A 1.2.3.4 +a.b in A 1.2.3.4 +a in NS ns1.vix.com. + diff --git a/bin/tests/db/dns_db_find_7_data b/bin/tests/db/dns_db_find_7_data new file mode 100644 index 0000000..6592758 --- /dev/null +++ b/bin/tests/db/dns_db_find_7_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_find DNS_R_NXDOMAIN +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_7.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_NXDOMAIN diff --git a/bin/tests/db/dns_db_find_8.data b/bin/tests/db/dns_db_find_8.data new file mode 100644 index 0000000..66e61ff --- /dev/null +++ b/bin/tests/db/dns_db_find_8.data @@ -0,0 +1,13 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum + +a.b.c.d in A 1.2.3.4 +a.b.c in A 1.2.3.4 +a.b in A 1.2.3.4 +a in NS ns1.vix.com. + diff --git a/bin/tests/db/dns_db_find_8_data b/bin/tests/db/dns_db_find_8_data new file mode 100644 index 0000000..4ad0c83 --- /dev/null +++ b/bin/tests/db/dns_db_find_8_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_find DNS_R_NXRRSET +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_8.data rbt vix.com. in zone a.b.c.vix.com. NS 0 0 DNS_R_NXRRSET diff --git a/bin/tests/db/dns_db_find_9.data b/bin/tests/db/dns_db_find_9.data new file mode 100644 index 0000000..54a6d5f --- /dev/null +++ b/bin/tests/db/dns_db_find_9.data @@ -0,0 +1,13 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum + +a.b.c.d in NS ns1.vix.com. +a.b.c in A 1.2.3.4 +a.b in NS ns1.vix.com. +a in NS ns1.vix.com. + diff --git a/bin/tests/db/dns_db_find_9_data b/bin/tests/db/dns_db_find_9_data new file mode 100644 index 0000000..d80795c --- /dev/null +++ b/bin/tests/db/dns_db_find_9_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_find ISC_R_NOTFOUND +# +# format: +# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results +# +dns_db_find_9.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_findnode_1.data b/bin/tests/db/dns_db_findnode_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_findnode_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_findnode_1_data b/bin/tests/db/dns_db_findnode_1_data new file mode 100644 index 0000000..a73c425 --- /dev/null +++ b/bin/tests/db/dns_db_findnode_1_data @@ -0,0 +1,9 @@ +# +# test data for dns_db_findnode, case ISC_R_SUCCESS +# +# format: +# filename type origin class cache existingname rdatatype +# +dns_db_findnode_1.data rbt vix.com. in zone a.vix.com. NS ISC_R_SUCCESS +dns_db_findnode_1.data rbt vix.com. in zone b.vix.com. A ISC_R_SUCCESS +dns_db_findnode_1.data rbt vix.com. in zone c.vix.com. A ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_findnode_2.data b/bin/tests/db/dns_db_findnode_2.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_findnode_2.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_findnode_2_data b/bin/tests/db/dns_db_findnode_2_data new file mode 100644 index 0000000..db69d20 --- /dev/null +++ b/bin/tests/db/dns_db_findnode_2_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_findnode 2 +# +# format: +# filename type origin class cache newname +# +dns_db_findnode_2.data rbt vix.com. in zone a.b.c.vix.com. diff --git a/bin/tests/db/dns_db_iscache_1.data b/bin/tests/db/dns_db_iscache_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_iscache_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iscache_1_data b/bin/tests/db/dns_db_iscache_1_data new file mode 100644 index 0000000..af591f9 --- /dev/null +++ b/bin/tests/db/dns_db_iscache_1_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_iscache test 1 +# +# format: +# filename db_type origin class +# +dns_db_iscache_1.data rbt . in diff --git a/bin/tests/db/dns_db_iscache_2.data b/bin/tests/db/dns_db_iscache_2.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_iscache_2.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iscache_2_data b/bin/tests/db/dns_db_iscache_2_data new file mode 100644 index 0000000..e859ef7 --- /dev/null +++ b/bin/tests/db/dns_db_iscache_2_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_iscache test 1 +# +# format: +# filename db_type origin class +# +dns_db_iscache_2.data rbt . in diff --git a/bin/tests/db/dns_db_iszone_1.data b/bin/tests/db/dns_db_iszone_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_iszone_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iszone_1_data b/bin/tests/db/dns_db_iszone_1_data new file mode 100644 index 0000000..02862d7 --- /dev/null +++ b/bin/tests/db/dns_db_iszone_1_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_iszone test 1 +# +# format: +# filename db_type origin class +# +dns_db_iszone_1.data rbt . in diff --git a/bin/tests/db/dns_db_iszone_2.data b/bin/tests/db/dns_db_iszone_2.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_iszone_2.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iszone_2_data b/bin/tests/db/dns_db_iszone_2_data new file mode 100644 index 0000000..02d3dc2 --- /dev/null +++ b/bin/tests/db/dns_db_iszone_2_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_iszone test 2 +# +# format: +# filename db_type origin class +# +dns_db_iszone_2.data rbt . in diff --git a/bin/tests/db/dns_db_load_1.data b/bin/tests/db/dns_db_load_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_load_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_load_25.data b/bin/tests/db/dns_db_load_25.data new file mode 100644 index 0000000..6e21bda --- /dev/null +++ b/bin/tests/db/dns_db_load_25.data @@ -0,0 +1,6 @@ +$TTL 5 +@ IN SOA ns1 hostmaster 1 3600 1200 3600000 3600 +@ IN NS ns1 +ns1 IN A 10.0.0.1 +sub IN SOA ns2 hostmaster 1 3600 1200 3600000 3600 +ns2 IN A 10.0.0.2 diff --git a/bin/tests/db/dns_db_load_data b/bin/tests/db/dns_db_load_data new file mode 100644 index 0000000..0684c62 --- /dev/null +++ b/bin/tests/db/dns_db_load_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_load +# +# format: +# filename type origin cache class findname expected_result +# +dns_db_load_1.data rbt . zone in ISC_R_SUCCESS a. A DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_load_soa_not_top b/bin/tests/db/dns_db_load_soa_not_top new file mode 100644 index 0000000..fbb8dcc --- /dev/null +++ b/bin/tests/db/dns_db_load_soa_not_top @@ -0,0 +1,7 @@ +# +# test data for dns_db_load_soa_not_top +# +# format: +# filename type origin cache class findname expected_result +# +dns_db_load_25.data rbt . zone in DNS_R_NOTZONETOP a. A DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_newversion.data b/bin/tests/db/dns_db_newversion.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_newversion.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_newversion_data b/bin/tests/db/dns_db_newversion_data new file mode 100644 index 0000000..be0c042 --- /dev/null +++ b/bin/tests/db/dns_db_newversion_data @@ -0,0 +1,7 @@ +# +# test data for dns_db_newversion +# +# format: +# filename type origin class cache newname newtype +# +dns_db_newversion.data rbt vix.com. in zone a.b.c.vix.com. A diff --git a/bin/tests/db/dns_db_origin_1.data b/bin/tests/db/dns_db_origin_1.data new file mode 100644 index 0000000..ab61c95 --- /dev/null +++ b/bin/tests/db/dns_db_origin_1.data @@ -0,0 +1,11 @@ +$TTL 1000 +@ in soa localhost. postmaster.localhost. ( + 1993050801 ;serial + 3600 ;refresh + 1800 ;retry + 604800 ;expiration + 3600 ) ;minimum +a in ns ns.vix.com. +a in ns ns2.vix.com. +a in ns ns3.vix.com. +b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_origin_data b/bin/tests/db/dns_db_origin_data new file mode 100644 index 0000000..9c3b458 --- /dev/null +++ b/bin/tests/db/dns_db_origin_data @@ -0,0 +1,8 @@ +# +# test data for dns_db_origin +# +# format: +# filename origin +# +dns_db_origin_1.data . +dns_db_origin_1.data vix.com. diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c new file mode 100644 index 0000000..727c49e --- /dev/null +++ b/bin/tests/db/t_db.c @@ -0,0 +1,3146 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: t_db.c,v 1.36 2007/06/19 23:46:59 tbox Exp $ */ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static isc_result_t +t_create(const char *db_type, const char *origin, const char *class, + const char *model, isc_mem_t *mctx, dns_db_t **db) +{ + int len; + isc_result_t dns_result; + dns_dbtype_t dbtype; + isc_textregion_t region; + isc_buffer_t origin_buffer; + dns_fixedname_t dns_origin; + dns_rdataclass_t rdataclass; + + + dbtype = dns_dbtype_zone; + if (strcasecmp(model, "cache") == 0) + dbtype = dns_dbtype_cache; + + dns_fixedname_init(&dns_origin); + len = strlen(origin); + isc_buffer_init(&origin_buffer, origin, len); + isc_buffer_add(&origin_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), + &origin_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(dns_result); + } + + DE_CONST(class, region.base); + region.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, ®ion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(dns_result); + } + + dns_result = dns_db_create(mctx, db_type, + dns_fixedname_name(&dns_origin), + dbtype, rdataclass, 0, NULL, db); + if (dns_result != ISC_R_SUCCESS) + t_info("dns_db_create failed %s\n", + dns_result_totext(dns_result)); + + return(dns_result); + +} + +static int +t_dns_db_load(char **av) { + char *filename; + char *db_type; + char *origin; + char *model; + char *class; + char *expected_load_result; + char *findname; + char *find_type; + char *expected_find_result; + + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_textregion_t textregion; + isc_buffer_t findname_buffer; + dns_fixedname_t dns_findname; + dns_fixedname_t dns_foundname; + dns_rdataset_t rdataset; + dns_rdatatype_t rdatatype; + dns_dbversion_t *versionp; + isc_result_t exp_load_result; + isc_result_t exp_find_result; + + result = T_UNRESOLVED; + db = NULL; + mctx = NULL; + ectx = NULL; + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + model = T_ARG(3); + class = T_ARG(4); + expected_load_result = T_ARG(5); + findname = T_ARG(6); + find_type = T_ARG(7); + expected_find_result = T_ARG(8); + + t_info("testing using file %s and name %s\n", filename, findname); + + exp_load_result = t_dns_result_fromtext(expected_load_result); + exp_find_result = t_dns_result_fromtext(expected_find_result); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != exp_load_result) { + t_info("dns_db_load returned %s, expected %s\n", + dns_result_totext(dns_result), + dns_result_totext(exp_load_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + if (dns_result != ISC_R_SUCCESS) { + result = T_PASS; + goto cleanup_db; + } + + dns_fixedname_init(&dns_findname); + len = strlen(findname); + isc_buffer_init(&findname_buffer, findname, len); + isc_buffer_add(&findname_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), + &findname_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = find_type; + textregion.length = strlen(find_type); + dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + find_type, + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + versionp = NULL; + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&rdataset); + if (dns_db_iszone(db)) + dns_db_currentversion(db, &versionp); + nodep = NULL; + + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_findname), + versionp, + rdatatype, + DNS_DBFIND_GLUEOK, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + if (dns_result != exp_find_result) { + t_info("dns_db_find returned %s, expected %s\n", + dns_result_totext(dns_result), + dns_result_totext(exp_find_result)); + result = T_FAIL; + } else { + result = T_PASS; + } + + if (dns_result != ISC_R_NOTFOUND) { + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&rdataset)) + dns_rdataset_disassociate(&rdataset); + } + + if (dns_db_iszone(db)) + dns_db_closeversion(db, &versionp, ISC_FALSE); + cleanup_db: + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(result); +} + +static const char *a1 = + "A call to dns_db_load(db, filename) loads the contents of " + "the database in filename into db."; + +static void +t1(void) { + int result; + + t_assert("dns_db_load", 1, T_REQUIRED, a1); + result = t_eval("dns_db_load_data", t_dns_db_load, 9); + t_result(result); +} + + +static const char *a2 = + "When the database db has cache semantics, a call to " + "dns_db_iscache(db) returns ISC_TRUE."; + +static int +t_dns_db_zc_x(char *filename, char *db_type, char *origin, char *class, + dns_dbtype_t dbtype, isc_boolean_t(*cf)(dns_db_t *), + isc_boolean_t exp_result) +{ + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_rdataclass_t rdataclass; + isc_textregion_t textregion; + isc_buffer_t origin_buffer; + dns_fixedname_t dns_origin; + + result = T_UNRESOLVED; + + db = NULL; + mctx = NULL; + ectx = NULL; + + t_info("testing using file %s\n", filename); + + dns_fixedname_init(&dns_origin); + len = strlen(origin); + isc_buffer_init(&origin_buffer, origin, len); + isc_buffer_add(&origin_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), + &origin_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(T_UNRESOLVED); + } + + textregion.base = class; + textregion.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_create(mctx, db_type, + dns_fixedname_name(&dns_origin), + dbtype, rdataclass, 0, NULL, &db); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_create failed %s\n", + dns_result_totext(dns_result)); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result == ISC_R_SUCCESS) { + if ((*cf)(db) == exp_result) + result = T_PASS; + else + result = T_FAIL; + } else { + t_info("dns_db_load failed %s\n", + dns_result_totext(dns_result)); + result = T_FAIL; + } + + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(result); +} + +static int +test_dns_db_zc_x(const char *filename, dns_dbtype_t dbtype, + isc_boolean_t(*cf)(dns_db_t *), isc_boolean_t exp_result) +{ + + FILE *fp; + char *p; + int line; + int cnt; + int result; + int nfails; + int nprobs; + char *tokens[T_MAXTOKS]; + + nfails = 0; + nprobs = 0; + + fp = fopen(filename, "r"); + if (fp != NULL) { + line = 0; + while ((p = t_fgetbs(fp)) != NULL) { + + ++line; + + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); + continue; + } + + cnt = t_bustline(p, tokens); + if (cnt == 4) { + result = t_dns_db_zc_x(tokens[0], /* file */ + tokens[1], /* type */ + tokens[2], /* origin */ + tokens[3], /* class */ + dbtype, /* cache */ + cf, /* check func */ + exp_result);/* expect */ + if (result != T_PASS) { + if (result == T_FAIL) + ++nfails; + else + ++nprobs; + } + } else { + t_info("bad format in %s at line %d\n", + filename, line); + ++nprobs; + } + + (void)free(p); + } + (void)fclose(fp); + } else { + t_info("Missing datafile %s\n", filename); + ++nprobs; + } + + result = T_UNRESOLVED; + + if (nfails == 0 && nprobs == 0) + result = T_PASS; + else if (nfails) + result = T_FAIL; + + return(result); +} + +static void +t2(void) { + int result; + + t_assert("dns_db_iscache", 2, T_REQUIRED, a2); + result = test_dns_db_zc_x("dns_db_iscache_1_data", + dns_dbtype_cache, dns_db_iscache, ISC_TRUE); + t_result(result); +} + + +static const char *a3 = + "When the database db has zone semantics, a call to " + "dns_db_iscache(db) returns ISC_FALSE."; + + +static void +t3(void) { + int result; + + t_assert("dns_db_iscache", 3, T_REQUIRED, a3); + result = test_dns_db_zc_x("dns_db_iscache_2_data", + dns_dbtype_zone, dns_db_iscache, ISC_FALSE); + t_result(result); +} + + +static const char *a4 = + "When the database db has zone semantics, a call to " + "dns_db_iszone(db) returns ISC_TRUE."; + + +static void +t4(void) { + int result; + + t_assert("dns_db_iszone", 4, T_REQUIRED, a4); + result = test_dns_db_zc_x("dns_db_iszone_1_data", + dns_dbtype_zone, dns_db_iszone, ISC_TRUE); + t_result(result); +} + + +static const char *a5 = + "When the database db has cache semantics, a call to " + "dns_db_iszone(db) returns ISC_FALSE."; + +static void +t5(void) { + int result; + + t_assert("dns_db_iszone", 5, T_REQUIRED, a5); + result = test_dns_db_zc_x("dns_db_iszone_2_data", + dns_dbtype_cache, dns_db_iszone, ISC_FALSE); + t_result(result); +} + +static int +t_dns_db_origin(char **av) { + + char *filename; + char *origin; + + int result; + int len; + int order; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_db_t *db; + dns_fixedname_t dns_origin; + dns_fixedname_t dns_dborigin; + isc_buffer_t origin_buffer; + + db = NULL; + mctx = NULL; + ectx = NULL; + + filename = T_ARG(0); + origin = T_ARG(1); + + t_info("testing with database %s and origin %s\n", + filename, origin); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create("rbt", origin, "in", "isc_true", mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + t_info("t_create failed %s\n", + dns_result_totext(dns_result)); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + dns_fixedname_init(&dns_origin); + dns_fixedname_init(&dns_dborigin); + + len = strlen(origin); + isc_buffer_init(&origin_buffer, origin, len); + isc_buffer_add(&origin_buffer, len); + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), + &origin_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + order = dns_name_compare(dns_fixedname_name(&dns_origin), + dns_db_origin(db)); + if (order == 0) { + result = T_PASS; + } else { + t_info("dns_name_compare returned %d\n", order); + result = T_FAIL; + } + + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(result); + +} + +static const char *a6 = + "A call to dns_db_origin(db) returns the origin of the database."; + +static void +t6(void) { + int result; + + t_assert("dns_db_origin", 6, T_REQUIRED, a6); + result = t_eval("dns_db_origin_data", t_dns_db_origin, 2); + t_result(result); +} + + +static const char *a7 = + "A call to dns_db_class(db) returns the class of the database."; + + +#define CLASSBUFLEN 256 + +static int +t_dns_db_class(char **av) { + + char *filename; + char *class; + + int result; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_db_t *db; + dns_rdataclass_t rdataclass; + dns_rdataclass_t db_rdataclass; + isc_textregion_t textregion; + + filename = T_ARG(0); + class = T_ARG(1); + db = NULL; + mctx = NULL; + ectx = NULL; + + t_info("testing with database %s and class %s\n", + filename, class); + + textregion.base = class; + textregion.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create("rbt", ".", class, "isc_true", mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + t_info("t_create failed %s\n", + dns_result_totext(dns_result)); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + db_rdataclass = dns_db_class(db); + if (db_rdataclass == rdataclass) + result = T_PASS; + else { + char classbuf[DNS_RDATACLASS_FORMATSIZE]; + dns_rdataclass_format(db_rdataclass, + classbuf, sizeof(classbuf)); + t_info("dns_db_class returned %s, expected %s\n", + classbuf, class); + result = T_FAIL; + } + + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(result); + +} +static void +t7(void) { + int result; + + t_assert("dns_db_class", 7, T_REQUIRED, a7); + result = t_eval("dns_db_class_data", t_dns_db_class, 2); + t_result(result); +} + + +static const char *a8 = + "A call to dns_db_currentversion() opens the current " + "version for reading."; + +static int +t_dns_db_currentversion(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *findname; + char *findtype; + + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_textregion_t textregion; + isc_buffer_t findname_buffer; + dns_fixedname_t dns_findname; + dns_fixedname_t dns_foundname; + dns_rdataset_t rdataset; + dns_rdatatype_t rdatatype; + dns_dbversion_t *cversionp; + dns_dbversion_t *nversionp; + + result = T_UNRESOLVED; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + findname = T_ARG(5); + findtype = T_ARG(6); + db = NULL; + mctx = NULL; + ectx = NULL; + + t_info("testing using file %s and name %s\n", filename, findname); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_fixedname_init(&dns_findname); + len = strlen(findname); + isc_buffer_init(&findname_buffer, findname, len); + isc_buffer_add(&findname_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), + &findname_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = findtype; + textregion.length = strlen(findtype); + dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + findtype, + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * find a name we know is there + */ + + cversionp = NULL; + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&rdataset); + dns_db_currentversion(db, &cversionp); + nodep = NULL; + + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_findname), + cversionp, + rdatatype, + 0, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + if (dns_result != ISC_R_SUCCESS) { + t_info("unable to find %s using current version\n", findname); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * create a new version + * delete the found rdataset in the new version + * attempt to find the rdataset again and expect the find to fail + * close/commit the new version + * attempt to find the rdataset in the current version and + * expect the find to succeed + */ + + nversionp = NULL; + dns_result = dns_db_newversion(db, &nversionp); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_newversion failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_rdataset_disassociate(&rdataset); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Delete the found rdataset in the new version. + */ + dns_result = dns_db_deleterdataset(db, nodep, nversionp, rdatatype, 0); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_deleterdataset failed %s\n", + dns_result_totext(dns_result)); + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &nodep); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Don't need these now. + */ + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &nodep); + nodep = NULL; + + /* + * Find the deleted rdataset and expect it to fail. + */ + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_findname), + nversionp, + rdatatype, + 0, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + t_info("unexpectedly found %s using current version\n", + findname); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Close/commit the new version. + */ + dns_db_closeversion(db, &nversionp, ISC_TRUE); + + /* + * Find the deleted rdata in the current version. + */ + dns_result = dns_db_find(db, dns_fixedname_name(&dns_findname), + cversionp, rdatatype, DNS_DBFIND_GLUEOK, + 0, &nodep, dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + /* + * And expect it to succeed. + */ + if (dns_result == ISC_R_SUCCESS) { + result = T_PASS; + } else { + t_info("cound not find %s using current version\n", findname); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + result = T_FAIL; + } + + dns_db_detachnode(db, &nodep); + dns_rdataset_disassociate(&rdataset); + + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + return(result); +} + +static void +t8(void) { + int result; + + t_assert("dns_db_currentversion", 8, T_REQUIRED, a8); + result = t_eval("dns_db_currentversion_data", + t_dns_db_currentversion, 7); + t_result(result); +} + +static const char *a9 = + "A call to dns_db_newversion() opens a new version for " + "reading and writing."; + +static int +t_dns_db_newversion(char **av) { + + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *newname; + char *newtype; + + int result; + int len; + int rval; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + dns_dbnode_t *found_nodep; + isc_textregion_t textregion; + isc_buffer_t newname_buffer; + dns_fixedname_t dns_newname; + dns_fixedname_t dns_foundname; + dns_rdata_t added_rdata = DNS_RDATA_INIT; + const char * added_rdata_data; + dns_rdataset_t added_rdataset; + dns_rdata_t found_rdata = DNS_RDATA_INIT; + dns_rdataset_t found_rdataset; + dns_rdatatype_t rdatatype; + dns_rdataclass_t rdataclass; + dns_dbversion_t *nversionp; + dns_rdatalist_t rdatalist; + + result = T_UNRESOLVED; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + newname = T_ARG(5); + newtype = T_ARG(6); + db = NULL; + mctx = NULL; + ectx = NULL; + + /* + * Open a new version, add some data, commit it, + * close it, open a new version, and check that changes + * are present. + */ + + t_info("testing using file %s and name %s\n", filename, newname); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Add a new name. + */ + + dns_fixedname_init(&dns_newname); + len = strlen(newname); + isc_buffer_init(&newname_buffer, newname, len); + isc_buffer_add(&newname_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), + &newname_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), + ISC_TRUE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Open a new version and associate some rdata with the new name. + */ + + textregion.base = newtype; + textregion.length = strlen(newtype); + dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); + + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + newtype, + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = class; + textregion.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_rdata_init(&added_rdata); + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); + added_rdata.length = 4; + added_rdata.rdclass = rdataclass; + added_rdata.type = rdatatype; + + dns_rdataset_init(&added_rdataset); + rdatalist.type = rdatatype; + rdatalist.covers = 0; + rdatalist.rdclass = rdataclass; + rdatalist.ttl = 0; + ISC_LIST_INIT(rdatalist.rdata); + ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); + + dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatalist_tordataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nversionp = NULL; + dns_result = dns_db_newversion(db, &nversionp); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_newversion failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, + &added_rdataset, 0, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_addrdataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Close and commit the version. + */ + dns_db_closeversion(db, &nversionp, ISC_TRUE); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&added_rdataset)) + dns_rdataset_disassociate(&added_rdataset); + nodep = NULL; + + /* + * Open a new version and find the data we added. + */ + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&found_rdataset); + nversionp = NULL; + found_nodep = NULL; + dns_db_newversion(db, &nversionp); + + /* + * Find the recently added name and rdata. + */ + dns_result = dns_db_find(db, dns_fixedname_name(&dns_newname), + nversionp, rdatatype, 0, 0, &found_nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + if (dns_result != ISC_R_SUCCESS) { + /* XXXWPK - NXRRSET ??? reference counts ??? */ + t_info("dns_db_find failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &found_nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + dns_result = dns_rdataset_first(&found_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataset_first failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Now make sure its what we expect. + */ + dns_rdata_init(&found_rdata); + dns_rdataset_current(&found_rdataset, &found_rdata); + rval = dns_rdata_compare(&added_rdata, &found_rdata); + if (rval == 0) { + result = T_PASS; + } else { + t_info("dns_rdata_compare returned %d\n", rval); + result = T_FAIL; + } + + /* + * Don't need these now. + */ + dns_db_closeversion(db, &nversionp, ISC_FALSE); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_detachnode(db, &found_nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + return(result); +} + +static void +t9(void) { + int result; + + t_assert("dns_db_newversion", 9, T_REQUIRED, a9); + result = t_eval("dns_db_newversion_data", t_dns_db_newversion, 7); + t_result(result); +} + +static const char *a10 = + "When versionp points to a read-write version and commit is " + "ISC_TRUE, a call to dns_db_closeversion(db, versionp, commit) " + "causes all changes made in the version to take effect, " + "and returns ISC_R_SUCCESS."; + +static int +t_dns_db_closeversion_1(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *new_name; + char *new_type; + char *existing_name; + char *existing_type; + + int result; + int len; + int rval; + int nfails; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_textregion_t textregion; + isc_buffer_t name_buffer; + dns_fixedname_t dns_newname; + dns_fixedname_t dns_foundname; + dns_fixedname_t dns_existingname; + dns_rdata_t added_rdata = DNS_RDATA_INIT; + const char * added_rdata_data; + dns_rdataset_t added_rdataset; + dns_rdata_t found_rdata = DNS_RDATA_INIT; + dns_rdataset_t found_rdataset; + dns_rdatatype_t new_rdatatype; + dns_rdatatype_t existing_rdatatype; + dns_rdataclass_t rdataclass; + dns_dbversion_t *nversionp; + dns_dbversion_t *cversionp; + dns_rdatalist_t rdatalist; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + new_name = T_ARG(5); + new_type = T_ARG(6); + existing_name = T_ARG(7); + existing_type = T_ARG(8); + + nfails = 0; + result = T_UNRESOLVED; + db = NULL; + mctx = NULL; + ectx = NULL; + + /* + * Open a new version, add some data, + * remove some data, close with commit, open the current + * version and check that changes are present. + */ + + t_info("testing using file %s and name %s\n", filename, new_name); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Remove all rdata for an existing name. + */ + + dns_fixedname_init(&dns_existingname); + len = strlen(existing_name); + isc_buffer_init(&name_buffer, existing_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), + &name_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = existing_type; + textregion.length = strlen(existing_type); + dns_result = dns_rdatatype_fromtext(&existing_rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + existing_type, + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), + ISC_FALSE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* open a new version */ + nversionp = NULL; + dns_result = dns_db_newversion(db, &nversionp); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_newversion failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_deleterdataset(db, nodep, nversionp, + existing_rdatatype, 0); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_deleterdataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * add a new name and associate some rdata with it + */ + + dns_db_detachnode(db, &nodep); + nodep = NULL; + + dns_fixedname_init(&dns_newname); + len = strlen(new_name); + isc_buffer_init(&name_buffer, new_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), + &name_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), + ISC_TRUE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * associate some rdata with the new name + */ + + textregion.base = new_type; + textregion.length = strlen(new_type); + dns_result = dns_rdatatype_fromtext(&new_rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + new_type, + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = class; + textregion.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_rdata_init(&added_rdata); + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); + added_rdata.length = 4; + added_rdata.rdclass = rdataclass; + added_rdata.type = new_rdatatype; + + dns_rdataset_init(&added_rdataset); + rdatalist.type = new_rdatatype; + rdatalist.covers = 0; + rdatalist.rdclass = rdataclass; + rdatalist.ttl = 0; + ISC_LIST_INIT(rdatalist.rdata); + ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); + + dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatalist_tordataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, + &added_rdataset, 0, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_addrdataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* close and commit the version */ + dns_db_closeversion(db, &nversionp, ISC_TRUE); + dns_db_detachnode(db, &nodep); + nodep = NULL; + + /* open the current version and check changes */ + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&found_rdataset); + cversionp = NULL; + dns_db_currentversion(db, &cversionp); + + /* find the recently added name and rdata */ + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_newname), + cversionp, + new_rdatatype, + 0, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + if (dns_result != ISC_R_SUCCESS) { + /* XXXWPK NXRRSET ??? reference counting ??? */ + t_info("dns_db_find failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + dns_result = dns_rdataset_first(&found_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataset_first failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Now make sure its what we expect. + */ + dns_rdata_init(&found_rdata); + dns_rdataset_current(&found_rdataset, &found_rdata); + rval = dns_rdata_compare(&added_rdata, &found_rdata); + if (rval != 0) { + t_info("dns_rdata_compare returned %d\n", rval); + ++nfails; + } + + /* + * Now check the rdata deletion. + */ + + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_rdataset_init(&found_rdataset); + dns_db_detachnode(db, &nodep); + nodep = NULL; + dns_fixedname_init(&dns_foundname); + + dns_result = dns_db_find(db, dns_fixedname_name(&dns_existingname), + cversionp, existing_rdatatype, + 0, 0, &nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + dns_rdataset_disassociate(&found_rdataset); + dns_db_detachnode(db, &nodep); + t_info("dns_db_find %s returned %s\n", existing_name, + dns_result_totext(dns_result)); + ++nfails; + } + + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + if (nfails == 0) + result = T_PASS; + else + result = T_FAIL; + + return(result); +} + +static void +t10(void) { + int result; + + t_assert("dns_db_closeversion", 10, T_REQUIRED, a10); + result = t_eval("dns_db_closeversion_1_data", + t_dns_db_closeversion_1, 9); + t_result(result); +} + +static const char *a11 = + "When versionp points to a read-write version and commit is " + "ISC_FALSE, a call to dns_db_closeversion(db, versionp, commit) " + "causes all changes made in the version to to be rolled back, " + "and returns ISC_R_SUCCESS."; + +static int +t_dns_db_closeversion_2(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *new_name; + char *new_type; + char *existing_name; + char *existing_type; + + int result; + int len; + int rval; + int nfails; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_textregion_t textregion; + isc_buffer_t name_buffer; + dns_fixedname_t dns_newname; + dns_fixedname_t dns_foundname; + dns_fixedname_t dns_existingname; + dns_rdata_t added_rdata = DNS_RDATA_INIT; + const char * added_rdata_data; + dns_rdataset_t added_rdataset; + dns_rdata_t found_rdata = DNS_RDATA_INIT; + dns_rdataset_t found_rdataset; + dns_rdatatype_t new_rdatatype; + dns_rdatatype_t existing_rdatatype; + dns_rdataclass_t rdataclass; + dns_dbversion_t *nversionp; + dns_dbversion_t *cversionp; + dns_rdatalist_t rdatalist; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + new_name = T_ARG(5); + new_type = T_ARG(6); + existing_name = T_ARG(7); + existing_type = T_ARG(8); + + nfails = 0; + result = T_UNRESOLVED; + db = NULL; + mctx = NULL; + ectx = NULL; + + /* + * Open a new version, add some data, + * remove some data, close with commit, open the current + * version and check that changes are present. + */ + + t_info("testing using file %s and name %s\n", filename, new_name); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Remove all rdata for an existing name. + */ + + dns_fixedname_init(&dns_existingname); + len = strlen(existing_name); + isc_buffer_init(&name_buffer, existing_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), + &name_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = existing_type; + textregion.length = strlen(existing_type); + dns_result = dns_rdatatype_fromtext(&existing_rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + existing_type, + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), + ISC_FALSE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Open a new version. + */ + nversionp = NULL; + dns_result = dns_db_newversion(db, &nversionp); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_newversion failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_deleterdataset(db, nodep, nversionp, + existing_rdatatype, 0); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_deleterdataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * add a new name and associate some rdata with it + */ + + dns_db_detachnode(db, &nodep); + nodep = NULL; + + dns_fixedname_init(&dns_newname); + len = strlen(new_name); + isc_buffer_init(&name_buffer, new_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), + &name_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), + ISC_TRUE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = new_type; + textregion.length = strlen(new_type); + dns_result = dns_rdatatype_fromtext(&new_rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + new_type, dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = class; + textregion.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataclass_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_rdata_init(&added_rdata); + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); + added_rdata.length = 4; + added_rdata.rdclass = rdataclass; + added_rdata.type = new_rdatatype; + + dns_rdataset_init(&added_rdataset); + rdatalist.type = new_rdatatype; + rdatalist.covers = 0; + rdatalist.rdclass = rdataclass; + rdatalist.ttl = 0; + ISC_LIST_INIT(rdatalist.rdata); + ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); + + dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatalist_tordataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, + &added_rdataset, 0, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_addrdataset failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Check that our changes took. + */ + dns_db_detachnode(db, &nodep); + nodep = NULL; + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&found_rdataset); + + /* + * Find the recently added name and rdata. + */ + dns_result = dns_db_find(db, dns_fixedname_name(&dns_newname), + nversionp, new_rdatatype, 0, 0, &nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + if ((dns_result == ISC_R_NOTFOUND) || + (dns_result == DNS_R_NXDOMAIN) || + (dns_result == DNS_R_NXRRSET)) { + + t_info("dns_db_find failed %s\n", + dns_result_totext(dns_result)); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + dns_result = dns_rdataset_first(&found_rdataset); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdataset_first failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_closeversion(db, &nversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Now make sure its what we expect. + */ + dns_rdata_init(&found_rdata); + dns_rdataset_current(&found_rdataset, &found_rdata); + rval = dns_rdata_compare(&added_rdata, &found_rdata); + if (rval != 0) { + t_info("dns_rdata_compare returned %d\n", rval); + ++nfails; + } + + /* + * Now check the rdata deletion. + */ + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_rdataset_init(&found_rdataset); + dns_db_detachnode(db, &nodep); + nodep = NULL; + dns_fixedname_init(&dns_foundname); + + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_existingname), + nversionp, + existing_rdatatype, + 0, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + t_info("dns_db_find %s returned %s\n", existing_name, + dns_result_totext(dns_result)); + if (dns_rdataset_isassociated(&found_rdataset)) + dns_rdataset_disassociate(&found_rdataset); + dns_db_detachnode(db, &nodep); + ++nfails; + } + + + /* + * Close the version without a commit. + */ + dns_db_closeversion(db, &nversionp, ISC_FALSE); + + /* + * Open the current version and check changes. + */ + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&found_rdataset); + cversionp = NULL; + dns_db_currentversion(db, &cversionp); + + /* + * Find the recently added name and rdata. + */ + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_newname), + cversionp, + new_rdatatype, + 0, + 0, + &nodep, + dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + t_info("dns_db_find %s returned %s\n", new_name, + dns_result_totext(dns_result)); + dns_rdataset_disassociate(&found_rdataset); + dns_db_detachnode(db, &nodep); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Now check the rdata deletion. + */ + nodep = NULL; + dns_rdataset_init(&found_rdataset); + dns_fixedname_init(&dns_foundname); + + dns_result = dns_db_find(db, dns_fixedname_name(&dns_existingname), + cversionp, existing_rdatatype, 0, 0, + &nodep, dns_fixedname_name(&dns_foundname), + &found_rdataset, NULL); + + + if ((dns_result == ISC_R_NOTFOUND) || + (dns_result == DNS_R_NXDOMAIN) || + (dns_result == DNS_R_NXRRSET)) { + + t_info("dns_db_find %s returned %s\n", existing_name, + dns_result_totext(dns_result)); + dns_rdataset_disassociate(&found_rdataset); + dns_db_detachnode(db, &nodep); + ++nfails; + } + + dns_db_detachnode(db, &nodep); + dns_rdataset_disassociate(&found_rdataset); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + if (nfails == 0) + result = T_PASS; + else + result = T_FAIL; + + return(result); +} + +static void +t11(void) { + int result; + + t_assert("dns_db_closeversion", 11, T_REQUIRED, a11); + result = t_eval("dns_db_closeversion_2_data", + t_dns_db_closeversion_2, 9); + t_result(result); +} + +static const char *a12 = + "A call to dns_db_expirenode() marks as stale all records at node " + "which expire at or before 'now'. If 'now' is zero, then the current " + "time will be used."; + +static int +t_dns_db_expirenode(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *existing_name; + char *node_xtime; + char *find_xtime; + char *exp_find_result; + + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t exp_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_buffer_t name_buffer; + dns_fixedname_t dns_foundname; + dns_fixedname_t dns_existingname; + isc_stdtime_t node_expire_time; + isc_stdtime_t find_expire_time; + isc_stdtime_t now; + dns_rdataset_t rdataset; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + existing_name = T_ARG(4); + node_xtime = T_ARG(5); + find_xtime = T_ARG(6); + exp_find_result = T_ARG(7); + mctx = NULL; + ectx = NULL; + + result = T_UNRESOLVED; + + /* + * Find a node, mark it as stale, do a dns_db_find on the name and + * expect it to fail. + */ + + t_info("testing using file %s and name %s\n", filename, existing_name); + + node_expire_time = (isc_stdtime_t) strtol(node_xtime, NULL, 10); + find_expire_time = (isc_stdtime_t) strtol(find_xtime, NULL, 10); + exp_result = t_dns_result_fromtext(exp_find_result); + + isc_stdtime_get(&now); + + dns_fixedname_init(&dns_existingname); + len = strlen(existing_name); + isc_buffer_init(&name_buffer, existing_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), + &name_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + db = NULL; + dns_result = t_create(db_type, origin, class, "cache", mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + + /* + * Check that the node is there. + */ + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), + ISC_FALSE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("unable to find %s\n", existing_name); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Expire it. + */ + if (node_expire_time != 0) + node_expire_time += now; + + dns_result = dns_db_expirenode(db, nodep, node_expire_time); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_expirenode failed %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&rdataset); + dns_db_detachnode(db, &nodep); + nodep = NULL; + + if (find_expire_time != 0) + find_expire_time += now; + + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_existingname), + NULL, + dns_rdatatype_any, + 0, + find_expire_time, + &nodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + if (dns_result == exp_result) { + result = T_PASS; + } else { + t_info("dns_db_find %s returned %s\n", existing_name, + dns_result_totext(dns_result)); + result = T_FAIL; + } + + if ((dns_result != ISC_R_NOTFOUND) && + (dns_result != DNS_R_NXDOMAIN) && + (dns_result != DNS_R_NXRRSET)) { + + /* + * Don't need to disassociate the rdataset because + * we're searching with dns_rdatatype_any. + */ + dns_db_detachnode(db, &nodep); + } + + + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + return(result); +} + +static void +t12(void) { + int result; + + t_assert("dns_db_expirenode", 12, T_REQUIRED, a12); + result = t_eval("dns_db_expirenode_data", t_dns_db_expirenode, 8); + t_result(result); +} + +static const char *a13 = + "If the node name exists, then a call to " + "dns_db_findnode(db, name, ISC_FALSE, nodep) initializes nodep " + "to point to the node and returns ISC_R_SUCCESS, otherwise " + "it returns ISC_R_NOTFOUND."; + +static int +t_dns_db_findnode_1(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *find_name; + char *find_type; + char *expected_result; + + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_buffer_t name_buffer; + dns_rdataset_t rdataset; + dns_rdatatype_t rdatatype; + isc_textregion_t textregion; + dns_fixedname_t dns_name; + dns_dbversion_t *cversionp; + isc_result_t exp_result; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + find_name = T_ARG(5); + find_type = T_ARG(6); + expected_result = T_ARG(7); + + db = NULL; + mctx = NULL; + ectx = NULL; + result = T_UNRESOLVED; + + t_info("testing using file %s and name %s\n", filename, find_name); + + exp_result = t_dns_result_fromtext(expected_result); + + textregion.base = find_type; + textregion.length = strlen(find_type); + dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + find_type, + dns_result_totext(dns_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + dns_fixedname_init(&dns_name); + + len = strlen(find_name); + isc_buffer_init(&name_buffer, find_name, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name), + &name_buffer, NULL, ISC_FALSE, NULL); + + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), + ISC_FALSE, &nodep); + if (dns_result != exp_result) { + t_info("dns_db_findnode failed %s\n", + dns_result_totext(dns_result)); + if (dns_result == ISC_R_SUCCESS) + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * if we're expecting the find to succeed and it did, + * check that the node has been initialized + * by checking for the specified type of rdata + * and expecting the search to succeed + */ + + if (dns_result == ISC_R_SUCCESS) { + cversionp = NULL; + dns_db_currentversion(db, &cversionp); + dns_rdataset_init(&rdataset); + + dns_result = dns_db_findrdataset(db, nodep, cversionp, + rdatatype, 0, + 0, &rdataset, NULL); + if (dns_result == ISC_R_SUCCESS) { + dns_rdataset_disassociate(&rdataset); + result = T_PASS; + } else { + t_info("dns_db_findrdataset failed %s\n", + dns_result_totext(dns_result)); + result = T_FAIL; + } + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detachnode(db, &nodep); + } else { + result = T_PASS; + } + + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + return(result); +} + +static void +t13(void) { + int result; + + t_assert("dns_db_findnode", 13, T_REQUIRED, a13); + result = t_eval("dns_db_findnode_1_data", t_dns_db_findnode_1, 8); + t_result(result); +} + +static const char *a14 = + "If the node name does not exist and create is ISC_TRUE, " + "then a call to dns_db_findnode(db, name, create, nodep) " + "creates the node, initializes nodep to point to the node, " + "and returns ISC_R_SUCCESS."; + +static int +t_dns_db_findnode_2(char **av) { + char *filename; + char *db_type; + char *origin; + char *class; + char *model; + char *newname; + + int nfails; + int result; + int len; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + dns_dbnode_t *newnodep; + isc_buffer_t name_buffer; + dns_rdataset_t rdataset; + dns_fixedname_t dns_name; + dns_fixedname_t dns_foundname; + dns_dbversion_t *cversionp; + + filename = T_ARG(0); + db_type = T_ARG(1); + origin = T_ARG(2); + class = T_ARG(3); + model = T_ARG(4); + newname = T_ARG(5); + + result = T_UNRESOLVED; + db = NULL; + mctx = NULL; + ectx = NULL; + nfails = 0; + + t_info("testing using file %s and name %s\n", filename, newname); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + dns_result = t_create(db_type, origin, class, model, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, filename); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + nodep = NULL; + dns_fixedname_init(&dns_name); + + /* + * Make sure the name isn't there + */ + len = strlen(newname); + isc_buffer_init(&name_buffer, newname, len); + isc_buffer_add(&name_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name), + &name_buffer, NULL, ISC_FALSE, NULL); + + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), + ISC_FALSE, &nodep); + if ((dns_result != ISC_R_NOTFOUND) && + (dns_result != DNS_R_NXDOMAIN) && + (dns_result != DNS_R_NXRRSET)) { + t_info("dns_db_findnode %s\n", + dns_result_totext(dns_result)); + dns_db_detachnode(db, &nodep); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + /* + * Add it. + */ + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), + ISC_TRUE, &nodep); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_findnode %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_FAIL); + } + + /* + * Check it. + */ + newnodep = NULL; + dns_rdataset_init(&rdataset); + dns_fixedname_init(&dns_foundname); + cversionp = NULL; + dns_db_currentversion(db, &cversionp); + + /* + * First try dns_db_find DNS_R_NXDOMAIN. + */ + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_name), + cversionp, + dns_rdatatype_any, + 0, + 0, + &newnodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + dns_db_detachnode(db, &newnodep); + } + + if (dns_result != DNS_R_NXDOMAIN) { + t_info("dns_db_find %s\n", + dns_result_totext(dns_result)); + ++nfails; + } + + /* + * Then try dns_db_findnode ISC_R_SUCCESS. + */ + dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), + ISC_FALSE, &newnodep); + t_info("dns_db_findnode %s\n", dns_result_totext(dns_result)); + if (dns_result == ISC_R_SUCCESS) { + dns_db_detachnode(db, &newnodep); + } else { + t_info("dns_db_findnode %s failed %s\n", newname, + dns_result_totext(dns_result)); + ++nfails; + } + + + dns_db_detachnode(db, &nodep); + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + if (nfails == 0) + result = T_PASS; + else + result = T_FAIL; + + return(result); +} + +static void +t14(void) { + int result; + + t_assert("dns_db_findnode", 14, T_REQUIRED, a14); + result = t_eval("dns_db_findnode_2_data", t_dns_db_findnode_2, 6); + t_result(result); +} + +static int +t_dns_db_find_x(char **av) { + char *dbfile; + char *dbtype; + char *dborigin; + char *dbclass; + char *dbmodel; + char *findname; + char *findtype; + char *findopts; + char *findtime; + char *expected_result; + + int result; + int len; + int opts; + dns_db_t *db; + isc_result_t dns_result; + isc_result_t isc_result; + isc_stdtime_t ftime; + isc_stdtime_t now; + isc_result_t exp_result; + isc_mem_t *mctx; + isc_entropy_t *ectx; + dns_dbnode_t *nodep; + isc_textregion_t textregion; + isc_buffer_t findname_buffer; + dns_fixedname_t dns_findname; + dns_fixedname_t dns_foundname; + dns_rdataset_t rdataset; + dns_rdatatype_t rdatatype; + dns_dbversion_t *cversionp; + + result = T_UNRESOLVED; + + dbfile = T_ARG(0); + dbtype = T_ARG(1); + dborigin = T_ARG(2); + dbclass = T_ARG(3); + dbmodel = T_ARG(4); + findname = T_ARG(5); + findtype = T_ARG(6); + findopts = T_ARG(7); + findtime = T_ARG(8); + expected_result = T_ARG(9); + db = NULL; + mctx = NULL; + ectx = NULL; + opts = 0; + + t_info("testing using %s, name %s, type %s\n", dbfile, findname, + findtype); + + isc_result = isc_mem_create(0, 0, &mctx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_mem_create failed %s\n", + isc_result_totext(isc_result)); + return(T_UNRESOLVED); + } + + isc_result = isc_entropy_create(mctx, &ectx); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_entropy_create failed %s\n", + isc_result_totext(isc_result)); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); + if (isc_result != ISC_R_SUCCESS) { + t_info("isc_hash_create failed %s\n", + isc_result_totext(isc_result)); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = t_create(dbtype, dborigin, dbclass, dbmodel, mctx, &db); + if (dns_result != ISC_R_SUCCESS) { + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + dns_result = dns_db_load(db, dbfile); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_db_load returned %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + exp_result = t_dns_result_fromtext(expected_result); + + dns_fixedname_init(&dns_findname); + len = strlen(findname); + isc_buffer_init(&findname_buffer, findname, len); + isc_buffer_add(&findname_buffer, len); + dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), + &findname_buffer, NULL, ISC_FALSE, NULL); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + textregion.base = findtype; + textregion.length = strlen(findtype); + dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); + if (dns_result != ISC_R_SUCCESS) { + t_info("dns_rdatatype_fromtext %s failed %s\n", + findtype, + dns_result_totext(dns_result)); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } + + if (strstr(findopts, "DNS_DBFIND_GLUEOK")) + opts |= DNS_DBFIND_GLUEOK; + if (strstr(findopts, "DNS_DBFIND_VALIDATEGLUE")) + opts |= DNS_DBFIND_VALIDATEGLUE; + + isc_stdtime_get(&now); + + ftime = strtol(findtime, NULL, 10); + if (ftime != 0) + ftime += now; + + cversionp = NULL; + dns_fixedname_init(&dns_foundname); + dns_rdataset_init(&rdataset); + if (dns_db_iszone(db)) + dns_db_currentversion(db, &cversionp); + nodep = NULL; + + dns_result = dns_db_find(db, + dns_fixedname_name(&dns_findname), + cversionp, + rdatatype, + opts, + ftime, + &nodep, + dns_fixedname_name(&dns_foundname), + &rdataset, NULL); + + if (dns_result != exp_result) { + t_info("dns_db_find %s %s unexpectedly returned %s, " + "expected %s\n", + findname, findtype, dns_result_totext(dns_result), + dns_result_totext(exp_result)); + result = T_FAIL; + } else { + result = T_PASS; + } + + if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { + + if ((dns_result != DNS_R_NXRRSET) && + (dns_result != DNS_R_ZONECUT)) + if (dns_rdataset_isassociated(&rdataset)) + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &nodep); + } + + if (dns_db_iszone(db)) + dns_db_closeversion(db, &cversionp, ISC_FALSE); + dns_db_detach(&db); + isc_hash_destroy(); + isc_entropy_detach(&ectx); + isc_mem_destroy(&mctx); + + return(result); +} + +static const char *a15 = + "A call to dns_db_find(db, name, version, type, options, now, ...) " + "finds the best match for 'name' and 'type' in version 'version' " + "of 'db'."; + +static void +t15(void) { + int result; + + t_assert("dns_db_find", 15, T_REQUIRED, a15); + result = t_eval("dns_db_find_1_data", t_dns_db_find_x, 10); + t_result(result); +} + + +static const char *a16 = + "When the desired node and type were found, but are glue, " + "and the DNS_DBFIND_GLUEOK option is set, a call to " + "dns_db_find(db, name, version, type, options, now, ...) " + "returns DNS_R_GLUE."; + +static void +t16(void) { + int result; + + t_assert("dns_db_find", 16, T_REQUIRED, a16); + result = t_eval("dns_db_find_2_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a17 = + "A call to dns_db_find() returns DNS_R_DELEGATION when the data " + "requested is beneath a zone cut."; + +static void +t17(void) { + int result; + + t_assert("dns_db_find", 17, T_REQUIRED, a17); + result = t_eval("dns_db_find_3_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a18 = + "A call to dns_db_find() returns DNS_R_DELEGATION when type is " + "dns_rdatatype_any and the desired node is a zone cut."; + +static void +t18(void) { + int result; + + t_assert("dns_db_find", 18, T_REQUIRED, a18); + result = t_eval("dns_db_find_4_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a19 = + "A call to dns_db_find() returns DNS_R_DNAME when the data " + "requested is beneath a DNAME."; + +static void +t19(void) { + int result; + + t_assert("dns_db_find", 19, T_REQUIRED, a19); + result = t_eval("dns_db_find_5_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a20 = + "A call to dns_db_find() returns DNS_R_CNAME when the requested " + "rdataset was not found but there is a CNAME at the desired name."; + +static void +t20(void) { + int result; + + t_assert("dns_db_find", 20, T_REQUIRED, a20); + result = t_eval("dns_db_find_6_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a21 = + "A call to dns_db_find() returns DNS_R_NXDOMAIN when name " + "does not exist."; + +static void +t21(void) { + int result; + + t_assert("dns_db_find", 21, T_REQUIRED, a21); + result = t_eval("dns_db_find_7_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a22 = + "A call to dns_db_find() returns DNS_R_NXRRSET when " + "the desired name exists, but the desired type does not."; + +static void +t22(void) { + int result; + + t_assert("dns_db_find", 22, T_REQUIRED, a22); + result = t_eval("dns_db_find_8_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a23 = + "When db is a cache database, a call to dns_db_find() " + "returns ISC_R_NOTFOUND when the desired name does not exist, " + "and no delegation could be found."; + +static void +t23(void) { + int result; + + t_assert("dns_db_find", 23, T_REQUIRED, a23); + result = t_eval("dns_db_find_9_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a24 = + "When db is a cache database, an rdataset will be found only " + "if at least one rdataset at the found node expires after 'now'."; + +static void +t24(void) { + int result; + + t_assert("dns_db_find", 24, T_REQUIRED, a24); + result = t_eval("dns_db_find_10_data", t_dns_db_find_x, 10); + t_result(result); +} + +static const char *a25 = + "A call to dns_db_load(db, filename) returns DNS_R_NOTZONETOP " + "when the zone data contains a SOA not at the zone apex."; + +static void +t25(void) { + int result; + + t_assert("dns_db_load", 25, T_REQUIRED, a25); + result = t_eval("dns_db_load_soa_not_top", t_dns_db_load, 9); + t_result(result); +} + +testspec_t T_testlist[] = { + { t1, "dns_db_load" }, + { t2, "dns_db_iscache" }, + { t3, "dns_db_iscache" }, + { t4, "dns_db_iszone" }, + { t5, "dns_db_iszone" }, + { t6, "dns_db_origin" }, + { t7, "dns_db_class" }, + { t8, "dns_db_currentversion" }, + { t9, "dns_db_newversion" }, + { t10, "dns_db_closeversion" }, + { t11, "dns_db_closeversion" }, + { t12, "dns_db_expirenode" }, + { t13, "dns_db_findnode" }, + { t14, "dns_db_findnode" }, + { t15, "dns_db_find" }, + { t16, "dns_db_find" }, + { t17, "dns_db_find" }, + { t18, "dns_db_find" }, + { t19, "dns_db_find" }, + { t20, "dns_db_find" }, + { t21, "dns_db_find" }, + { t22, "dns_db_find" }, + { t23, "dns_db_find" }, + { t24, "dns_db_find" }, + { t25, "dns_db_load" }, + { NULL, NULL } +}; diff --git a/bin/tests/db_test.c b/bin/tests/db_test.c new file mode 100644 index 0000000..9b0d90d --- /dev/null +++ b/bin/tests/db_test.c @@ -0,0 +1,946 @@ +/* + * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: db_test.c,v 1.66 2008/09/25 04:02:38 tbox Exp $ */ + +/*! \file + * \author + * Principal Author: Bob Halley + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXHOLD 100 +#define MAXVERSIONS 100 + +typedef struct dbinfo { + dns_db_t * db; + dns_dbversion_t * version; + dns_dbversion_t * wversion; + dns_dbversion_t * rversions[MAXVERSIONS]; + int rcount; + dns_dbnode_t * hold_nodes[MAXHOLD]; + int hold_count; + dns_dbiterator_t * dbiterator; + dns_dbversion_t * iversion; + int pause_every; + isc_boolean_t ascending; + ISC_LINK(struct dbinfo) link; +} dbinfo; + +static isc_mem_t * mctx = NULL; +static char dbtype[128]; +static dns_dbtable_t * dbtable; +static ISC_LIST(dbinfo) dbs; +static dbinfo * cache_dbi = NULL; +static int pause_every = 0; +static isc_boolean_t ascending = ISC_TRUE; + +static void +print_result(const char *message, isc_result_t result) { + size_t len; + + if (message == NULL) { + len = 0; + message = ""; + } + len = strlen(message); + printf("%s%sresult %08x: %s\n", message, (len == 0U) ? "" : " ", + result, isc_result_totext(result)); +} + +static void +print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) { + isc_buffer_t text; + char t[1000]; + isc_result_t result; + isc_region_t r; + + isc_buffer_init(&text, t, sizeof(t)); + result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE, + &text); + isc_buffer_usedregion(&text, &r); + if (result == ISC_R_SUCCESS) + printf("%.*s", (int)r.length, (char *)r.base); + else + print_result("", result); +} + +static void +print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter) { + isc_result_t result; + dns_rdataset_t rdataset; + + dns_rdataset_init(&rdataset); + result = dns_rdatasetiter_first(rdsiter); + while (result == ISC_R_SUCCESS) { + dns_rdatasetiter_current(rdsiter, &rdataset); + print_rdataset(name, &rdataset); + dns_rdataset_disassociate(&rdataset); + result = dns_rdatasetiter_next(rdsiter); + } + if (result != ISC_R_NOMORE) + print_result("", result); +} + +static dbinfo * +select_db(char *origintext) { + dns_fixedname_t forigin; + dns_name_t *origin; + isc_buffer_t source; + size_t len; + dbinfo *dbi; + isc_result_t result; + + if (strcasecmp(origintext, "cache") == 0) { + if (cache_dbi == NULL) + printf("the cache does not exist\n"); + return (cache_dbi); + } + len = strlen(origintext); + isc_buffer_init(&source, origintext, len); + isc_buffer_add(&source, len); + dns_fixedname_init(&forigin); + origin = dns_fixedname_name(&forigin); + result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE, + NULL); + if (result != ISC_R_SUCCESS) { + print_result("bad name", result); + return (NULL); + } + + for (dbi = ISC_LIST_HEAD(dbs); + dbi != NULL; + dbi = ISC_LIST_NEXT(dbi, link)) { + if (dns_name_compare(dns_db_origin(dbi->db), origin) == 0) + break; + } + + return (dbi); +} + +static void +list(dbinfo *dbi, char *seektext) { + dns_fixedname_t fname; + dns_name_t *name; + dns_dbnode_t *node; + dns_rdatasetiter_t *rdsiter; + isc_result_t result; + int i; + size_t len; + dns_fixedname_t fseekname; + dns_name_t *seekname; + isc_buffer_t source; + + dns_fixedname_init(&fname); + name = dns_fixedname_name(&fname); + + if (dbi->dbiterator == NULL) { + INSIST(dbi->iversion == NULL); + if (dns_db_iszone(dbi->db)) { + if (dbi->version != NULL) + dns_db_attachversion(dbi->db, dbi->version, + &dbi->iversion); + else + dns_db_currentversion(dbi->db, &dbi->iversion); + } + + result = dns_db_createiterator(dbi->db, 0, &dbi->dbiterator); + if (result == ISC_R_SUCCESS) { + if (seektext != NULL) { + len = strlen(seektext); + isc_buffer_init(&source, seektext, len); + isc_buffer_add(&source, len); + dns_fixedname_init(&fseekname); + seekname = dns_fixedname_name(&fseekname); + result = dns_name_fromtext(seekname, &source, + dns_db_origin( + dbi->db), + ISC_FALSE, + NULL); + if (result == ISC_R_SUCCESS) + result = dns_dbiterator_seek( + dbi->dbiterator, + seekname); + } else if (dbi->ascending) + result = dns_dbiterator_first(dbi->dbiterator); + else + result = dns_dbiterator_last(dbi->dbiterator); + } + } else + result = ISC_R_SUCCESS; + + node = NULL; + rdsiter = NULL; + i = 0; + while (result == ISC_R_SUCCESS) { + result = dns_dbiterator_current(dbi->dbiterator, &node, name); + if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) + break; + result = dns_db_allrdatasets(dbi->db, node, dbi->iversion, 0, + &rdsiter); + if (result != ISC_R_SUCCESS) { + dns_db_detachnode(dbi->db, &node); + break; + } + print_rdatasets(name, rdsiter); + dns_rdatasetiter_destroy(&rdsiter); + dns_db_detachnode(dbi->db, &node); + if (dbi->ascending) + result = dns_dbiterator_next(dbi->dbiterator); + else + result = dns_dbiterator_prev(dbi->dbiterator); + i++; + if (result == ISC_R_SUCCESS && i == dbi->pause_every) { + printf("[more...]\n"); + result = dns_dbiterator_pause(dbi->dbiterator); + if (result == ISC_R_SUCCESS) + return; + } + } + if (result != ISC_R_NOMORE) + print_result("", result); + + dns_dbiterator_destroy(&dbi->dbiterator); + if (dbi->iversion != NULL) + dns_db_closeversion(dbi->db, &dbi->iversion, ISC_FALSE); +} + +static isc_result_t +load(const char *filename, const char *origintext, isc_boolean_t cache) { + dns_fixedname_t forigin; + dns_name_t *origin; + isc_result_t result; + isc_buffer_t source; + size_t len; + dbinfo *dbi; + unsigned int i; + + dbi = isc_mem_get(mctx, sizeof(*dbi)); + if (dbi == NULL) + return (ISC_R_NOMEMORY); + + dbi->db = NULL; + dbi->version = NULL; + dbi->wversion = NULL; + for (i = 0; i < MAXVERSIONS; i++) + dbi->rversions[i] = NULL; + dbi->hold_count = 0; + for (i = 0; i < MAXHOLD; i++) + dbi->hold_nodes[i] = NULL; + dbi->dbiterator = NULL; + dbi->iversion = NULL; + dbi->pause_every = pause_every; + dbi->ascending = ascending; + ISC_LINK_INIT(dbi, link); + + len = strlen(origintext); + isc_buffer_init(&source, origintext, len); + isc_buffer_add(&source, len); + dns_fixedname_init(&forigin); + origin = dns_fixedname_name(&forigin); + result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE, + NULL); + if (result != ISC_R_SUCCESS) + return (result); + + result = dns_db_create(mctx, dbtype, origin, + cache ? dns_dbtype_cache : dns_dbtype_zone, + dns_rdataclass_in, + 0, NULL, &dbi->db); + if (result != ISC_R_SUCCESS) { + isc_mem_put(mctx, dbi, sizeof(*dbi)); + return (result); + } + + printf("loading %s (%s)\n", filename, origintext); + result = dns_db_load(dbi->db, filename); + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) { + dns_db_detach(&dbi->db); + isc_mem_put(mctx, dbi, sizeof(*dbi)); + return (result); + } + printf("loaded\n"); + + if (cache) { + INSIST(cache_dbi == NULL); + dns_dbtable_adddefault(dbtable, dbi->db); + cache_dbi = dbi; + } else { + if (dns_dbtable_add(dbtable, dbi->db) != ISC_R_SUCCESS) { + dns_db_detach(&dbi->db); + isc_mem_put(mctx, dbi, sizeof(*dbi)); + return (result); + } + } + ISC_LIST_APPEND(dbs, dbi, link); + + return (ISC_R_SUCCESS); +} + +static void +unload_all(void) { + dbinfo *dbi, *dbi_next; + + for (dbi = ISC_LIST_HEAD(dbs); dbi != NULL; dbi = dbi_next) { + dbi_next = ISC_LIST_NEXT(dbi, link); + if (dns_db_iszone(dbi->db)) + dns_dbtable_remove(dbtable, dbi->db); + else { + INSIST(dbi == cache_dbi); + dns_dbtable_removedefault(dbtable); + cache_dbi = NULL; + } + dns_db_detach(&dbi->db); + ISC_LIST_UNLINK(dbs, dbi, link); + isc_mem_put(mctx, dbi, sizeof(*dbi)); + } +} + +#define DBI_CHECK(dbi) \ +if ((dbi) == NULL) { \ + printf("You must first select a database with !DB\n"); \ + continue; \ +} + +int +main(int argc, char *argv[]) { + dns_db_t *db; + dns_dbnode_t *node; + isc_result_t result; + dns_name_t name; + dns_offsets_t offsets; + size_t len; + isc_buffer_t source, target; + char s[1000]; + char b[255]; + dns_rdataset_t rdataset, sigrdataset; + int ch; + dns_rdatatype_t type = 1; + isc_boolean_t printnode = ISC_FALSE; + isc_boolean_t addmode = ISC_FALSE; + isc_boolean_t delmode = ISC_FALSE; + isc_boolean_t holdmode = ISC_FALSE; + isc_boolean_t verbose = ISC_FALSE; + isc_boolean_t done = ISC_FALSE; + isc_boolean_t quiet = ISC_FALSE; + isc_boolean_t time_lookups = ISC_FALSE; + isc_boolean_t found_as; + isc_boolean_t find_zonecut = ISC_FALSE; + isc_boolean_t noexact_zonecut = ISC_FALSE; + int i, v; + dns_rdatasetiter_t *rdsiter; + char t1[256]; + char t2[256]; + isc_buffer_t tb1, tb2; + isc_region_t r1, r2; + dns_fixedname_t foundname; + dns_name_t *fname; + unsigned int options = 0, zcoptions; + isc_time_t start, finish; + char *origintext; + dbinfo *dbi; + dns_dbversion_t *version; + dns_name_t *origin; + size_t memory_quota = 0; + dns_trust_t trust = 0; + unsigned int addopts; + isc_log_t *lctx = NULL; + + dns_result_register(); + + RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) == + ISC_R_SUCCESS); + + + + strcpy(dbtype, "rbt"); + while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:glpqvT")) + != -1) { + switch (ch) { + case 'c': + result = load(isc_commandline_argument, ".", ISC_TRUE); + if (result != ISC_R_SUCCESS) + printf("cache load(%s) %08x: %s\n", + isc_commandline_argument, result, + isc_result_totext(result)); + break; + case 'd': + strcpy(dbtype, isc_commandline_argument); + break; + case 'g': + options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE); + break; + case 'l': + RUNTIME_CHECK(isc_log_create(mctx, &lctx, + NULL) == ISC_R_SUCCESS); + isc_log_setcontext(lctx); + dns_log_init(lctx); + dns_log_setcontext(lctx); + break; + case 'q': + quiet = ISC_TRUE; + verbose = ISC_FALSE; + break; + case 'p': + printnode = ISC_TRUE; + break; + case 'P': + pause_every = atoi(isc_commandline_argument); + break; + case 'Q': + memory_quota = atoi(isc_commandline_argument); + isc_mem_setquota(mctx, memory_quota); + break; + case 't': + type = atoi(isc_commandline_argument); + break; + case 'T': + time_lookups = ISC_TRUE; + break; + case 'v': + verbose = ISC_TRUE; + break; + case 'z': + origintext = strrchr(isc_commandline_argument, '/'); + if (origintext == NULL) + origintext = isc_commandline_argument; + else + origintext++; /* Skip '/'. */ + result = load(isc_commandline_argument, origintext, + ISC_FALSE); + if (result != ISC_R_SUCCESS) + printf("zone load(%s) %08x: %s\n", + isc_commandline_argument, result, + isc_result_totext(result)); + break; + } + } + + argc -= isc_commandline_index; + argv += isc_commandline_index; + + if (argc != 0) + printf("ignoring trailing arguments\n"); + + /* + * Some final initialization... + */ + dns_fixedname_init(&foundname); + fname = dns_fixedname_name(&foundname); + dbi = NULL; + origin = dns_rootname; + version = NULL; + + if (time_lookups) { + TIME_NOW(&start); + } + + while (!done) { + if (!quiet) + printf("\n"); + if (fgets(s, sizeof(s), stdin) == NULL) { + done = ISC_TRUE; + continue; + } + len = strlen(s); + if (len > 0U && s[len - 1] == '\n') { + s[len - 1] = '\0'; + len--; + } + if (verbose && dbi != NULL) { + if (dbi->wversion != NULL) + printf("future version (%p)\n", dbi->wversion); + for (i = 0; i < dbi->rcount; i++) + if (dbi->rversions[i] != NULL) + printf("open version %d (%p)\n", i, + dbi->rversions[i]); + } + dns_name_init(&name, offsets); + if (strcmp(s, "!R") == 0) { + DBI_CHECK(dbi); + if (dbi->rcount == MAXVERSIONS) { + printf("too many open versions\n"); + continue; + } + dns_db_currentversion(dbi->db, + &dbi->rversions[dbi->rcount]); + printf("opened version %d\n", dbi->rcount); + dbi->version = dbi->rversions[dbi->rcount]; + version = dbi->version; + dbi->rcount++; + continue; + } else if (strcmp(s, "!W") == 0) { + DBI_CHECK(dbi); + if (dbi->wversion != NULL) { + printf("using existing future version\n"); + dbi->version = dbi->wversion; + version = dbi->version; + continue; + } + result = dns_db_newversion(dbi->db, &dbi->wversion); + if (result != ISC_R_SUCCESS) + print_result("", result); + else + printf("newversion\n"); + dbi->version = dbi->wversion; + version = dbi->version; + continue; + } else if (strcmp(s, "!C") == 0) { + DBI_CHECK(dbi); + addmode = ISC_FALSE; + delmode = ISC_FALSE; + if (dbi->version == NULL) + continue; + if (dbi->version == dbi->wversion) { + printf("closing future version\n"); + dbi->wversion = NULL; + } else { + for (i = 0; i < dbi->rcount; i++) { + if (dbi->version == + dbi->rversions[i]) { + dbi->rversions[i] = NULL; + printf("closing open version %d\n", + i); + break; + } + } + } + dns_db_closeversion(dbi->db, &dbi->version, ISC_TRUE); + version = NULL; + continue; + } else if (strcmp(s, "!X") == 0) { + DBI_CHECK(dbi); + addmode = ISC_FALSE; + delmode = ISC_FALSE; + if (dbi->version == NULL) + continue; + if (dbi->version == dbi->wversion) { + printf("aborting future version\n"); + dbi->wversion = NULL; + } else { + for (i = 0; i < dbi->rcount; i++) { + if (dbi->version == + dbi->rversions[i]) { + dbi->rversions[i] = NULL; + printf("closing open version %d\n", + i); + break; + } + } + } + dns_db_closeversion(dbi->db, &dbi->version, ISC_FALSE); + version = NULL; + continue; + } else if (strcmp(s, "!A") == 0) { + DBI_CHECK(dbi); + delmode = ISC_FALSE; + if (addmode) + addmode = ISC_FALSE; + else + addmode = ISC_TRUE; + printf("addmode = %s\n", addmode ? "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!D") == 0) { + DBI_CHECK(dbi); + addmode = ISC_FALSE; + if (delmode) + delmode = ISC_FALSE; + else + delmode = ISC_TRUE; + printf("delmode = %s\n", delmode ? "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!H") == 0) { + DBI_CHECK(dbi); + if (holdmode) + holdmode = ISC_FALSE; + else + holdmode = ISC_TRUE; + printf("holdmode = %s\n", holdmode ? "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!HR") == 0) { + DBI_CHECK(dbi); + for (i = 0; i < dbi->hold_count; i++) + dns_db_detachnode(dbi->db, + &dbi->hold_nodes[i]); + dbi->hold_count = 0; + holdmode = ISC_FALSE; + printf("held nodes have been detached\n"); + continue; + } else if (strcmp(s, "!VC") == 0) { + DBI_CHECK(dbi); + printf("switching to current version\n"); + dbi->version = NULL; + version = NULL; + continue; + } else if (strstr(s, "!V") == s) { + DBI_CHECK(dbi); + v = atoi(&s[2]); + if (v >= dbi->rcount) { + printf("unknown open version %d\n", v); + continue; + } else if (dbi->rversions[v] == NULL) { + printf("version %d is not open\n", v); + continue; + } + printf("switching to open version %d\n", v); + dbi->version = dbi->rversions[v]; + version = dbi->version; + continue; + } else if (strstr(s, "!TR") == s) { + trust = (unsigned int)atoi(&s[3]); + printf("trust level is now %u\n", (unsigned int)trust); + continue; + } else if (strstr(s, "!T") == s) { + type = (unsigned int)atoi(&s[2]); + printf("now searching for type %u\n", type); + continue; + } else if (strcmp(s, "!G") == 0) { + if ((options & DNS_DBFIND_GLUEOK) != 0) + options &= ~DNS_DBFIND_GLUEOK; + else + options |= DNS_DBFIND_GLUEOK; + printf("glue ok = %s\n", + ((options & DNS_DBFIND_GLUEOK) != 0) ? + "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!GV") == 0) { + if ((options & DNS_DBFIND_VALIDATEGLUE) != 0) + options &= ~DNS_DBFIND_VALIDATEGLUE; + else + options |= DNS_DBFIND_VALIDATEGLUE; + printf("validate glue = %s\n", + ((options & DNS_DBFIND_VALIDATEGLUE) != 0) ? + "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!WC") == 0) { + if ((options & DNS_DBFIND_NOWILD) != 0) + options &= ~DNS_DBFIND_NOWILD; + else + options |= DNS_DBFIND_NOWILD; + printf("wildcard matching = %s\n", + ((options & DNS_DBFIND_NOWILD) == 0) ? + "TRUE" : "FALSE"); + continue; + } else if (strstr(s, "!LS ") == s) { + DBI_CHECK(dbi); + list(dbi, &s[4]); + continue; + } else if (strcmp(s, "!LS") == 0) { + DBI_CHECK(dbi); + list(dbi, NULL); + continue; + } else if (strstr(s, "!DU ") == s) { + DBI_CHECK(dbi); + result = dns_db_dump(dbi->db, dbi->version, s+4); + if (result != ISC_R_SUCCESS) { + printf("\n"); + print_result("", result); + } + continue; + } else if (strcmp(s, "!PN") == 0) { + if (printnode) + printnode = ISC_FALSE; + else + printnode = ISC_TRUE; + printf("printnode = %s\n", + printnode ? "TRUE" : "FALSE"); + continue; + } else if (strstr(s, "!P") == s) { + DBI_CHECK(dbi); + v = atoi(&s[2]); + dbi->pause_every = v; + continue; + } else if (strcmp(s, "!+") == 0) { + DBI_CHECK(dbi); + dbi->ascending = ISC_TRUE; + continue; + } else if (strcmp(s, "!-") == 0) { + DBI_CHECK(dbi); + dbi->ascending = ISC_FALSE; + continue; + } else if (strcmp(s, "!DB") == 0) { + dbi = NULL; + origin = dns_rootname; + version = NULL; + printf("now searching all databases\n"); + continue; + } else if (strncmp(s, "!DB ", 4) == 0) { + dbi = select_db(s+4); + if (dbi != NULL) { + db = dbi->db; + origin = dns_db_origin(dbi->db); + version = dbi->version; + addmode = ISC_FALSE; + delmode = ISC_FALSE; + holdmode = ISC_FALSE; + } else { + db = NULL; + version = NULL; + origin = dns_rootname; + printf("database not found; " + "now searching all databases\n"); + } + continue; + } else if (strcmp(s, "!ZC") == 0) { + if (find_zonecut) + find_zonecut = ISC_FALSE; + else + find_zonecut = ISC_TRUE; + printf("find_zonecut = %s\n", + find_zonecut ? "TRUE" : "FALSE"); + continue; + } else if (strcmp(s, "!NZ") == 0) { + if (noexact_zonecut) + noexact_zonecut = ISC_FALSE; + else + noexact_zonecut = ISC_TRUE; + printf("noexact_zonecut = %s\n", + noexact_zonecut ? "TRUE" : "FALSE"); + continue; + } + + isc_buffer_init(&source, s, len); + isc_buffer_add(&source, len); + isc_buffer_init(&target, b, sizeof(b)); + result = dns_name_fromtext(&name, &source, origin, + ISC_FALSE, &target); + if (result != ISC_R_SUCCESS) { + print_result("bad name: ", result); + continue; + } + + if (dbi == NULL) { + zcoptions = 0; + if (noexact_zonecut) + zcoptions |= DNS_DBTABLEFIND_NOEXACT; + db = NULL; + result = dns_dbtable_find(dbtable, &name, zcoptions, + &db); + if (result != ISC_R_SUCCESS && + result != DNS_R_PARTIALMATCH) { + if (!quiet) { + printf("\n"); + print_result("", result); + } + continue; + } + isc_buffer_init(&tb1, t1, sizeof(t1)); + result = dns_name_totext(dns_db_origin(db), ISC_FALSE, + &tb1); + if (result != ISC_R_SUCCESS) { + printf("\n"); + print_result("", result); + dns_db_detach(&db); + continue; + } + isc_buffer_usedregion(&tb1, &r1); + printf("\ndatabase = %.*s (%s)\n", + (int)r1.length, r1.base, + (dns_db_iszone(db)) ? "zone" : "cache"); + } + node = NULL; + dns_rdataset_init(&rdataset); + dns_rdataset_init(&sigrdataset); + + if (find_zonecut && dns_db_iscache(db)) { + zcoptions = options; + if (noexact_zonecut) + zcoptions |= DNS_DBFIND_NOEXACT; + result = dns_db_findzonecut(db, &name, zcoptions, + 0, &node, fname, + &rdataset, &sigrdataset); + } else { + result = dns_db_find(db, &name, version, type, + options, 0, &node, fname, + &rdataset, &sigrdataset); + } + + if (!quiet) { + if (dbi != NULL) + printf("\n"); + print_result("", result); + } + + found_as = ISC_FALSE; + switch (result) { + case ISC_R_SUCCESS: + case DNS_R_GLUE: + case DNS_R_CNAME: + case DNS_R_ZONECUT: + break; + case DNS_R_DNAME: + case DNS_R_DELEGATION: + found_as = ISC_TRUE; + break; + case DNS_R_NXRRSET: + if (dns_rdataset_isassociated(&rdataset)) + break; + if (dbi != NULL) { + if (holdmode) { + RUNTIME_CHECK(dbi->hold_count < + MAXHOLD); + dbi->hold_nodes[dbi->hold_count++] = + node; + node = NULL; + } else + dns_db_detachnode(db, &node); + } else { + dns_db_detachnode(db, &node); + dns_db_detach(&db); + } + continue; + case DNS_R_NXDOMAIN: + if (dns_rdataset_isassociated(&rdataset)) + break; + /* FALLTHROUGH */ + default: + if (dbi == NULL) + dns_db_detach(&db); + if (quiet) + print_result("", result); + continue; + } + if (found_as && !quiet) { + isc_buffer_init(&tb1, t1, sizeof(t1)); + isc_buffer_init(&tb2, t2, sizeof(t2)); + result = dns_name_totext(&name, ISC_FALSE, &tb1); + if (result != ISC_R_SUCCESS) { + print_result("", result); + dns_db_detachnode(db, &node); + if (dbi == NULL) + dns_db_detach(&db); + continue; + } + result = dns_name_totext(fname, ISC_FALSE, &tb2); + if (result != ISC_R_SUCCESS) { + print_result("", result); + dns_db_detachnode(db, &node); + if (dbi == NULL) + dns_db_detach(&db); + continue; + } + isc_buffer_usedregion(&tb1, &r1); + isc_buffer_usedregion(&tb2, &r2); + printf("found %.*s as %.*s\n", + (int)r1.length, r1.base, + (int)r2.length, r2.base); + } + + if (printnode) + dns_db_printnode(db, node, stdout); + + if (!found_as && type == dns_rdatatype_any) { + rdsiter = NULL; + result = dns_db_allrdatasets(db, node, version, 0, + &rdsiter); + if (result == ISC_R_SUCCESS) { + if (!quiet) + print_rdatasets(fname, rdsiter); + dns_rdatasetiter_destroy(&rdsiter); + } else + print_result("", result); + } else { + if (!quiet) + print_rdataset(fname, &rdataset); + if (dns_rdataset_isassociated(&sigrdataset)) { + if (!quiet) + print_rdataset(fname, &sigrdataset); + dns_rdataset_disassociate(&sigrdataset); + } + if (dbi != NULL && addmode && !found_as) { + rdataset.ttl++; + rdataset.trust = trust; + if (dns_db_iszone(db)) + addopts = DNS_DBADD_MERGE; + else + addopts = 0; + result = dns_db_addrdataset(db, node, version, + 0, &rdataset, + addopts, NULL); + if (result != ISC_R_SUCCESS) + print_result("", result); + if (printnode) + dns_db_printnode(db, node, stdout); + } else if (dbi != NULL && delmode && !found_as) { + result = dns_db_deleterdataset(db, node, + version, type, + 0); + if (result != ISC_R_SUCCESS) + print_result("", result); + if (printnode) + dns_db_printnode(db, node, stdout); + } + dns_rdataset_disassociate(&rdataset); + } + + if (dbi != NULL) { + if (holdmode) { + RUNTIME_CHECK(dbi->hold_count < MAXHOLD); + dbi->hold_nodes[dbi->hold_count++] = node; + node = NULL; + } else + dns_db_detachnode(db, &node); + } else { + dns_db_detachnode(db, &node); + dns_db_detach(&db); + } + } + + if (time_lookups) { + isc_uint64_t usec; + + TIME_NOW(&finish); + + usec = isc_time_microdiff(&finish, &start); + + printf("elapsed time: %lu.%06lu seconds\n", + (unsigned long)(usec / 1000000), + (unsigned long)(usec % 1000000)); + } + + unload_all(); + + dns_dbtable_detach(&dbtable); + + if (lctx != NULL) + isc_log_destroy(&lctx); + + if (!quiet) + isc_mem_stats(mctx, stdout); + + return (0); +} diff --git a/bin/tests/dst/Kdh.+002+18602.key b/bin/tests/dst/Kdh.+002+18602.key new file mode 100644 index 0000000..09b4cf5 --- /dev/null +++ b/bin/tests/dst/Kdh.+002+18602.key @@ -0,0 +1 @@ +dh. IN KEY 0 2 2 AAEBAAAAYIHI/wjtOagNga9GILSoS02IVelgLilPE/TfhtvShsiDAXqb IfxQcj2JkuOnNLs5ttb2WZXWl5/jsSjIxHMwMF2XY4gwt/lwHBf/vgYH r7aIxnKXov1jk9rymTLHGKIOtg== diff --git a/bin/tests/dst/Kdh.+002+18602.private b/bin/tests/dst/Kdh.+002+18602.private new file mode 100644 index 0000000..a2245bf --- /dev/null +++ b/bin/tests/dst/Kdh.+002+18602.private @@ -0,0 +1,6 @@ +Private-key-format: v1.2 +Algorithm: 2 (DH) +Prime(p): ///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP////////// +Generator(g): Ag== +Private_value(x): bpdsGQ1jbV3f2CGN/0Pk5KM1MlkFmMryPO1J1zoGn585fRmc9Ygw6l/HKmi2ViiDNorvd9/eV9uyYO6lYZC82R3D7rST1mAqCwbg/8gNE5dXBRbRIIq3qIl6GUYYs8mK +Public_value(y): gcj/CO05qA2Br0YgtKhLTYhV6WAuKU8T9N+G29KGyIMBepsh/FByPYmS46c0uzm21vZZldaXn+OxKMjEczAwXZdjiDC3+XAcF/++BgevtojGcpei/WOT2vKZMscYog62 diff --git a/bin/tests/dst/Kdh.+002+48957.key b/bin/tests/dst/Kdh.+002+48957.key new file mode 100644 index 0000000..9838829 --- /dev/null +++ b/bin/tests/dst/Kdh.+002+48957.key @@ -0,0 +1 @@ +dh. IN KEY 0 2 2 AAEBAAAAYOuaKjyMXYame2F6/ZFdEmXv0a2edB+69PEZgrExA6SJlivn 4KqAsfBHr/+0BCb+7nfWeMDSh2BXnSzWkXF1wMaCHMuz9EleG1gKFKeV Q9gKli88Cb8/jbovWChrGBNp2w== diff --git a/bin/tests/dst/Kdh.+002+48957.private b/bin/tests/dst/Kdh.+002+48957.private new file mode 100644 index 0000000..e191235 --- /dev/null +++ b/bin/tests/dst/Kdh.+002+48957.private @@ -0,0 +1,6 @@ +Private-key-format: v1.2 +Algorithm: 2 (DH) +Prime(p): ///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP////////// +Generator(g): Ag== +Private_value(x): WJG0moh+QoZV+DYhqW7Z6O6TYpYGtSlN0Ym6JV6VRnzeH69OqMUFivqZorj3a3ofR/4zogNVyy5KLLj2NFTaLGP4Hcvt7uETJik6HrjLMhGf40QPXYgVK57Im0rv88Ca +Public_value(y): 65oqPIxdhqZ7YXr9kV0SZe/RrZ50H7r08RmCsTEDpImWK+fgqoCx8Eev/7QEJv7ud9Z4wNKHYFedLNaRcXXAxoIcy7P0SV4bWAoUp5VD2AqWLzwJvz+Nui9YKGsYE2nb diff --git a/bin/tests/dst/Ktest.+001+00002.key b/bin/tests/dst/Ktest.+001+00002.key new file mode 100644 index 0000000..a8b4b4d --- /dev/null +++ b/bin/tests/dst/Ktest.+001+00002.key @@ -0,0 +1 @@ +test. IN DNSKEY 49152 2 1 diff --git a/bin/tests/dst/Ktest.+001+54622.key b/bin/tests/dst/Ktest.+001+54622.key new file mode 100644 index 0000000..b0277e3 --- /dev/null +++ b/bin/tests/dst/Ktest.+001+54622.key @@ -0,0 +1 @@ +test. IN DNSKEY 257 3 1 AQPQjwSpaVzxIgRCpiUoozUQKGh2oX8NIFKDOvtxK+tn536OZg2cROKTlgGEHXJK9YHfW/6nzQULTVpb63P+SQMmjCCidb8IYyhItixRztVeJQ== diff --git a/bin/tests/dst/Ktest.+001+54622.private b/bin/tests/dst/Ktest.+001+54622.private new file mode 100644 index 0000000..c97ac30 --- /dev/null +++ b/bin/tests/dst/Ktest.+001+54622.private @@ -0,0 +1,10 @@ +Private-key-format: v1.2 +Algorithm: 1 (RSA) +Modulus: 0I8EqWlc8SIEQqYlKKM1EChodqF/DSBSgzr7cSvrZ+d+jmYNnETik5YBhB1ySvWB31v+p80FC01aW+tz/kkDJowgonW/CGMoSLYsUc7VXiU= +PublicExponent: Aw== +PrivateExponent: iwoDG5uTS2wC1xluGxd4tXBFpGuqCMA3AidSS3Kc7++ptEQJEtiXC9kfCJMvZhGfQLaujft2OgrmkcuDVtPIbQWEENhyJhb4Lk82kFXbfus= +Prime1: /rSKuzcZY7R5cY2YWD4CiBNyj9WJMq1wWmBnb9+5M08nTl5E9NW5qQ== +Prime2: 0Z5shXQYd16E2Gs6e5WxtO0Oqlly2KkSqXohwTQWDWTb8Pw0WTZmHQ== +Exponent1: qc2x0iS7l82mS7O65X6sWrehtTkGIcj1kZWaSpUmIjTE3umDTePRGw== +Exponent2: i77zA6K6+j8DOvIm/Q52eJ4JxuZMkHC3G6bBK3gOs5iSoKgi5iREEw== +Coefficient: 3+wYZB0SJad7z2EsjzgbSlg6CawoaOvrROGSbwSiW5DCsMFROudOTw== diff --git a/bin/tests/dst/Ktest.+003+23616.key b/bin/tests/dst/Ktest.+003+23616.key new file mode 100644 index 0000000..958d585 --- /dev/null +++ b/bin/tests/dst/Ktest.+003+23616.key @@ -0,0 +1 @@ +test. IN DNSKEY 16641 3 3 ANp1//lqDlEfTavcFI+cyudNfgEz73V/K7fSDvkA0eDYcGg/kSvEjAEO/oLWCERltkuC55ZcM/mSv17WF1d/wR6kww/pLI9eXwkjftAYqs5sNxk+mbEGl6zwve9wq5z7IoTY5/J4l7XLCKftg/wGvrzXQhggIkRvEh3myhxd+ouILcpfvTIthWlTKiH59tSJpmgmiSMTE7nDYaf10iVRWN6DMSprgejiH05/fpmyZAt44tyAh4m1wXS5u4tam1PXDJYJozn7EfQ8e2weIv1yC+t6PHSx diff --git a/bin/tests/dst/Ktest.+003+23616.private b/bin/tests/dst/Ktest.+003+23616.private new file mode 100644 index 0000000..5781c9d --- /dev/null +++ b/bin/tests/dst/Ktest.+003+23616.private @@ -0,0 +1,7 @@ +Private-key-format: v1.2 +Algorithm: 3 (DSA) +Prime(p): 73V/K7fSDvkA0eDYcGg/kSvEjAEO/oLWCERltkuC55ZcM/mSv17WF1d/wR6kww/pLI9eXwkjftAYqs5sNxk+mQ== +Subprime(q): 2nX/+WoOUR9Nq9wUj5zK501+ATM= +Base(g): sQaXrPC973CrnPsihNjn8niXtcsIp+2D/Aa+vNdCGCAiRG8SHebKHF36i4gtyl+9Mi2FaVMqIfn21ImmaCaJIw== +Private_value(x): Nky4tvIwg6xlcyeHXr4k2DEZg0E= +Public_value(y): ExO5w2Gn9dIlUVjegzEqa4Ho4h9Of36ZsmQLeOLcgIeJtcF0ubuLWptT1wyWCaM5+xH0PHtsHiL9cgvrejx0sQ== diff --git a/bin/tests/dst/Ktest.+003+49667.key b/bin/tests/dst/Ktest.+003+49667.key new file mode 100644 index 0000000..fb73f57 --- /dev/null +++ b/bin/tests/dst/Ktest.+003+49667.key @@ -0,0 +1 @@ +test. IN DNSKEY 49152 2 3 diff --git a/bin/tests/dst/Makefile.in b/bin/tests/dst/Makefile.in new file mode 100644 index 0000000..9b317fc --- /dev/null +++ b/bin/tests/dst/Makefile.in @@ -0,0 +1,65 @@ +# Copyright (C) 2004, 2006-2008 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 1999-2002 Internet Software Consortium. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# $Id: Makefile.in,v 1.46 2008/05/19 23:47:03 tbox Exp $ + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +@BIND9_MAKE_INCLUDES@ + +CINCLUDES = ${TEST_INCLUDES} ${DNS_INCLUDES} \ + ${ISC_INCLUDES} @DST_GSSAPI_INC@ + +CDEFINES = +CWARNINGS = + +DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +ISCLIBS = ../../../lib/isc/libisc.@A@ + +DNSDEPLIBS = ../../../lib/dns/libdns.@A@ +ISCDEPLIBS = ../../../lib/isc/libisc.@A@ + +DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} + +LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ + +TLIB = ../../../lib/tests/libt_api.@A@ + +TARGETS = dst_test@EXEEXT@ t_dst@EXEEXT@ gsstest@EXEEXT@ + +SRCS = dst_test.c t_dst.c gsstest.c + +@BIND9_MAKE_RULES@ + +dst_test@EXEEXT@: dst_test.@O@ ${DEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + dst_test.@O@ ${LIBS} + +t_dst@EXEEXT@: t_dst.@O@ ${DEPLIBS} ${TLIB} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + t_dst.@O@ ${TLIB} ${LIBS} + +gsstest@EXEEXT@: gsstest.@O@ ${DEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + gsstest.@O@ ${LIBS} + +test: t_dst@EXEEXT@ + ../genrandom@EXEEXT@ 100 randomfile + -@ ./t_dst@EXEEXT@ -b @srcdir@ -q 1800 -a + +clean distclean:: + rm -f ${TARGETS} randomfile diff --git a/bin/tests/dst/dst_2_data b/bin/tests/dst/dst_2_data new file mode 100644 index 0000000..a303065 --- /dev/null +++ b/bin/tests/dst/dst_2_data @@ -0,0 +1,16 @@ +# +# data for signature verification test +# +# format: +# datafile, sigpath, keyname, keyid, alg, exp_result +# +t2_data_1 t2_dsasig test. 23616 DST_ALG_DSA ISC_R_SUCCESS +t2_data_1 t2_rsasig test. 54622 DST_ALG_RSAMD5 ISC_R_SUCCESS +# wrong sig +t2_data_1 t2_dsasig test. 54622 DST_ALG_RSAMD5 !ISC_R_SUCCESS +# wrong key +#t2_data_1 t2_dsasig test. 54622 DST_ALG_DSA !ISC_R_SUCCESS +# wrong alg +#t2_data_1 t2_dsasig test. 23616 DST_ALG_RSAMD5 !ISC_R_SUCCESS +# wrong data +t2_data_2 t2_dsasig test. 23616 DST_ALG_DSA !ISC_R_SUCCESS diff --git a/bin/tests/dst/dst_test.c b/bin/tests/dst/dst_test.c new file mode 100644 index 0000000..8347a7d --- /dev/null +++ b/bin/tests/dst/dst_test.c @@ -0,0 +1,294 @@ +/* + * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: dst_test.c,v 1.43 2007/06/19 23:47:00 tbox Exp $ */ + +#include + +#include + +#include /* XXX */ + +#include +#include +#include +#include +#include /* Required for HP/UX (and others?) */ + +#include +#include +#include + +#include +#include + +char *current; +const char *tmp = "/tmp"; + +static void +use(dst_key_t *key, isc_mem_t *mctx) { + isc_result_t ret; + const char *data = "This is some data"; + unsigned char sig[512]; + isc_buffer_t databuf, sigbuf; + isc_region_t datareg, sigreg; + dst_context_t *ctx = NULL; + + isc_buffer_init(&sigbuf, sig, sizeof(sig)); + /* + * Advance 1 byte for fun. + */ + isc_buffer_add(&sigbuf, 1); + + isc_buffer_init(&databuf, data, strlen(data)); + isc_buffer_add(&databuf, strlen(data)); + isc_buffer_usedregion(&databuf, &datareg); + + ret = dst_context_create(key, mctx, &ctx); + if (ret != ISC_R_SUCCESS) { + printf("contextcreate(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + return; + } + ret = dst_context_adddata(ctx, &datareg); + if (ret != ISC_R_SUCCESS) { + printf("adddata(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + dst_context_destroy(&ctx); + return; + } + ret = dst_context_sign(ctx, &sigbuf); + printf("sign(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + dst_context_destroy(&ctx); + + isc_buffer_forward(&sigbuf, 1); + isc_buffer_remainingregion(&sigbuf, &sigreg); + ret = dst_context_create(key, mctx, &ctx); + if (ret != ISC_R_SUCCESS) { + printf("contextcreate(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + return; + } + ret = dst_context_adddata(ctx, &datareg); + if (ret != ISC_R_SUCCESS) { + printf("adddata(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + dst_context_destroy(&ctx); + return; + } + ret = dst_context_verify(ctx, &sigreg); + printf("verify(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + dst_context_destroy(&ctx); +} + +static void +dns(dst_key_t *key, isc_mem_t *mctx) { + unsigned char buffer1[2048]; + unsigned char buffer2[2048]; + isc_buffer_t buf1, buf2; + isc_region_t r1, r2; + dst_key_t *newkey = NULL; + isc_result_t ret; + isc_boolean_t match; + + isc_buffer_init(&buf1, buffer1, sizeof(buffer1)); + ret = dst_key_todns(key, &buf1); + printf("todns(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + if (ret != ISC_R_SUCCESS) + return; + ret = dst_key_fromdns(dst_key_name(key), dns_rdataclass_in, + &buf1, mctx, &newkey); + printf("fromdns(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + if (ret != ISC_R_SUCCESS) + return; + isc_buffer_init(&buf2, buffer2, sizeof(buffer2)); + ret = dst_key_todns(newkey, &buf2); + printf("todns2(%d) returned: %s\n", dst_key_alg(key), + isc_result_totext(ret)); + if (ret != ISC_R_SUCCESS) + return; + isc_buffer_usedregion(&buf1, &r1); + isc_buffer_usedregion(&buf2, &r2); + match = ISC_TF(r1.length == r2.length && + memcmp(r1.base, r2.base, r1.length) == 0); + printf("compare(%d): %s\n", dst_key_alg(key), + match ? "true" : "false"); + dst_key_free(&newkey); +} + +static void +io(dns_name_t *name, int id, int alg, int type, isc_mem_t *mctx) { + dst_key_t *key = NULL; + isc_result_t ret; + + ret = dst_key_fromfile(name, id, alg, type, current, mctx, &key); + printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + ret = dst_key_tofile(key, type, tmp); + printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + use(key, mctx); + dns(key, mctx); + dst_key_free(&key); +} + +static void +dh(dns_name_t *name1, int id1, dns_name_t *name2, int id2, isc_mem_t *mctx) { + dst_key_t *key1 = NULL, *key2 = NULL; + isc_result_t ret; + isc_buffer_t b1, b2; + isc_region_t r1, r2; + unsigned char array1[1024], array2[1024]; + int alg = DST_ALG_DH; + int type = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE|DST_TYPE_KEY; + + ret = dst_key_fromfile(name1, id1, alg, type, current, mctx, &key1); + printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + ret = dst_key_fromfile(name2, id2, alg, type, current, mctx, &key2); + printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + + ret = dst_key_tofile(key1, type, tmp); + printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + ret = dst_key_tofile(key2, type, tmp); + printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != 0) + return; + + isc_buffer_init(&b1, array1, sizeof(array1)); + ret = dst_key_computesecret(key1, key2, &b1); + printf("computesecret() returned: %s\n", isc_result_totext(ret)); + if (ret != 0) + return; + + isc_buffer_init(&b2, array2, sizeof(array2)); + ret = dst_key_computesecret(key2, key1, &b2); + printf("computesecret() returned: %s\n", isc_result_totext(ret)); + if (ret != 0) + return; + + isc_buffer_usedregion(&b1, &r1); + isc_buffer_usedregion(&b2, &r2); + + if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0) + { + int i; + printf("secrets don't match\n"); + printf("secret 1: %d bytes\n", r1.length); + for (i = 0; i < (int) r1.length; i++) + printf("%02x ", r1.base[i]); + printf("\n"); + printf("secret 2: %d bytes\n", r2.length); + for (i = 0; i < (int) r2.length; i++) + printf("%02x ", r2.base[i]); + printf("\n"); + } + dst_key_free(&key1); + dst_key_free(&key2); +} + +static void +generate(int alg, isc_mem_t *mctx) { + isc_result_t ret; + dst_key_t *key = NULL; + + ret = dst_key_generate(dns_rootname, alg, 512, 0, 0, 0, + dns_rdataclass_in, mctx, &key); + printf("generate(%d) returned: %s\n", alg, isc_result_totext(ret)); + if (ret != ISC_R_SUCCESS) + return; + + if (alg != DST_ALG_DH) + use(key, mctx); + + dst_key_free(&key); +} + +int +main(void) { + isc_mem_t *mctx = NULL; + isc_entropy_t *ectx = NULL; + isc_buffer_t b; + dns_fixedname_t fname; + dns_name_t *name; + isc_result_t result; + + result = isc_mem_create(0, 0, &mctx); + if (result != ISC_R_SUCCESS) + return (1); + + current = isc_mem_get(mctx, 256); + if (current == NULL) + return (1); + getcwd(current, 256); + + dns_result_register(); + + result = isc_entropy_create(mctx, &ectx); + if (result != ISC_R_SUCCESS) + return (1); + result = isc_entropy_createfilesource(ectx, "randomfile"); + if (result != ISC_R_SUCCESS) + return (1); + dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING|ISC_ENTROPY_GOODONLY); + + dns_fixedname_init(&fname); + name = dns_fixedname_name(&fname); + isc_buffer_init(&b, "test.", 5); + isc_buffer_add(&b, 5); + result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (result != ISC_R_SUCCESS) + return (1); + io(name, 23616, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); + io(name, 54622, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, + mctx); + + io(name, 49667, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); + io(name, 2, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); + + isc_buffer_init(&b, "dh.", 3); + isc_buffer_add(&b, 3); + result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (result != ISC_R_SUCCESS) + return (1); + dh(name, 18602, name, 48957, mctx); + + generate(DST_ALG_RSAMD5, mctx); + generate(DST_ALG_DH, mctx); + generate(DST_ALG_DSA, mctx); + generate(DST_ALG_HMACMD5, mctx); + + dst_lib_destroy(); + isc_entropy_detach(&ectx); + + isc_mem_put(mctx, current, 256); +/* isc_mem_stats(mctx, stdout);*/ + isc_mem_destroy(&mctx); + + return (0); +} diff --git a/bin/tests/dst/gsstest.c b/bin/tests/dst/gsstest.c new file mode 100755 index 0000000..98e16d2 --- /dev/null +++ b/bin/tests/dst/gsstest.c @@ -0,0 +1,566 @@ +/* + * Copyright (C) 2006, 2007 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: gsstest.c,v 1.6 2007/06/19 23:47:00 tbox Exp $ */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef GSSAPI +#include ISC_PLATFORM_GSSAPIHEADER + +struct dst_context { + unsigned int magic; + dst_key_t *key; + isc_mem_t *mctx; + void *opaque; +}; + +#define CHECK(str, x) { \ + if ((x) != ISC_R_SUCCESS) { \ + fprintf(stderr, "I:%d:%s: %s\n", __LINE__, (str), isc_result_totext(x)); \ + goto end; \ + } \ +} + +static char contextname[512]; +static char gssid[512]; +static char serveraddress[512]; +static dns_fixedname_t servername, gssname; + +static isc_mem_t *mctx; +static dns_requestmgr_t *requestmgr; +static isc_sockaddr_t address; + +static dns_tsig_keyring_t *ring; +static dns_tsigkey_t *tsigkey = NULL; +static gss_ctx_id_t gssctx; +static gss_ctx_id_t *gssctxp = &gssctx; + +#define RUNCHECK(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS) + +#define PORT 53 +#define TIMEOUT 30 + +static void initctx1(isc_task_t *task, isc_event_t *event); +static void sendquery(isc_task_t *task, isc_event_t *event); +static void setup(); + +static void +console(isc_task_t *task, isc_event_t *event) +{ + char buf[32]; + isc_event_t *ev = NULL; + + isc_event_free(&event); + + while(1) { + printf("\nCommand => "); + scanf("%s", buf); + + if(strcmp(buf, "quit") == 0) { + isc_app_shutdown(); + return; + } + + if(strcmp(buf, "initctx") == 0) { + ev = isc_event_allocate(mctx, (void *)1, 1, initctx1, + NULL, sizeof(*event)); + isc_task_send(task, &ev); + return; + } + + if(strcmp(buf, "query") == 0) { + ev = isc_event_allocate(mctx, (void *)1, 1, sendquery, + NULL, sizeof(*event)); + isc_task_send(task, &ev); + return; + } + + printf("Unknown command\n"); + } +} + +static void +recvresponse(isc_task_t *task, isc_event_t *event) { + dns_requestevent_t *reqev = (dns_requestevent_t *)event; + isc_result_t result, result2; + dns_message_t *query, *response = NULL; + isc_buffer_t outtoken; + isc_buffer_t outbuf; + char output[10 * 1024]; + + unsigned char array[DNS_NAME_MAXTEXT + 1]; + isc_buffer_init(&outtoken, array, sizeof(array)); + + UNUSED(task); + + REQUIRE(reqev != NULL); + + if (reqev->result != ISC_R_SUCCESS) { + fprintf(stderr, "I:request event result: %s\n", + isc_result_totext(reqev->result)); + goto end; + } + + query = reqev->ev_arg; + + response = NULL; + result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response); + CHECK("dns_message_create", result); + + printf("\nReceived Response:\n"); + + result2 = dns_request_getresponse(reqev->request, response, + DNS_MESSAGEPARSE_PRESERVEORDER); + isc_buffer_init(&outbuf, output, sizeof(output)); + result = dns_message_totext(response, &dns_master_style_debug, 0, + &outbuf); + CHECK("dns_message_totext", result); + printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf), + (char *)isc_buffer_base(&outbuf)); + + CHECK("dns_request_getresponse", result2); + + if (response) + dns_message_destroy(&response); + +end: + if (query) + dns_message_destroy(&query); + + if (reqev->request) + dns_request_destroy(&reqev->request); + + isc_event_free(&event); + + event = isc_event_allocate(mctx, (void *)1, 1, console, NULL, + sizeof(*event)); + isc_task_send(task, &event); + return; +} + + +static void +sendquery(isc_task_t *task, isc_event_t *event) +{ + dns_request_t *request = NULL; + dns_message_t *message = NULL; + dns_name_t *qname = NULL; + dns_rdataset_t *qrdataset = NULL; + isc_result_t result; + dns_fixedname_t queryname; + isc_buffer_t buf; + isc_buffer_t outbuf; + char output[10 * 1024]; + + static char host[256]; + + isc_event_free(&event); + + printf("Query => "); + scanf("%s", host); + + dns_fixedname_init(&queryname); + isc_buffer_init(&buf, host, strlen(host)); + isc_buffer_add(&buf, strlen(host)); + result = dns_name_fromtext(dns_fixedname_name(&queryname), &buf, + dns_rootname, ISC_FALSE, NULL); + CHECK("dns_name_fromtext", result); + + result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message); + + message->opcode = dns_opcode_query; + message->rdclass = dns_rdataclass_in; + message->id = (unsigned short)(random() & 0xFFFF); + + result = dns_message_gettempname(message, &qname); + if (result != ISC_R_SUCCESS) + goto end; + + result = dns_message_gettemprdataset(message, &qrdataset); + if (result != ISC_R_SUCCESS) + goto end; + + dns_name_init(qname, NULL); + dns_name_clone(dns_fixedname_name(&queryname), qname); + dns_rdataset_init(qrdataset); + dns_rdataset_makequestion(qrdataset, dns_rdataclass_in, + dns_rdatatype_a); + ISC_LIST_APPEND(qname->list, qrdataset, link); + dns_message_addname(message, qname, DNS_SECTION_QUESTION); + + result = dns_request_create(requestmgr, message, &address, 0, tsigkey, + TIMEOUT, task, recvresponse, + message, &request); + CHECK("dns_request_create", result); + + printf("Submitting query:\n"); + isc_buffer_init(&outbuf, output, sizeof(output)); + result = dns_message_totext(message, &dns_master_style_debug, 0, + &outbuf); + CHECK("dns_message_totext", result); + printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf), + (char *)isc_buffer_base(&outbuf)); + + return; + + end: + if (qname != NULL) + dns_message_puttempname(message, &qname); + if (qrdataset != NULL) + dns_message_puttemprdataset(message, &qrdataset); + if (message != NULL) + dns_message_destroy(&message); +} + +static void +initctx2(isc_task_t *task, isc_event_t *event) { + dns_requestevent_t *reqev = (dns_requestevent_t *)event; + isc_result_t result; + dns_message_t *query, *response = NULL; + isc_buffer_t outtoken; + unsigned char array[DNS_NAME_MAXTEXT + 1]; + dns_rdataset_t *rdataset; + dns_rdatatype_t qtype; + dns_name_t *question_name; + + UNUSED(task); + + REQUIRE(reqev != NULL); + + if (reqev->result != ISC_R_SUCCESS) { + fprintf(stderr, "I:request event result: %s\n", + isc_result_totext(reqev->result)); + goto end; + } + + query = reqev->ev_arg; + + response = NULL; + result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response); + CHECK("dns_message_create", result); + + result = dns_request_getresponse(reqev->request, response, + DNS_MESSAGEPARSE_PRESERVEORDER); + CHECK("dns_request_getresponse", result); + + if (response->rcode != dns_rcode_noerror) { + result = ISC_RESULTCLASS_DNSRCODE + response->rcode; + fprintf(stderr, "I:response rcode: %s\n", + isc_result_totext(result)); + goto end; + } + + printf("Received token from server, calling gss_init_sec_context()\n"); + isc_buffer_init(&outtoken, array, DNS_NAME_MAXTEXT + 1); + result = dns_tkey_processgssresponse(query, response, + dns_fixedname_name(&gssname), + &gssctx, &outtoken, + &tsigkey, ring); + gssctx = *gssctxp; + CHECK("dns_tkey_processgssresponse", result); + printf("Context accepted\n"); + + question_name = NULL; + dns_message_currentname(response, DNS_SECTION_ANSWER, &question_name); + rdataset = ISC_LIST_HEAD(question_name->list); + INSIST(rdataset != NULL); + qtype = rdataset->type; + if(qtype == dns_rdatatype_tkey) { + printf("Received TKEY response from server\n"); + printf("Context completed\n"); + } else { + printf("Did not receive TKEY response from server\n"); + printf("Context not completed\n"); + dns_tsigkey_detach(&tsigkey); + tsigkey = NULL; + } + + if(response) + dns_message_destroy(&response); + +end: + if(query) + dns_message_destroy(&query); + + if(reqev->request) + dns_request_destroy(&reqev->request); + + isc_event_free(&event); + + event = isc_event_allocate(mctx, (void *)1, 1, console, NULL, + sizeof(*event)); + isc_task_send(task, &event); + return; +} + +static void +initctx1(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + isc_buffer_t buf; + dns_message_t *query; + dns_request_t *request; + + isc_event_free(&event); + + printf("Initctx - GSS name => "); + scanf("%s", gssid); + + sprintf(contextname, "gsstest.context.%d.", (int)time(NULL)); + + printf("Initctx - context name we're using: %s\n", contextname); + + printf("Negotiating GSSAPI context: "); + printf(gssid); + printf("\n"); + + /* + * Setup a GSSAPI context with the server + */ + dns_fixedname_init(&servername); + isc_buffer_init(&buf, contextname, strlen(contextname)); + isc_buffer_add(&buf, strlen(contextname)); + result = dns_name_fromtext(dns_fixedname_name(&servername), &buf, + dns_rootname, ISC_FALSE, NULL); + CHECK("dns_name_fromtext", result); + + /* Make name happen */ + dns_fixedname_init(&gssname); + isc_buffer_init(&buf, gssid, strlen(gssid)); + isc_buffer_add(&buf, strlen(gssid)); + result = dns_name_fromtext(dns_fixedname_name(&gssname), &buf, + dns_rootname, ISC_FALSE, NULL); + CHECK("dns_name_fromtext", result); + + query = NULL; + result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query); + CHECK("dns_message_create", result); + + printf("Calling gss_init_sec_context()\n"); + gssctx = GSS_C_NO_CONTEXT; + result = dns_tkey_buildgssquery(query, dns_fixedname_name(&servername), + dns_fixedname_name(&gssname), + NULL, 36000, &gssctx, ISC_TRUE); + CHECK("dns_tkey_buildgssquery", result); + + printf("Sending context token to server\n"); + request = NULL; + result = dns_request_create(requestmgr, query, &address, 0, NULL, + TIMEOUT, task, initctx2, query, &request); + CHECK("dns_request_create", result); + + return; +end: + event = isc_event_allocate(mctx, (void *)1, 1, console, NULL, + sizeof(*event)); + isc_task_send(task, &event);return; +} + +static void +setup(void) +{ + struct in_addr inaddr; + int c; + + while (1) { + printf("Server IP => "); + c = scanf("%s", serveraddress); + + if(c == EOF || strcmp(serveraddress, "quit") == 0) { + isc_app_shutdown(); + return; + } + + if (inet_pton(AF_INET, serveraddress, &inaddr) == 1) { + isc_sockaddr_fromin(&address, &inaddr, PORT); + return; + } + + }; +} + +int +main(int argc, char *argv[]) { + isc_taskmgr_t *taskmgr; + isc_timermgr_t *timermgr; + isc_socketmgr_t *socketmgr; + isc_socket_t *sock; + unsigned int attrs, attrmask; + isc_sockaddr_t bind_any; + dns_dispatchmgr_t *dispatchmgr; + dns_dispatch_t *dispatchv4; + dns_view_t *view; + isc_entropy_t *ectx; + isc_task_t *task; + isc_log_t *lctx = NULL; + isc_logconfig_t *lcfg = NULL; + isc_logdestination_t destination; + + UNUSED(argv); + UNUSED(argc); + + RUNCHECK(isc_app_start()); + + dns_result_register(); + + mctx = NULL; + RUNCHECK(isc_mem_create(0, 0, &mctx)); + + RUNCHECK(isc_log_create(mctx, &lctx, &lcfg)); + isc_log_setcontext(lctx); + dns_log_init(lctx); + dns_log_setcontext(lctx); + + /* + * Create and install the default channel. + */ + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + RUNCHECK(isc_log_createchannel(lcfg, "_default", + ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, + &destination, ISC_LOG_PRINTTIME)); + RUNCHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL)); + + isc_log_setdebuglevel(lctx, 9); + + ectx = NULL; + RUNCHECK(isc_entropy_create(mctx, &ectx)); + RUNCHECK(isc_entropy_createfilesource(ectx, "/dev/urandom")); + + RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + + taskmgr = NULL; + RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr)); + task = NULL; + RUNCHECK(isc_task_create(taskmgr, 0, &task)); + timermgr = NULL; + RUNCHECK(isc_timermgr_create(mctx, &timermgr)); + socketmgr = NULL; + RUNCHECK(isc_socketmgr_create(mctx, &socketmgr)); + dispatchmgr = NULL; + RUNCHECK(dns_dispatchmgr_create(mctx, ectx, &dispatchmgr)); + isc_sockaddr_any(&bind_any); + attrs = DNS_DISPATCHATTR_UDP | + DNS_DISPATCHATTR_MAKEQUERY | + DNS_DISPATCHATTR_IPV4; + attrmask = DNS_DISPATCHATTR_UDP | + DNS_DISPATCHATTR_TCP | + DNS_DISPATCHATTR_IPV4 | + DNS_DISPATCHATTR_IPV6; + dispatchv4 = NULL; + RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, + &bind_any, 4096, 4, 2, 3, 5, + attrs, attrmask, &dispatchv4)); + requestmgr = NULL; + RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr, + dispatchmgr, dispatchv4, NULL, + &requestmgr)); + + ring = NULL; + RUNCHECK(dns_tsigkeyring_create(mctx, &ring)); + + view = NULL; + RUNCHECK(dns_view_create(mctx, 0, "_test", &view)); + dns_view_setkeyring(view, ring); + + sock = NULL; + RUNCHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, + &sock)); + + setup(); + + RUNCHECK(isc_app_onrun(mctx, task, console, NULL)); + + (void)isc_app_run(); + + if (tsigkey) + dns_tsigkey_detach(&tsigkey); + + dns_requestmgr_shutdown(requestmgr); + dns_requestmgr_detach(&requestmgr); + + dns_dispatch_detach(&dispatchv4); + dns_dispatchmgr_destroy(&dispatchmgr); + + isc_timermgr_destroy(&timermgr); + + isc_task_detach(&task); + isc_taskmgr_destroy(&taskmgr); + + isc_socket_detach(&sock); + isc_socketmgr_destroy(&socketmgr); + + isc_mem_stats(mctx, stdout); + + dns_view_detach(&view); + + dst_lib_destroy(); + isc_entropy_detach(&ectx); + + isc_mem_stats(mctx, stdout); + isc_mem_destroy(&mctx); + + isc_app_finish(); + + return (0); +} +#else +int +main(int argc, char *argv[]) { + UNUSED(argc); + UNUSED(argv); + fprintf(stderr, "R:GSSAPIONLY\n"); + return (0); +} +#endif diff --git a/bin/tests/dst/t2_data_1 b/bin/tests/dst/t2_data_1 new file mode 100644 index 0000000..b1a9bf5 --- /dev/null +++ b/bin/tests/dst/t2_data_1 @@ -0,0 +1,3077 @@ +Network Working Group P. Mockapetris +Request for Comments: 1035 ISI + November 1987 +Obsoletes: RFCs 882, 883, 973 + + DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION + + +1. STATUS OF THIS MEMO + +This RFC describes the details of the domain system and protocol, and +assumes that the reader is familiar with the concepts discussed in a +companion RFC, "Domain Names - Concepts and Facilities" [RFC-1034]. + +The domain system is a mixture of functions and data types which are an +official protocol and functions and data types which are still +experimental. Since the domain system is intentionally extensible, new +data types and experimental behavior should always be expected in parts +of the system beyond the official protocol. The official protocol parts +include standard queries, responses and the Internet class RR data +formats (e.g., host addresses). Since the previous RFC set, several +definitions have changed, so some previous definitions are obsolete. + +Experimental or obsolete features are clearly marked in these RFCs, and +such information should be used with caution. + +The reader is especially cautioned not to depend on the values which +appear in examples to be current or complete, since their purpose is +primarily pedagogical. Distribution of this memo is unlimited. + + Table of Contents + + 1. STATUS OF THIS MEMO 1 + 2. INTRODUCTION 3 + 2.1. Overview 3 + 2.2. Common configurations 4 + 2.3. Conventions 7 + 2.3.1. Preferred name syntax 7 + 2.3.2. Data Transmission Order 8 + 2.3.3. Character Case 9 + 2.3.4. Size limits 10 + 3. DOMAIN NAME SPACE AND RR DEFINITIONS 10 + 3.1. Name space definitions 10 + 3.2. RR definitions 11 + 3.2.1. Format 11 + 3.2.2. TYPE values 12 + 3.2.3. QTYPE values 12 + 3.2.4. CLASS values 13 + + + +Mockapetris [Page 1] + +RFC 1035 Domain Implementation and Specification November 1987 + + + 3.2.5. QCLASS values 13 + 3.3. Standard RRs 13 + 3.3.1. CNAME RDATA format 14 + 3.3.2. HINFO RDATA format 14 + 3.3.3. MB RDATA format (EXPERIMENTAL) 14 + 3.3.4. MD RDATA format (Obsolete) 15 + 3.3.5. MF RDATA format (Obsolete) 15 + 3.3.6. MG RDATA format (EXPERIMENTAL) 16 + 3.3.7. MINFO RDATA format (EXPERIMENTAL) 16 + 3.3.8. MR RDATA format (EXPERIMENTAL) 17 + 3.3.9. MX RDATA format 17 + 3.3.10. NULL RDATA format (EXPERIMENTAL) 17 + 3.3.11. NS RDATA format 18 + 3.3.12. PTR RDATA format 18 + 3.3.13. SOA RDATA format 19 + 3.3.14. TXT RDATA format 20 + 3.4. ARPA Internet specific RRs 20 + 3.4.1. A RDATA format 20 + 3.4.2. WKS RDATA format 21 + 3.5. IN-ADDR.ARPA domain 22 + 3.6. Defining new types, classes, and special namespaces 24 + 4. MESSAGES 25 + 4.1. Format 25 + 4.1.1. Header section format 26 + 4.1.2. Question section format 28 + 4.1.3. Resource record format 29 + 4.1.4. Message compression 30 + 4.2. Transport 32 + 4.2.1. UDP usage 32 + 4.2.2. TCP usage 32 + 5. MASTER FILES 33 + 5.1. Format 33 + 5.2. Use of master files to define zones 35 + 5.3. Master file example 36 + 6. NAME SERVER IMPLEMENTATION 37 + 6.1. Architecture 37 + 6.1.1. Control 37 + 6.1.2. Database 37 + 6.1.3. Time 39 + 6.2. Standard query processing 39 + 6.3. Zone refresh and reload processing 39 + 6.4. Inverse queries (Optional) 40 + 6.4.1. The contents of inverse queries and responses 40 + 6.4.2. Inverse query and response example 41 + 6.4.3. Inverse query processing 42 + + + + + + +Mockapetris [Page 2] + +RFC 1035 Domain Implementation and Specification November 1987 + + + 6.5. Completion queries and responses 42 + 7. RESOLVER IMPLEMENTATION 43 + 7.1. Transforming a user request into a query 43 + 7.2. Sending the queries 44 + 7.3. Processing responses 46 + 7.4. Using the cache 47 + 8. MAIL SUPPORT 47 + 8.1. Mail exchange binding 48 + 8.2. Mailbox binding (Experimental) 48 + 9. REFERENCES and BIBLIOGRAPHY 50 + Index 54 + +2. INTRODUCTION + +2.1. Overview + +The goal of domain names is to provide a mechanism for naming resources +in such a way that the names are usable in different hosts, networks, +protocol families, internets, and administrative organizations. + +From the user's point of view, domain names are useful as arguments to a +local agent, called a resolver, which retrieves information associated +with the domain name. Thus a user might ask for the host address or +mail information associated with a particular domain name. To enable +the user to request a particular type of information, an appropriate +query type is passed to the resolver with the domain name. To the user, +the domain tree is a single information space; the resolver is +responsible for hiding the distribution of data among name servers from +the user. + +From the resolver's point of view, the database that makes up the domain +space is distributed among various name servers. Different parts of the +domain space are stored in different name servers, although a particular +data item will be stored redundantly in two or more name servers. The +resolver starts with knowledge of at least one name server. When the +resolver processes a user query it asks a known name server for the +information; in return, the resolver either receives the desired +information or a referral to another name server. Using these +referrals, resolvers learn the identities and contents of other name +servers. Resolvers are responsible for dealing with the distribution of +the domain space and dealing with the effects of name server failure by +consulting redundant databases in other servers. + +Name servers manage two kinds of data. The first kind of data held in +sets called zones; each zone is the complete database for a particular +"pruned" subtree of the domain space. This data is called +authoritative. A name server periodically checks to make sure that its +zones are up to date, and if not, obtains a new copy of updated zones + + + +Mockapetris [Page 3] + +RFC 1035 Domain Implementation and Specification November 1987 + + +from master files stored locally or in another name server. The second +kind of data is cached data which was acquired by a local resolver. +This data may be incomplete, but improves the performance of the +retrieval process when non-local data is repeatedly accessed. Cached +data is eventually discarded by a timeout mechanism. + +This functional structure isolates the problems of user interface, +failure recovery, and distribution in the resolvers and isolates the +database update and refresh problems in the name servers. + +2.2. Common configurations + +A host can participate in the domain name system in a number of ways, +depending on whether the host runs programs that retrieve information +from the domain system, name servers that answer queries from other +hosts, or various combinations of both functions. The simplest, and +perhaps most typical, configuration is shown below: + + Local Host | Foreign + | + +---------+ +----------+ | +--------+ + | | user queries | |queries | | | + | User |-------------->| |---------|->|Foreign | + | Program | | Resolver | | | Name | + | |<--------------| |<--------|--| Server | + | | user responses| |responses| | | + +---------+ +----------+ | +--------+ + | A | + cache additions | | references | + V | | + +----------+ | + | cache | | + +----------+ | + +User programs interact with the domain name space through resolvers; the +format of user queries and user responses is specific to the host and +its operating system. User queries will typically be operating system +calls, and the resolver and its cache will be part of the host operating +system. Less capable hosts may choose to implement the resolver as a +subroutine to be linked in with every program that needs its services. +Resolvers answer user queries with information they acquire via queries +to foreign name servers and the local cache. + +Note that the resolver may have to make several queries to several +different foreign name servers to answer a particular user query, and +hence the resolution of a user query may involve several network +accesses and an arbitrary amount of time. The queries to foreign name +servers and the corresponding responses have a standard format described + + + +Mockapetris [Page 4] + +RFC 1035 Domain Implementation and Specification November 1987 + + +in this memo, and may be datagrams. + +Depending on its capabilities, a name server could be a stand alone +program on a dedicated machine or a process or processes on a large +timeshared host. A simple configuration might be: + + Local Host | Foreign + | + +---------+ | + / /| | + +---------+ | +----------+ | +--------+ + | | | | |responses| | | + | | | | Name |---------|->|Foreign | + | Master |-------------->| Server | | |Resolver| + | files | | | |<--------|--| | + | |/ | | queries | +--------+ + +---------+ +----------+ | + +Here a primary name server acquires information about one or more zones +by reading master files from its local file system, and answers queries +about those zones that arrive from foreign resolvers. + +The DNS requires that all zones be redundantly supported by more than +one name server. Designated secondary servers can acquire zones and +check for updates from the primary server using the zone transfer +protocol of the DNS. This configuration is shown below: + + Local Host | Foreign + | + +---------+ | + / /| | + +---------+ | +----------+ | +--------+ + | | | | |responses| | | + | | | | Name |---------|->|Foreign | + | Master |-------------->| Server | | |Resolver| + | files | | | |<--------|--| | + | |/ | | queries | +--------+ + +---------+ +----------+ | + A |maintenance | +--------+ + | +------------|->| | + | queries | |Foreign | + | | | Name | + +------------------|--| Server | + maintenance responses | +--------+ + +In this configuration, the name server periodically establishes a +virtual circuit to a foreign name server to acquire a copy of a zone or +to check that an existing copy has not changed. The messages sent for + + + +Mockapetris [Page 5] + +RFC 1035 Domain Implementation and Specification November 1987 + + +these maintenance activities follow the same form as queries and +responses, but the message sequences are somewhat different. + +The information flow in a host that supports all aspects of the domain +name system is shown below: + + Local Host | Foreign + | + +---------+ +----------+ | +--------+ + | | user queries | |queries | | | + | User |-------------->| |---------|->|Foreign | + | Program | | Resolver | | | Name | + | |<--------------| |<--------|--| Server | + | | user responses| |responses| | | + +---------+ +----------+ | +--------+ + | A | + cache additions | | references | + V | | + +----------+ | + | Shared | | + | database | | + +----------+ | + A | | + +---------+ refreshes | | references | + / /| | V | + +---------+ | +----------+ | +--------+ + | | | | |responses| | | + | | | | Name |---------|->|Foreign | + | Master |-------------->| Server | | |Resolver| + | files | | | |<--------|--| | + | |/ | | queries | +--------+ + +---------+ +----------+ | + A |maintenance | +--------+ + | +------------|->| | + | queries | |Foreign | + | | | Name | + +------------------|--| Server | + maintenance responses | +--------+ + +The shared database holds domain space data for the local name server +and resolver. The contents of the shared database will typically be a +mixture of authoritative data maintained by the periodic refresh +operations of the name server and cached data from previous resolver +requests. The structure of the domain data and the necessity for +synchronization between name servers and resolvers imply the general +characteristics of this database, but the actual format is up to the +local implementor. + + + + +Mockapetris [Page 6] + +RFC 1035 Domain Implementation and Specification November 1987 + + +Information flow can also be tailored so that a group of hosts act +together to optimize activities. Sometimes this is done to offload less +capable hosts so that they do not have to implement a full resolver. +This can be appropriate for PCs or hosts which want to minimize the +amount of new network code which is required. This scheme can also +allow a group of hosts can share a small number of caches rather than +maintaining a large number of separate caches, on the premise that the +centralized caches will have a higher hit ratio. In either case, +resolvers are replaced with stub resolvers which act as front ends to +resolvers located in a recursive server in one or more name servers +known to perform that service: + + Local Hosts | Foreign + | + +---------+ | + | | responses | + | Stub |<--------------------+ | + | Resolver| | | + | |----------------+ | | + +---------+ recursive | | | + queries | | | + V | | + +---------+ recursive +----------+ | +--------+ + | | queries | |queries | | | + | Stub |-------------->| Recursive|---------|->|Foreign | + | Resolver| | Server | | | Name | + | |<--------------| |<--------|--| Server | + +---------+ responses | |responses| | | + +----------+ | +--------+ + | Central | | + | cache | | + +----------+ | + +In any case, note that domain components are always replicated for +reliability whenever possible. + +2.3. Conventions + +The domain system has several conventions dealing with low-level, but +fundamental, issues. While the implementor is free to violate these +conventions WITHIN HIS OWN SYSTEM, he must observe these conventions in +ALL behavior observed from other hosts. + +2.3.1. Preferred name syntax + +The DNS specifications attempt to be as general as possible in the rules +for constructing domain names. The idea is that the name of any +existing object can be expressed as a domain name with minimal changes. + + + +Mockapetris [Page 7] + +RFC 1035 Domain Implementation and Specification November 1987 + + +However, when assigning a domain name for an object, the prudent user +will select a name which satisfies both the rules of the domain system +and any existing rules for the object, whether these rules are published +or implied by existing programs. + +For example, when naming a mail domain, the user should satisfy both the +rules of this memo and those in RFC-822. When creating a new host name, +the old rules for HOSTS.TXT should be followed. This avoids problems +when old software is converted to use domain names. + +The following syntax will result in fewer problems with many + +applications that use domain names (e.g., mail, TELNET). + + ::= | " " + + ::=