dbtable.c File Reference

#include <config.h>
#include <isc/mem.h>
#include <isc/rwlock.h>
#include <isc/util.h>
#include <dns/dbtable.h>
#include <dns/db.h>
#include <dns/rbt.h>
#include <dns/result.h>

Go to the source code of this file.

Data Structures

struct  dns_dbtable

Defines

#define DBTABLE_MAGIC   ISC_MAGIC('D', 'B', '-', '-')
#define VALID_DBTABLE(dbtable)   ISC_MAGIC_VALID(dbtable, DBTABLE_MAGIC)

Functions

static void dbdetach (void *data, void *arg)
isc_result_t dns_dbtable_create (isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_dbtable_t **dbtablep)
 Make a new dbtable of class 'rdclass'.
static void dbtable_free (dns_dbtable_t *dbtable)
void dns_dbtable_attach (dns_dbtable_t *source, dns_dbtable_t **targetp)
 Attach '*targetp' to 'source'.
void dns_dbtable_detach (dns_dbtable_t **dbtablep)
 Detach *dbtablep from its dbtable.
isc_result_t dns_dbtable_add (dns_dbtable_t *dbtable, dns_db_t *db)
 Add 'db' to 'dbtable'.
void dns_dbtable_remove (dns_dbtable_t *dbtable, dns_db_t *db)
 Remove 'db' from 'dbtable'.
void dns_dbtable_adddefault (dns_dbtable_t *dbtable, dns_db_t *db)
 Use 'db' as the result of a dns_dbtable_find() if no better match is available.
void dns_dbtable_getdefault (dns_dbtable_t *dbtable, dns_db_t **dbp)
 Get the 'db' used as the result of a dns_dbtable_find() if no better match is available.
void dns_dbtable_removedefault (dns_dbtable_t *dbtable)
 Remove the default db from 'dbtable'.
isc_result_t dns_dbtable_find (dns_dbtable_t *dbtable, dns_name_t *name, unsigned int options, dns_db_t **dbp)
 Find the deepest match to 'name' in the dbtable, and return it.


Detailed Description

Author:
Principal Author: DCL

Definition in file dbtable.c.


Define Documentation

#define DBTABLE_MAGIC   ISC_MAGIC('D', 'B', '-', '-')

Definition at line 52 of file dbtable.c.

Referenced by dns_dbtable_create().

#define VALID_DBTABLE ( dbtable   )     ISC_MAGIC_VALID(dbtable, DBTABLE_MAGIC)

Definition at line 53 of file dbtable.c.

Referenced by dns_dbtable_add(), dns_dbtable_adddefault(), dns_dbtable_attach(), dns_dbtable_detach(), dns_dbtable_getdefault(), dns_dbtable_remove(), and dns_dbtable_removedefault().


Function Documentation

static void dbdetach ( void *  data,
void *  arg 
) [static]

Definition at line 56 of file dbtable.c.

References dns_db_detach(), and UNUSED.

Referenced by dns_dbtable_create().

isc_result_t dns_dbtable_create ( isc_mem_t mctx,
dns_rdataclass_t  rdclass,
dns_dbtable_t **  dbtablep 
)

Make a new dbtable of class 'rdclass'.

Requires:

Returns:

Definition at line 65 of file dbtable.c.

References dbdetach(), DBTABLE_MAGIC, dns_dbtable::default_db, DESTROYLOCK, dns_rbt_create(), dns_rbt_destroy(), isc_mem_attach(), isc_mem_get, isc_mem_putanddetach, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_rwlock_init(), dns_dbtable::lock, dns_dbtable::magic, dns_dbtable::mctx, dns_dbtable::rbt, dns_dbtable::rdclass, dns_dbtable::references, REQUIRE, and dns_dbtable::tree_lock.

static void dbtable_free ( dns_dbtable_t dbtable  )  [inline, static]

Definition at line 115 of file dbtable.c.

References dns_dbtable::default_db, dns_db_detach(), dns_rbt_destroy(), isc_mem_putanddetach, isc_rwlock_destroy(), isc_rwlocktype_write, dns_dbtable::magic, dns_dbtable::mctx, dns_dbtable::rbt, RWLOCK, RWUNLOCK, and dns_dbtable::tree_lock.

Referenced by dns_dbtable_detach().

void dns_dbtable_attach ( dns_dbtable_t source,
dns_dbtable_t **  targetp 
)

Attach '*targetp' to 'source'.

Requires:

Ensures:

Definition at line 137 of file dbtable.c.

References INSIST, dns_dbtable::lock, LOCK, dns_dbtable::references, REQUIRE, UNLOCK, and VALID_DBTABLE.

void dns_dbtable_detach ( dns_dbtable_t **  dbtablep  ) 

Detach *dbtablep from its dbtable.

Requires:

Ensures:

Definition at line 153 of file dbtable.c.

References dbtable_free(), INSIST, ISC_FALSE, ISC_TRUE, dns_dbtable::lock, LOCK, dns_dbtable::references, REQUIRE, UNLOCK, and VALID_DBTABLE.

isc_result_t dns_dbtable_add ( dns_dbtable_t dbtable,
dns_db_t db 
)

Add 'db' to 'dbtable'.

Requires:

Definition at line 177 of file dbtable.c.

References dns_db_attach(), dns_db_class(), dns_db_origin(), dns_rbt_addname(), isc_rwlocktype_write, dns_dbtable::rbt, dns_dbtable::rdclass, REQUIRE, RWLOCK, RWUNLOCK, dns_dbtable::tree_lock, and VALID_DBTABLE.

void dns_dbtable_remove ( dns_dbtable_t dbtable,
dns_db_t db 
)

Remove 'db' from 'dbtable'.

Requires:

Definition at line 195 of file dbtable.c.

References dns_db_origin(), dns_rbt_deletename(), dns_rbt_findname(), INSIST, ISC_FALSE, ISC_R_SUCCESS, isc_rwlocktype_write, name, dns_dbtable::rbt, REQUIRE, RWLOCK, RWUNLOCK, dns_dbtable::tree_lock, and VALID_DBTABLE.

void dns_dbtable_adddefault ( dns_dbtable_t dbtable,
dns_db_t db 
)

Use 'db' as the result of a dns_dbtable_find() if no better match is available.

Definition at line 227 of file dbtable.c.

References dns_dbtable::default_db, dns_db_attach(), dns_db_origin(), dns_name_compare(), dns_rootname, isc_rwlocktype_write, REQUIRE, RWLOCK, RWUNLOCK, dns_dbtable::tree_lock, and VALID_DBTABLE.

void dns_dbtable_getdefault ( dns_dbtable_t dbtable,
dns_db_t **  dbp 
)

Get the 'db' used as the result of a dns_dbtable_find() if no better match is available.

Definition at line 241 of file dbtable.c.

References dns_dbtable::default_db, dns_db_attach(), isc_rwlocktype_read, REQUIRE, RWLOCK, RWUNLOCK, dns_dbtable::tree_lock, and VALID_DBTABLE.

void dns_dbtable_removedefault ( dns_dbtable_t dbtable  ) 

Remove the default db from 'dbtable'.

Definition at line 253 of file dbtable.c.

References dns_dbtable::default_db, dns_db_detach(), isc_rwlocktype_write, REQUIRE, RWLOCK, RWUNLOCK, dns_dbtable::tree_lock, and VALID_DBTABLE.

isc_result_t dns_dbtable_find ( dns_dbtable_t dbtable,
dns_name_t name,
unsigned int  options,
dns_db_t **  dbp 
)

Find the deepest match to 'name' in the dbtable, and return it.

Notes:

Returns:

Definition at line 264 of file dbtable.c.

References dns_dbtable::default_db, dns_db_attach(), DNS_DBTABLEFIND_NOEXACT, DNS_R_PARTIALMATCH, dns_rbt_findname(), DNS_RBTFIND_NOEXACT, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_rwlocktype_read, dns_dbtable::rbt, REQUIRE, RWLOCK, RWUNLOCK, and dns_dbtable::tree_lock.


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