xfrout.c revision 34b394b43e2207e8f8f3703f0402422121455638
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Copyright (C) 1999, 2000 Internet Software Consortium.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Permission to use, copy, modify, and distribute this software for any
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * purpose with or without fee is hereby granted, provided that the above
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * copyright notice and this permission notice appear in all copies.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
031ce3bc62d273c5bd99596e01aa95c7ed33bbd7Brian Wellington/* $Id: xfrout.c,v 1.62 2000/05/15 21:14:01 tale Exp $ */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Outgoing AXFR and IXFR.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * - IXFR over UDP
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff ns_g_lctx, DNS_LOGCATEGORY_XFER_OUT, NS_LOGMODULE_XFER_OUT
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff * Fail unconditionally and log as a client error.
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff * The test against ISC_R_SUCCESS is there to keep the Solaris compiler
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * from complaining about "end-of-loop code not reached".
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff ns_client_log(client, DNS_LOGCATEGORY_XFER_OUT, \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff "bad zone transfer request: %s (%s)", \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff/**************************************************************************/
b81306ccd14066cb7378f7f74bbf3843b5a88985Michael Graff * A db_rr_iterator_t is an iterator that iterates over an entire database,
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * returning one RR at a time, in some arbitrary order.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Grafftypedef struct db_rr_iterator db_rr_iterator_t;
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffdb_rr_iterator_init(db_rr_iterator_t *it, dns_db_t *db, dns_dbversion_t *ver,
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graffdb_rr_iterator_current(db_rr_iterator_t *it, dns_name_t **name,
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffdb_rr_iterator_init(db_rr_iterator_t *it, dns_db_t *db, dns_dbversion_t *ver,
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff result = dns_db_createiterator(it->db, ISC_FALSE, &it->dbit);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff INSIST(! dns_rdataset_isassociated(&it->rdataset));
58ff88cca7c169f7fbebc9b6e93bbba1fb345157Michael Graff it->result = dns_dbiterator_current(it->dbit, &it->node,
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff it->result = dns_db_allrdatasets(it->db, it->node,
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff it->result = dns_rdatasetiter_first(it->rdatasetit);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff dns_rdatasetiter_current(it->rdatasetit, &it->rdataset);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff it->result = dns_rdataset_first(&it->rdataset);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff it->result = dns_rdataset_next(&it->rdataset);
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff it->result = dns_rdatasetiter_next(it->rdatasetit);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff /* We are at the end of the entire database. */
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff it->result = dns_db_allrdatasets(it->db, it->node,
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff it->result = dns_rdatasetiter_first(it->rdatasetit);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graff dns_rdatasetiter_current(it->rdatasetit, &it->rdataset);
658db10162f779c8a5ed4e40c77111a7e18492beMichael Graffdb_rr_iterator_current(db_rr_iterator_t *it, dns_name_t **name,
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff dns_rdataset_current(&it->rdataset, &it->rdata);
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff/**************************************************************************/
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff/* Log an RR (for debugging) */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Grafflog_rr(dns_name_t *name, dns_rdata_t *rdata, isc_uint32_t ttl) {
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff RUNTIME_CHECK(dns_rdatalist_tordataset(&rdl, &rds) == ISC_R_SUCCESS);
typedef struct rrstream {
} rrstream_t;
struct rrstream_methods {
dns_name_t **,
isc_uint32_t *,
dns_rdata_t **);
typedef struct ixfr_rrstream {
static isc_result_t
const char *journal_filename,
ixfr_rrstream_t *s;
if (s == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
static isc_result_t
if (s->journal != 0)
typedef struct axfr_rrstream {
int state;
static isc_result_t
axfr_rrstream_t *s;
if (s == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (result);
return (result);
static isc_result_t
return (result);
if (s->it_valid)
typedef struct soa_rrstream {
static isc_result_t
soa_rrstream_t *s;
if (s == NULL)
return (ISC_R_NOMEMORY);
&s->soa_tuple));
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOMORE);
typedef struct compound_rrstream {
int state;
static isc_result_t
static isc_result_t
if (s == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
s->state = 0;
return (s->result);
static isc_result_t
return (ISC_R_NOMORE);
s->state++;
return (s->result);
void *txmem;
unsigned int txmemlen;
} xfrout_ctx_t;
static isc_result_t
unsigned int maxtime,
unsigned int idletime,
const char *fmt, ...);
switch (reqtype) {
case dns_rdatatype_axfr:
case dns_rdatatype_ixfr:
INSIST(0);
goto failure;
&zone);
case dns_zone_master:
case dns_zone_slave:
&soa_name);
goto got_soa;
goto axfr_fallback;
if (! have_soa)
goto have_stream;
&data_stream);
goto axfr_fallback;
&data_stream));
&stream));
&xfr));
static isc_result_t
unsigned int len;
void *mem;
return (ISC_R_NOMEMORY);
goto failure;
goto failure;
ISC_FALSE));
return (ISC_R_SUCCESS);
return (result);
int n_rrs;
isc_region_t r;
goto failure;
goto failure;
unsigned int size;
isc_region_t r;
if (n_rrs == 0) {
goto failure;
xfr));
const char *fmt, ...)