spf_dns_zone.c File Reference

#include "spf_sys_config.h"
#include <time.h>
#include <ctype.h>
#include "spf.h"
#include "spf_dns.h"
#include "spf_internal.h"
#include "spf_dns_internal.h"
#include "spf_dns_zone.h"

Include dependency graph for spf_dns_zone.c:

Go to the source code of this file.

Data Structures

struct  SPF_dns_zone_config_t

Defines

#define SPF_RR_TRY_REALLOC(rr, i, s)

Functions

SPF_errcode_t SPF_dns_zone_add_str (SPF_dns_server_t *spf_dns_server, const char *domain, ns_type rr_type, SPF_dns_stat_t herrno, const char *data)
SPF_dns_server_tSPF_dns_zone_new (SPF_dns_server_t *layer_below, const char *name, int debug)


Detailed Description

This is really little more than a proof-of-concept static zone.

The static zone shouldn't just be an unsorted list that must be completely searched each time. Rather something should be done to allow quicker access. For example, sorting/bsearch, or red-black trees, or perfect hashes, or something.

Note that wildcards mean that a domain could match more than one record. The most specific record should match.

Definition in file spf_dns_zone.c.


Define Documentation

#define SPF_RR_TRY_REALLOC ( rr,
i,
 ) 

Value:

do {                         SPF_errcode_t __err = SPF_dns_rr_buf_realloc(rr, i, s);                         if (__err != SPF_E_SUCCESS) return __err;                 } while(0)

Referenced by SPF_dns_zone_add_str().


Function Documentation

SPF_errcode_t SPF_dns_zone_add_str ( SPF_dns_server_t spf_dns_server,
const char *  domain,
ns_type  rr_type,
SPF_dns_stat_t  herrno,
const char *  data 
)

Adds an entry to a DNS zone.

If a given domain name has multiple records of a given RR type, you can call the add routine multiple times to add to the RR set.

Definition at line 189 of file spf_dns_zone.c.

References SPF_dns_rr_data_t::a, SPF_dns_rr_data_t::aaaa, SPF_dns_server_struct::hook, SPF_dns_rr_data_t::mx, NETDB_SUCCESS, ns_t_a, ns_t_aaaa, ns_t_any, ns_t_mx, ns_t_ptr, ns_t_spf, ns_t_txt, NULL, SPF_dns_rr_t::num_rr, SPF_dns_zone_config_t::num_zone, SPF_dns_rr_data_t::ptr, SPF_dns_rr_t::rr, SPF_dns_rr_new_init(), SPF_E_INVALID_IP4, SPF_E_INVALID_IP6, SPF_E_NO_MEMORY, SPF_E_SUCCESS, SPF_error, SPF_RR_TRY_REALLOC, TRUE, SPF_dns_rr_data_t::txt, SPF_dns_zone_config_t::zone, and SPF_dns_zone_config_t::zone_buf_len.

Referenced by SPF_dns_test_new().

Here is the call graph for this function:

SPF_dns_server_t* SPF_dns_zone_new ( SPF_dns_server_t layer_below,
const char *  name,
int  debug 
)

These routines take care of creating/destroying/etc. the objects that hold the DNS layer configuration. SPF_dns_server_t objects contain malloc'ed data, so they must be destroyed when you are finished with them, or you will leak memory.

The "name" will be used when displaying debugging information so that you can tell which zone layer in the stack of DNS layers generated the output.

Definition at line 337 of file spf_dns_zone.c.

References SPF_dns_server_struct::add_cache, SPF_dns_server_struct::debug, SPF_dns_server_struct::destroy, SPF_dns_server_struct::get_exp, SPF_dns_server_struct::get_spf, SPF_dns_server_struct::hook, HOST_NOT_FOUND, SPF_dns_server_struct::layer_below, SPF_dns_server_struct::lookup, SPF_dns_server_struct::name, ns_t_any, NULL, SPF_dns_zone_config_t::num_zone, SPF_dns_zone_config_t::nxdomain, SPF_dns_rr_new_init(), SPF_dns_zone_config_t::zone, and SPF_dns_zone_config_t::zone_buf_len.

Referenced by SPF_dns_test_new(), and SPF_server_new().

Here is the call graph for this function:


Generated on Tue Nov 4 13:27:49 2008 for libspf2 by  doxygen 1.5.4