ecdb.c File Reference

#include "config.h"
#include <isc/result.h>
#include <isc/util.h>
#include <isc/mutex.h>
#include <isc/mem.h>
#include <dns/db.h>
#include <dns/ecdb.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/rdataslab.h>

Go to the source code of this file.

Data Structures

struct  dns_ecdb
 The 'ephemeral' cache DB (ecdb) implementation. An ecdb just provides temporary storage for ongoing name resolution with the common DB interfaces. It actually doesn't cache anything. The implementation expects any stored data is released within a short period, and does not care about the scalability in terms of the number of nodes. More...
struct  dns_ecdbnode
struct  rdatasetheader
struct  ecdb_rdatasetiter

Defines

#define ECDB_MAGIC   ISC_MAGIC('E', 'C', 'D', 'B')
#define VALID_ECDB(db)
#define ECDBNODE_MAGIC   ISC_MAGIC('E', 'C', 'D', 'N')
#define VALID_ECDBNODE(ecdbn)   ISC_MAGIC_VALID(ecdbn, ECDBNODE_MAGIC)
#define RDATASET_ATTR_NXDOMAIN   0x0010
#define RDATASET_ATTR_NEGATIVE   0x0100
#define NXDOMAIN(header)   (((header)->attributes & RDATASET_ATTR_NXDOMAIN) != 0)
#define NEGATIVE(header)   (((header)->attributes & RDATASET_ATTR_NEGATIVE) != 0)

Typedefs

typedef struct dns_ecdb dns_ecdb_t
typedef struct dns_ecdbnode dns_ecdbnode_t
typedef struct rdatasetheader rdatasetheader_t
typedef struct ecdb_rdatasetiter ecdb_rdatasetiter_t

Functions

static isc_result_t dns_ecdb_create (isc_mem_t *mctx, dns_name_t *origin, dns_dbtype_t type, dns_rdataclass_t rdclass, unsigned int argc, char *argv[], void *driverarg, dns_db_t **dbp)
static void rdataset_disassociate (dns_rdataset_t *rdataset)
 Rdataset Methods.
static isc_result_t rdataset_first (dns_rdataset_t *rdataset)
static isc_result_t rdataset_next (dns_rdataset_t *rdataset)
static void rdataset_current (dns_rdataset_t *rdataset, dns_rdata_t *rdata)
static void rdataset_clone (dns_rdataset_t *source, dns_rdataset_t *target)
static unsigned int rdataset_count (dns_rdataset_t *rdataset)
static void rdataset_settrust (dns_rdataset_t *rdataset, dns_trust_t trust)
static void rdatasetiter_destroy (dns_rdatasetiter_t **iteratorp)
static isc_result_t rdatasetiter_first (dns_rdatasetiter_t *iterator)
static isc_result_t rdatasetiter_next (dns_rdatasetiter_t *iterator)
static void rdatasetiter_current (dns_rdatasetiter_t *iterator, dns_rdataset_t *rdataset)
isc_result_t dns_ecdb_register (isc_mem_t *mctx, dns_dbimplementation_t **dbimp)
void dns_ecdb_unregister (dns_dbimplementation_t **dbimp)
static void attach (dns_db_t *source, dns_db_t **targetp)
 DB routines.
static void destroy_ecdb (dns_ecdb_t **ecdbp)
static void detach (dns_db_t **dbp)
static void attachnode (dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp)
static void destroynode (dns_ecdbnode_t *node)
static void detachnode (dns_db_t *db, dns_dbnode_t **nodep)
static isc_result_t find (dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, dns_dbnode_t **nodep, dns_name_t *foundname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
static isc_result_t findzonecut (dns_db_t *db, dns_name_t *name, unsigned int options, isc_stdtime_t now, dns_dbnode_t **nodep, dns_name_t *foundname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
static isc_result_t findnode (dns_db_t *db, dns_name_t *name, isc_boolean_t create, dns_dbnode_t **nodep)
static void bind_rdataset (dns_ecdb_t *ecdb, dns_ecdbnode_t *node, rdatasetheader_t *header, dns_rdataset_t *rdataset)
static isc_result_t addrdataset (dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, isc_stdtime_t now, dns_rdataset_t *rdataset, unsigned int options, dns_rdataset_t *addedrdataset)
static isc_result_t deleterdataset (dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, dns_rdatatype_t type, dns_rdatatype_t covers)
static isc_result_t createiterator (dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
static isc_result_t allrdatasets (dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, isc_stdtime_t now, dns_rdatasetiter_t **iteratorp)

Variables

static dns_rdatasetmethods_t rdataset_methods
static dns_rdatasetitermethods_t rdatasetiter_methods
static dns_dbmethods_t ecdb_methods


Define Documentation

#define ECDB_MAGIC   ISC_MAGIC('E', 'C', 'D', 'B')

Definition at line 31 of file ecdb.c.

Referenced by dns_ecdb_create().

#define VALID_ECDB ( db   ) 

Value:

((db) != NULL && \
                                 (db)->common.impmagic == ECDB_MAGIC)

Definition at line 32 of file ecdb.c.

Referenced by addrdataset(), allrdatasets(), attach(), attachnode(), detach(), detachnode(), find(), findnode(), findzonecut(), and rdatasetiter_current().

#define ECDBNODE_MAGIC   ISC_MAGIC('E', 'C', 'D', 'N')

Definition at line 35 of file ecdb.c.

Referenced by findnode().

#define VALID_ECDBNODE ( ecdbn   )     ISC_MAGIC_VALID(ecdbn, ECDBNODE_MAGIC)

Definition at line 36 of file ecdb.c.

Referenced by addrdataset(), allrdatasets(), attachnode(), and detachnode().

#define RDATASET_ATTR_NXDOMAIN   0x0010

Definition at line 80 of file ecdb.c.

Referenced by addrdataset().

#define RDATASET_ATTR_NEGATIVE   0x0100

Definition at line 81 of file ecdb.c.

Referenced by addrdataset().

#define NXDOMAIN ( header   )     (((header)->attributes & RDATASET_ATTR_NXDOMAIN) != 0)

Definition at line 82 of file ecdb.c.

Referenced by bind_rdataset(), cache_find(), cache_findrdataset(), cache_name(), ncache_adderesult(), rdataset_totext(), and update_rrsetstats().

#define NEGATIVE ( header   )     (((header)->attributes & RDATASET_ATTR_NEGATIVE) != 0)

Definition at line 84 of file ecdb.c.

Referenced by add32(), bind_rdataset(), cache_find(), cache_findrdataset(), cache_name(), dsvalidated(), fctx_sendevents(), ncache_adderesult(), rdatasetiter_next(), update_rrsetstats(), and validator_start().


Typedef Documentation

typedef struct dns_ecdb dns_ecdb_t

typedef struct dns_ecdbnode dns_ecdbnode_t

typedef struct rdatasetheader rdatasetheader_t

typedef struct ecdb_rdatasetiter ecdb_rdatasetiter_t


Function Documentation

static isc_result_t dns_ecdb_create ( isc_mem_t mctx,
dns_name_t origin,
dns_dbtype_t  type,
dns_rdataclass_t  rdclass,
unsigned int  argc,
char *  argv[],
void *  driverarg,
dns_db_t **  dbp 
) [static]

Definition at line 596 of file ecdb.c.

References dns_db::attributes, dns_ecdb::common, DNS_DB_MAGIC, DNS_DBATTR_CACHE, dns_dbtype_cache, dns_name_dupwithoffsets(), dns_name_dynamic(), dns_name_free(), dns_name_init(), dns_rootname, ECDB_MAGIC, dns_db::impmagic, ISC_LIST_INIT, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), dns_ecdb::lock, dns_db::magic, dns_db::mctx, dns_db::methods, dns_db::origin, dns_db::rdclass, dns_ecdb::references, REQUIRE, UNEXPECTED_ERROR, and UNUSED.

Referenced by dns_ecdb_register().

static void rdataset_disassociate ( dns_rdataset_t rdataset  )  [static]

Rdataset Methods.

Definition at line 655 of file ecdb.c.

References dns_db_detachnode(), dns_rdataset::private1, and dns_rdataset::private2.

static isc_result_t rdataset_first ( dns_rdataset_t rdataset  )  [static]

Definition at line 663 of file ecdb.c.

References ISC_R_NOMORE, ISC_R_SUCCESS, dns_rdataset::private3, dns_rdataset::private5, and dns_rdataset::privateuint4.

static isc_result_t rdataset_next ( dns_rdataset_t rdataset  )  [static]

Definition at line 690 of file ecdb.c.

References ISC_R_NOMORE, ISC_R_SUCCESS, dns_rdataset::private5, and dns_rdataset::privateuint4.

Referenced by clear_entry().

static void rdataset_current ( dns_rdataset_t rdataset,
dns_rdata_t rdata 
) [static]

Definition at line 713 of file ecdb.c.

References isc_region::base, dns_rdata_fromregion(), DNS_RDATA_OFFLINE, DNS_RDATASLAB_OFFLINE, dns_rdata::flags, isc_region::length, dns_rdataset::private5, r, dns_rdataset::rdclass, REQUIRE, and dns_rdataset::type.

static void rdataset_clone ( dns_rdataset_t source,
dns_rdataset_t target 
) [static]

Definition at line 740 of file ecdb.c.

References attachnode(), dns_rdataset::private1, dns_rdataset::private2, dns_rdataset::private5, and dns_rdataset::privateuint4.

static unsigned int rdataset_count ( dns_rdataset_t rdataset  )  [static]

Definition at line 756 of file ecdb.c.

References dns_rdataset::private3.

static void rdataset_settrust ( dns_rdataset_t rdataset,
dns_trust_t  trust 
) [static]

Definition at line 766 of file ecdb.c.

References header, dns_rdataset::private3, dns_rdataset::trust, and rdatasetheader::trust.

static void rdatasetiter_destroy ( dns_rdatasetiter_t **  iteratorp  )  [static]

Definition at line 778 of file ecdb.c.

References dns_db_detachnode(), DNS_RDATASETITER_VALID, isc_mem_put, isc_mem::magic, mctx, and REQUIRE.

static isc_result_t rdatasetiter_first ( dns_rdatasetiter_t iterator  )  [static]

Definition at line 802 of file ecdb.c.

References ecdb_rdatasetiter::current, DNS_RDATASETITER_VALID, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_R_NOMORE, ISC_R_SUCCESS, dns_rdatasetiter::node, and REQUIRE.

static isc_result_t rdatasetiter_next ( dns_rdatasetiter_t iterator  )  [static]

Definition at line 815 of file ecdb.c.

References ecdb_rdatasetiter::current, DNS_RDATASETITER_VALID, ISC_LIST_NEXT, ISC_R_NOMORE, ISC_R_SUCCESS, and REQUIRE.

static void rdatasetiter_current ( dns_rdatasetiter_t iterator,
dns_rdataset_t rdataset 
) [static]

Definition at line 828 of file ecdb.c.

References bind_rdataset(), ecdb_rdatasetiter::current, dns_rdatasetiter::db, dns_rdatasetiter::node, REQUIRE, and VALID_ECDB.

isc_result_t dns_ecdb_register ( isc_mem_t mctx,
dns_dbimplementation_t **  dbimp 
)

Definition at line 141 of file ecdb.c.

References dns_db_register(), dns_ecdb_create(), and REQUIRE.

Referenced by initialize().

void dns_ecdb_unregister ( dns_dbimplementation_t **  dbimp  ) 

Definition at line 149 of file ecdb.c.

References dns_db_unregister(), and REQUIRE.

Referenced by dns_lib_shutdown(), and initialize().

static void attach ( dns_db_t source,
dns_db_t **  targetp 
) [static]

DB routines.

Definition at line 160 of file ecdb.c.

References dns_ecdb::lock, LOCK, dns_ecdb::references, REQUIRE, UNLOCK, and VALID_ECDB.

Referenced by createnode(), and decrement_reference().

static void destroy_ecdb ( dns_ecdb_t **  ecdbp  )  [static]

Definition at line 174 of file ecdb.c.

References dns_ecdb::common, DESTROYLOCK, dns_name_dynamic(), dns_name_free(), dns_db::impmagic, isc_mem_putanddetach, dns_ecdb::lock, dns_db::magic, dns_db::mctx, mctx, and dns_db::origin.

Referenced by destroynode(), and detach().

static void detach ( dns_db_t **  dbp  )  [static]

Definition at line 192 of file ecdb.c.

References destroy_ecdb(), ISC_FALSE, ISC_LIST_EMPTY, ISC_TRUE, dns_ecdb::lock, LOCK, dns_ecdb::references, REQUIRE, UNLOCK, and VALID_ECDB.

Referenced by destroynode(), prune_tree(), and refresh_callback().

static void attachnode ( dns_db_t db,
dns_dbnode_t source,
dns_dbnode_t **  targetp 
) [static]

Definition at line 213 of file ecdb.c.

References INSIST, dns_ecdbnode::lock, LOCK, dns_ecdbnode::references, REQUIRE, UNLOCK, VALID_ECDB, and VALID_ECDBNODE.

Referenced by allrdatasets(), dbiterator_current(), rdataset_clone(), rdataset_getclosest(), and rdataset_getnoqname().

static void destroynode ( dns_ecdbnode_t node  )  [static]

Definition at line 231 of file ecdb.c.

References dns_ecdb::common, destroy_ecdb(), DESTROYLOCK, dns_name_free(), dns_rdataslab_size(), dns_ecdbnode::ecdb, header, ISC_FALSE, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_put, ISC_TRUE, dns_ecdbnode::lock, dns_ecdb::lock, LOCK, dns_ecdbnode::magic, dns_db::mctx, mctx, dns_ecdbnode::name, dns_ecdb::references, and UNLOCK.

Referenced by dbiterator_destroy(), detachnode(), dns_sdlz_putnamedrr(), findext(), findnodeext(), getnode(), and getnodedata().

static void detachnode ( dns_db_t db,
dns_dbnode_t **  nodep 
) [static]

Definition at line 267 of file ecdb.c.

References destroynode(), INSIST, ISC_FALSE, ISC_TRUE, dns_ecdbnode::lock, LOCK, dns_ecdbnode::references, REQUIRE, UNLOCK, UNUSED, VALID_ECDB, and VALID_ECDBNODE.

Referenced by disassociate(), findext(), rdataset_disassociate(), and rdatasetiter_destroy().

static isc_result_t find ( dns_db_t db,
dns_name_t name,
dns_dbversion_t version,
dns_rdatatype_t  type,
unsigned int  options,
isc_stdtime_t  now,
dns_dbnode_t **  nodep,
dns_name_t foundname,
dns_rdataset_t rdataset,
dns_rdataset_t sigrdataset 
) [static]

Definition at line 293 of file ecdb.c.

References ISC_R_NOTFOUND, REQUIRE, UNUSED, and VALID_ECDB.

Referenced by ATF_TC_BODY(), ATF_TP_ADD_TCS(), clean_finds_at_name(), dns_adb_createfind2(), dns_adb_destroyfind(), event_free(), free_adbfind(), and print_find_list().

static isc_result_t findzonecut ( dns_db_t db,
dns_name_t name,
unsigned int  options,
isc_stdtime_t  now,
dns_dbnode_t **  nodep,
dns_name_t foundname,
dns_rdataset_t rdataset,
dns_rdataset_t sigrdataset 
) [static]

Definition at line 316 of file ecdb.c.

References ISC_R_NOTFOUND, REQUIRE, UNUSED, and VALID_ECDB.

static isc_result_t findnode ( dns_db_t db,
dns_name_t name,
isc_boolean_t  create,
dns_dbnode_t **  nodep 
) [static]

Definition at line 337 of file ecdb.c.

References dns_ecdb::common, DESTROYLOCK, dns_name_dup(), dns_name_init(), dns_ecdbnode::ecdb, ECDBNODE_MAGIC, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_INIT, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOTFOUND, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), ISC_TRUE, dns_ecdb::lock, LOCK, dns_ecdbnode::lock, dns_ecdbnode::magic, dns_db::mctx, mctx, dns_ecdbnode::name, dns_ecdbnode::references, REQUIRE, UNEXPECTED_ERROR, UNLOCK, UNUSED, and VALID_ECDB.

static void bind_rdataset ( dns_ecdb_t ecdb,
dns_ecdbnode_t node,
rdatasetheader_t header,
dns_rdataset_t rdataset 
) [static]

Definition at line 394 of file ecdb.c.

References dns_rdataset::attributes, dns_ecdb::common, dns_rdataset::count, rdatasetheader::covers, dns_rdataset::covers, dns_rdataset_isassociated(), DNS_RDATASETATTR_NEGATIVE, DNS_RDATASETATTR_NXDOMAIN, INSIST, dns_rdataset::methods, NEGATIVE, NXDOMAIN, dns_rdataset::private1, dns_rdataset::private2, dns_rdataset::private3, dns_rdataset::private5, dns_rdataset::privateuint4, dns_db::rdclass, dns_rdataset::rdclass, dns_ecdbnode::references, REQUIRE, rdatasetheader::trust, dns_rdataset::trust, rdatasetheader::ttl, dns_rdataset::ttl, rdatasetheader::type, and dns_rdataset::type.

Referenced by add32(), addrdataset(), cache_find(), cache_findrdataset(), cache_findzonecut(), find_closest_nsec(), find_coveringnsec(), find_deepest_zonecut(), getsigningtime(), rdatasetiter_current(), setup_delegation(), subtractrdataset(), zone_find(), and zone_findrdataset().

static isc_result_t addrdataset ( dns_db_t db,
dns_dbnode_t node,
dns_dbversion_t version,
isc_stdtime_t  now,
dns_rdataset_t rdataset,
unsigned int  options,
dns_rdataset_t addedrdataset 
) [static]

Definition at line 433 of file ecdb.c.

References dns_rdataset::attributes, rdatasetheader::attributes, isc_region::base, bind_rdataset(), dns_ecdb::common, dns_rdataset::covers, rdatasetheader::covers, DNS_RDATASETATTR_NEGATIVE, DNS_RDATASETATTR_NXDOMAIN, dns_rdataslab_fromrdataset(), header, INSIST, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, dns_ecdbnode::lock, LOCK, dns_db::mctx, mctx, r, RDATASET_ATTR_NEGATIVE, RDATASET_ATTR_NXDOMAIN, REQUIRE, dns_rdataset::trust, rdatasetheader::trust, dns_rdataset::ttl, rdatasetheader::ttl, dns_rdataset::type, rdatasetheader::type, UNLOCK, UNUSED, VALID_ECDB, and VALID_ECDBNODE.

Referenced by ATF_TC_BODY(), and ATF_TP_ADD_TCS().

static isc_result_t deleterdataset ( dns_db_t db,
dns_dbnode_t node,
dns_dbversion_t version,
dns_rdatatype_t  type,
dns_rdatatype_t  covers 
) [static]

Definition at line 495 of file ecdb.c.

References ISC_R_NOTIMPLEMENTED, and UNUSED.

Referenced by ATF_TC_BODY(), and ATF_TP_ADD_TCS().

static isc_result_t createiterator ( dns_db_t db,
unsigned int  options,
dns_dbiterator_t **  iteratorp 
) [static]

Definition at line 508 of file ecdb.c.

References ISC_R_NOTIMPLEMENTED, and UNUSED.

static isc_result_t allrdatasets ( dns_db_t db,
dns_dbnode_t node,
dns_dbversion_t version,
isc_stdtime_t  now,
dns_rdatasetiter_t **  iteratorp 
) [static]

Definition at line 519 of file ecdb.c.

References attachnode(), ecdb_rdatasetiter::common, dns_ecdb::common, dns_rdatasetiter::db, DNS_RDATASETITER_MAGIC, isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_rdatasetiter::magic, dns_db::mctx, mctx, dns_rdatasetiter::methods, dns_rdatasetiter::node, dns_rdatasetiter::now, REQUIRE, VALID_ECDB, VALID_ECDBNODE, and dns_rdatasetiter::version.

Referenced by ATF_TC_BODY(), and ATF_TP_ADD_TCS().


Variable Documentation

dns_rdatasetmethods_t rdataset_methods [static]

Initial value:

 {
        rdataset_disassociate,
        rdataset_first,
        rdataset_next,
        rdataset_current,
        rdataset_clone,
        rdataset_count,
        NULL,                   
        NULL,                   
        NULL,                   
        NULL,                   
        NULL,                   
        NULL,                   
        NULL,                   
        rdataset_settrust,      
        NULL,                   
        NULL,                   
        NULL,                   
        NULL                    
}

Definition at line 101 of file ecdb.c.

Referenced by bind_rdataset(), and resigned().

dns_rdatasetitermethods_t rdatasetiter_methods [static]

Initial value:

Definition at line 133 of file ecdb.c.

Referenced by allrdatasets().

dns_dbmethods_t ecdb_methods [static]

Definition at line 549 of file ecdb.c.


Generated on Tue Apr 28 17:41:08 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha