client.c revision 0874abad14e3e9ecfc3dc1a1a2b9969f2f027724
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User * Copyright (C) 2009, 2010 Internet Systems Consortium, Inc. ("ISC")
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Permission to use, copy, modify, and/or distribute this software for any
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater * purpose with or without fee is hereby granted, provided that the above
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * copyright notice and this permission notice appear in all copies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * PERFORMANCE OF THIS SOFTWARE.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein/* $Id: client.c,v 1.13 2011/03/11 06:11:23 marka Exp $ */
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User#define DNS_CLIENT_MAGIC ISC_MAGIC('D', 'N', 'S', 'c')
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define DNS_CLIENT_VALID(c) ISC_MAGIC_VALID(c, DNS_CLIENT_MAGIC)
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User#define RCTX_MAGIC ISC_MAGIC('R', 'c', 't', 'x')
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define RCTX_VALID(c) ISC_MAGIC_VALID(c, RCTX_MAGIC)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define REQCTX_MAGIC ISC_MAGIC('R', 'q', 'c', 'x')
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define REQCTX_VALID(c) ISC_MAGIC_VALID(c, REQCTX_MAGIC)
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User#define UCTX_VALID(c) ISC_MAGIC_VALID(c, UCTX_MAGIC)
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * DNS client object
48abcd3eb789fdd24a2e0a6155b25e6979a39ae0Mark Andrews /* Unlocked */
48abcd3eb789fdd24a2e0a6155b25e6979a39ae0Mark Andrews unsigned int magic;
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews * Timeout/retry constants for dynamic update borrowed from nsupdate
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * Internal state for a single name resolution procedure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeintypedef struct resctx {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /* Unlocked */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein unsigned int magic;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /* Locked */
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews unsigned int restarts;
} resctx_t;
typedef struct resarg {
} resarg_t;
typedef struct reqctx {
unsigned int magic;
unsigned int parseoptions;
} reqctx_t;
typedef struct reqarg {
} reqarg_t;
typedef struct updatearg {
} updatearg_t;
typedef struct updatectx {
unsigned int magic;
unsigned int nservers;
} updatectx_t;
static isc_result_t
attrs = 0;
switch (family) {
case AF_INET:
case AF_INET6:
INSIST(0);
attrmask = 0;
return (result);
static isc_result_t
const char *dbtype;
return (result);
return (result);
return (result);
return (result);
return (ISC_R_SUCCESS);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_NOMEMORY);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
&view);
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
if (destroyok)
return (result);
return (result);
return (result);
return (result);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static inline isc_result_t
return (result);
static isc_result_t
return (result);
unsigned int nlabels;
int order;
goto done;
sizeof(*ansname));
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_CNAME:
goto done;
goto done;
goto done;
case DNS_R_DNAME:
&nlabels);
goto done;
goto done;
goto done;
case DNS_R_NCACHENXDOMAIN:
case DNS_R_NCACHENXRRSET:
goto done;
goto done;
&rdsiter);
goto done;
link);
goto done;
done:
!= NULL) {
if (want_restart) {
} while (want_restart);
if (send_event) {
return (ISC_R_NOMEMORY);
return (result);
return (result);
return (result);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
if (want_dnssec) {
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
if (need_destroyclient)
goto cleanup;
goto cleanup;
&dstkey);
goto cleanup;
return (result);
return (ISC_R_NOMEMORY);
return (result);
return (result);
return (result);
return (result);
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
if (need_destroyclient)
static isc_result_t
switch (rcode) {
case dns_rcode_formerr:
return (DNS_R_FORMERR);
case dns_rcode_servfail:
return (DNS_R_SERVFAIL);
case dns_rcode_nxdomain:
return (DNS_R_NXDOMAIN);
case dns_rcode_notimp:
return (DNS_R_NOTIMP);
case dns_rcode_refused:
return (DNS_R_REFUSED);
case dns_rcode_yxdomain:
return (DNS_R_YXDOMAIN);
case dns_rcode_yxrrset:
return (DNS_R_YXRRSET);
case dns_rcode_nxrrset:
return (DNS_R_NXRRSET);
case dns_rcode_notauth:
return (DNS_R_NOTAUTH);
case dns_rcode_notzone:
return (DNS_R_NOTZONE);
case dns_rcode_badvers:
return (DNS_R_BADVERS);
return (ISC_R_FAILURE);
unsigned int timeout;
goto out;
&answer);
goto out;
out:
NULL,
static isc_result_t
unsigned int timeout;
return (result);
return (result);
return (result);
return (result);
int family;
goto done;
sizeof(*sa));
goto done;
switch (family) {
case AF_INET:
NULL);
case AF_INET6:
NULL);
done:
if (completed) {
static isc_result_t
return (result);
return (result);
goto out;
&primary,
out:
return (result);
int pass = 0;
unsigned int nlabels;
goto out;
goto out;
NULL,
&newrequest);
goto out;
goto out;
if (pass == 0)
goto out;
pass++;
goto lookforsoa;
&soaset);
pass++;
goto lookforsoa;
if (seencname) {
goto out;
out:
if (droplabel) {
&tname);
static isc_result_t
&soaquery);
return (result);
goto fail;
goto fail;
return (ISC_R_SUCCESS);
fail:
return (result);
unsigned int nlabels;
goto out;
goto out;
&tname);
out:
static isc_result_t
isc_region_t r;
return (result);
goto fail;
goto fail;
goto fail;
goto fail;
r.length);
goto fail;
goto fail;
return (ISC_R_SUCCESS);
fail:
return (result);
return (ISC_R_NOMEMORY);
return (result);
return (result);
return (result);
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
goto fail;
goto fail;
goto fail;
goto fail;
&newname);
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
return (ISC_R_SUCCESS);
fail:
return (result);
if (need_destroyclient)
return (ISC_R_NOMEMORY);
isc_region_t r;
switch (op) {
case updateop_add:
case updateop_delete:
ttl = 0;
case updateop_notexist:
case updateop_exist:
ttl = 0;
case updateop_none:
INSIST(0);
return (ISC_R_SUCCESS);