#include <isc/lang.h>
#include <dns/clientinfo.h>
#include <dns/types.h>
Go to the source code of this file.
Data Structures | |
struct | dns_sdbmethods |
Defines | |
#define | DNS_SDB_H 1 |
#define | DNS_SDBFLAG_RELATIVEOWNER 0x00000001U |
#define | DNS_SDBFLAG_RELATIVERDATA 0x00000002U |
#define | DNS_SDBFLAG_THREADSAFE 0x00000004U |
#define | DNS_SDBFLAG_DNS64 0x00000008U |
Typedefs | |
typedef struct dns_sdb | dns_sdb_t |
A simple database. This is an opaque type. | |
typedef struct dns_sdblookup | dns_sdblookup_t |
A simple database lookup in progress. This is an opaque type. | |
typedef struct dns_sdballnodes | dns_sdballnodes_t |
A simple database traversal in progress. This is an opaque type. | |
typedef isc_result_t(* | dns_sdblookupfunc_t )(const char *zone, const char *name, void *dbdata, dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) |
typedef isc_result_t(* | dns_sdblookup2func_t )(const dns_name_t *zone, const dns_name_t *name, void *dbdata, dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) |
typedef isc_result_t(* | dns_sdbauthorityfunc_t )(const char *zone, void *dbdata, dns_sdblookup_t *) |
typedef isc_result_t(* | dns_sdballnodesfunc_t )(const char *zone, void *dbdata, dns_sdballnodes_t *allnodes) |
typedef isc_result_t(* | dns_sdbcreatefunc_t )(const char *zone, int argc, char **argv, void *driverdata, void **dbdata) |
typedef void(* | dns_sdbdestroyfunc_t )(const char *zone, void *driverdata, void **dbdata) |
typedef struct dns_sdbmethods | dns_sdbmethods_t |
Functions | |
isc_result_t | dns_sdb_register (const char *drivername, const dns_sdbmethods_t *methods, void *driverdata, unsigned int flags, isc_mem_t *mctx, dns_sdbimplementation_t **sdbimp) |
Register a simple database driver for the database type 'drivername', implemented by the functions in '*methods'. | |
void | dns_sdb_unregister (dns_sdbimplementation_t **sdbimp) |
Removes the simple database driver from the list of registered database types. There must be no active databases of this type when this function is called. | |
isc_result_t | dns_sdb_putrr (dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl, const char *data) |
See dns_sdb_putradata(). | |
isc_result_t | dns_sdb_putrdata (dns_sdblookup_t *lookup, dns_rdatatype_t type, dns_ttl_t ttl, const unsigned char *rdata, unsigned int rdlen) |
Add a single resource record to the lookup structure to be returned in the query response. dns_sdb_putrr() takes the resource record in master file text format as a null-terminated string, and dns_sdb_putrdata() takes the raw RDATA in uncompressed wire format. | |
isc_result_t | dns_sdb_putnamedrr (dns_sdballnodes_t *allnodes, const char *name, const char *type, dns_ttl_t ttl, const char *data) |
See dns_sdb_putnamerdata(). | |
isc_result_t | dns_sdb_putnamedrdata (dns_sdballnodes_t *allnodes, const char *name, dns_rdatatype_t type, dns_ttl_t ttl, const void *rdata, unsigned int rdlen) |
Add a single resource record to the allnodes structure to be included in a zone transfer response, in text or wire format as above. | |
isc_result_t | dns_sdb_putsoa (dns_sdblookup_t *lookup, const char *mname, const char *rname, isc_uint32_t serial) |
This function may optionally be called from the 'authority' callback to simplify construction of the SOA record for 'zone'. It will provide a SOA listing 'mname' as as the master server and 'rname' as the responsible person mailbox. It is the responsibility of the driver to increment the serial number between responses if necessary. All other SOA fields will have reasonable default values. |
Definition in file sdb.h.
#define DNS_SDBFLAG_RELATIVEOWNER 0x00000001U |
Definition at line 101 of file sdb.h.
Referenced by dns_sdb_register(), findnodeext(), and ns_builtin_init().
#define DNS_SDBFLAG_RELATIVERDATA 0x00000002U |
Definition at line 102 of file sdb.h.
Referenced by dns_sdb_putrr(), dns_sdb_register(), getnode(), and ns_builtin_init().
#define DNS_SDBFLAG_THREADSAFE 0x00000004U |
#define DNS_SDBFLAG_DNS64 0x00000008U |
Definition at line 104 of file sdb.h.
Referenced by dns_sdb_register(), findext(), and ns_builtin_init().
typedef struct dns_sdblookup dns_sdblookup_t |
typedef struct dns_sdballnodes dns_sdballnodes_t |
typedef isc_result_t(* dns_sdblookupfunc_t)(const char *zone, const char *name, void *dbdata, dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) |
typedef isc_result_t(* dns_sdblookup2func_t)(const dns_name_t *zone, const dns_name_t *name, void *dbdata, dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) |
typedef isc_result_t(* dns_sdbauthorityfunc_t)(const char *zone, void *dbdata, dns_sdblookup_t *) |
typedef isc_result_t(* dns_sdballnodesfunc_t)(const char *zone, void *dbdata, dns_sdballnodes_t *allnodes) |
typedef isc_result_t(* dns_sdbcreatefunc_t)(const char *zone, int argc, char **argv, void *driverdata, void **dbdata) |
typedef void(* dns_sdbdestroyfunc_t)(const char *zone, void *driverdata, void **dbdata) |
typedef struct dns_sdbmethods dns_sdbmethods_t |
isc_result_t dns_sdb_register | ( | const char * | drivername, | |
const dns_sdbmethods_t * | methods, | |||
void * | driverdata, | |||
unsigned int | flags, | |||
isc_mem_t * | mctx, | |||
dns_sdbimplementation_t ** | sdbimp | |||
) |
Register a simple database driver for the database type 'drivername', implemented by the functions in '*methods'.
sdbimp must point to a NULL dns_sdbimplementation_t pointer. That is, sdbimp != NULL && *sdbimp == NULL. It will be assigned a value that will later be used to identify the driver when deregistering it.
The name server will perform lookups in the database by calling the function 'lookup', passing it a printable zone name 'zone', a printable domain name 'name', and a copy of the argument 'dbdata' that was potentially returned by the create function. The 'dns_sdblookup_t' argument to 'lookup' and 'authority' is an opaque pointer to be passed to ns_sdb_putrr().
The lookup function returns the lookup results to the name server by calling ns_sdb_putrr() once for each record found. On success, the return value of the lookup function should be ISC_R_SUCCESS. If the domain name 'name' does not exist, the lookup function should ISC_R_NOTFOUND. Any other return value is treated as an error.
Lookups at the zone apex will cause the server to also call the function 'authority' (if non-NULL), which must provide an SOA record and NS records for the zone by calling ns_sdb_putrr() once for each of these records. The 'authority' function may be NULL if invoking the 'lookup' function on the zone apex will return SOA and NS records.
The allnodes function, if non-NULL, fills in an opaque structure to be used by a database iterator. This allows the zone to be transferred. This may use a considerable amount of memory for large zones, and the zone transfer may not be fully RFC1035 compliant if the zone is frequently changed.
The create function will be called for each zone configured into the name server using this database type. It can be used to create a "database object" containing zone specific data, which can make use of the database arguments specified in the name server configuration.
The destroy function will be called to free the database object when its zone is destroyed.
The create and destroy functions may be NULL.
If flags includes DNS_SDBFLAG_RELATIVEOWNER, the lookup and authority functions will be called with relative names rather than absolute names. The string "@" represents the zone apex in this case.
If flags includes DNS_SDBFLAG_RELATIVERDATA, the rdata strings may include relative names. Otherwise, all names in the rdata string must be absolute. Be aware that if relative names are allowed, any absolute names must contain a trailing dot.
If flags includes DNS_SDBFLAG_THREADSAFE, the driver must be able to handle multiple lookups in parallel. Otherwise, calls into the driver are serialized.
Definition at line 210 of file sdb.c.
References dns_sdbimplementation::dbimp, DESTROYLOCK, dns_db_register(), dns_sdb_create(), DNS_SDBFLAG_DNS64, DNS_SDBFLAG_RELATIVEOWNER, DNS_SDBFLAG_RELATIVERDATA, DNS_SDBFLAG_THREADSAFE, dns_sdbimplementation::driverdata, dns_sdbimplementation::driverlock, dns_sdbimplementation::flags, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_sdbmethods::lookup, dns_sdbmethods::lookup2, dns_sdbimplementation::mctx, dns_sdbimplementation::methods, and REQUIRE.
Referenced by ns_builtin_init().
void dns_sdb_unregister | ( | dns_sdbimplementation_t ** | sdbimp | ) |
Removes the simple database driver from the list of registered database types. There must be no active databases of this type when this function is called.
Definition at line 256 of file sdb.c.
References dns_sdbimplementation::dbimp, DESTROYLOCK, dns_db_unregister(), dns_sdbimplementation::driverlock, isc_mem_detach(), isc_mem_put, dns_sdbimplementation::mctx, mctx, and REQUIRE.
Referenced by ns_builtin_deinit().
isc_result_t dns_sdb_putrr | ( | dns_sdblookup_t * | lookup, | |
const char * | type, | |||
dns_ttl_t | ttl, | |||
const char * | data | |||
) |
See dns_sdb_putradata().
Definition at line 342 of file sdb.c.
References isc_textregion::base, dns_sdb::common, DE_CONST, dns_rdata_fromtext(), dns_rdatatype_fromtext(), dns_rootname, dns_sdb_putrdata(), DNS_SDBFLAG_RELATIVERDATA, dns_sdbimplementation::flags, dns_sdb::implementation, initial_size(), isc_buffer_add, isc_buffer_base, isc_buffer_constinit, isc_buffer_init, isc_buffer_usedlength, isc_lex_create(), isc_lex_destroy(), isc_lex_openbuffer(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_textregion::length, dns_db::mctx, mctx, dns_db::origin, origin, r, dns_db::rdclass, REQUIRE, dns_sdblookup::sdb, and VALID_SDBLOOKUP.
Referenced by builtin_authority(), dns_sdb_putnamedrr(), and dns_sdb_putsoa().
isc_result_t dns_sdb_putrdata | ( | dns_sdblookup_t * | lookup, | |
dns_rdatatype_t | type, | |||
dns_ttl_t | ttl, | |||
const unsigned char * | rdata, | |||
unsigned int | rdlen | |||
) |
Add a single resource record to the lookup structure to be returned in the query response. dns_sdb_putrr() takes the resource record in master file text format as a null-terminated string, and dns_sdb_putrdata() takes the raw RDATA in uncompressed wire format.
Definition at line 284 of file sdb.c.
References isc_region::base, dns_sdb::common, DE_CONST, DNS_R_BADTTL, dns_rdata_fromregion(), dns_rdata_init(), dns_rdatalist_init(), isc_buffer_allocate(), isc_buffer_copyregion(), isc_buffer_usedregion, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_region::length, dns_db::mctx, mctx, dns_db::rdclass, dns_rdatalist::rdclass, dns_sdblookup::sdb, dns_rdatalist::ttl, and dns_rdatalist::type.
Referenced by dns64_cname(), dns_sdb_putnamedrdata(), dns_sdb_putrr(), and put_txt().
isc_result_t dns_sdb_putnamedrr | ( | dns_sdballnodes_t * | allnodes, | |
const char * | name, | |||
const char * | type, | |||
dns_ttl_t | ttl, | |||
const char * | data | |||
) |
See dns_sdb_putnamerdata().
Definition at line 490 of file sdb.c.
References dns_sdb_putrr(), getnode(), and ISC_R_SUCCESS.
isc_result_t dns_sdb_putnamedrdata | ( | dns_sdballnodes_t * | allnodes, | |
const char * | name, | |||
dns_rdatatype_t | type, | |||
dns_ttl_t | ttl, | |||
const void * | rdata, | |||
unsigned int | rdlen | |||
) |
Add a single resource record to the allnodes structure to be included in a zone transfer response, in text or wire format as above.
Definition at line 502 of file sdb.c.
References dns_sdb_putrdata(), getnode(), and ISC_R_SUCCESS.
isc_result_t dns_sdb_putsoa | ( | dns_sdblookup_t * | lookup, | |
const char * | mname, | |||
const char * | rname, | |||
isc_uint32_t | serial | |||
) |
This function may optionally be called from the 'authority' callback to simplify construction of the SOA record for 'zone'. It will provide a SOA listing 'mname' as as the master server and 'rname' as the responsible person mailbox. It is the responsibility of the driver to increment the serial number between responses if necessary. All other SOA fields will have reasonable default values.
Definition at line 515 of file sdb.c.
References DNS_NAME_MAXTEXT, dns_sdb_putrr(), ISC_R_NOSPACE, REQUIRE, SDB_DEFAULT_EXPIRE, SDB_DEFAULT_MINIMUM, SDB_DEFAULT_REFRESH, SDB_DEFAULT_RETRY, SDB_DEFAULT_TTL, and str.
Referenced by builtin_authority().