client.c File Reference

#include <config.h>
#include <stddef.h>
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/sockaddr.h>
#include <isc/socket.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <dns/adb.h>
#include <dns/client.h>
#include <dns/db.h>
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/forward.h>
#include <dns/keytable.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatatype.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatastruct.h>
#include <dns/request.h>
#include <dns/resolver.h>
#include <dns/result.h>
#include <dns/tsec.h>
#include <dns/tsig.h>
#include <dns/view.h>
#include <dst/dst.h>

Go to the source code of this file.

Data Structures

struct  dns_client
 DNS client object. More...
struct  resctx
 Internal state for a single name resolution procedure. More...
struct  resarg
 Argument of an internal event for synchronous name resolution. More...
struct  reqctx
 Internal state for a single DNS request. More...
struct  reqarg
 Argument of an internal event for synchronous DNS request. More...
struct  updatearg
 Argument of an internal event for synchronous name resolution. More...
struct  updatectx
 Internal state for a single dynamic update procedure. More...
struct  dns_client_updaterec_t

Defines

#define DNS_CLIENT_MAGIC   ISC_MAGIC('D', 'N', 'S', 'c')
#define DNS_CLIENT_VALID(c)   ISC_MAGIC_VALID(c, DNS_CLIENT_MAGIC)
#define RCTX_MAGIC   ISC_MAGIC('R', 'c', 't', 'x')
#define RCTX_VALID(c)   ISC_MAGIC_VALID(c, RCTX_MAGIC)
#define REQCTX_MAGIC   ISC_MAGIC('R', 'q', 'c', 'x')
#define REQCTX_VALID(c)   ISC_MAGIC_VALID(c, REQCTX_MAGIC)
#define UCTX_MAGIC   ISC_MAGIC('U', 'c', 't', 'x')
#define UCTX_VALID(c)   ISC_MAGIC_VALID(c, UCTX_MAGIC)
#define MAX_RESTARTS   16
#define RESOLVER_NTASKS   31
#define DEF_UPDATE_TIMEOUT   300
 Timeout/retry constants for dynamic update borrowed from nsupdate.
#define MIN_UPDATE_TIMEOUT   30
#define DEF_UPDATE_UDPTIMEOUT   3
#define DEF_UPDATE_UDPRETRIES   3
#define DEF_FIND_TIMEOUT   5
#define DEF_FIND_UDPRETRIES   3
#define DNS_CLIENTATTR_OWNCTX   0x01
#define DNS_CLIENTVIEW_NAME   "dnsclient"

Typedefs

typedef struct resctx resctx_t
typedef struct resarg resarg_t
typedef struct reqctx reqctx_t
typedef struct reqarg reqarg_t
typedef struct updatearg updatearg_t
typedef struct updatectx updatectx_t

Functions

static isc_result_t request_soa (updatectx_t *uctx)
static void client_resfind (resctx_t *rctx, dns_fetchevent_t *event)
static isc_result_t send_update (updatectx_t *uctx)
static isc_result_t getudpdispatch (int family, dns_dispatchmgr_t *dispatchmgr, isc_socketmgr_t *socketmgr, isc_taskmgr_t *taskmgr, isc_boolean_t is_shared, dns_dispatch_t **dispp, isc_sockaddr_t *localaddr)
static isc_result_t createview (isc_mem_t *mctx, dns_rdataclass_t rdclass, unsigned int options, isc_taskmgr_t *taskmgr, unsigned int ntasks, isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, dns_dispatchmgr_t *dispatchmgr, dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6, dns_view_t **viewp)
isc_result_t dns_client_create (dns_client_t **clientp, unsigned int options)
isc_result_t dns_client_createx (isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, unsigned int options, dns_client_t **clientp)
isc_result_t dns_client_createx2 (isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, unsigned int options, dns_client_t **clientp, isc_sockaddr_t *localaddr4, isc_sockaddr_t *localaddr6)
 Create a DNS client. These functions create a new client object with minimal internal resources such as the default 'view' for the IN class and IPv4/IPv6 dispatches for the view.
static void destroyclient (dns_client_t **clientp)
void dns_client_destroy (dns_client_t **clientp)
 Destroy 'client'.
isc_result_t dns_client_setservers (dns_client_t *client, dns_rdataclass_t rdclass, dns_name_t *namespace, isc_sockaddrlist_t *addrs)
 Specify a list of addresses of recursive name servers that the client will use for name resolution. A view for the 'rdclass' class must be created beforehand. If 'namespace' is non NULL, the specified server will be used if and only if the query name is a subdomain of 'namespace'. When servers for multiple 'namespace's are provided, and a query name is covered by more than one 'namespace', the servers for the best (longest) matching namespace will be used. If 'namespace' is NULL, it works as if dns_rootname (.) were specified.
isc_result_t dns_client_clearservers (dns_client_t *client, dns_rdataclass_t rdclass, dns_name_t *namespace)
 Remove configured recursive name servers for the 'rdclass' and 'namespace' from the client. See the description of dns_client_setservers() for the requirements about 'rdclass' and 'namespace'.
isc_result_t dns_client_setdlv (dns_client_t *client, dns_rdataclass_t rdclass, const char *dlvname)
 Specify a name to use for DNSSEC lookaside validation (e.g., "dlv.isc.org"). If a trusted key has been added for that name, then DLV will be used during validation. If 'dlvname' is NULL, then DLV will no longer be used for this client.
static isc_result_t getrdataset (isc_mem_t *mctx, dns_rdataset_t **rdatasetp)
static void putrdataset (isc_mem_t *mctx, dns_rdataset_t **rdatasetp)
static void fetch_done (isc_task_t *task, isc_event_t *event)
static isc_result_t start_fetch (resctx_t *rctx)
static isc_result_t view_find (resctx_t *rctx, dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname)
static void suspend (isc_task_t *task, isc_event_t *event)
static void resolve_done (isc_task_t *task, isc_event_t *event)
isc_result_t dns_client_resolve (dns_client_t *client, dns_name_t *name, dns_rdataclass_t rdclass, dns_rdatatype_t type, unsigned int options, dns_namelist_t *namelist)
isc_result_t dns_client_startresolve (dns_client_t *client, dns_name_t *name, dns_rdataclass_t rdclass, dns_rdatatype_t type, unsigned int options, isc_task_t *task, isc_taskaction_t action, void *arg, dns_clientrestrans_t **transp)
 Perform name resolution for 'name', 'rdclass', and 'type'.
void dns_client_cancelresolve (dns_clientrestrans_t *trans)
 Cancel an ongoing resolution procedure started via dns_client_startresolve().
void dns_client_freeresanswer (dns_client_t *client, dns_namelist_t *namelist)
 Free resources allocated for the content of 'namelist'.
void dns_client_destroyrestrans (dns_clientrestrans_t **transp)
 Destroy name resolution transaction state identified by '*transp'.
isc_result_t dns_client_addtrustedkey (dns_client_t *client, dns_rdataclass_t rdclass, dns_name_t *keyname, isc_buffer_t *keydatabuf)
 Add a DNSSEC trusted key for the 'rdclass' class. A view for the 'rdclass' class must be created beforehand. 'keyname' is the DNS name of the key, and 'keydatabuf' stores the resource data of the key.
static void request_done (isc_task_t *task, isc_event_t *event)
 Simple request routines.
static void localrequest_done (isc_task_t *task, isc_event_t *event)
isc_result_t dns_client_request (dns_client_t *client, dns_message_t *qmessage, dns_message_t *rmessage, isc_sockaddr_t *server, unsigned int options, unsigned int parseoptions, dns_tsec_t *tsec, unsigned int timeout, unsigned int udptimeout, unsigned int udpretries)
isc_result_t dns_client_startrequest (dns_client_t *client, dns_message_t *qmessage, dns_message_t *rmessage, isc_sockaddr_t *server, unsigned int options, unsigned int parseoptions, dns_tsec_t *tsec, unsigned int timeout, unsigned int udptimeout, unsigned int udpretries, isc_task_t *task, isc_taskaction_t action, void *arg, dns_clientreqtrans_t **transp)
 Send a DNS request containig a query message 'query' to 'server'.
void dns_client_cancelrequest (dns_clientreqtrans_t *trans)
 Cancel an ongoing DNS request procedure started via dns_client_startrequest().
void dns_client_destroyreqtrans (dns_clientreqtrans_t **transp)
static isc_result_t rcode2result (dns_rcode_t rcode)
 Dynamic update routines.
static void update_sendevent (updatectx_t *uctx, isc_result_t result)
static void update_done (isc_task_t *task, isc_event_t *event)
static void resolveaddr_done (isc_task_t *task, isc_event_t *event)
static isc_result_t process_soa (updatectx_t *uctx, dns_rdataset_t *soaset, dns_name_t *soaname)
static void receive_soa (isc_task_t *task, isc_event_t *event)
static void resolvesoa_done (isc_task_t *task, isc_event_t *event)
static isc_result_t copy_name (isc_mem_t *mctx, dns_message_t *msg, dns_name_t *name, dns_name_t **newnamep)
static void internal_update_callback (isc_task_t *task, isc_event_t *event)
isc_result_t dns_client_update (dns_client_t *client, dns_rdataclass_t rdclass, dns_name_t *zonename, dns_namelist_t *prerequisites, dns_namelist_t *updates, isc_sockaddrlist_t *servers, dns_tsec_t *tsec, unsigned int options)
 Destroy DNS request transaction state identified by '*transp'.
isc_result_t dns_client_startupdate (dns_client_t *client, dns_rdataclass_t rdclass, dns_name_t *zonename, dns_namelist_t *prerequisites, dns_namelist_t *updates, isc_sockaddrlist_t *servers, dns_tsec_t *tsec, unsigned int options, isc_task_t *task, isc_taskaction_t action, void *arg, dns_clientupdatetrans_t **transp)
 Perform DNS dynamic update for 'updates' of the 'rdclass' class with optional 'prerequisites'.
void dns_client_cancelupdate (dns_clientupdatetrans_t *trans)
 Cancel an ongoing dynamic update procedure started via dns_client_startupdate().
void dns_client_destroyupdatetrans (dns_clientupdatetrans_t **transp)
 Destroy dynamic update transaction identified by '*transp'.
isc_mem_tdns_client_mctx (dns_client_t *client)
isc_result_t dns_client_updaterec (dns_client_updateop_t op, dns_name_t *owner, dns_rdatatype_t type, dns_rdata_t *source, dns_ttl_t ttl, dns_name_t *target, dns_rdataset_t *rdataset, dns_rdatalist_t *rdatalist, dns_rdata_t *rdata, isc_mem_t *mctx)
 TBD.
void dns_client_freeupdate (dns_name_t **namep)
 TBD.


Define Documentation

#define DNS_CLIENT_MAGIC   ISC_MAGIC('D', 'N', 'S', 'c')

Definition at line 57 of file client.c.

Referenced by dns_client_createx2().

#define DNS_CLIENT_VALID (  )     ISC_MAGIC_VALID(c, DNS_CLIENT_MAGIC)

Definition at line 58 of file client.c.

Referenced by dns_client_addtrustedkey(), dns_client_clearservers(), dns_client_destroy(), dns_client_destroyreqtrans(), dns_client_destroyrestrans(), dns_client_destroyupdatetrans(), dns_client_freeresanswer(), dns_client_mctx(), dns_client_request(), dns_client_resolve(), dns_client_setdlv(), dns_client_setservers(), dns_client_startrequest(), dns_client_startresolve(), dns_client_startupdate(), dns_client_update(), and update_done().

#define RCTX_MAGIC   ISC_MAGIC('R', 'c', 't', 'x')

Definition at line 60 of file client.c.

Referenced by dns_client_startresolve().

#define RCTX_VALID (  )     ISC_MAGIC_VALID(c, RCTX_MAGIC)

Definition at line 61 of file client.c.

Referenced by client_resfind(), dns_client_cancelresolve(), dns_client_destroyrestrans(), and fetch_done().

#define REQCTX_MAGIC   ISC_MAGIC('R', 'q', 'c', 'x')

Definition at line 63 of file client.c.

Referenced by dns_client_startrequest().

#define REQCTX_VALID (  )     ISC_MAGIC_VALID(c, REQCTX_MAGIC)

Definition at line 64 of file client.c.

Referenced by dns_client_cancelrequest(), dns_client_destroyreqtrans(), and request_done().

#define UCTX_MAGIC   ISC_MAGIC('U', 'c', 't', 'x')

Definition at line 66 of file client.c.

Referenced by dns_client_startupdate().

#define UCTX_VALID (  )     ISC_MAGIC_VALID(c, UCTX_MAGIC)

Definition at line 67 of file client.c.

Referenced by dns_client_cancelupdate(), dns_client_destroyupdatetrans(), resolveaddr_done(), resolvesoa_done(), and update_done().

#define MAX_RESTARTS   16

Definition at line 69 of file client.c.

#define RESOLVER_NTASKS   31

Definition at line 74 of file client.c.

Referenced by configure_view(), and dns_client_createx2().

#define DEF_UPDATE_TIMEOUT   300

Timeout/retry constants for dynamic update borrowed from nsupdate.

Definition at line 112 of file client.c.

Referenced by dns_client_createx2().

#define MIN_UPDATE_TIMEOUT   30

Definition at line 113 of file client.c.

Referenced by send_update(), and update_done().

#define DEF_UPDATE_UDPTIMEOUT   3

Definition at line 114 of file client.c.

Referenced by dns_client_createx2().

#define DEF_UPDATE_UDPRETRIES   3

Definition at line 115 of file client.c.

Referenced by dns_client_createx2().

#define DEF_FIND_TIMEOUT   5

Definition at line 117 of file client.c.

Referenced by dns_client_createx2().

#define DEF_FIND_UDPRETRIES   3

Definition at line 118 of file client.c.

Referenced by dns_client_createx2().

#define DNS_CLIENTATTR_OWNCTX   0x01

Definition at line 120 of file client.c.

Referenced by destroyclient(), dns_client_create(), dns_client_request(), dns_client_resolve(), and dns_client_update().

#define DNS_CLIENTVIEW_NAME   "dnsclient"

Definition at line 122 of file client.c.

Referenced by createview(), dns_client_addtrustedkey(), dns_client_clearservers(), dns_client_setdlv(), dns_client_setservers(), dns_client_startrequest(), dns_client_startresolve(), and dns_client_startupdate().


Typedef Documentation

typedef struct resctx resctx_t

typedef struct resarg resarg_t

typedef struct reqctx reqctx_t

typedef struct reqarg reqarg_t

typedef struct updatearg updatearg_t

typedef struct updatectx updatectx_t


Function Documentation

static isc_result_t request_soa ( updatectx_t uctx  )  [static]

Definition at line 2444 of file client.c.

References updatectx::client, updatectx::currentserver, dns_message_addname(), dns_message_create(), dns_message_destroy(), dns_message_gettempname(), dns_message_gettemprdataset(), DNS_MESSAGE_INTENTRENDER, dns_message_puttempname(), dns_message_puttemprdataset(), DNS_MESSAGEFLAG_RD, dns_name_clone(), dns_rdataset_makequestion(), dns_request_createvia3(), DNS_REQUESTOPT_TCP, DNS_SECTION_QUESTION, dns_client::find_timeout, updatectx::firstname, dns_message::flags, ISC_LIST_APPEND, ISC_LIST_UNLINK, ISC_R_SUCCESS, dns_client::mctx, name, updatectx::rdclass, receive_soa(), dns_view::requestmgr, updatectx::soaquery, updatectx::soareq, dns_client::task, updatectx::tsigkey, updatectx::view, and updatectx::want_tcp.

Referenced by dns_client_startupdate().

static void client_resfind ( resctx_t rctx,
dns_fetchevent_t event 
) [static]

Definition at line 825 of file client.c.

References dns_clientresevent::answerlist, resctx::canceled, dns_db_allrdatasets(), dns_db_detach(), dns_db_detachnode(), dns_fixedname_init, dns_fixedname_name, dns_name_concatenate(), dns_name_copy(), dns_name_dup(), dns_name_free(), dns_name_fullcompare(), dns_name_init(), dns_name_split(), dns_namereln_subdomain, DNS_R_CNAME, DNS_R_DNAME, DNS_R_NCACHENXDOMAIN, DNS_R_NCACHENXRRSET, DNS_R_SERVFAIL, dns_rdata_freestruct(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_disassociate(), dns_rdataset_first(), dns_rdataset_isassociated(), dns_rdatasetiter_current(), dns_rdatasetiter_destroy(), dns_rdatasetiter_first(), dns_rdatasetiter_next(), dns_resolver_destroyfetch(), resctx::event, resctx::fetch, fixed, getrdataset(), INSIST, isc_event_free(), ISC_EVENT_PTR, ISC_FALSE, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_get, isc_mem_put, ISC_R_CANCELED, ISC_R_NOMEMORY, ISC_R_NOMORE, ISC_R_NOTFOUND, ISC_R_QUOTA, ISC_R_SUCCESS, isc_task_sendanddetach(), ISC_TRUE, resctx::lock, LOCK, MAX_RESTARTS, dns_view::mctx, dns_client::mctx, resctx::name, name, resctx::namelist, POST, putrdataset(), RCTX_VALID, resctx::rdataset, REQUIRE, resctx::restarts, dns_clientresevent::result, resctx::sigrdataset, start_fetch(), dns_client::task, dns_rdataset::type, resctx::type, UNLOCK, resctx::view, view_find(), dns_clientresevent::vresult, and resctx::want_dnssec.

Referenced by dns_client_startresolve(), and fetch_done().

static isc_result_t send_update ( updatectx_t uctx  )  [static]

Definition at line 2021 of file client.c.

References updatectx::client, updatectx::currentserver, dns_clientupdatestate_prepare, dns_clientupdatestate_sent, dns_message_addname(), dns_message_gettempname(), dns_message_gettemprdataset(), dns_message_puttempname(), dns_message_setsig0key(), dns_name_clone(), dns_name_init(), dns_rdataset_makequestion(), dns_request_createvia3(), DNS_REQUESTOPT_TCP, DNS_SECTION_ZONE, ISC_LIST_APPEND, ISC_LIST_INIT, ISC_R_SUCCESS, MIN_UPDATE_TIMEOUT, name, updatectx::nservers, updatectx::rdclass, dns_view::requestmgr, REQUIRE, updatectx::sig0key, updatectx::state, dns_client::task, timeout, updatectx::tsigkey, update_done(), dns_client::update_timeout, dns_client::update_udpretries, dns_client::update_udptimeout, updatectx::updatemsg, updatectx::updatereq, updatectx::view, updatectx::want_tcp, and updatectx::zonename.

Referenced by dns_client_startupdate(), process_soa(), recvsoa(), resolveaddr_done(), start_update(), and update_completed().

static isc_result_t getudpdispatch ( int  family,
dns_dispatchmgr_t dispatchmgr,
isc_socketmgr_t socketmgr,
isc_taskmgr_t taskmgr,
isc_boolean_t  is_shared,
dns_dispatch_t **  dispp,
isc_sockaddr_t localaddr 
) [static]

Definition at line 261 of file client.c.

References AF_INET6, dns_dispatch_getudp(), DNS_DISPATCHATTR_IPV4, DNS_DISPATCHATTR_IPV6, DNS_DISPATCHATTR_TCP, DNS_DISPATCHATTR_UDP, INSIST, ISC_R_SUCCESS, and isc_sockaddr_anyofpf().

Referenced by dns_client_createx2().

static isc_result_t createview ( isc_mem_t mctx,
dns_rdataclass_t  rdclass,
unsigned int  options,
isc_taskmgr_t taskmgr,
unsigned int  ntasks,
isc_socketmgr_t socketmgr,
isc_timermgr_t timermgr,
dns_dispatchmgr_t dispatchmgr,
dns_dispatch_t dispatchv4,
dns_dispatch_t dispatchv6,
dns_view_t **  viewp 
) [static]

Definition at line 314 of file client.c.

References dns_view::cachedb, dbtype, DNS_CLIENTCREATEOPT_USECACHE, DNS_CLIENTVIEW_NAME, dns_db_create(), dns_dbtype_cache, dns_rootname, dns_view_create(), dns_view_createresolver(), dns_view_detach(), dns_view_initsecroots(), and ISC_R_SUCCESS.

Referenced by dns_client_createx2().

isc_result_t dns_client_create ( dns_client_t **  clientp,
unsigned int  options 
)

Definition at line 365 of file client.c.

References dns_client::actx, cleanup(), dns_client_createx(), DNS_CLIENTATTR_OWNCTX, dns_log_init(), dns_log_setcontext(), isc_app_ctxstart(), isc_appctx_create(), isc_appctx_destroy(), isc_log_create(), isc_log_setcontext(), isc_log_setdebuglevel(), isc_log_usechannel(), isc_mem_create(), isc_mem_detach(), ISC_R_SUCCESS, isc_socketmgr_createinctx(), isc_socketmgr_destroy(), isc_taskmgr_createinctx(), isc_taskmgr_destroy(), isc_timermgr_createinctx(), isc_timermgr_destroy(), lctx, logdebuglevel, dns_client::mctx, dns_client::socketmgr, dns_client::taskmgr, and dns_client::timermgr.

isc_result_t dns_client_createx ( isc_mem_t mctx,
isc_appctx_t actx,
isc_taskmgr_t taskmgr,
isc_socketmgr_t socketmgr,
isc_timermgr_t timermgr,
unsigned int  options,
dns_client_t **  clientp 
)

Definition at line 436 of file client.c.

References dns_client_createx2().

Referenced by dns_client_create().

isc_result_t dns_client_createx2 ( isc_mem_t mctx,
isc_appctx_t actx,
isc_taskmgr_t taskmgr,
isc_socketmgr_t socketmgr,
isc_timermgr_t timermgr,
unsigned int  options,
dns_client_t **  clientp,
isc_sockaddr_t localaddr4,
isc_sockaddr_t localaddr6 
)

Create a DNS client. These functions create a new client object with minimal internal resources such as the default 'view' for the IN class and IPv4/IPv6 dispatches for the view.

dns_client_createx() takes 'manager' arguments so that the caller can control the behavior of the client through the underlying event framework. On the other hand, dns_client_create() simplifies the interface and creates the managers internally. A DNS client object created via dns_client_create() is expected to be used by an application that only needs simple synchronous services or by a thread-based application.

dns_client_createx2 takes two additional parameters, 'localaddr4' and 'localaddr6', to specify the local address to use for each family. If both are set to NULL, then wildcard addresses will be used for both families. If only one is NULL, then the other address will be used as the local address, and the other protocol family will not be used.

If the DNS_CLIENTCREATEOPT_USECACHE flag is set in 'options', dns_client_create(x) will create a cache database with the view.

Requires:

Returns:

Definition at line 447 of file client.c.

References dns_client::actx, AF_INET6, dns_client::attributes, cleanup(), createview(), DEF_FIND_TIMEOUT, DEF_FIND_UDPRETRIES, DEF_UPDATE_TIMEOUT, DEF_UPDATE_UDPRETRIES, DEF_UPDATE_UDPTIMEOUT, dns_client::dispatchmgr, dns_client::dispatchv4, dns_client::dispatchv6, DNS_CLIENT_MAGIC, dns_dispatch_detach(), dns_dispatchmgr_create(), dns_dispatchmgr_destroy(), dns_view_freeze(), dns_client::find_timeout, dns_client::find_udpretries, getudpdispatch(), INSIST, ISC_LIST_APPEND, ISC_LIST_INIT, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_task_create(), isc_task_detach(), ISC_TRUE, dns_client::lock, dns_client::magic, dns_client::mctx, dns_client::references, REQUIRE, RESOLVER_NTASKS, dns_client::socketmgr, dns_client::task, dns_client::taskmgr, dns_client::timermgr, dns_client::update_timeout, dns_client::update_udpretries, dns_client::update_udptimeout, and dns_client::viewlist.

Referenced by dns_client_createx().

static void destroyclient ( dns_client_t **  clientp  )  [static]

Definition at line 566 of file client.c.

References dns_client::actx, dns_client::attributes, DESTROYLOCK, dns_client::dispatchmgr, dns_client::dispatchv4, dns_client::dispatchv6, DNS_CLIENTATTR_OWNCTX, dns_dispatch_detach(), dns_dispatchmgr_destroy(), dns_view_detach(), isc_app_ctxfinish(), isc_appctx_destroy(), ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_putanddetach, isc_socketmgr_destroy(), isc_task_detach(), isc_taskmgr_destroy(), isc_timermgr_destroy(), dns_client::lock, dns_client::magic, dns_client::mctx, dns_client::socketmgr, dns_client::task, dns_client::taskmgr, dns_client::timermgr, and dns_client::viewlist.

Referenced by dns_client_destroy(), dns_client_destroyreqtrans(), dns_client_destroyrestrans(), and dns_client_destroyupdatetrans().

void dns_client_destroy ( dns_client_t **  clientp  ) 

Destroy 'client'.

Requires:

Ensures:

Definition at line 606 of file client.c.

References destroyclient(), DNS_CLIENT_VALID, ISC_FALSE, ISC_LIST_EMPTY, ISC_TRUE, dns_client::lock, LOCK, dns_client::references, REQUIRE, and UNLOCK.

isc_result_t dns_client_setservers ( dns_client_t client,
dns_rdataclass_t  rdclass,
dns_name_t namespace,
isc_sockaddrlist_t *  addrs 
)

Specify a list of addresses of recursive name servers that the client will use for name resolution. A view for the 'rdclass' class must be created beforehand. If 'namespace' is non NULL, the specified server will be used if and only if the query name is a subdomain of 'namespace'. When servers for multiple 'namespace's are provided, and a query name is covered by more than one 'namespace', the servers for the best (longest) matching namespace will be used. If 'namespace' is NULL, it works as if dns_rootname (.) were specified.

Requires:

Returns:

Definition at line 630 of file client.c.

References DNS_CLIENT_VALID, DNS_CLIENTVIEW_NAME, dns_fwdpolicy_only, dns_fwdtable_add(), dns_rootname, dns_view_detach(), dns_viewlist_find(), dns_view::fwdtable, ISC_R_SUCCESS, dns_client::lock, LOCK, REQUIRE, UNLOCK, and dns_client::viewlist.

isc_result_t dns_client_clearservers ( dns_client_t client,
dns_rdataclass_t  rdclass,
dns_name_t namespace 
)

Remove configured recursive name servers for the 'rdclass' and 'namespace' from the client. See the description of dns_client_setservers() for the requirements about 'rdclass' and 'namespace'.

Requires:

Returns:

Definition at line 660 of file client.c.

References DNS_CLIENT_VALID, DNS_CLIENTVIEW_NAME, dns_fwdtable_delete(), dns_rootname, dns_view_detach(), dns_viewlist_find(), dns_view::fwdtable, ISC_R_SUCCESS, dns_client::lock, LOCK, REQUIRE, UNLOCK, and dns_client::viewlist.

isc_result_t dns_client_setdlv ( dns_client_t client,
dns_rdataclass_t  rdclass,
const char *  dlvname 
)

Specify a name to use for DNSSEC lookaside validation (e.g., "dlv.isc.org"). If a trusted key has been added for that name, then DLV will be used during validation. If 'dlvname' is NULL, then DLV will no longer be used for this client.

Requires:

Returns:

Definition at line 688 of file client.c.

References cleanup(), dns_view::dlv, dns_view::dlv_fixed, DNS_CLIENT_VALID, DNS_CLIENTVIEW_NAME, dns_fixedname_name, DNS_NAME_DOWNCASE, dns_name_fromtext(), dns_rootname, dns_view_detach(), dns_viewlist_find(), isc_buffer_add, isc_buffer_constinit, ISC_R_SUCCESS, dns_client::lock, LOCK, REQUIRE, UNLOCK, and dns_client::viewlist.

static isc_result_t getrdataset ( isc_mem_t mctx,
dns_rdataset_t **  rdatasetp 
) [static]

Definition at line 728 of file client.c.

References dns_rdataset_init(), isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, and REQUIRE.

Referenced by client_resfind(), and dns_client_startresolve().

static void putrdataset ( isc_mem_t mctx,
dns_rdataset_t **  rdatasetp 
) [static]

Definition at line 746 of file client.c.

References dns_rdataset_disassociate(), dns_rdataset_isassociated(), isc_mem_put, and REQUIRE.

Referenced by client_resfind(), dns_client_freeresanswer(), and dns_client_startresolve().

static void fetch_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 762 of file client.c.

References client_resfind(), DNS_EVENT_FETCHDONE, RCTX_VALID, REQUIRE, and resctx::task.

Referenced by checkbogus(), and start_fetch().

static isc_result_t start_fetch ( resctx_t rctx  )  [inline, static]

Definition at line 775 of file client.c.

References DNS_FETCHOPT_NOCDFLAG, DNS_FETCHOPT_NOVALIDATE, DNS_FETCHOPT_TCP, dns_fixedname_name, dns_resolver_createfetch(), resctx::fetch, fetch_done(), resctx::name, resctx::rdataset, REQUIRE, dns_view::resolver, resctx::sigrdataset, resctx::task, resctx::type, resctx::view, resctx::want_cdflag, resctx::want_tcp, and resctx::want_validation.

Referenced by client_resfind(), and lookup_find().

static isc_result_t view_find ( resctx_t rctx,
dns_db_t **  dbp,
dns_dbnode_t **  nodep,
dns_name_t foundname 
) [static]

Definition at line 805 of file client.c.

References dns_fixedname_name, dns_view_find(), ISC_FALSE, resctx::name, name, resctx::rdataset, resctx::sigrdataset, resctx::type, and resctx::view.

Referenced by client_resfind(), finddlvsep(), get_key(), lookup_find(), proveunsecure(), and validatezonekey().

static void suspend ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1184 of file client.c.

References dns_client::actx, isc_app_ctxsuspend(), isc_event_free(), and UNUSED.

Referenced by resolve_done().

static void resolve_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1194 of file client.c.

References resarg::actx, dns_clientresevent::answerlist, resarg::canceled, resarg::client, DESTROYLOCK, dns_client_destroyrestrans(), isc_app_ctxonrun(), isc_app_ctxsuspend(), isc_event_free(), ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_put, ISC_R_ALREADYRUNNING, resarg::lock, LOCK, dns_client::mctx, name, resarg::namelist, dns_clientresevent::result, resarg::result, suspend(), resarg::trans, UNLOCK, UNUSED, dns_clientresevent::vresult, and resarg::vresult.

Referenced by dns_client_resolve().

isc_result_t dns_client_resolve ( dns_client_t client,
dns_name_t name,
dns_rdataclass_t  rdclass,
dns_rdatatype_t  type,
unsigned int  options,
dns_namelist_t *  namelist 
)

Definition at line 1239 of file client.c.

References resarg::actx, dns_client::actx, dns_client::attributes, resarg::canceled, resarg::client, DESTROYLOCK, dns_client_cancelresolve(), dns_client_startresolve(), DNS_CLIENT_VALID, DNS_CLIENTATTR_OWNCTX, DNS_CLIENTRESOPT_ALLOWRUN, DNS_R_SERVFAIL, isc_app_ctxrun(), ISC_FALSE, ISC_LIST_EMPTY, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, ISC_R_SUSPEND, ISC_TRUE, LOCK, resarg::lock, dns_client::mctx, resarg::namelist, REQUIRE, resolve_done(), resarg::result, dns_client::task, resarg::trans, UNLOCK, and resarg::vresult.

isc_result_t dns_client_startresolve ( dns_client_t client,
dns_name_t name,
dns_rdataclass_t  rdclass,
dns_rdatatype_t  type,
unsigned int  options,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_clientrestrans_t **  transp 
)

Perform name resolution for 'name', 'rdclass', and 'type'.

If any trusted keys are configured and the query name is considered to belong to a secure zone, these functions also validate the responses using DNSSEC by default. If the DNS_CLIENTRESOPT_NOVALIDATE flag is set in 'options', DNSSEC validation is disabled regardless of the configured trusted keys or the query name. With DNS_CLIENTRESOPT_NODNSSEC DNSSEC data is not returned with response. DNS_CLIENTRESOPT_NOCDFLAG disables the CD flag on queries, DNS_CLIENTRESOPT_TCP switches to the TCP (vs. UDP) transport.

dns_client_resolve() provides a synchronous service. This function starts name resolution internally and blocks until it completes. On success, 'namelist' will contain a list of answer names, each of which has corresponding RRsets. The caller must provide a valid empty list, and is responsible for freeing the list content via dns_client_freeresanswer(). If the name resolution fails due to an error in DNSSEC validation, dns_client_resolve() returns the result code indicating the validation error. Otherwise, it returns the result code of the entire resolution process, either success or failure.

It is typically expected that the client object passed to dns_client_resolve() was created via dns_client_create() and has its own managers and contexts. However, if the DNS_CLIENTRESOPT_ALLOWRUN flag is set in 'options', this function performs the synchronous service even if it does not have its own manager and context structures.

dns_client_startresolve() is an asynchronous version of dns_client_resolve() and does not block. When name resolution is completed, 'action' will be called with the argument of a 'dns_clientresevent_t' object, which contains the resulting list of answer names (on success). On return, '*transp' is set to an opaque transaction ID so that the caller can cancel this resolution process.

Requires:

Returns:

Definition at line 1325 of file client.c.

References resctx::canceled, cleanup(), resctx::client, client_resfind(), DESTROYLOCK, DNS_CLIENT_VALID, DNS_CLIENTRESOPT_NOCDFLAG, DNS_CLIENTRESOPT_NODNSSEC, DNS_CLIENTRESOPT_NOVALIDATE, DNS_CLIENTRESOPT_TCP, DNS_CLIENTVIEW_NAME, DNS_EVENT_CLIENTRESDONE, dns_fixedname_init, dns_fixedname_name, dns_name_copy(), DNS_R_SERVFAIL, dns_view_detach(), dns_viewlist_find(), resctx::event, resctx::fetch, getrdataset(), isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_INIT, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_task_attach(), isc_task_detach(), ISC_TF, resctx::lock, dns_client::lock, LOCK, resctx::magic, dns_client::mctx, resctx::name, resctx::namelist, putrdataset(), RCTX_MAGIC, resctx::rdataset, REQUIRE, resctx::restarts, resctx::sigrdataset, dns_client::task, resctx::task, resctx::type, UNLOCK, resctx::view, dns_client::viewlist, resctx::want_cdflag, resctx::want_dnssec, resctx::want_tcp, and resctx::want_validation.

Referenced by dns_client_resolve(), dns_client_startupdate(), process_soa(), and resolvesoa_done().

void dns_client_cancelresolve ( dns_clientrestrans_t trans  ) 

Cancel an ongoing resolution procedure started via dns_client_startresolve().

Notes:

Requires:

Definition at line 1447 of file client.c.

References resctx::canceled, dns_resolver_cancelfetch(), resctx::fetch, ISC_TRUE, resctx::lock, LOCK, RCTX_VALID, REQUIRE, and UNLOCK.

Referenced by dns_client_cancelupdate(), dns_client_request(), and dns_client_resolve().

void dns_client_freeresanswer ( dns_client_t client,
dns_namelist_t *  namelist 
)

Free resources allocated for the content of 'namelist'.

Requires:

Definition at line 1466 of file client.c.

References DNS_CLIENT_VALID, dns_name_free(), ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_put, dns_client::mctx, name, putrdataset(), and REQUIRE.

Referenced by resolveaddr_done(), and resolvesoa_done().

void dns_client_destroyrestrans ( dns_clientrestrans_t **  transp  ) 

Destroy name resolution transaction state identified by '*transp'.

Requires:

Ensures:

Definition at line 1485 of file client.c.

References resctx::client, destroyclient(), DESTROYLOCK, DNS_CLIENT_VALID, dns_view_detach(), resctx::event, resctx::fetch, INSIST, ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_EMPTY, ISC_LIST_UNLINK, isc_mem_put, ISC_TRUE, resctx::lock, dns_client::lock, LOCK, resctx::magic, dns_client::mctx, resctx::namelist, RCTX_VALID, dns_client::references, REQUIRE, UNLOCK, and resctx::view.

Referenced by resolve_done(), resolveaddr_done(), and resolvesoa_done().

isc_result_t dns_client_addtrustedkey ( dns_client_t client,
dns_rdataclass_t  rdclass,
dns_name_t keyname,
isc_buffer_t keydatabuf 
)

Add a DNSSEC trusted key for the 'rdclass' class. A view for the 'rdclass' class must be created beforehand. 'keyname' is the DNS name of the key, and 'keydatabuf' stores the resource data of the key.

Requires:

Returns:

Definition at line 1528 of file client.c.

References cleanup(), DNS_CLIENT_VALID, DNS_CLIENTVIEW_NAME, dns_keytable_add(), dns_keytable_detach(), dns_view_detach(), dns_view_getsecroots(), dns_viewlist_find(), dst_key_free(), dst_key_fromdns(), ISC_FALSE, ISC_R_SUCCESS, dns_client::lock, LOCK, dns_client::mctx, REQUIRE, UNLOCK, and dns_client::viewlist.

static void request_done ( isc_task_t task,
isc_event_t event 
) [static]

Simple request routines.

Definition at line 1570 of file client.c.

References reqctx::canceled, DNS_EVENT_REQUESTDONE, dns_request_getresponse(), dns_tsigkey_detach(), reqctx::event, isc_event_free(), ISC_EVENT_PTR, ISC_R_CANCELED, ISC_R_SUCCESS, isc_task_sendanddetach(), reqctx::lock, LOCK, reqctx::parseoptions, REQCTX_VALID, dns_requestevent::request, REQUIRE, dns_clientreqevent::result, dns_requestevent::result, dns_clientreqevent::rmessage, reqctx::tsigkey, UNLOCK, and UNUSED.

Referenced by dns_client_startrequest().

static void localrequest_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1609 of file client.c.

References reqarg::actx, reqarg::canceled, reqarg::client, DESTROYLOCK, dns_client_destroyreqtrans(), DNS_EVENT_CLIENTREQDONE, isc_app_ctxsuspend(), isc_event_free(), isc_mem_put, reqarg::lock, LOCK, dns_client::mctx, REQUIRE, dns_clientreqevent::result, reqarg::result, reqarg::trans, UNLOCK, and UNUSED.

Referenced by dns_client_request().

isc_result_t dns_client_request ( dns_client_t client,
dns_message_t qmessage,
dns_message_t rmessage,
isc_sockaddr_t server,
unsigned int  options,
unsigned int  parseoptions,
dns_tsec_t tsec,
unsigned int  timeout,
unsigned int  udptimeout,
unsigned int  udpretries 
)

Definition at line 1640 of file client.c.

References reqarg::actx, dns_client::actx, dns_client::attributes, reqarg::canceled, reqarg::client, DESTROYLOCK, dns_client_cancelresolve(), dns_client_startrequest(), DNS_CLIENT_VALID, DNS_CLIENTATTR_OWNCTX, DNS_CLIENTREQOPT_ALLOWRUN, isc_app_ctxrun(), ISC_FALSE, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, ISC_R_SUSPEND, ISC_TRUE, localrequest_done(), LOCK, reqarg::lock, dns_client::mctx, REQUIRE, reqarg::result, dns_client::task, reqarg::trans, and UNLOCK.

isc_result_t dns_client_startrequest ( dns_client_t client,
dns_message_t qmessage,
dns_message_t rmessage,
isc_sockaddr_t server,
unsigned int  options,
unsigned int  parseoptions,
dns_tsec_t tsec,
unsigned int  timeout,
unsigned int  udptimeout,
unsigned int  udpretries,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_clientreqtrans_t **  transp 
)

Send a DNS request containig a query message 'query' to 'server'.

'parseoptions' will be used when the response packet is parsed, and will be passed to dns_message_parse() via dns_request_getresponse(). See dns_message_parse() for more details.

'tsec' is a transaction security object containing, e.g. a TSIG key for authenticating the request/response transaction. This is optional and can be NULL, in which case this library performs the transaction without any transaction authentication.

'timeout', 'udptimeout', and 'udpretries' are passed to dns_request_createvia3(). See dns_request_createvia3() for more details.

dns_client_request() provides a synchronous service. This function sends the request and blocks until a response is received. On success, 'rmessage' will contain the response message. The caller must provide a valid initialized message.

It is usually expected that the client object passed to dns_client_request() was created via dns_client_create() and has its own managers and contexts. However, if the DNS_CLIENTREQOPT_ALLOWRUN flag is set in 'options', this function performs the synchronous service even if it does not have its own manager and context structures.

dns_client_startrequest() is an asynchronous version of dns_client_request() and does not block. When the transaction is completed, 'action' will be called with the argument of a 'dns_clientreqevent_t' object, which contains the response message (on success). On return, '*transp' is set to an opaque transaction ID so that the caller can cancel this request.

DNS_CLIENTREQOPT_TCP switches to the TCP (vs. UDP) transport.

Requires:

Returns:

Definition at line 1722 of file client.c.

References reqctx::canceled, cleanup(), reqctx::client, DESTROYLOCK, DNS_CLIENT_VALID, DNS_CLIENTREQOPT_TCP, DNS_CLIENTVIEW_NAME, DNS_EVENT_CLIENTREQDONE, dns_request_createvia3(), DNS_REQUESTOPT_TCP, dns_tsec_getkey(), dns_tsec_gettype(), dns_tsectype_none, dns_tsectype_tsig, dns_view_detach(), dns_viewlist_find(), reqctx::event, isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_UNLINK, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_task_attach(), isc_task_detach(), reqctx::lock, dns_client::lock, LOCK, reqctx::magic, dns_client::mctx, reqctx::parseoptions, dns_message::rdclass, REQCTX_MAGIC, reqctx::request, request_done(), dns_view::requestmgr, REQUIRE, dns_clientreqevent::rmessage, dns_client::task, reqctx::tsigkey, UNLOCK, and dns_client::viewlist.

Referenced by dns_client_request().

void dns_client_cancelrequest ( dns_clientreqtrans_t transp  ) 

Cancel an ongoing DNS request procedure started via dns_client_startrequest().

Notes:

Requires:

Definition at line 1829 of file client.c.

References reqctx::canceled, dns_request_cancel(), ISC_TRUE, reqctx::lock, LOCK, REQCTX_VALID, reqctx::request, REQUIRE, and UNLOCK.

void dns_client_destroyreqtrans ( dns_clientreqtrans_t **  transp  ) 

Definition at line 1848 of file client.c.

References reqctx::client, destroyclient(), DESTROYLOCK, DNS_CLIENT_VALID, dns_request_destroy(), reqctx::event, INSIST, ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_EMPTY, ISC_LIST_UNLINK, isc_mem_put, ISC_TRUE, reqctx::lock, dns_client::lock, LOCK, reqctx::magic, dns_client::mctx, dns_client::references, REQCTX_VALID, reqctx::request, REQUIRE, and UNLOCK.

Referenced by localrequest_done().

static isc_result_t rcode2result ( dns_rcode_t  rcode  )  [static]

Dynamic update routines.

Definition at line 1893 of file client.c.

References DNS_R_BADVERS, DNS_R_FORMERR, DNS_R_NOTAUTH, DNS_R_NOTIMP, DNS_R_NOTZONE, DNS_R_NXDOMAIN, DNS_R_NXRRSET, DNS_R_REFUSED, DNS_R_SERVFAIL, DNS_R_YXDOMAIN, DNS_R_YXRRSET, dns_rcode_badvers, dns_rcode_formerr, dns_rcode_notauth, dns_rcode_notimp, dns_rcode_notzone, dns_rcode_nxdomain, dns_rcode_nxrrset, dns_rcode_refused, dns_rcode_servfail, dns_rcode_yxdomain, dns_rcode_yxrrset, and ISC_R_FAILURE.

Referenced by receive_soa(), and update_done().

static void update_sendevent ( updatectx_t uctx,
isc_result_t  result 
) [static]

Definition at line 1924 of file client.c.

References updatectx::canceled, dns_message_destroy(), dns_tsigkey_detach(), dst_key_free(), updatectx::event, ISC_EVENT_PTR, ISC_R_CANCELED, isc_task_sendanddetach(), dns_clientupdateevent::result, updatectx::sig0key, updatectx::state, dns_clientupdateevent::state, dns_client::task, updatectx::tsigkey, and updatectx::updatemsg.

Referenced by receive_soa(), resolveaddr_done(), resolvesoa_done(), and update_done().

static void update_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1944 of file client.c.

References answer, updatectx::canceled, updatectx::client, updatectx::currentserver, DNS_CLIENT_VALID, dns_clientupdatestate_done, dns_clientupdatestate_sent, DNS_EVENT_REQUESTDONE, dns_message_create(), dns_message_destroy(), DNS_MESSAGE_INTENTPARSE, dns_message_renderreset(), dns_message_settsigkey(), DNS_MESSAGEPARSE_PRESERVEORDER, dns_rcode_noerror, dns_request_createvia3(), dns_request_destroy(), dns_request_getresponse(), DNS_REQUESTOPT_TCP, isc_event_free(), ISC_LIST_NEXT, ISC_R_SUCCESS, updatectx::lock, LOCK, dns_client::mctx, MIN_UPDATE_TIMEOUT, updatectx::nservers, dns_message::rcode, rcode2result(), dns_requestevent::request, dns_view::requestmgr, REQUIRE, dns_requestevent::result, updatectx::state, dns_client::task, timeout, updatectx::tsigkey, UCTX_VALID, UNLOCK, UNUSED, update_sendevent(), dns_client::update_timeout, dns_client::update_udpretries, dns_client::update_udptimeout, updatectx::updatemsg, updatectx::updatereq, updatectx::view, and updatectx::want_tcp.

Referenced by send_update().

static void resolveaddr_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2073 of file client.c.

References AF_INET6, dns_clientresevent::answerlist, updatectx::bp4, updatectx::bp6, updatectx::canceled, updatectx::client, updatectx::currentserver, dns_client_destroyrestrans(), dns_client_freeresanswer(), dns_rdata_freestruct(), dns_rdata_init(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_isassociated(), dns_rdataset_next(), INSIST, isc_event_free(), ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_get, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_sockaddr_fromin(), isc_sockaddr_fromin6(), ISC_TRUE, updatectx::lock, LOCK, dns_client::mctx, name, updatectx::nservers, REQUIRE, updatectx::restrans, updatectx::restrans2, dns_clientresevent::result, RUNTIME_CHECK, send_update(), updatectx::servers, dns_rdataset::type, UCTX_VALID, UNLOCK, UNUSED, and update_sendevent().

Referenced by process_soa().

static isc_result_t process_soa ( updatectx_t uctx,
dns_rdataset_t soaset,
dns_name_t soaname 
) [static]

Definition at line 2191 of file client.c.

References updatectx::bp4, updatectx::bp6, updatectx::client, updatectx::currentserver, dns_client_startresolve(), DNS_CLIENTRESOPT_TCP, dns_fixedname_name, dns_name_clone(), dns_name_copy(), dns_name_init(), dns_rdata_freestruct(), dns_rdata_init(), DNS_RDATA_INIT, dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), ISC_R_SUCCESS, updatectx::lock, LOCK, updatectx::rdclass, resolveaddr_done(), updatectx::restrans, updatectx::restrans2, send_update(), dns_client::task, UNLOCK, updatectx::want_tcp, updatectx::zonefname, and updatectx::zonename.

Referenced by receive_soa(), and resolvesoa_done().

static void receive_soa ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2258 of file client.c.

References updatectx::client, updatectx::currentserver, DNS_EVENT_REQUESTDONE, dns_message_create(), dns_message_currentname(), dns_message_destroy(), dns_message_findtype(), dns_message_firstname(), DNS_MESSAGE_INTENTPARSE, dns_message_nextname(), dns_message_renderreset(), dns_message_settsigkey(), DNS_MESSAGEPARSE_PRESERVEORDER, dns_name_clone(), dns_name_countlabels(), dns_name_getlabelsequence(), dns_name_init(), DNS_R_SERVFAIL, DNS_R_TSIGERRORSET, dns_rcode_noerror, dns_rcode_nxdomain, dns_request_createvia3(), dns_request_destroy(), dns_request_getresponse(), DNS_REQUESTOPT_TCP, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_client::find_timeout, INSIST, isc_event_free(), ISC_FALSE, ISC_R_SUCCESS, ISC_TRUE, updatectx::lock, LOCK, dns_client::mctx, name, POST, process_soa(), dns_message::rcode, rcode2result(), dns_requestevent::request, dns_view::requestmgr, REQUIRE, dns_requestevent::result, updatectx::soaquery, updatectx::soareq, dns_client::task, updatectx::tsigkey, UNLOCK, UNUSED, update_sendevent(), updatectx::view, and updatectx::want_tcp.

Referenced by request_soa().

static void resolvesoa_done ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2500 of file client.c.

References dns_clientresevent::answerlist, updatectx::client, dns_client_destroyrestrans(), dns_client_freeresanswer(), dns_client_startresolve(), DNS_CLIENTRESOPT_TCP, dns_name_clone(), dns_name_countlabels(), dns_name_getlabelsequence(), dns_name_init(), DNS_R_NCACHENXDOMAIN, DNS_R_NCACHENXRRSET, DNS_R_SERVFAIL, dns_rdataset_isassociated(), isc_event_free(), ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, updatectx::lock, LOCK, name, process_soa(), updatectx::rdclass, REQUIRE, updatectx::restrans, dns_clientresevent::result, updatectx::soaqname, dns_client::task, dns_rdataset::type, UCTX_VALID, UNLOCK, UNUSED, update_sendevent(), and updatectx::want_tcp.

Referenced by dns_client_startupdate().

static isc_result_t copy_name ( isc_mem_t mctx,
dns_message_t msg,
dns_name_t name,
dns_name_t **  newnamep 
) [static]

Definition at line 2570 of file client.c.

References isc_region::base, dns_rdataset::covers, dns_rdatalist::covers, dns_message_gettempname(), dns_message_gettemprdata(), dns_message_gettemprdatalist(), dns_message_gettemprdataset(), dns_message_puttempname(), dns_message_takebuffer(), dns_name_copy(), dns_name_init(), DNS_NAME_MAXWIRE, dns_name_setbuffer(), dns_rdata_fromregion(), dns_rdata_init(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_toregion(), dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_init(), dns_rdataset_next(), dns_rdata::flags, isc_buffer_allocate(), isc_buffer_putmem, isc_buffer_usedregion, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, isc_region::length, namebuf, newrdata(), r, dns_rdata::rdclass, dns_rdataset::rdclass, dns_rdatalist::rdclass, dns_rdataset::ttl, dns_rdatalist::ttl, dns_rdata::type, dns_rdataset::type, and dns_rdatalist::type.

Referenced by dns_client_startupdate().

static void internal_update_callback ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2656 of file client.c.

References updatearg::actx, updatearg::canceled, updatearg::client, DESTROYLOCK, dns_client_destroyupdatetrans(), isc_app_ctxsuspend(), isc_event_free(), isc_mem_put, updatearg::lock, LOCK, dns_client::mctx, dns_clientupdateevent::result, updatearg::result, updatearg::trans, UNLOCK, and UNUSED.

Referenced by dns_client_update().

isc_result_t dns_client_update ( dns_client_t client,
dns_rdataclass_t  rdclass,
dns_name_t zonename,
dns_namelist_t *  prerequisites,
dns_namelist_t *  updates,
isc_sockaddrlist_t *  servers,
dns_tsec_t tsec,
unsigned int  options 
)

Destroy DNS request transaction state identified by '*transp'.

Requires:

Ensures:

Definition at line 2686 of file client.c.

References updatearg::actx, dns_client::actx, dns_client::attributes, updatearg::canceled, updatearg::client, DESTROYLOCK, dns_client_cancelupdate(), dns_client_startupdate(), DNS_CLIENT_VALID, DNS_CLIENTATTR_OWNCTX, DNS_CLIENTUPDOPT_ALLOWRUN, internal_update_callback(), isc_app_ctxrun(), ISC_FALSE, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_FAILURE, ISC_R_NOMEMORY, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, ISC_R_SUSPEND, ISC_TRUE, LOCK, updatearg::lock, dns_client::mctx, REQUIRE, updatearg::result, dns_client::task, updatearg::trans, and UNLOCK.

isc_result_t dns_client_startupdate ( dns_client_t client,
dns_rdataclass_t  rdclass,
dns_name_t zonename,
dns_namelist_t *  prerequisites,
dns_namelist_t *  updates,
isc_sockaddrlist_t *  servers,
dns_tsec_t tsec,
unsigned int  options,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_clientupdatetrans_t **  transp 
)

Perform DNS dynamic update for 'updates' of the 'rdclass' class with optional 'prerequisites'.

'updates' are a list of names with associated RRsets to be updated.

'prerequisites' are a list of names with associated RRsets corresponding to the prerequisites of the updates. This is optional and can be NULL, in which case the prerequisite section of the update message will be empty.

Both 'updates' and 'prerequisites' must be constructed as specified in RFC2136.

'zonename' is the name of the zone in which the updated names exist. This is optional and can be NULL. In this case, these functions internally identify the appropriate zone through some queries for the SOA RR starting with the first name in prerequisites or updates.

'servers' is a list of authoritative servers to which the update message should be sent. This is optional and can be NULL. In this case, these functions internally identify the appropriate primary server name and its addresses through some queries for the SOA RR (like the case of zonename) and supplemental A/AAAA queries for the server name. Note: The client module generally assumes the given addresses are of the primary server of the corresponding zone. It will work even if a secondary server address is specified as long as the server allows update forwarding, it is generally discouraged to include secondary server addresses unless there's strong reason to do so.

'tsec' is a transaction security object containing, e.g. a TSIG key for authenticating the update transaction (and the supplemental query/response transactions if the server is specified). This is optional and can be NULL, in which case the library tries the update without any transaction authentication.

It is typically expected that the client object passed to dns_client_update() was created via dns_client_create() and has its own managers and contexts. However, if the DNS_CLIENTUPDOPT_ALLOWRUN flag is set in 'options', this function performs the synchronous service even if it does not have its own manager and context structures.

dns_client_update() provides a synchronous service. This function blocks until the entire update procedure completes, including the additional queries when necessary.

dns_client_startupdate() is an asynchronous version of dns_client_update(). It immediately returns (typically with *transp being set to a non-NULL pointer), and performs the update procedure through a set of internal events. All transactions including the additional query exchanges are performed as a separate event, so none of these events cause blocking operation. When the update procedure completes, the specified function 'action' will be called with the argument of a 'dns_clientupdateevent_t' structure. On return, '*transp' is set to an opaque transaction ID so that the caller can cancel this update process.

DNS_CLIENTUPDOPT_TCP switches to the TCP (vs. UDP) transport.

Requires:

Returns:

Definition at line 2767 of file client.c.

References updatectx::bp4, updatectx::bp6, updatectx::canceled, updatectx::client, copy_name(), updatectx::currentserver, DESTROYLOCK, dns_client_startresolve(), DNS_CLIENT_VALID, DNS_CLIENTRESOPT_TCP, dns_clientupdatestate_prepare, DNS_CLIENTUPDOPT_TCP, DNS_CLIENTVIEW_NAME, DNS_EVENT_UPDATEDONE, dns_fixedname_init, dns_fixedname_name, dns_message_addname(), dns_message_create(), dns_message_currentname(), dns_message_destroy(), dns_message_firstname(), DNS_MESSAGE_INTENTRENDER, dns_name_clone(), dns_name_copy(), dns_name_init(), dns_opcode_update, DNS_SECTION_PREREQUISITE, DNS_SECTION_UPDATE, dns_tsec_getkey(), dns_tsec_gettype(), dns_tsectype_none, dns_tsectype_tsig, dns_tsigkey_detach(), dns_view_detach(), dns_viewlist_find(), updatectx::event, updatectx::firstname, isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, ISC_FALSE, ISC_LINK_INIT, ISC_LINK_LINKED, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOMORE, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_task_attach(), isc_task_detach(), ISC_TF, isc_sockaddr::length, updatectx::lock, dns_client::lock, LOCK, updatectx::magic, dns_client::mctx, name, updatectx::nservers, dns_message::opcode, updatectx::rdclass, request_soa(), REQUIRE, resolvesoa_done(), updatectx::restrans, updatectx::restrans2, send_update(), updatectx::servers, updatectx::sig0key, updatectx::soaqname, updatectx::soaquery, updatectx::soareq, updatectx::state, dns_client::task, updatectx::tsigkey, isc_sockaddr::type, UCTX_MAGIC, UNLOCK, UNUSED, updatectx::updatemsg, updatectx::updatereq, updatectx::view, dns_client::viewlist, updatectx::want_tcp, updatectx::zonefname, and updatectx::zonename.

Referenced by dns_client_update().

void dns_client_cancelupdate ( dns_clientupdatetrans_t trans  ) 

Cancel an ongoing dynamic update procedure started via dns_client_startupdate().

Notes:

Requires:

Definition at line 2971 of file client.c.

References updatectx::canceled, dns_client_cancelresolve(), dns_request_cancel(), ISC_TRUE, updatectx::lock, LOCK, REQUIRE, updatectx::restrans, updatectx::restrans2, updatectx::soareq, UCTX_VALID, UNLOCK, and updatectx::updatereq.

Referenced by dns_client_update().

void dns_client_destroyupdatetrans ( dns_clientupdatetrans_t **  transp  ) 

Destroy dynamic update transaction identified by '*transp'.

Requires:

Ensures:

Definition at line 2996 of file client.c.

References updatectx::client, destroyclient(), DESTROYLOCK, DNS_CLIENT_VALID, dns_view_detach(), updatectx::event, INSIST, ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_put, ISC_TRUE, updatectx::lock, dns_client::lock, LOCK, updatectx::magic, dns_client::mctx, dns_client::references, REQUIRE, updatectx::servers, updatectx::sig0key, updatectx::soaquery, updatectx::soareq, updatectx::tsigkey, UCTX_VALID, UNLOCK, updatectx::updatemsg, updatectx::updatereq, and updatectx::view.

Referenced by internal_update_callback().

isc_mem_t* dns_client_mctx ( dns_client_t client  ) 

Definition at line 3044 of file client.c.

References DNS_CLIENT_VALID, dns_client::mctx, and REQUIRE.

isc_result_t dns_client_updaterec ( dns_client_updateop_t  op,
dns_name_t owner,
dns_rdatatype_t  type,
dns_rdata_t source,
dns_ttl_t  ttl,
dns_name_t target,
dns_rdataset_t rdataset,
dns_rdatalist_t rdatalist,
dns_rdata_t rdata,
isc_mem_t mctx 
)

TBD.

Definition at line 3061 of file client.c.

References dns_name::attributes, dns_client_updaterec_t::buffer, dns_rdatalist::covers, dns_rdata::data, dns_client_updaterec_t::data, dns_name_copy(), dns_name_setbuffer(), DNS_NAMEATTR_HASUPDATEREC, DNS_NAMEATTR_PREREQUISITE, DNS_NAMEATTR_UPDATE, dns_rdata_clone(), dns_rdata_covers(), dns_rdata_deleterrset(), dns_rdata_exists(), dns_rdata_init(), dns_rdata_makedelete(), dns_rdata_notexist(), dns_rdata_toregion(), dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_init(), INSIST, isc_buffer_copyregion(), isc_buffer_init, isc_buffer_used, ISC_LIST_APPEND, isc_mem_attach(), isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_rdata::length, dns_name::length, dns_client_updaterec_t::mctx, r, dns_client_updaterec_t::rdata, dns_client_updaterec_t::rdatalist, dns_client_updaterec_t::rdataset, dns_rdata::rdclass, dns_rdatalist::rdclass, REQUIRE, dns_rdatalist::ttl, dns_rdatalist::type, dns_rdata::type, updateop_add, updateop_delete, updateop_exist, updateop_max, updateop_none, and updateop_notexist.

void dns_client_freeupdate ( dns_name_t **  namep  ) 

TBD.

Definition at line 3159 of file client.c.

References dns_name::attributes, dns_name::buffer, DNS_NAMEATTR_HASUPDATEREC, dns_rdatalist_fromrdataset(), dns_rdataset_disassociate(), INSIST, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_putanddetach, dns_client_updaterec_t::mctx, name, REQUIRE, and dns_client_updaterec_t::size.


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