bind9/bin/tests/system/dyndb/driver
Ondřej Surý c2dad0dcb2 Replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf()
Use the semantic patch from the previous commit to replace all the calls to
dns_name_copy() with NULL as third argument with dns_name_copynf().
2019-10-01 10:43:26 +10:00
..
.gitignore address linking issues 2015-09-30 12:38:07 +10:00
AUTHORS [master] merge dyndb 2015-09-28 23:12:35 -07:00
COPYING more copyright cleanups 2016-07-21 19:16:05 +10:00
db.c Use coccinelle to remove explicit '#include <config.h>' from the source files 2019-03-08 15:15:05 +01:00
db.h 4546. [func] Extend the use of const declarations. [RT #43379] 2016-12-30 15:45:08 +11:00
driver.c Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup 2019-07-23 15:32:36 -04:00
instance.c Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup 2019-07-23 15:32:36 -04:00
instance.h Replace custom isc_boolean_t with C standard bool type 2018-08-08 09:37:30 +02:00
lock.c Use coccinelle to remove explicit '#include <config.h>' from the source files 2019-03-08 15:15:05 +01:00
lock.h [master] merge dyndb 2015-09-28 23:12:35 -07:00
log.c Use coccinelle to remove explicit '#include <config.h>' from the source files 2019-03-08 15:15:05 +01:00
log.h [master] merge dyndb 2015-09-28 23:12:35 -07:00
Makefile.in Rename OPENSSL_INCLUDES to OPENSSL_CFLAGS in AX_CHECK_OPENSSL() macro 2019-06-25 12:36:01 +02:00
README [master] merge dyndb 2015-09-28 23:12:35 -07:00
syncptr.c Replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf() 2019-10-01 10:43:26 +10:00
syncptr.h [master] merge dyndb 2015-09-28 23:12:35 -07:00
util.h [master] merge dyndb 2015-09-28 23:12:35 -07:00
zone.c further cleanup 2019-07-23 15:32:36 -04:00
zone.h [master] merge dyndb 2015-09-28 23:12:35 -07:00

To use the Dynamic DB sample driver, run named and check the log.

    $ cd testing
    $ named -gc named.conf

You should be able to see something like:

zone test/IN: loaded serial 0
zone arpa/IN: loaded serial 0

This means that the sample driver created empty zones "test." and
"arpa." as defined by "arg" parameters in named.conf.

$ dig @localhost test.

should work as usual and you should be able to see the dummy zone with
NS record pointing to the zone apex and A record with 127.0.0.1:

;; ANSWER SECTION:
test.			86400	IN	A	127.0.0.1
test.			86400	IN	NS	test.
test.			86400	IN	SOA	test. test. 0 28800 7200 604800 86400

This driver creates two empty zones and allows query/transfer/update to
all IP addresses for demonstration purposes.

The driver wraps the RBT database implementation used natively by BIND,
and modifies the addrdataset() and substractrdataset() functions to do
additional work during dynamic updates.

A dynamic update modifies the target zone as usual. After that, the
driver detects whether the modified RR was of type A or AAAA, and if so,
attempts to appropriately generate or delete a matching PTR record in
one of the two zones managed by the driver.

E.g.:

$ nsupdate
> update add a.test. 300 IN A 192.0.2.1
> send

will add the A record
a.test.			300	IN	A	192.0.2.1

and also automatically generate the PTR record
1.2.0.192.in-addr.arpa.	300	IN	PTR	a.test.

AXFR and RR deletion via dynamic updates should work as usual. Deletion
of a type A or AAAA record should delete the corresponding PTR record
too.

The zone is stored only in memory, and all changes will be lost on
reload/reconfig.

Hints for code readers:
- Driver initialization starts in driver.c: dyndb_init() function.
- New database implementation is registered by calling dns_db_register()
  and passing a function pointer to it. This sample uses the function
  create_db() to initialize the database.
- Zones are created later in instance.c: load_sample_instance_zones().
- Database entry points are in structure db.c: dns_dbmethods_t
  sampledb_methods
- sampledb_methods points to an implementation of the database interface.
  See the db.c: addrdataset() implementation and look at how the RBT
  database instance is wrapped into an additional layer of logic.