Commit b110b1bc authored by James Brister's avatar James Brister
Browse files

Misc changes.

parent 915440a0
......@@ -42,53 +42,15 @@
#define ZONE_FREE_MAGIC 0x0
/* This structure contains all the run-time information about a zone. */
struct zoneinfo
{
char *origin; /* name of zone */
time_t filemodtime; /* mod time of zone file */
char *source; /* where zone data came from */
#if 0
dns_db_t what_am_i; /* XXX unknown thing... */
#endif
time_t lastupdate; /* time last soa serial increment */
u_int32_t refresh; /* refresh interval */
u_int32_t retry; /* refresh retry interval */
u_int32_t expire; /* expiration time for cached info */
u_int32_t minimum; /* minimum TTL value */
u_int32_t serial; /* SOA serial number */
u_int options; /* zone specific options */
int zoneclass; /* zone class type */
int32_t magic; /* private magic stamp for valid'ng */
struct zonectx *zctx; /* contect zone came from. */
ISC_LINK(struct zoneinfo) chainlink;
};
/* This structure contains context information about a set of
zones. Presumamable there'd only be one of these passed around the
various threads, but separating out zones might be useful in some way */
struct zonectx
{
ISC_LIST(zoneinfo_t) freezones;
ISC_LIST(zoneinfo_t) usedzones;
isc_mem_t *memctx; /* where we get all our memory from */
};
static isc_result_t set_string(char **string, size_t *len,
const char *source, isc_mem_t *mem);
isc_result_t
new_zonecontext(isc_mem_t *memctx, zonectx_t **zctx) {
zonectx_t *zc ;
isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **zctx)
{
isc_zonectx_t *zc ;
INSIST(zctx != NULL);
INSIST(memctx != NULL);
......@@ -105,9 +67,23 @@ new_zonecontext(isc_mem_t *memctx, zonectx_t **zctx) {
}
isc_result_t
isc_zone_freecontext(isc_zonectx_t *zonectx)
{
isc_zoneinfo_t *zi ;
zi = ISC_LIST_HEAD(zonectx->freezones) ;
while (zi != NULL ) {
isc_zone_release_zone(zi);
}
return (ISC_R_SUCCESS);
}
isc_result_t
new_zone(zonectx_t *zctx, zoneinfo_t **zone) {
struct zoneinfo *zp;
isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone)
{
struct isc_zoneinfo *zp;
INSIST(zctx != NULL);
INSIST(zone != NULL);
......@@ -144,7 +120,8 @@ new_zone(zonectx_t *zctx, zoneinfo_t **zone) {
isc_result_t
free_zone(zoneinfo_t *zone) {
isc_zone_freezone(isc_zoneinfo_t *zone)
{
INSIST(zone != NULL);
INSIST(zone->magic == ZONE_USED_MAGIC);
INSIST(zone->zctx != NULL);
......@@ -157,235 +134,65 @@ free_zone(zoneinfo_t *zone) {
}
isc_result_t zone_setorigin(zoneinfo_t *zone, char *origin)
{
(void) zone;
(void) origin;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getorigin(zoneinfo_t *zone, char **origin)
{
(void) zone;
(void) origin;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setfilemodtime(zoneinfo_t *zone, time_t ftime)
{
(void) zone;
(void) ftime;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getfilemodtime(zoneinfo_t *zone, time_t *ftime)
{
(void) zone;
(void) ftime;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setsource(zoneinfo_t *zone, char *source)
{
(void) zone;
(void) source;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getsource(zoneinfo_t *zone, char **source)
{
(void) zone;
(void) source;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setlastupdate(zoneinfo_t *zone, time_t lastupdate)
{
(void) zone;
(void) lastupdate;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getlastupdate(zoneinfo_t *zone, time_t *lastupdate)
{
(void) zone;
(void) lastupdate;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setrefresh(zoneinfo_t *zone, u_int32_t refresh)
{
(void) zone;
(void) refresh;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getrefresh(zoneinfo_t *zone, u_int32_t *refresh)
{
(void) zone;
(void) refresh;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setretry(zoneinfo_t *zone, u_int32_t retry)
{
(void) zone;
(void) retry;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getretry(zoneinfo_t *zone, u_int32_t *retry)
{
(void) zone;
(void) retry;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setexpire(zoneinfo_t *zone, u_int32_t expire)
{
(void) zone;
(void) expire;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getexpire(zoneinfo_t *zone, u_int32_t *expire)
{
(void) zone;
(void) expire;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_setminimum(zoneinfo_t *zone, u_int32_t minimum)
{
(void) zone;
(void) minimum;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getminimum(zoneinfo_t *zone, u_int32_t *minimum)
isc_result_t
isc_zone_release_zone(isc_zoneinfo_t *zone)
{
(void) zone;
(void) minimum;
isc_mem_put(zone->zctx->memctx, zone, sizeof *zone);
/* XXX fill this in */
return ISC_R_SUCCESS;
return (ISC_R_SUCCESS);
}
isc_result_t zone_setserial(zoneinfo_t *zone, u_int32_t serial)
{
(void) zone;
(void) serial;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getserial(zoneinfo_t *zone, u_int32_t *serial)
isc_result_t
isc_zone_setsource(isc_zoneinfo_t *zone, const char *source)
{
(void) zone;
(void) serial;
/* XXX fill this in */
INSIST(zone != NULL);
INSIST(source != NULL);
INSIST(strlen(source) > 0);
return ISC_R_SUCCESS;
return (set_string(&zone->source, &zone->sourcelen,
source, zone->zctx->memctx));
}
isc_result_t zone_setoptions(zoneinfo_t *zone, u_int options)
{
(void) zone;
(void) options;
/* XXX fill this in */
return ISC_R_SUCCESS;
}
isc_result_t zone_getoptions(zoneinfo_t *zone, u_int *options)
isc_result_t
isc_zone_setorigin(isc_zoneinfo_t *zone, const char *source)
{
(void) zone;
(void) options;
INSIST(zone != NULL);
INSIST(source != NULL);
INSIST(strlen(source) > 0);
/* XXX fill this in */
return (set_string(&zone->origin, &zone->originlen,
source, zone->zctx->memctx));
}
return ISC_R_SUCCESS;
}
isc_result_t zone_setzoneclass(zoneinfo_t *zone, int zclass)
static isc_result_t
set_string(char **string, size_t *len, const char *source, isc_mem_t *mem)
{
(void) zone;
(void) zclass;
/* XXX fill this in */
INSIST(string != NULL);
INSIST(len != 0);
INSIST(mem != NULL);
if (*len > 0 && *len <= strlen(source)) {
isc_mem_put(mem, *string, *len);
*len = 0;
*string = NULL;
}
return ISC_R_SUCCESS;
}
if (*len == 0) {
size_t need = strlen(source) + 1;
isc_result_t zone_getzoneclass(zoneinfo_t *zone, int *zclass)
{
(void) zone;
(void) zclass;
*string = isc_mem_get(mem, need);
if (*string == NULL) {
return (ISC_R_NOMEMORY);
}
}
/* XXX fill this in */
strcpy (*string, source);
return ISC_R_SUCCESS;
return (ISC_R_SUCCESS);
}
......@@ -15,6 +15,9 @@
* SOFTWARE.
*/
#if ! defined(ZONE_H)
#define ZONE_H
#include <config.h>
#include <sys/types.h>
......@@ -23,66 +26,87 @@
#include <isc/result.h>
#include <isc/mem.h>
#include <dns/types.h>
/* Zone context structures contain a set of zones and related information
(like isc_mem_t contexts to allocate memory from). */
typedef struct zonectx zonectx_t;
typedef struct isc_zonectx isc_zonectx_t;
/* The zone. All access is through function API */
typedef struct zoneinfo zoneinfo_t;
typedef struct isc_zoneinfo isc_zoneinfo_t;
/* Allocate a zone context from the memctx pool. All zone-private data
* structures will be will be made from that same pool.
*/
isc_result_t new_zonecontext(isc_mem_t *memctx, zonectx_t **ctx);
typedef enum {
zone_master, zone_slave, zone_hint, zone_stub, zone_forward
} isc_zonet_t ;
/* Allocate a zone from the give zone context. */
isc_result_t new_zone(zonectx_t *zctx, zoneinfo_t **zone);
/* This structure contains all the run-time information about a zone. */
struct isc_zoneinfo
{
int32_t magic; /* private magic stamp for valid'ng */
/* Free up a zone and all associated data structures. The zone knows which
*zone context to go back to
*/
isc_result_t free_zone(zoneinfo_t *zone);
size_t originlen;
char *origin; /* name of zone */
size_t sourcelen;
char *source; /* where zone data came from */
/* Misc accessor routines. All returned data is through the parameter
* lists. Function return values indicates success (or not). All the set
* functions copy their arguments so the caller retains ownership of any
* pointers passed through the API. All pointers that come back through
* the API in the get functions (e.g. getorigin and getsource) are still
* owned by the zoneinfo_t structure and the data they point to must be
* copied by the caller
*/
isc_result_t zone_setorigin(zoneinfo_t *zone, char *origin);
isc_result_t zone_getorigin(zoneinfo_t *zone, char **origin);
isc_zonet_t type; /* master, slave etc. */
dns_db_t *thedb;
/* The rest below aren't implmented yet */
isc_result_t zone_setfilemodtime(zoneinfo_t *zone, time_t ftime);
isc_result_t zone_getfilemodtime(zoneinfo_t *zone, time_t *ftime);
time_t filemodtime; /* mod time of zone file */
time_t lastupdate; /* time last soa serial increment */
u_int32_t refresh; /* refresh interval */
u_int32_t retry; /* refresh retry interval */
u_int32_t expire; /* expiration time for cached info */
u_int32_t minimum; /* minimum TTL value */
u_int32_t serial; /* SOA serial number */
isc_result_t zone_setsource(zoneinfo_t *zone, char *source);
isc_result_t zone_getsource(zoneinfo_t *zone, char **source);
u_int options; /* zone specific options */
int zoneclass; /* zone class type */
isc_result_t zone_setlastupdate(zoneinfo_t *zone, time_t lastupdate);
isc_result_t zone_getlastupdate(zoneinfo_t *zone, time_t *lastupdate);
struct isc_zonectx *zctx; /* contect zone came from. */
ISC_LINK(struct isc_zoneinfo) chainlink;
};
isc_result_t zone_setrefresh(zoneinfo_t *zone, u_int32_t refresh);
isc_result_t zone_getrefresh(zoneinfo_t *zone, u_int32_t *refresh);
isc_result_t zone_setretry(zoneinfo_t *zone, u_int32_t retry);
isc_result_t zone_getretry(zoneinfo_t *zone, u_int32_t *retry);
/* This structure contains context information about a set of
zones. Presumamable there'd only be one of these passed around the
various threads, but separating out zones might be useful in some way */
struct isc_zonectx
{
ISC_LIST(isc_zoneinfo_t) freezones;
ISC_LIST(isc_zoneinfo_t) usedzones;
isc_result_t zone_setexpire(zoneinfo_t *zone, u_int32_t expire);
isc_result_t zone_getexpire(zoneinfo_t *zone, u_int32_t *expire);
isc_mem_t *memctx; /* where we get all our memory from */
};
isc_result_t zone_setminimum(zoneinfo_t *zone, u_int32_t minimum);
isc_result_t zone_getminimum(zoneinfo_t *zone, u_int32_t *minimum);
isc_result_t zone_setserial(zoneinfo_t *zone, u_int32_t serial);
isc_result_t zone_getserial(zoneinfo_t *zone, u_int32_t *serial);
isc_result_t zone_setoptions(zoneinfo_t *zone, u_int options);
isc_result_t zone_getoptions(zoneinfo_t *zone, u_int *options);
/* Allocate a zone context from the memctx pool. All zone-private data
* structures will be will be made from that same pool.
*/
isc_result_t isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **ctx);
/* Allocate a zone from the give zone context. */
isc_result_t isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone);
isc_result_t isc_zone_release_zone(isc_zoneinfo_t *zone);
/* Free up a zone and all associated data structures. The zone knows which
*zone context to go back to
*/
isc_result_t isc_zone_freezone(isc_zoneinfo_t *zone);
isc_result_t isc_zone_freecontext(isc_zonectx_t *ctx);
isc_result_t isc_zone_setsource(isc_zoneinfo_t *zone, const char *source);
isc_result_t isc_zone_setorigin(isc_zoneinfo_t *zone, const char *origin);
isc_result_t zone_setzoneclass(zoneinfo_t *zone, int zclass);
isc_result_t zone_getzoneclass(zoneinfo_t *zone, int *zclass);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment