2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

New config file library headers.

This commit is contained in:
James Brister
1999-07-19 13:14:12 +00:00
parent 727524f623
commit bbe0dc743b
12 changed files with 2846 additions and 0 deletions

View File

@@ -0,0 +1,280 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFACL_H
#define DNS_CONFIG_CONFACL_H 1
/*****
***** Module Info
*****/
/*
* ADT for ACLs as used by the config file module. An ACL is a name and a
* list of ipmatch lists or references to other acls. ACLS are created in
* ACL tables, and ACLs that reference other ACLs must be created in the
* same table.
*/
/*
* MP:
* Caller must do necessary locking.
*
* Reliability:
*
* No known problems.
*
* Resources:
*
* Uses memory managers supplied by caller.
*
* Security:
*
* N/A.
*
* Standards:
*
* N/A.
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/list.h>
#include <isc/mem.h>
#include <dns/confip.h>
/***
*** Types
***/
typedef struct dns_c_acl dns_c_acl_t;
typedef struct dns_c_acl_table dns_c_acl_table_t;
struct dns_c_acl
{
dns_c_acl_table_t *mytable;
char *name;
dns_c_ipmatch_list_t *ipml;
isc_boolean_t is_special;
ISC_LINK(dns_c_acl_t) next;
};
struct dns_c_acl_table
{
isc_mem_t *mem;
ISC_LIST(dns_c_acl_t) acl_list;
};
/***
*** Functions
***/
isc_result_t dns_c_acl_table_new(isc_mem_t *mem,
dns_c_acl_table_t **newtable);
/*
* Creates a new ACL table. Returns pointer to the new table through
* NEWTABLE paramater. The memory is allocated from the MEM memory pool.
*
* Requires:
* mem is a valid memory pool
* newtable is a valid non-NULL pointer.
* mem remain a valuid memory pool until the table is destroyed.
*
* Returns:
* ISC_R_SUCCESS -- all is well.
* ISC_R_NOMEMORY -- not enough memory.
*
*/
isc_result_t dns_c_acl_table_delete(dns_c_acl_table_t **table);
/*
* Destroys the table pointed to by *TABLE and all the ACLs in it. The
* value of *TABLE can be NULL.
*
* Requires:
* table is a valid pointer.
* The memory pool used at creation time still be valid.
*
* Returns:
* ISC_R_SUCCESS
*
*/
isc_result_t dns_c_acl_table_get_acl(dns_c_acl_table_t *table,
const char *aclname,
dns_c_acl_t **retval);
/*
* Looks up an ACL by name in the given table. The result is returned
* through the parameter RETVAL. The returned ACL must not be modified.
*
* Requires:
* TABLE be a value ACL table.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOTFOUND -- acl was not found
*
*/
isc_result_t dns_c_acl_table_remove_acl(dns_c_acl_table_t *table,
const char *aclname);
/*
* Removes an acl from a table. The acl is looked up by name.
*
* Requires:
* table be a valid pointer to an acl table
* aclname be a valid pointer to string of positive length.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOTFOUND -- acl was not in the table.
*
*/
void dns_c_acl_table_print(FILE *fp, int indent,
dns_c_acl_table_t *table);
/*
* Prints the ACL table and the ACLs in it to the give stdio stream.
* indent is the indentation level (number of tabs) printed before
* each line of the table
*
* Requires:
* fp be a valid stdio stream
* indent be a non-negative number
* table be a valid acl table.
*
*/
isc_result_t dns_c_acl_table_clear(dns_c_acl_table_t *table);
/*
* Deletes all the acls from the table.
*
* Requires:
* table must point to a valid ACL table.
*
* Returns:
* ISC_R_SUCCESS
*
*/
isc_result_t dns_c_acl_new(dns_c_acl_table_t *table, const char *aclname,
isc_boolean_t isspecial,
dns_c_acl_t **newacl);
/*
* Creates a new ACL. The acl is placed in the given table. If isspecial is
* true then the acl is not printed by dns_c_acl_print. The new acl is
* returned via the newacl parameter
*
* Requires:
* table be a pointer to a valid acl table.
* aclname be a pointer to a valid string of positive length
* newacl be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOMEMORY -- out of memory
*
*/
void dns_c_acl_print(FILE *fp, int indent, dns_c_acl_t *acl);
/*
* Prints out the acl to the stdio stream. The outupt is indented by INDENT
* tabs.
*
* Requires:
* fp be a pointer to a valid stdio stream
* indent be non-negative,
* acl be a pointer to a valid acl.
*
*/
isc_result_t dns_c_acl_set_ipml(dns_c_acl_t *acl,
dns_c_ipmatch_list_t *ipml,
isc_boolean_t deepcopy);
/*
* Sets the ipmatch list of the ACL to the IPML. If DEEPCOPY is true, then
* a full copy of IPML is made using the MEM memory pool. In which case the
* caller still is the owner the memory IPML points to. If DEEPCOPY is
* false, then the acl takes ownership of the memory IPML points to. If the
* acl already has an ipmatch list, then it is deleted before the new one
* is added.
*
* Requires:
* mem be a pointer to a valid memory manager
* ipml be a valid dns_c_ipmatch_list_t
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOMEMORY -- memory could not be allocated for the
* deepcopy .
*
*/
isc_result_t dns_c_acl_get_ipml_expanded(isc_mem_t *mem, dns_c_acl_t *acl,
dns_c_ipmatch_list_t **retval);
/*
* Retuns a copy through the RETVAL parameter (the caller is responsible
* for deleting the returned value) of the given ACLs ipmatch list. Any
* references in the acl list are recursivly expanded so that the end
* result has no references in it. Memory allocation for the copy is done
* via the memory pool pointed to by the MEM paramater.
*
* Requires:
* mem be a pointer to a valid memory manager
* acl be a pointer to a valid acl.
* retval be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOMEMORY -- not enough memory to make copy.
* ISC_R_FAILURE -- an acl reference couldn't be expanded.
*
*/
#endif /* DNS_CONFIG_CONFACL_H */

View File

@@ -0,0 +1,358 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFCOMMON_H
#define DNS_CONFIG_CONFCOMMON_H 1
/*****
***** Module Info
*****/
/*
* Various declarations of types and functions that are used by multiple
* headers in the config file module (put here to avoid circular include
* dependencies).
*
* Also some memory debugging aids that should eventually get moved to
* isc/mem.h or removed.
*/
/*
* MP:
*
* N/A
*
* Reliability:
*
* No problems known.
*
* Resources:
*
* N/A
*
* Security:
*
* N/A
*/
/***
*** Imports
***/
#include <config.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include <isc/int.h>
#include <isc/result.h>
#include <isc/types.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <dns/types.h>
/* Constants used in the defintions of default logging channels and
categories */
#define DNS_C_DEFAULT_SYSLOG "default_syslog"
#define DNS_C_DEFAULT_DEBUG "default_debug"
#define DNS_C_DEFAULT_DEBUG_PATH "named.run"
#define DNS_C_NULL "null"
#define DNS_C_DEFAULT_STDERR "default_stderr"
#define DNS_C_STDERR_PATH " <stderr> " /* not really a path */
/* The value we use in config files if the user doesn't specify the port or
* in some statements
*/
#define DNS_C_DEFAULTPORT 53 /* XXX this should be imported */
/* What an 'unlimited' value for a size_spec is stored as internally */
#define DNS_C_SIZE_SPEC_UNLIM (~((isc_uint32_t) 0x0))
/* What a 'default' value for a size_spec is stored as internally */
#define DNS_C_SIZE_SPEC_DEFAULT (DNS_C_SIZE_SPEC_UNLIM - 1)
/* What 'unlimited' is stored as internally for logging file versions */
#define DNS_C_UNLIM_VERSIONS DNS_C_SIZE_SPEC_UNLIM
/* The default ordering given to rrset-order statements when the type given
is illegal (so parsing can continue). */
#define DNS_DEFAULT_ORDERING dns_c_ordering_fixed
/***
*** Types
***/
/* Value of a 'forward' statement */
typedef enum {
dns_c_forw_only,
dns_c_forw_first,
dns_c_forw_no_answer,
dns_c_forw_no_domain,
} dns_c_forw_t;
/* value of a 'check-names' method */
typedef enum {
dns_c_severity_ignore,
dns_c_severity_warn,
dns_c_severity_fail,
} dns_c_severity_t;
/* Value of a 'check-names' type. */
typedef enum {
dns_trans_primary,
dns_trans_secondary,
dns_trans_response,
} dns_c_trans_t ;
#define DNS_C_TRANSCOUNT 3 /* number of items in dns_c_trans_t enum */
/* The tag values for the different types of control channels */
typedef enum {
dns_c_inet_control,
dns_c_unix_control
} dns_c_control_t;
/* The possible rrset-order ordering values. */
typedef enum {
dns_c_ordering_fixed,
dns_c_ordering_random,
dns_c_ordering_cyclic,
} dns_c_ordering_t;
/* Possible zone types */
typedef enum {
dns_c_zone_master,
dns_c_zone_slave,
dns_c_zone_hint,
dns_c_zone_stub,
dns_c_zone_forward
} dns_c_zonetype_t;
/* Possible address-match-element types */
typedef enum {
dns_c_ipmatch_pattern,
dns_c_ipmatch_indirect,
dns_c_ipmatch_localhost,
dns_c_ipmatch_localnets,
dns_c_ipmatch_key,
dns_c_ipmatch_acl,
dns_c_ipmatch_none
} dns_c_ipmatch_type_t;
/* Tag values for the different types of log channel */
typedef enum {
dns_c_logchan_file,
dns_c_logchan_syslog,
dns_c_logchan_null
} dns_c_logchantype_t;
/* Possible logging severity values */
typedef enum {
dns_c_log_critical,
dns_c_log_error,
dns_c_log_warn,
dns_c_log_notice,
dns_c_log_info,
dns_c_log_debug,
dns_c_log_dynamic,
dns_c_log_no_severity
} dns_c_log_severity_t;
/* Possible logging categories. */
typedef enum {
dns_c_cat_default,
dns_c_cat_config,
dns_c_cat_parser,
dns_c_cat_queries,
dns_c_cat_lame_servers,
dns_c_cat_statistics,
dns_c_cat_panic,
dns_c_cat_update,
dns_c_cat_ncache,
dns_c_cat_xfer_in,
dns_c_cat_xfer_out,
dns_c_cat_db,
dns_c_cat_eventlib,
dns_c_cat_packet,
dns_c_cat_notify,
dns_c_cat_cname,
dns_c_cat_security,
dns_c_cat_os,
dns_c_cat_insist,
dns_c_cat_maint,
dns_c_cat_load,
dns_c_cat_resp_checks,
dns_c_cat_control,
dns_c_cat_none
} dns_c_category_t;
/* Type of the bit sets used in various structures. Macros in confpvt.h
* depending on this being an integer type, and some structures need more
* than 32 bits.
*/
typedef isc_int64_t dns_setbits_t;
/* XXX This should be moved to a more general (non-config specific) place */
/* An IP address. We support IPv4 and IPv6 addresses together so we wrap
them up in this strcture*/
typedef struct dns_c_addr {
int a_family; /* AF_INET or AF_INET6 */
union {
struct in_addr a; /* if a_family == AF_INET */
struct in6_addr a6; /* if a_family == AF_INET6 */
} u;
} dns_c_addr_t;
/*
* Set this variable to a true value to get output by the wrapper
* functions (if the memory debugging hack is compiled in--it isn't by
* default
*/
extern isc_boolean_t debug_mem_print;
extern FILE *debug_mem_print_stream; /* NULL means stderr */
extern struct in6_addr in6addr_any; /* all 0 bits wildcard addr. */
typedef void (*dns_cfg_err_handler_t)(isc_result_t code,
const char *fmt, va_list args);
/***
*** Functions
***/
/* The following dns_c_xxx2string() functions convert the first argument into
* a string value and returns that value. If the first argument is not a
* legal value, then NULL is returned, unless PRINTABLE is true, in which
* case an ugly, but safe-to-pass-to-printf string is returned.
*
* e.g. dns_c_ordering2string(dns_c_ordering_cyclic,ISC_FALSE) returns the
* string "cyclic", but
* dns_c_ordering2string((dns_c_ordering_t)0xffff,ISC_TRUE) returns the
* value "UNKNOWN_ORDERING"
*/
const char * dns_c_ordering2string(dns_c_ordering_t ordering,
isc_boolean_t printable);
const char * dns_c_logseverity2string(dns_c_log_severity_t level,
isc_boolean_t printable);
const char * dns_c_category2string(dns_c_category_t cat,
isc_boolean_t printable);
const char * dns_c_facility2string(int facility,
isc_boolean_t printable);
const char * dns_c_transformat2string(dns_transfer_format_t tformat,
isc_boolean_t printable);
const char * dns_c_transport2string(dns_c_trans_t transport,
isc_boolean_t printable);
const char * dns_c_nameseverity2string(dns_c_severity_t severity,
isc_boolean_t printable);
const char * dns_c_forward2string(dns_c_forw_t forw,
isc_boolean_t printable);
/*
* The following dns_c_string2xxx() functions will look up the string
* argument in a table of values and will return the appropriate enum/integer
* through the second argument and ISC_R_SUCCESS is returned. If the string
* doesn't match a valid value then ISC_R_FAILURE is returned.
*/
isc_result_t dns_c_string2ordering(char *name,
dns_c_ordering_t *ordering);
isc_result_t dns_c_string2logseverity(const char *string,
dns_c_log_severity_t *result);
isc_result_t dns_c_string2category(const char *string,
dns_c_category_t *category);
isc_result_t dns_c_string2facility(const char *string, int *res);
void dns_c_error(isc_result_t result, const char *fmt, ...);
void dns_c_print_ipaddr(FILE *fp, dns_c_addr_t *addr);
dns_cfg_err_handler_t dns_c_set_error_handler(dns_cfg_err_handler_t
newhandler);
isc_boolean_t dns_c_need_quote(const char *string);
void dns_c_printtabs(FILE *fp, int count);
void dns_c_print_in_units(FILE *fp, isc_uint32_t val);
void dns_c_dataclass_to_stream(FILE *fp,
dns_rdataclass_t rclass);
void dns_c_datatype_to_stream(FILE *fp,
dns_rdatatype_t rtype);
#if defined(DEBUG_MEM_STUFF)
/* XXX debugging stuff that should probably be moved to isc/mem.h */
#undef isc_mem_get
#undef isc_mem_put
/*
* Some wrappers for the various mem functions to help in debugging.
*/
#define isc_mem_get(a, b) \
dns_c_memget_wrapper(__FILE__,__LINE__, a, b)
#define isc_mem_put(a, b, c) \
dns_c_memput_wrapper(__FILE__, __LINE__, a, b, c)
#define isc_mem_strdup(a, b) \
dns_c_memstrdup_wrapper(__FILE__,__LINE__, a, b)
#define isc_mem_free(a, b) \
dns_c_memfree_wrapper(__FILE__, __LINE__, a, b)
#define isc_mem_destroy(a) \
dns_c_memdestroy_wrapper(__FILE__, __LINE__, a)
/*
* These functions create output that's meant to be used by the
* find_leak.pl script.
*/
void *dns_c_memget_wrapper(const char *file, int line,
isc_mem_t *mem, size_t sz);
void dns_c_memput_wrapper(const char *file, int line,
isc_mem_t *mem, void *p, size_t sz);
char *dns_c_memstrdup_wrapper(const char *file, int line,
isc_mem_t *mem, const char *string);
void dns_c_memfree_wrapper(const char *file, int line,
isc_mem_t *mem, char *string);
void dns_c_memdestroy_wrapper(const char *file, int line, isc_mem_t **mem);
#endif /* defined(DEBUG_MEM_STUFF) */
#endif /* DNS_CONFIG_CONFCOMMON_H */

View File

@@ -0,0 +1,212 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFCTL_H
#define DNS_CONFIG_CONFCTL_H 1
/*****
***** Module Info
*****/
/*
* ADTs for the data defined by a named.conf ``control'' statement.
*/
/*
*
* MP:
*
* Caller must do necessary locking.
*
* Reliability:
*
* No known problems.
*
* Resources:
*
* Uses memory managers supplied by caller.
*
* Security:
*
* N/A.
*
* Standards:
*
* N/A.
*
*/
/***
*** Imports
***/
#include <config.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <isc/mem.h>
#include <dns/confip.h>
/***
*** Types
***/
typedef struct dns_c_ctrl dns_c_ctrl_t;
typedef struct dns_c_ctrl_list dns_c_ctrl_list_t;
struct dns_c_ctrl
{
isc_mem_t *mem; /* where it's memory came from */
dns_c_control_t control_type;
union {
struct {
dns_c_addr_t addr;
short port;
dns_c_ipmatch_list_t *matchlist;
} inet_v; /* when control_type == dns_c_inet_control */
struct {
char *pathname;
int perm;
uid_t owner;
gid_t group;
} unix_v; /* when control_type == dns_c_unix_control */
} u;
ISC_LINK(dns_c_ctrl_t) next;
};
struct dns_c_ctrl_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_ctrl_t) elements;
};
/***
*** Functions
***/
isc_result_t dns_c_ctrl_inet_new(isc_mem_t *mem, dns_c_ctrl_t **control,
dns_c_addr_t addr, short port,
dns_c_ipmatch_list_t *iml,
isc_boolean_t copy);
/*
* Creates a new INET control object. If COPY is true then a deep copy is
* made of IML, otherwise the value of IML is stored directly in the new
* object.
*
* Requires:
* mem be a valid memoery manager
* control be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOMEMORY -- insufficient memory available
*/
isc_result_t dns_c_ctrl_unix_new(isc_mem_t *mem, dns_c_ctrl_t **control,
const char *path,
int perm, uid_t uid, gid_t gid);
/*
* Creates a new UNIX control object. A copy is made of the PATH argument.
*
* Requires:
* mem be a valid memoery manager
* control be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS -- all is well
* ISC_R_NOMEMORY -- insufficient memory available
*
*/
isc_result_t dns_c_ctrl_delete(dns_c_ctrl_t **control);
/*
* Deletes the object pointed to by *CONTROL. *CONTROL may be NULL.
*
* Requires:
* control be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS
*/
void dns_c_ctrl_print(FILE *fp, int indent, dns_c_ctrl_t *ctl);
/*
* Prints the control object ctl in standard named.conf format. The output
* is indented by indent number of tabs.
*
* Requires:
* fp be a pointer to a valid stdio stream.
* indent be a non-negative number.
*
*/
isc_result_t dns_c_ctrl_list_new(isc_mem_t *mem,
dns_c_ctrl_list_t **newlist);
/*
* Creates a new control object list using the MEM memory manager.
*
* Requires:
* mem be a pointer to a valid memory manager,
* newlist be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS -- all is well.
* ISC_R_NOMEMORY -- insufficient memory available.
*/
isc_result_t dns_c_ctrl_list_delete(dns_c_ctrl_list_t **list);
/*
* Deletes the control list. The value of *list may be NULL. Sets *list to
* NULL when done.
*
* Requires:
* list be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS
*
*/
void dns_c_ctrl_list_print(FILE *fp, int indent,
dns_c_ctrl_list_t *cl);
/*
* Prints the control objects inside the list. The output is indented with
* indent number of tabs.
*
* Requires:
* fp be a pointer to a valid stdio stream.
*
*/
#endif /* DNS_CONFIG_CONFCTL_H */

View File

@@ -0,0 +1,451 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFCTX_H
#define DNS_CONFIG_CONFCTX_H 1
/*****
***** Module Info
*****/
/*
* Defines the structures and accessor/modifier functions for the top level
* structures created by the config file parsing routines.
*/
/*
*
* MP:
*
*
* Reliability:
*
*
* Resources:
*
*
* Security:
*
*
* Standards:
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
#include <isc/int.h>
#include <isc/list.h>
#include <dns/confcommon.h>
#include <dns/confip.h>
#include <dns/confzone.h>
#include <dns/confkeys.h>
#include <dns/conflog.h>
#include <dns/confacl.h>
#include <dns/conflsn.h>
#include <dns/confrrset.h>
#include <dns/confctl.h>
#include <dns/confserv.h>
/***
*** Types
***/
typedef struct dns_c_options dns_c_options_t;
typedef struct dns_c_ctx dns_c_ctx_t;
/*
* The main baby. A pointer to one of these is what the caller gets back
* when the parsing routine is called.
*/
struct dns_c_ctx
{
isc_uint32_t magic;
isc_mem_t *mem;
int warnings; /* semantic warning count */
int errors; /* semantic error count */
dns_c_options_t *options;
dns_c_ctrl_list_t *controls;
dns_c_srv_list_t *servers;
dns_c_acl_table_t *acls;
dns_c_kdef_list_t *keydefs;
dns_c_zone_list_t *zlist;
dns_c_tkey_list_t *trusted_keys;
dns_c_logging_list_t *logging;
};
/*
* This structure holds all the values defined by a config file 'options'
* statement
*/
struct dns_c_options
{
isc_mem_t *mem;
isc_uint32_t magic;
char *directory;
char *version;
char *dump_filename;
char *pid_filename;
char *stats_filename;
char *memstats_filename;
char *named_xfer;
isc_uint32_t flags;
isc_uint32_t max_ncache_ttl;
isc_int32_t transfers_in;
isc_int32_t transfers_per_ns;
isc_int32_t transfers_out;
isc_int32_t max_log_size_ixfr;
isc_int32_t clean_interval;
isc_int32_t interface_interval;
isc_int32_t stats_interval;
isc_int32_t heartbeat_interval;
isc_int32_t max_transfer_time_in;
isc_uint32_t data_size;
isc_uint32_t stack_size;
isc_uint32_t core_size;
isc_uint32_t files;
isc_boolean_t expert_mode;
isc_boolean_t fake_iquery;
isc_boolean_t recursion;
isc_boolean_t fetch_glue;
isc_boolean_t notify;
isc_boolean_t host_statistics;
isc_boolean_t dealloc_on_exit;
isc_boolean_t use_ixfr;
isc_boolean_t maintain_ixfr_base;
isc_boolean_t has_old_clients;
isc_boolean_t auth_nx_domain;
isc_boolean_t multiple_cnames;
isc_boolean_t use_id_pool;
isc_boolean_t dialup;
dns_c_addr_t query_source_addr;
short query_source_port;
dns_c_severity_t check_names[DNS_C_TRANSCOUNT];
dns_transfer_format_t transfer_format;
dns_c_ipmatch_list_t *queryacl;
dns_c_ipmatch_list_t *transferacl;
dns_c_ipmatch_list_t *blackhole;
dns_c_ipmatch_list_t *topology;
dns_c_ipmatch_list_t *sortlist;
dns_c_lstn_list_t *listens;
dns_c_forw_t forward;
dns_c_ipmatch_list_t *forwarders;
dns_c_rrso_list_t *ordering;
/*
* For the non-pointer fields of the struct a bit will be set in
* this field if a field value was explicitly set.
*/
dns_setbits_t setflags1;
};
/***
*** Functions
***/
isc_result_t dns_c_ctx_new(isc_mem_t *mem, dns_c_ctx_t **cfg);
isc_result_t dns_c_ctx_delete(dns_c_ctx_t **cfg);
isc_result_t dns_c_ctx_get_options(dns_c_ctx_t *cfg, dns_c_options_t **options);
isc_result_t dns_c_ctx_set_logging(dns_c_ctx_t *cfg,
dns_c_logging_list_t *newval,
isc_boolean_t deepcopy);
isc_result_t dns_c_ctx_get_logging(dns_c_ctx_t *cfg,
dns_c_logging_list_t **retval);
isc_result_t dns_c_ctx_add_file_channel(dns_c_ctx_t *cfg, const char *name,
dns_c_logchan_t **chan);
isc_result_t dns_c_ctx_add_syslog_channel(dns_c_ctx_t *cfg,
const char *name,
dns_c_logchan_t **chan);
isc_result_t dns_c_ctx_add_null_channel(dns_c_ctx_t *cfg, const char *name,
dns_c_logchan_t **chan);
isc_result_t dns_c_ctx_add_category(dns_c_ctx_t *cfg,
dns_c_category_t category,
dns_c_logcat_t **newcat);
isc_result_t dns_c_ctx_currchannel(dns_c_ctx_t *cfg,
dns_c_logchan_t **channel);
isc_result_t dns_c_ctx_currcategory(dns_c_ctx_t *cfg,
dns_c_logcat_t **category);
isc_boolean_t dns_c_ctx_key_defined_p(dns_c_ctx_t *ctx, const char *keyname);
isc_boolean_t dns_c_ctx_channel_defined_p(dns_c_ctx_t *cfg,
const char *name);
isc_result_t dns_c_ctx_options_new(isc_mem_t *mem,
dns_c_options_t **options);
isc_result_t dns_c_ctx_options_delete(dns_c_options_t **options);
isc_result_t dns_c_ctx_erase_options(dns_c_ctx_t *cfg);
void dns_c_ctx_print(FILE *fp, int indent, dns_c_ctx_t *cfg);
void dns_c_ctx_options_print(FILE *fp, int indent,
dns_c_options_t *options);
void dns_c_ctx_forwarder_print(FILE *fp, int indent,
dns_c_options_t *options);
/* The modifier functions below all return ISC_R_SUCCESS when the value is
* successfully set. If the value had already been set, then the value
* ISC_R_EXISTS is returned (the value is still set).
*
* In a few functions there is a boolean parameter named 'copy'. If that is
* true, then a deep copy is made of the parameter and the parameter itself
* is not touched. If the value is false, then the parameter is stored
* directly in the dns_c_ctx_t structure, and the client looses ownership
* of it. ISC_R_NOMEMORY is a possible return value for many of these
* functions.
*
*/
isc_result_t dns_c_ctx_set_directory(dns_c_ctx_t *cfg, const char *newval);
isc_result_t dns_c_ctx_set_version(dns_c_ctx_t *cfg, const char *newval);
isc_result_t dns_c_ctx_set_dump_filename(dns_c_ctx_t *cfg,
const char *newval);
isc_result_t dns_c_ctx_set_pid_filename(dns_c_ctx_t *cfg,
const char *newval);
isc_result_t dns_c_ctx_set_stats_filename(dns_c_ctx_t *cfg,
const char *newval);
isc_result_t dns_c_ctx_set_memstats_filename(dns_c_ctx_t *cfg,
const char *newval);
isc_result_t dns_c_ctx_set_named_xfer(dns_c_ctx_t *cfg, const char *newval);
isc_result_t dns_c_ctx_set_max_ncache_ttl(dns_c_ctx_t *cfg,
isc_uint32_t newval);
isc_result_t dns_c_ctx_set_transfers_in(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_transfers_per_ns(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_transfers_out(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_max_log_size_ixfr(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_clean_interval(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_interface_interval(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_stats_interval(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_heartbeat_interval(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_max_transfer_time_in(dns_c_ctx_t *cfg,
isc_int32_t newval);
isc_result_t dns_c_ctx_set_data_size(dns_c_ctx_t *cfg, isc_uint32_t newval);
isc_result_t dns_c_ctx_set_stack_size(dns_c_ctx_t *cfg,
isc_uint32_t newval);
isc_result_t dns_c_ctx_set_core_size(dns_c_ctx_t *cfg, isc_uint32_t newval);
isc_result_t dns_c_ctx_set_files(dns_c_ctx_t *cfg, isc_uint32_t newval);
isc_result_t dns_c_ctx_set_expert_mode(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_fake_iquery(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_recursion(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_fetch_glue(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_notify(dns_c_ctx_t *cfg, isc_boolean_t newval);
isc_result_t dns_c_ctx_set_host_statistics(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_dealloc_on_exit(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_use_ixfr(dns_c_ctx_t *cfg, isc_boolean_t newval);
isc_result_t dns_c_ctx_set_maintain_ixfr_base(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_has_old_clients(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_auth_nx_domain(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_multiple_cnames(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_use_id_pool(dns_c_ctx_t *cfg,
isc_boolean_t newval);
isc_result_t dns_c_ctx_set_dialup(dns_c_ctx_t *cfg, isc_boolean_t newval);
isc_result_t dns_c_ctx_set_query_source_addr(dns_c_ctx_t *cfg,
dns_c_addr_t addr);
isc_result_t dns_c_ctx_set_query_source_port(dns_c_ctx_t *cfg, short port);
isc_result_t dns_c_ctx_set_checknames(dns_c_ctx_t *cfg,
dns_c_trans_t transtype,
dns_c_severity_t sever);
isc_result_t dns_c_ctx_set_transfer_format(dns_c_ctx_t *cfg,
dns_transfer_format_t newval);
isc_result_t dns_c_ctx_set_queryacl(dns_c_ctx_t *cfg, isc_boolean_t copy,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_ctx_set_transferacl(dns_c_ctx_t *cfg, isc_boolean_t copy,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_ctx_set_blackhole(dns_c_ctx_t *cfg, isc_boolean_t copy,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_ctx_set_topology(dns_c_ctx_t *cfg, isc_boolean_t copy,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_ctx_set_sortlist(dns_c_ctx_t *cfg, isc_boolean_t copy,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_ctx_set_forward(dns_c_ctx_t *cfg, dns_c_forw_t forw);
isc_result_t dns_c_ctx_set_forwarders(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t *iml,
isc_boolean_t copy);
isc_result_t dns_c_ctx_set_rrsetorder_list(dns_c_ctx_t *cfg,
isc_boolean_t copy,
dns_c_rrso_list_t *olist);
isc_result_t dns_c_ctx_add_listen_on(dns_c_ctx_t *cfg, int port,
dns_c_ipmatch_list_t *ml,
isc_boolean_t copy);
isc_result_t dns_c_ctx_set_trusted_keys(dns_c_ctx_t *cfg,
dns_c_tkey_list_t *list,
isc_boolean_t copy);
/*
* Accessor functions for the various fields in the config structure. The
* value of the field is copied into the location pointed to by the RETVAL
* paramater and ISC_R_SUCCESS is returned. The caller must not modify the
* returned value, and should copy the value if it needs to hold on to it.
*
* If the value has not been set in the config structure, then
* ISC_R_NOTFOUND is returned and the location pointed to by the RETVAL
* paramater is not modified (i.e. the library assumes no particular
* defaults for any unset values).
*/
isc_result_t dns_c_ctx_get_directory(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_version(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_dump_filename(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_pid_filename(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_stats_filename(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_memstats_filename(dns_c_ctx_t *cfg,
char **retval);
isc_result_t dns_c_ctx_get_named_xfer(dns_c_ctx_t *cfg, char **retval);
isc_result_t dns_c_ctx_get_max_ncache_ttl(dns_c_ctx_t *cfg,
isc_uint32_t *retval);
isc_result_t dns_c_ctx_get_transfers_in(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_transfers_per_ns(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_transfers_out(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_max_log_size_ixfr(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_clean_interval(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_interface_interval(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_stats_interval(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_heartbeat_interval(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_max_transfer_time_in(dns_c_ctx_t *cfg,
isc_int32_t *retval);
isc_result_t dns_c_ctx_get_data_size(dns_c_ctx_t *cfg,
isc_uint32_t *retval);
isc_result_t dns_c_ctx_get_stack_size(dns_c_ctx_t *cfg,
isc_uint32_t *retval);
isc_result_t dns_c_ctx_get_core_size(dns_c_ctx_t *cfg,
isc_uint32_t *retval);
isc_result_t dns_c_ctx_get_files(dns_c_ctx_t *cfg, isc_uint32_t *retval);
isc_result_t dns_c_ctx_get_expert_mode(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_fake_iquery(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_recursion(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_fetch_glue(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_notify(dns_c_ctx_t *cfg, isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_host_statistics(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_dealloc_on_exit(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_use_ixfr(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_maintain_ixfr_base(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_has_old_clients(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_auth_nx_domain(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_multiple_cnames(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_use_id_pool(dns_c_ctx_t *cfg,
isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_dialup(dns_c_ctx_t *cfg, isc_boolean_t *retval);
isc_result_t dns_c_ctx_get_query_source_addr(dns_c_ctx_t *cfg,
dns_c_addr_t *addr);
isc_result_t dns_c_ctx_get_query_source_port(dns_c_ctx_t *cfg,
short *port);
isc_result_t dns_c_ctx_get_checknames(dns_c_ctx_t *cfg,
dns_c_trans_t transtype,
dns_c_severity_t *sever);
isc_result_t dns_c_ctx_get_transfer_format(dns_c_ctx_t *cfg,
dns_transfer_format_t *retval);
isc_result_t dns_c_ctx_get_queryacl(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_transferacl(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_blackhole(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_topology(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_sortlist(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_listen_list(dns_c_ctx_t *cfg,
dns_c_lstn_list_t **ll);
isc_result_t dns_c_ctx_get_forward(dns_c_ctx_t *cfg, dns_c_forw_t *forw);
isc_result_t dns_c_ctx_get_forwarders(dns_c_ctx_t *cfg,
dns_c_ipmatch_list_t **list);
isc_result_t dns_c_ctx_get_rrsetorder_list(dns_c_ctx_t *cfg,
dns_c_rrso_list_t **olist);
isc_result_t dns_c_ctx_get_trusted_keys(dns_c_ctx_t *cfg,
dns_c_tkey_list_t **retval);
isc_result_t dns_c_ctx_get_logging(dns_c_ctx_t *cfg,
dns_c_logging_list_t **retval);
#endif /* DNS_CONFIG_CONFCTX_H */

View File

@@ -0,0 +1,204 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFIP_H
#define DNS_CONFIG_CONFIP_H 1
/*****
***** Module Info
*****/
/*
* Data structures used by the config file parser for managing address
* lists and address-match lists. These structures are reference counted,
* so clients can call 'attach' to increment the reference count. The
* normal destructors won't delete the data until the counter goes to zero.
*/
/*
* MP:
* Caller must do necessary locking
*
* Reliability:
*
* No problems known.
*
* Resources:
*
* Uses memory managers supplied by caller.
*
* Security:
*
* No issues.
*
*/
/***
*** Imports
***/
#include <config.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <isc/region.h>
#include <isc/list.h>
#include <isc/mem.h>
#include <dns/confcommon.h>
/***
*** Types
***/
typedef struct dns_c_iplist dns_c_iplist_t;
typedef struct dns_c_ipmatch_direct dns_c_ipmatch_direct_t ;
typedef struct dns_c_ipmatch_indirect dns_c_ipmatch_indirect_t;
typedef struct dns_c_ipmatch_key dns_c_ipmatch_key_t;
typedef struct dns_c_ipmatch_element dns_c_ipmatch_element_t;
typedef struct dns_c_ipmatch_list dns_c_ipmatch_list_t;
/* A list of IP addresses (IPv4 or IPv6) */
struct dns_c_iplist {
isc_mem_t *mem;
int refcount;
dns_c_addr_t *ips;
isc_uint32_t size;
isc_uint32_t nextidx;
};
struct dns_c_ipmatch_direct
{
dns_c_addr_t address; /* XXX IPv6??? */
dns_c_addr_t mask;
};
struct dns_c_ipmatch_indirect
{
isc_textregion_t refname; /* for acls, mostly. */
dns_c_ipmatch_list_t *list;
};
struct dns_c_ipmatch_element
{
dns_c_ipmatch_type_t type;
u_int flags;
union {
dns_c_ipmatch_direct_t direct;
dns_c_ipmatch_indirect_t indirect;
char *key;
char *aclname;
} u;
ISC_LINK(dns_c_ipmatch_element_t) next;
};
struct dns_c_ipmatch_list
{
isc_mem_t *mem;
int refcount;
ISC_LIST(dns_c_ipmatch_element_t) elements;
};
/***
*** Functions
***/
/*
* In all the functions below where an isc_mem_t is a parameter, that
* paramater will be used for all memory allocation.
*/
isc_result_t dns_c_ipmatch_element_new(isc_mem_t *mem,
dns_c_ipmatch_element_t
**result);
isc_result_t dns_c_ipmatch_element_delete(isc_mem_t *mem,
dns_c_ipmatch_element_t **ipme);
isc_result_t dns_c_ipmatch_element_copy(isc_mem_t *mem,
dns_c_ipmatch_element_t **dest,
dns_c_ipmatch_element_t *src);
isc_result_t dns_c_ipmatch_element_print(FILE *fp, int indent,
dns_c_ipmatch_element_t *ime);
isc_boolean_t dns_c_ipmatch_element_isneg(dns_c_ipmatch_element_t *elem);
isc_result_t dns_c_ipmatch_negate(dns_c_ipmatch_element_t *ipe);
isc_result_t dns_c_ipmatch_acl_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result,
const char *aclname);
isc_result_t dns_c_ipmatch_key_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result,
const char *key);
isc_result_t dns_c_ipmatch_localhost_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result);
isc_result_t dns_c_ipmatch_localnets_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result);
isc_result_t dns_c_ipmatch_pattern_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result,
dns_c_addr_t address,
isc_uint32_t maskbits);
isc_result_t dns_c_ipmatch_indirect_new(isc_mem_t *mem,
dns_c_ipmatch_element_t **result,
dns_c_ipmatch_list_t *iml,
const char *name);
isc_result_t dns_c_ipmatch_list_new(isc_mem_t *mem,
dns_c_ipmatch_list_t **ptr);
isc_result_t dns_c_ipmatch_list_delete(dns_c_ipmatch_list_t **ml);
dns_c_ipmatch_list_t *dns_c_ipmatch_list_attach(dns_c_ipmatch_list_t *ipml);
isc_result_t dns_c_ipmatch_list_copy(isc_mem_t *mem,
dns_c_ipmatch_list_t **dest,
dns_c_ipmatch_list_t *src);
isc_result_t dns_c_ipmatch_list_empty(dns_c_ipmatch_list_t *ipml);
isc_result_t dns_c_ipmatch_list_append(dns_c_ipmatch_list_t *dest,
dns_c_ipmatch_list_t *src,
isc_boolean_t negate);
isc_result_t dns_c_ipmatch_list_print(FILE *fp, int indent,
dns_c_ipmatch_list_t *iml);
isc_result_t dns_c_iplist_new(isc_mem_t *mem, int length,
dns_c_iplist_t **newlist);
isc_result_t dns_c_iplist_delete(dns_c_iplist_t **list);
isc_result_t dns_c_iplist_copy(isc_mem_t *mem, dns_c_iplist_t **dest,
dns_c_iplist_t *src);
dns_c_iplist_t *dns_c_iplist_attach(dns_c_iplist_t *list);
isc_result_t dns_c_iplist_append(dns_c_iplist_t *list,
dns_c_addr_t newaddr);
isc_result_t dns_c_iplist_remove(dns_c_iplist_t *list,
dns_c_addr_t newaddr);
void dns_c_iplist_print(FILE *fp, int indent,
dns_c_iplist_t *list);
#endif /* DNS_CONFIG_CONFIP_H */

View File

@@ -0,0 +1,228 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFKEYS_H
#define DNS_CONFIG_CONFKEYS_H 1
/*****
***** Module Info
*****/
/*
* The ADTs for the key values defined in a named.conf config file.
*/
/*
*
* MP:
*
* Caller must to all necessary locking.
*
* Reliability:
*
* Not applicable.
*
* Resources:
*
* Memory allocators supplied by caller
*
* Security:
*
* Not applicable.
*
* Standards:
*
* Not applicable.
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
#include <isc/list.h>
/***
*** Types
***/
typedef struct dns_c_pubkey dns_c_pubkey_t;
typedef struct dns_c_tkey dns_c_tkey_t;
typedef struct dns_c_tkey_list dns_c_tkey_list_t;
typedef struct dns_c_kdef dns_c_kdef_t;
typedef struct dns_c_kdef_list dns_c_kdef_list_t;
typedef struct dns_c_kid dns_c_kid_t;
typedef struct dns_c_kid_list dns_c_kid_list_t;
/* The type for holding a trusted key value. */
struct dns_c_tkey
{
isc_mem_t *mem;
char *domain;
dns_c_pubkey_t *pubkey;
ISC_LINK(dns_c_tkey_t) next;
};
/* A list of trusted keys. */
struct dns_c_tkey_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_tkey_t) tkeylist;
};
/* A public key value */
struct dns_c_pubkey
{
isc_mem_t *mem;
isc_int32_t flags;
isc_int32_t protocol;
isc_int32_t algorithm;
char *key;
};
/* A private key definition from a 'key' statement */
struct dns_c_kdef
{
dns_c_kdef_list_t *mylist;
char *keyid;
char *algorithm;
char *secret;
ISC_LINK(dns_c_kdef_t) next;
};
/* A list of private keys */
struct dns_c_kdef_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_kdef_t) keydefs;
};
/* A key id for in a server statement 'keys' list */
struct dns_c_kid
{
dns_c_kid_list_t *mylist;
char *keyid;
ISC_LINK(dns_c_kid_t) next;
};
/* List of key ids for a 'server' statement */
struct dns_c_kid_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_kid_t) keyids;
};
/***
*** Functions
***/
isc_result_t dns_c_pubkey_new(isc_mem_t *mem, isc_int32_t flags,
isc_int32_t protocol,
isc_int32_t algorithm,
const char *key, dns_c_pubkey_t **pubkey);
isc_result_t dns_c_pubkey_delete(dns_c_pubkey_t **pubkey);
isc_result_t dns_c_pubkey_copy(isc_mem_t *mem, dns_c_pubkey_t **dest,
dns_c_pubkey_t *src);
void dns_c_pubkey_print(FILE *fp, int indent,
dns_c_pubkey_t *pubkey);
isc_result_t dns_c_kid_list_new(isc_mem_t *mem,
dns_c_kid_list_t **list);
isc_result_t dns_c_kid_list_delete(dns_c_kid_list_t **list);
isc_result_t dns_c_kid_list_undef(dns_c_kid_list_t *list,
const char *keyid);
isc_result_t dns_c_kid_list_find(dns_c_kid_list_t *list,
const char *keyid,
dns_c_kid_t **retval);
void dns_c_kid_list_print(FILE *fp, int indent,
dns_c_kid_list_t *list);
isc_result_t dns_c_kid_new(dns_c_kid_list_t *list, const char *name,
dns_c_kid_t **keyid);
isc_result_t dns_c_kdef_list_new(isc_mem_t *mem,
dns_c_kdef_list_t **list);
isc_result_t dns_c_kdef_list_delete(dns_c_kdef_list_t **list);
isc_result_t dns_c_kdef_list_undef(dns_c_kdef_list_t *list,
const char *keyid);
isc_result_t dns_c_kdef_list_find(dns_c_kdef_list_t *list,
const char *keyid,
dns_c_kdef_t **retval);
void dns_c_kdef_list_print(FILE *fp, int indent,
dns_c_kdef_list_t *list);
isc_result_t dns_c_kdef_new(dns_c_kdef_list_t *list, const char *name,
dns_c_kdef_t **keyid);
void dns_c_kdef_print(FILE *fp, int indent, dns_c_kdef_t *keydef);
isc_result_t dns_c_kdef_set_algorithm(dns_c_kdef_t *elem,
const char *algorithm);
isc_result_t dns_c_kdef_set_secret(dns_c_kdef_t *elem,
const char *secret);
isc_result_t dns_c_tkey_list_new(isc_mem_t *mem,
dns_c_tkey_list_t **newlist);
isc_result_t dns_c_tkey_list_delete(dns_c_tkey_list_t **list);
isc_result_t dns_c_tkey_list_copy(isc_mem_t *mem,
dns_c_tkey_list_t **dest,
dns_c_tkey_list_t *src);
void dns_c_tkey_list_print(FILE *fp, int indent,
dns_c_tkey_list_t *list);
isc_result_t dns_c_tkey_list_append(dns_c_tkey_list_t *list,
dns_c_tkey_t *element,
isc_boolean_t copy);
isc_result_t dns_c_tkey_new(isc_mem_t *mem, const char *domain,
isc_int32_t flags,
isc_int32_t protocol,
isc_int32_t algorithm,
const char *key, dns_c_tkey_t **newkey);
isc_result_t dns_c_tkey_delete(dns_c_tkey_t **tkey);
isc_result_t dns_c_tkey_copy(isc_mem_t *mem,
dns_c_tkey_t **dest, dns_c_tkey_t *src);
isc_result_t dns_c_tkey_get_flags(dns_c_tkey_t *tkey,
isc_int32_t *flags);
isc_result_t dns_c_tkey_get_protocol(dns_c_tkey_t *tkey,
isc_int32_t *protocol);
isc_result_t dns_c_tkey_get_algorithm(dns_c_tkey_t *tkey,
isc_int32_t *algorithm);
isc_result_t dns_c_tkey_get_key(dns_c_tkey_t *tkey,
const char **key);
void dns_c_tkey_print(FILE *fp, int indent, dns_c_tkey_t *tkey);
#endif /* DNS_CONFIG_CONFKEYS_H */

View File

@@ -0,0 +1,251 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFLOG_H
#define DNS_CONFIG_CONFLOG_H 1
/*****
***** Module Info
*****/
/*
* Various ADTs for holding the values defined inside a config
* file's "logging" statement.
*/
/*
* MP:
*
* Caller must do appropriate locking
*
* Reliability:
*
* No impact.
*
* Resources:
*
* Caller supplies memory allocators
*
* Security:
*
* No impact.
*
* Standards:
*
* N/A
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
#include <dns/confcommon.h>
/***
*** Types
***/
typedef struct dns_c_logchan dns_c_logchan_t;
typedef struct dns_c_logcat dns_c_logcat_t;
typedef struct dns_c_logging_list dns_c_logging_list_t;
/* The structure that holds the list of channel and category definitions */
struct dns_c_logging_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_logchan_t) channels;
ISC_LIST(dns_c_logcat_t) categories;
};
/* Definition of a logging channel */
struct dns_c_logchan
{
isc_mem_t *mem;
char *name;
dns_c_logchantype_t ctype;
union {
struct
{ /* when ctype == dns_c_logchan_file */
char *path;
isc_int32_t versions;
isc_uint32_t size;
} filec;
struct /* when ctype == dns_c_logchan_syslog*/
{
int facility;
} syslogc;
} u;
dns_c_log_severity_t severity;
isc_int32_t debug_level;
isc_boolean_t print_category;
isc_boolean_t print_severity;
isc_boolean_t print_time;
/* Some channels are predefined e.g. default_syslog, in which case
* this is true
*/
isc_boolean_t predefined;
ISC_LINK(dns_c_logchan_t) next;
dns_setbits_t setflags;
};
/* Structure for holding a category definition */
struct dns_c_logcat
{
isc_mem_t *mem;
dns_c_category_t category;
char **channel_names;
size_t cnames_len; /* size, in elements of
channel_names */
size_t nextcname; /* index in
channel_names of next
free spot. */
isc_boolean_t predefined;
ISC_LINK(dns_c_logcat_t) next;
};
/***
*** Functions
***/
isc_result_t dns_c_logging_list_new(isc_mem_t *mem,
dns_c_logging_list_t **list);
isc_result_t dns_c_logging_list_delete(dns_c_logging_list_t **list);
void dns_c_logging_list_print(FILE *fp, int indent,
dns_c_logging_list_t *ll,
isc_boolean_t if_predef_too);
isc_result_t dns_c_logging_list_copy(isc_mem_t *mem,
dns_c_logging_list_t **dest,
dns_c_logging_list_t *src);
isc_result_t dns_c_logging_list_add_channel(dns_c_logging_list_t *list,
dns_c_logchan_t *newchan,
isc_boolean_t deepcopy);
isc_result_t dns_c_logging_list_add_category(dns_c_logging_list_t *list,
dns_c_logcat_t *newcat,
isc_boolean_t *deepcopy);
isc_result_t dns_c_logging_list_del_channel(dns_c_logging_list_t *list,
const char *name);
isc_result_t dns_c_logging_list_del_category(dns_c_logging_list_t *list,
const char *name);
isc_result_t dns_c_logging_list_chanbyname(dns_c_logging_list_t *list,
const char *name,
dns_c_logchan_t **chan);
isc_result_t dns_c_logging_list_catbyname(dns_c_logging_list_t *list,
const char *name,
dns_c_logcat_t **cat);
isc_result_t dns_c_logging_list_catbytype(dns_c_logging_list_t *list,
dns_c_category_t cattype,
dns_c_logcat_t **cat);
isc_result_t dns_c_logchan_new(isc_mem_t *mem, const char *name,
dns_c_logchantype_t ctype,
dns_c_logchan_t **newchan);
isc_result_t dns_c_logchan_delete(dns_c_logchan_t **channel);
isc_result_t dns_c_logchan_copy(isc_mem_t *mem, dns_c_logchan_t **dest,
dns_c_logchan_t *src);
void dns_c_logchan_print(FILE *fp, int indent,
dns_c_logchan_t *logchan,
isc_boolean_t if_predef_too);
isc_result_t dns_c_logchan_set_path(dns_c_logchan_t *channel,
const char *path);
isc_result_t dns_c_logchan_set_versions(dns_c_logchan_t *channel,
isc_int32_t versions);
isc_result_t dns_c_logchan_set_size(dns_c_logchan_t *channel,
isc_uint32_t size);
isc_result_t dns_c_logchan_set_facility(dns_c_logchan_t *channel,
int facility);
isc_result_t dns_c_logchan_set_severity(dns_c_logchan_t *channel,
dns_c_log_severity_t severity);
isc_result_t dns_c_logchan_set_debug_level(dns_c_logchan_t *channel,
isc_int32_t level);
isc_result_t dns_c_logchan_set_printcat(dns_c_logchan_t *channel,
isc_boolean_t newval);
isc_result_t dns_c_logchan_set_printsev(dns_c_logchan_t *channel,
isc_boolean_t newval);
isc_result_t dns_c_logchan_set_printtime(dns_c_logchan_t *channel,
isc_boolean_t newval);
isc_result_t dns_c_logchan_set_predef(dns_c_logchan_t *channel,
isc_boolean_t newval);
isc_result_t dns_c_logchan_get_path(dns_c_logchan_t *channel,
const char **path);
isc_result_t dns_c_logchan_get_versions(dns_c_logchan_t *channel,
isc_int32_t *versions);
isc_result_t dns_c_logchan_get_size(dns_c_logchan_t *channel,
isc_uint32_t *size);
isc_result_t dns_c_logchan_get_facility(dns_c_logchan_t *channel,
int *facility);
isc_result_t dns_c_logchan_get_severity(dns_c_logchan_t *channel,
dns_c_log_severity_t *severity);
isc_result_t dns_c_logchan_get_debug_level(dns_c_logchan_t *channel,
isc_int32_t *level);
isc_result_t dns_c_logchan_get_printcat(dns_c_logchan_t *channel,
isc_boolean_t *retval);
isc_result_t dns_c_logchan_get_printsev(dns_c_logchan_t *channel,
isc_boolean_t *retval);
isc_result_t dns_c_logchan_get_printtime(dns_c_logchan_t *channel,
isc_boolean_t *retval);
isc_result_t dns_c_logchan_get_predef(dns_c_logchan_t *channel,
isc_boolean_t *retval);
/*
* Logging category
*/
isc_result_t dns_c_logcat_new(isc_mem_t *mem, dns_c_category_t cat,
dns_c_logcat_t **newlc);
isc_result_t dns_c_logcat_delete(dns_c_logcat_t **logcat);
void dns_c_logcat_print(FILE *fp, int indent,
dns_c_logcat_t *logcat,
isc_boolean_t if_predef_too);
isc_result_t dns_c_logcat_copy(isc_mem_t *mem, dns_c_logcat_t **dest,
dns_c_logcat_t *src);
isc_result_t dns_c_logcat_add_name(dns_c_logcat_t *logcat,
const char *name);
isc_result_t dns_c_logcat_del_name(dns_c_logcat_t *logcat,
const char *name);
isc_result_t dns_c_logcat_set_predef(dns_c_logcat_t *logcat,
isc_boolean_t newval);
isc_result_t dns_c_logcat_get_predef(dns_c_logcat_t *logcat,
isc_boolean_t *retval);
#endif /* ISC_WHATEVER_H */

View File

@@ -0,0 +1,189 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFLSN_H
#define DNS_CONFIG_CONFLSN_H 1
/*****
***** Module Info
*****/
/*
* Data structures to hold information related to ``listen-on'' statements
* in the named.conf file.
*/
/*
*
* MP:
*
* Caller must do necessary locking
*
* Reliability:
*
* No issues.
*
* Resources:
*
* Uses memory managers supplied by callers.
*
* Security:
*
* N/A
*
* Standards:
*
* N/A
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
#include <isc/int.h>
#include <dns/confip.h>
/***
*** Types
***/
typedef struct dns_c_lstn_on dns_c_lstn_on_t;
typedef struct dns_c_lstn_list dns_c_lstn_list_t;
/* Structure for holing value of a single listen-on statement. */
struct dns_c_lstn_on
{
isc_mem_t *mem;
isc_uint32_t magic;
short port;
dns_c_ipmatch_list_t *iml;
ISC_LINK(dns_c_lstn_on_t) next;
};
/* A list of listen-on statements */
struct dns_c_lstn_list
{
isc_mem_t *mem;
isc_uint32_t magic;
ISC_LIST(dns_c_lstn_on_t) elements;
};
/***
*** Functions
***/
isc_result_t dns_c_lstn_list_new(isc_mem_t *mem, dns_c_lstn_list_t
**llist);
/*
* Creates a new dns_c_lstn_list_t structure from the allocator pointed to
* by MEM, and stores the pointer to the new structure in *LLIST.
*
* Requires:
* mem be a pointer to a valid allocator.
* llist be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS on success.
* ISC_R_NOMEMORY on allocation failure.
*/
isc_result_t dns_c_lstn_list_delete(dns_c_lstn_list_t **llist);
/*
* Deletes the list pointed to by **LLIST, and all the elements in it.
* Sets *LLIST to NULL when done.
*
* Requires:
*
* Returns:
*
* ISC_R_SUCCESS on success.
*/
isc_result_t dns_c_lstn_list_print(FILE *fp, int indent,
dns_c_lstn_list_t *ll);
/*
* Prints the given the list LL to the stream FP. INDENT number of tabs
* preceed each line of output.
*
* Requires:
*
* fp be a pointer to a valid FILE.
*
*/
isc_result_t dns_c_lstn_on_new(isc_mem_t *mem, dns_c_lstn_on_t
**listen);
/*
* Creates a new dns_c_lstn_on_t structure and stores the pointer
* in *LISTEN.
*
* Requires:
* mem be pointer to a valid memory allocator.
* listen be a valid non-NULL pointer.
*
* Returns:
* ISC_R_SUCCESS on success.
* ISC_R_NOMEMORY on allocation failure.
*/
isc_result_t dns_c_lstn_on_delete(dns_c_lstn_on_t **listen);
/*
* Deletes the dns_c_lstn_on_t structure pointed to by *LISTEN.
*
* Requires:
*
* listen be a valid non-NULL pointer.
*
* Returns:
*/
isc_result_t dns_c_lstn_on_setiml(dns_c_lstn_on_t *listen,
dns_c_ipmatch_list_t *iml,
isc_boolean_t deepcopy);
/*
* Sets the iml field of the structure to the value of the IML
* parameter. If deepcopy paramater is true the structure field is
* assigned a depp copy of the IML parameter.
*
* Requires:
*
* Returns:
*
* ISC_R_SUCCESS on happiness
* ISC_R_NOMEMORY on allocation failure.
*/
isc_result_t dns_c_lstn_on_print(FILE *fp, int indent, dns_c_lstn_on_t
*lo);
#endif /* DNS_CONFIG_CONFLSN_H */

View File

@@ -0,0 +1,108 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/*****
***** Module Info
*****/
/*
* Main entry point in the config file parser module.
*
* The parser module handles the parsing of config files. The entry point
* is:
*
* isc_result_t dns_c_parse_namedconf(const char *filename, isc_mem_t *mem,
* dns_c_ctx_t **configctx,
* dns_c_cbks_t *callbacks);
*
* MP:
* Only a single thread is let through the module at once.
*
* Reliability:
* No anticipated impact.
*
* Resources:
* Long-term memory allocation done with memory allocator supplied by
* caller.
*
* Security:
* <TBS>
*
* Standards:
* None.
*/
/***
*** Imports
***/
#include <config.h>
#include <dns/confctx.h>
/***
*** Functions
***/
/*
* Typedefs for the callbacks done while parsing. If the callback functions
* return anything other than ISC_R_SUCCESS, then the parse routine
* terminates with an error.
*/
typedef isc_result_t (*dns_c_zonecbk_t)(dns_c_ctx_t *ctx,
dns_c_zone_t *zone,
void *uap);
typedef isc_result_t (*dns_c_optscbk_t)(dns_c_ctx_t *ctx, void *uap);
typedef struct dns_c_cbks
{
dns_c_zonecbk_t zonecbk;
void *zonecbkuap;
dns_c_optscbk_t optscbk;
void *optscbkuap;
} dns_c_cbks_t;
isc_result_t dns_c_parse_namedconf(const char *filename, isc_mem_t *mem,
dns_c_ctx_t **configctx,
dns_c_cbks_t *callbacks);
/*
* Parse a named confile file. Fills up a new config context with the config
* data. All memory allocations for the contents of configctx are done
* using the MEM argument. Caller must destroy the config context with
* dns_c_ctx_delete() when done.
*
* Requires:
* *filename is a valid filename.
* *mem is a valid memory manager.
* *configctx is a valid isc_config_ctx_t pointer
* callbacks is NULL or it points to a valid dns_c_cbks_t structure.
*
* Ensures:
* On success, *configctx is attached to the newly created config context.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
* ISC_R_INVALIDFILE file doesn't exist or is unreadable
* ISC_R_FAILURE file contains errors.
*/

View File

@@ -0,0 +1,122 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFRRSET_H
#define DNS_CONFIG_CONFRRSET_H 1
/*****
***** Module Info
*****/
/*
*
* MP:
*
*
* Reliability:
*
*
* Resources:
*
*
* Security:
*
*
* Standards:
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
/* XXX these next two are needed by rdatatype.h. It should be fixed to
* include them itself.
*/
#include <isc/buffer.h>
#include <dns/result.h>
#include <dns/rdatatype.h>
#include <dns/confcommon.h>
/***
*** Types
***/
typedef struct dns_c_rrso dns_c_rrso_t;
typedef struct dns_c_rrso_list dns_c_rrso_list_t;
struct dns_c_rrso
{
isc_mem_t *mem;
dns_rdataclass_t oclass;
dns_rdatatype_t otype;
char *name;
dns_c_ordering_t ordering;
ISC_LINK(dns_c_rrso_t) next;
};
struct dns_c_rrso_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_rrso_t) elements;
};
/***
*** Functions
***/
isc_result_t dns_c_rrso_list_new(isc_mem_t *mem,
dns_c_rrso_list_t **rval);
isc_result_t dns_c_rrso_list_delete(dns_c_rrso_list_t **list);
isc_result_t dns_c_rrso_list_copy(isc_mem_t *mem,
dns_c_rrso_list_t **dest,
dns_c_rrso_list_t *source);
isc_result_t dns_c_rrso_list_clear(dns_c_rrso_list_t *olist);
isc_result_t dns_c_rrso_list_append(dns_c_rrso_list_t *dest,
dns_c_rrso_list_t *src);
isc_result_t dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res,
dns_rdataclass_t oclass,
dns_rdatatype_t otype,
char *name,
dns_c_ordering_t ordering);
isc_result_t dns_c_rrso_delete(dns_c_rrso_t **order);
isc_result_t dns_c_rrso_copy(isc_mem_t *mem, dns_c_rrso_t **dest,
dns_c_rrso_t *source);
void dns_c_rrso_list_print(FILE *fp, int indent,
dns_c_rrso_list_t *rrlist);
void dns_c_rrso_print(FILE *fp, int indent,
dns_c_rrso_t *rrlist);
#endif /* DNS_CONFIG_CONFRRSET_H */

View File

@@ -0,0 +1,131 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFSERV_H
#define DNS_CONFIG_CONFSERV_H 1
/*****
***** Module Info
*****/
/*
*
*
*
*
*
*
* MP:
*
*
* Reliability:
*
*
* Resources:
*
*
* Security:
*
*
* Standards:
*
*/
/***
*** Imports
***/
#include <config.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <isc/mem.h>
#include <dns/types.h>
#include <dns/confcommon.h>
#include <dns/confkeys.h>
/***
*** Types
***/
typedef struct dns_c_srv dns_c_srv_t;
typedef struct dns_c_srv_list dns_c_srv_list_t;
struct dns_c_srv_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_srv_t) elements;
};
struct dns_c_srv
{
isc_mem_t *mem;
dns_c_addr_t address;
isc_boolean_t bogus;
dns_transfer_format_t transfer_format;
int transfers;
isc_boolean_t support_ixfr;
dns_c_kid_list_t *keys;
dns_setbits_t bitflags;
ISC_LINK(dns_c_srv_t) next;
};
/***
*** Functions
***/
isc_result_t dns_c_srv_list_new(isc_mem_t *mem,
dns_c_srv_list_t **list);
isc_result_t dns_c_srv_list_delete(dns_c_srv_list_t **list);
void dns_c_srv_list_print(FILE *fp, int indent,
dns_c_srv_list_t *servers);
isc_result_t dns_c_srv_new(isc_mem_t *mem, dns_c_addr_t ipaddr,
dns_c_srv_t **server); /* XX ipv6??? */
isc_result_t dns_c_srv_delete(dns_c_srv_t **server);
void dns_c_srv_print(FILE *fp, int indent, dns_c_srv_t *server);
isc_result_t dns_c_srv_set_bogus(dns_c_srv_t *server,
isc_boolean_t newval);
isc_result_t dns_c_srv_get_bogus(dns_c_srv_t *server,
isc_boolean_t *retval);
isc_result_t dns_c_srv_set_support_ixfr(dns_c_srv_t *server,
isc_boolean_t newval);
isc_result_t dns_c_srv_get_support_ixfr(dns_c_srv_t *server,
isc_boolean_t *retval);
isc_result_t dns_c_srv_set_transfers(dns_c_srv_t *server,
isc_int32_t newval);
isc_result_t dns_c_srv_get_transfers(dns_c_srv_t *server,
isc_int32_t *retval);
isc_result_t dns_c_srv_set_transfer_format(dns_c_srv_t *server,
dns_transfer_format_t newval);
isc_result_t dns_c_srv_get_transfer_format(dns_c_srv_t *server,
dns_transfer_format_t *retval);
isc_result_t dns_c_srv_get_keylist(dns_c_srv_t *server,
dns_c_kid_list_t **keylist);
#endif /* DNS_CONFIG_CONFSERV_H */

View File

@@ -0,0 +1,312 @@
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CONFIG_CONFZONE_H
#define DNS_CONFIG_CONFZONE_H 1
/*****
***** Module Info
*****/
/*
* Zones as seen by the config file parser. The data structures here define
* the zone data as it is in the config file. The data structures here do
* *not* define the things like red-black trees for named's internal data
* structures.
*
*/
/*
*
* MP:
* Client must do necessary locking.
*
* Reliability:
*
* No problems.
*
* Resources:
*
* Use memory managers supplied by client.
*
* Security:
*
* N/A
*
*/
/***
*** Imports
***/
#include <config.h>
#include <isc/mem.h>
/* XXX these next two are needed by rdatatype.h. It should be fixed to
* include them itself.
*/
#include <isc/buffer.h>
#include <dns/result.h>
#include <dns/rdatatype.h>
#include <dns/confcommon.h>
#include <dns/confip.h>
#include <dns/confkeys.h>
/***
*** Types
***/
typedef struct dns_c_master_zone dns_c_master_zone_t;
typedef struct dns_c_slave_zone dns_c_slave_zone_t;
typedef struct dns_c_stub_zone dns_c_stub_zone_t;
typedef struct dns_c_forward_zone dns_c_forward_zone_t;
typedef struct dns_c_hint_zone dns_c_hint_zone_t;
typedef struct dns_c_zone dns_c_zone_t;
typedef struct dns_c_zone_list dns_c_zone_list_t;
struct dns_c_zone_list
{
isc_mem_t *mem;
ISC_LIST(dns_c_zone_t) zones;
};
struct dns_c_master_zone
{
char *file;
dns_c_severity_t check_names;
dns_c_ipmatch_list_t *allow_update;
dns_c_ipmatch_list_t *allow_query;
dns_c_ipmatch_list_t *allow_transfer;
isc_boolean_t dialup;
isc_boolean_t notify;
dns_c_iplist_t *also_notify;
char *ixfr_base;
char *ixfr_tmp;
isc_int32_t max_ixfr_log;
isc_boolean_t maint_ixfr_base;
dns_c_pubkey_t *pubkey;
dns_setbits_t setflags;
};
struct dns_c_slave_zone
{
char *file;
dns_c_severity_t check_names;
dns_c_ipmatch_list_t *allow_update;
dns_c_ipmatch_list_t *allow_query;
dns_c_ipmatch_list_t *allow_transfer;
dns_c_iplist_t *also_notify;
isc_boolean_t notify;
isc_boolean_t dialup;
char *ixfr_base;
char *ixfr_tmp;
isc_boolean_t maint_ixfr_base;
isc_int32_t max_ixfr_log;
dns_c_pubkey_t *pubkey;
isc_int32_t master_port;
dns_c_iplist_t *master_ips;
dns_c_addr_t transfer_source; /* XXX ipv6?? */
isc_int32_t max_trans_time_in;
dns_setbits_t setflags;
};
struct dns_c_stub_zone
{
char *file;
dns_c_severity_t check_names;
dns_c_ipmatch_list_t *allow_update; /* should be here??? */
dns_c_ipmatch_list_t *allow_query;
dns_c_ipmatch_list_t *allow_transfer; /* should be here??? */
isc_boolean_t dialup;
dns_c_pubkey_t *pubkey;
isc_int32_t master_port;
dns_c_iplist_t *master_ips;
dns_c_addr_t transfer_source; /* XXX ipv6?? */
isc_int32_t max_trans_time_in;
dns_setbits_t setflags;
};
struct dns_c_forward_zone
{
dns_c_severity_t check_names;
dns_c_forw_t forward;
dns_c_iplist_t *forwarders;
dns_setbits_t setflags;
};
struct dns_c_hint_zone
{
char *file;
dns_c_severity_t check_names;
dns_setbits_t setflags;
};
struct dns_c_zone
{
dns_c_zone_list_t *mylist;
char *name;
dns_rdataclass_t zclass;
dns_c_zonetype_t ztype;
union
{
dns_c_master_zone_t mzone;
dns_c_slave_zone_t szone;
dns_c_stub_zone_t tzone;
dns_c_forward_zone_t fzone;
dns_c_hint_zone_t hzone;
} u;
isc_boolean_t afteropts;
ISC_LINK(dns_c_zone_t) next;
};
/***
*** Functions
***/
isc_result_t dns_c_zone_list_new(isc_mem_t *mem, dns_c_zone_list_t **zlist);
isc_result_t dns_c_zone_list_delete(dns_c_zone_list_t **zlist);
isc_result_t dns_c_zone_list_find(dns_c_zone_list_t *zlist,
const char *name,
dns_c_zone_t **retval);
isc_result_t dns_c_zone_list_rmbyname(dns_c_zone_list_t *zlist,
const char *name);
isc_result_t dns_c_zone_list_rmzone(dns_c_zone_list_t *zlist,
dns_c_zone_t *zone);
void dns_c_zone_list_print(FILE *fp, int indent,
dns_c_zone_list_t *list);
void dns_c_zone_list_print_postopts(FILE *fp, int indent,
dns_c_zone_list_t *list);
void dns_c_zone_list_print_preopts(FILE *fp, int indent,
dns_c_zone_list_t *list);
isc_result_t dns_c_zone_new(dns_c_zone_list_t *zlist,
dns_c_zonetype_t ztype,
dns_rdataclass_t zclass,
const char *name, dns_c_zone_t **zone);
void dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone);
isc_result_t dns_c_zone_set_file(dns_c_zone_t *zone, const char *newfile);
isc_result_t dns_c_zone_set_checknames(dns_c_zone_t *zone,
dns_c_severity_t severity);
isc_result_t dns_c_zone_set_allow_upd(dns_c_zone_t *zone,
dns_c_ipmatch_list_t *ipml,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_allow_query(dns_c_zone_t *zone,
dns_c_ipmatch_list_t *ipml,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_allow_transfer(dns_c_zone_t *zone,
dns_c_ipmatch_list_t *ipml,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_dialup(dns_c_zone_t *zone,
isc_boolean_t newval);
isc_result_t dns_c_zone_set_notify(dns_c_zone_t *zone,
isc_boolean_t newval);
isc_result_t dns_c_zone_set_maint_ixfr_base(dns_c_zone_t *zone,
isc_boolean_t newval);
isc_result_t dns_c_zone_set_also_notify(dns_c_zone_t *zone,
dns_c_iplist_t *newval,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_ixfr_base(dns_c_zone_t *zone,
const char *newval);
isc_result_t dns_c_zone_set_ixfr_tmp(dns_c_zone_t *zone,
const char *newval);
isc_result_t dns_c_zone_set_pubkey(dns_c_zone_t *zone,
dns_c_pubkey_t *pubkey,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_master_port(dns_c_zone_t *zone,
isc_int32_t port);
isc_result_t dns_c_zone_set_master_ips(dns_c_zone_t *zone,
dns_c_iplist_t *newval,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_set_transfer_source(dns_c_zone_t *zone,
dns_c_addr_t newval);
isc_result_t dns_c_zone_set_max_trans_time_in(dns_c_zone_t *zone,
isc_int32_t newval);
isc_result_t dns_c_zone_set_max_ixfr_log(dns_c_zone_t *zone,
isc_int32_t new);
isc_result_t dns_c_zone_set_forward(dns_c_zone_t *zone,
dns_c_forw_t newval);
isc_result_t dns_c_zone_set_forwarders(dns_c_zone_t *zone,
dns_c_iplist_t *ipml,
isc_boolean_t deepcopy);
isc_result_t dns_c_zone_get_name(dns_c_zone_t *zone,
const char **retval);
isc_result_t dns_c_zone_get_file(dns_c_zone_t *zone,
const char **retval);
isc_result_t dns_c_zone_get_checknames(dns_c_zone_t *zone,
dns_c_severity_t *retval);
isc_result_t dns_c_zone_get_allow_upd(dns_c_zone_t *zone,
dns_c_ipmatch_list_t **retval);
isc_result_t dns_c_zone_get_allow_query(dns_c_zone_t *zone,
dns_c_ipmatch_list_t **retval);
isc_result_t dns_c_zone_get_allow_transfer(dns_c_zone_t *zone,
dns_c_ipmatch_list_t **retval);
isc_result_t dns_c_zone_get_dialup(dns_c_zone_t *zone,
isc_boolean_t *retval);
isc_result_t dns_c_zone_get_notify(dns_c_zone_t *zone,
isc_boolean_t *retval);
isc_result_t dns_c_zone_get_maint_ixfr_base(dns_c_zone_t *zone,
isc_boolean_t *retval);
isc_result_t dns_c_zone_get_also_notify(dns_c_zone_t *zone,
dns_c_iplist_t **retval);
isc_result_t dns_c_zone_get_ixfr_base(dns_c_zone_t *zone,
const char **retval);
isc_result_t dns_c_zone_get_ixfr_tmp(dns_c_zone_t *zone,
const char **retval);
isc_result_t dns_c_zone_get_pubkey(dns_c_zone_t *zone,
dns_c_pubkey_t **retval);
isc_result_t dns_c_zone_get_master_port(dns_c_zone_t *zone,
isc_int32_t *retval);
isc_result_t dns_c_zone_get_master_ips(dns_c_zone_t *zone,
dns_c_iplist_t **retval);
isc_result_t dns_c_zone_get_transfer_source(dns_c_zone_t *zone,
dns_c_addr_t *retval);
isc_result_t dns_c_zone_get_max_trans_time_in(dns_c_zone_t *zone,
isc_int32_t *retval);
isc_result_t dns_c_zone_get_max_ixfr_log(dns_c_zone_t *zone,
isc_int32_t *retval);
isc_result_t dns_c_zone_get_forward(dns_c_zone_t *zone,
dns_c_forw_t *retval);
isc_result_t dns_c_zone_get_forwarders(dns_c_zone_t *zone,
dns_c_iplist_t **retval);
#endif /* DNS_CONFIG_CONFZONE_H */