spf_record.h File Reference

#include "spf_response.h"
#include "spf_request.h"
#include "spf_server.h"

Include dependency graph for spf_record.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SPF_data_str_t
struct  SPF_data_var_t
struct  SPF_data_cidr_t
union  SPF_data_t
struct  SPF_mech_t
struct  SPF_mod_t
struct  SPF_record_struct
struct  SPF_macro_struct

Defines

#define SPF_MAX_STR_LEN   255
#define SPF_MAX_MECH_LEN   511
#define SPF_MAX_MOD_LEN   511
#define PARM_LP_FROM   0
#define PARM_ENV_FROM   1
#define PARM_DP_FROM   2
#define PARM_CUR_DOM   3
#define PARM_CLIENT_IP   4
#define PARM_CLIENT_IP_P   5
#define PARM_TIME   6
#define PARM_CLIENT_DOM   7
#define PARM_CLIENT_VER   8
#define PARM_HELO_DOM   9
#define PARM_REC_DOM   10
#define PARM_CIDR   11
#define PARM_STRING   12
#define PREFIX_PASS   SPF_RESULT_PASS
#define PREFIX_FAIL   SPF_RESULT_FAIL
#define PREFIX_SOFTFAIL   SPF_RESULT_SOFTFAIL
#define PREFIX_NEUTRAL   SPF_RESULT_NEUTRAL
#define PREFIX_UNKNOWN   SPF_RESULT_PERMERROR
#define MECH_UNKNOWN   0
#define MECH_A   1
#define MECH_MX   2
#define MECH_PTR   3
#define MECH_INCLUDE   4
#define MECH_IP4   5
#define MECH_IP6   6
#define MECH_EXISTS   7
#define MECH_ALL   8
#define MECH_REDIRECT   9

Typedefs

typedef struct SPF_record_struct SPF_record_t
typedef struct SPF_macro_struct SPF_macro_t

Functions

SPF_record_tSPF_record_new (SPF_server_t *spf_server, const char *text)
void SPF_record_free (SPF_record_t *rp)
void SPF_macro_free (SPF_macro_t *mac)
SPF_errcode_t SPF_record_find_mod_value (SPF_server_t *spf_server, SPF_request_t *spf_request, SPF_response_t *spf_response, SPF_record_t *spf_record, const char *mod_name, char **bufp, size_t *buflenp)
SPF_errcode_t SPF_record_compile (SPF_server_t *spf_server, SPF_response_t *spf_response, SPF_record_t **spf_recordp, const char *record)
SPF_errcode_t SPF_record_compile_macro (SPF_server_t *spf_server, SPF_response_t *spf_response, SPF_macro_t **spf_macrop, const char *record)
SPF_errcode_t SPF_record_interpret (SPF_record_t *spf_record, SPF_request_t *spf_request, SPF_response_t *spf_response, int depth)
SPF_errcode_t SPF_record_expand_data (SPF_server_t *spf_server, SPF_request_t *spf_request, SPF_response_t *spf_response, SPF_data_t *data, size_t data_len, char **bufp, size_t *buflenp)
SPF_errcode_t SPF_record_print (SPF_record_t *spf_record)
SPF_errcode_t SPF_record_stringify (SPF_record_t *spf_record, char **bufp, size_t *buflenp)


Define Documentation

#define MECH_A   1

Definition at line 167 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_ALL   8

Definition at line 174 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_EXISTS   7

Definition at line 173 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_INCLUDE   4

Definition at line 170 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_IP4   5

Definition at line 171 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_IP6   6

Definition at line 172 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_MX   2

Definition at line 168 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_PTR   3

Definition at line 169 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_REDIRECT   9

Definition at line 175 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define MECH_UNKNOWN   0

Definition at line 166 of file spf_record.h.

#define PARM_CIDR   11

Definition at line 103 of file spf_record.h.

Referenced by SPF_record_expand_data(), and SPF_record_stringify().

#define PARM_CLIENT_DOM   7

Definition at line 99 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_CLIENT_IP   4

Definition at line 96 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_CLIENT_IP_P   5

Definition at line 97 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_CLIENT_VER   8

Definition at line 100 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_CUR_DOM   3

Definition at line 95 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_DP_FROM   2

Definition at line 94 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_ENV_FROM   1

Definition at line 93 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_HELO_DOM   9

Definition at line 101 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_LP_FROM   0

Definition at line 92 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_REC_DOM   10

Definition at line 102 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_STRING   12

Definition at line 104 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PARM_TIME   6

Definition at line 98 of file spf_record.h.

Referenced by SPF_record_expand_data().

#define PREFIX_FAIL   SPF_RESULT_FAIL

Definition at line 158 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define PREFIX_NEUTRAL   SPF_RESULT_NEUTRAL

Definition at line 160 of file spf_record.h.

Referenced by SPF_record_compile(), and SPF_record_stringify().

#define PREFIX_PASS   SPF_RESULT_PASS

Definition at line 157 of file spf_record.h.

Referenced by SPF_record_compile(), and SPF_record_stringify().

#define PREFIX_SOFTFAIL   SPF_RESULT_SOFTFAIL

Definition at line 159 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define PREFIX_UNKNOWN   SPF_RESULT_PERMERROR

Definition at line 161 of file spf_record.h.

Referenced by SPF_record_compile(), SPF_record_interpret(), and SPF_record_stringify().

#define SPF_MAX_MECH_LEN   511

Definition at line 75 of file spf_record.h.

#define SPF_MAX_MOD_LEN   511

Definition at line 76 of file spf_record.h.

Referenced by SPF_record_compile_macro().

#define SPF_MAX_STR_LEN   255

Compiled SPF record

The compiled form of the SPF record is as follows:

* A four byte header which contains the version, and information about the mechanisms and modifiers

* Mechanism information, repeated once for each mechanism

* A two byte header describing the mechanism

* Data associated with the mechanism. This can be of several forms

* ip4/ip6 have a fixed format data field, cidr length is in the mechanism's parm_len field

* Mechanisms that allow a macro-string

* Optional two byte CIDR length structure. (Yes, this is at the beginning, rather than at the end.)

* tokenized data description blocks that can be either:

* two byte macro variable description

* two byte string description, followed by the string

* Modifier information, repeated once for each modifier

* two byte header describing the modifier

* name of the modifier

* tokenized data description blocks that can be either:

* two byte macro variable description

* two byte string description, followed by the string

Definition at line 71 of file spf_record.h.


Typedef Documentation

typedef struct SPF_macro_struct SPF_macro_t

Definition at line 23 of file spf_record.h.

typedef struct SPF_record_struct SPF_record_t

Definition at line 22 of file spf_record.h.


Function Documentation

void SPF_macro_free ( SPF_macro_t mac  ) 

Definition at line 73 of file spf_record.c.

Referenced by SPF_request_get_exp(), SPF_server_free(), and SPF_server_set_explanation().

SPF_errcode_t SPF_record_compile ( SPF_server_t spf_server,
SPF_response_t spf_response,
SPF_record_t **  spf_recordp,
const char *  record 
)

The SPF compiler.

It converts the SPF record in string format that is easy for people to deal with into a compact binary format that is easy for computers to deal with.

Definition at line 1180 of file spf_compile.c.

References SPF_server_struct::debug, MECH_A, MECH_ALL, MECH_EXISTS, MECH_INCLUDE, MECH_IP4, MECH_IP6, MECH_MX, MECH_PTR, MECH_REDIRECT, SPF_mechtype_t::mech_type, NULL, PREFIX_FAIL, PREFIX_NEUTRAL, PREFIX_PASS, PREFIX_SOFTFAIL, PREFIX_UNKNOWN, SPF_ASSERT_NOTNULL, SPF_debugf, SPF_E_INTERNAL_ERROR, SPF_E_INVALID_CHAR, SPF_E_INVALID_OPT, SPF_E_INVALID_PREFIX, SPF_E_MOD_W_PREF, SPF_E_NO_MEMORY, SPF_E_NOT_SPF, SPF_E_SUCCESS, SPF_E_UNKNOWN_MECH, SPF_error_code(), SPF_error_errorp(), SPF_record_new(), SPF_response_add_error(), SPF_response_add_error_ptr(), SPF_response_add_warn_ptr(), SPF_response_errors(), SPF_response_message(), SPF_response_messages(), SPF_VER_STR, STREQ_SIZEOF, STREQ_SIZEOF_N, strncasecmp(), and SPF_record_struct::version.

Referenced by main(), SPF_request_query_fallback(), SPF_request_query_rcptto(), SPF_server_get_record(), and SPF_server_set_localpolicy().

Here is the call graph for this function:

SPF_errcode_t SPF_record_compile_macro ( SPF_server_t spf_server,
SPF_response_t spf_response,
SPF_macro_t **  spf_macrop,
const char *  record 
)

Definition at line 1499 of file spf_compile.c.

References ALIGN_DECL, ALIGNED_DECL, SPF_E_BIG_MOD, SPF_E_NO_MEMORY, SPF_E_SUCCESS, SPF_MAX_MOD_LEN, and TRUE.

Referenced by SPF_request_get_exp(), and SPF_server_set_explanation().

SPF_errcode_t SPF_record_expand_data ( SPF_server_t spf_server,
SPF_request_t spf_request,
SPF_response_t spf_response,
SPF_data_t data,
size_t  data_len,
char **  bufp,
size_t *  buflenp 
)

This could better collect errors, like the compiler does. This requires that *bufp be either malloced to *buflenp, or NULL This may realloc *bufp.

Definition at line 82 of file spf_expand.c.

References array_elem, SPF_request_struct::client_ver, SPF_request_struct::cur_dom, SPF_data_t::dc, SPF_data_t::ds, SPF_data_t::dv, SPF_request_struct::env_from, SPF_request_struct::env_from_dp, SPF_request_struct::env_from_lp, SPF_request_struct::helo_dom, SPF_request_struct::ipv4, SPF_request_struct::ipv6, SPF_data_str_t::len, SPF_request_struct::max_var_len, NULL, SPF_data_var_t::num_rhs, PARM_CIDR, PARM_CLIENT_DOM, PARM_CLIENT_IP, PARM_CLIENT_IP_P, PARM_CLIENT_VER, PARM_CUR_DOM, PARM_DP_FROM, PARM_ENV_FROM, PARM_HELO_DOM, PARM_LP_FROM, PARM_REC_DOM, PARM_STRING, PARM_TIME, SPF_data_var_t::parm_type, SPF_data_cidr_t::parm_type, SPF_data_str_t::parm_type, SPF_data_var_t::rev, SPF_ASSERT_NOTNULL, SPF_E_INTERNAL_ERROR, SPF_E_INVALID_VAR, SPF_E_NO_MEMORY, SPF_E_SUCCESS, SPF_E_UNINIT_VAR, SPF_error, SPF_realloc(), SPF_request_get_client_dom(), SPF_request_get_rec_dom(), and SPF_data_var_t::url_encode.

Referenced by SPF_record_find_mod_value(), SPF_record_interpret(), and SPF_request_get_exp().

Here is the call graph for this function:

SPF_errcode_t SPF_record_find_mod_value ( SPF_server_t spf_server,
SPF_request_t spf_request,
SPF_response_t spf_response,
SPF_record_t spf_record,
const char *  mod_name,
char **  bufp,
size_t *  buflenp 
)

Definition at line 126 of file spf_record.c.

References SPF_ASSERT_NOTNULL, and SPF_record_expand_data().

Referenced by SPF_request_get_exp().

Here is the call graph for this function:

void SPF_record_free ( SPF_record_t rp  ) 

Definition at line 63 of file spf_record.c.

References SPF_record_struct::mech_first, and SPF_record_struct::mod_first.

Referenced by main(), SPF_record_interpret(), SPF_server_free(), and SPF_server_set_localpolicy().

SPF_errcode_t SPF_record_interpret ( SPF_record_t spf_record,
SPF_request_t spf_request,
SPF_response_t spf_response,
int  depth 
)

Definition at line 584 of file spf_interpret.c.

References SPF_dns_rr_data_t::a, SPF_dns_rr_data_t::aaaa, SPF_request_struct::client_ver, SPF_request_struct::cur_dom, SPF_server_struct::debug, DONE, DONE_MECH, DONE_PERMERR, DONE_TEMPERR, FALSE, SPF_dns_rr_t::herrno, INET_NTOP, SPF_request_struct::ipv4, SPF_request_struct::ipv6, SPF_server_struct::local_policy, SPF_server_struct::max_dns_mech, SPF_server_struct::max_dns_mx, SPF_server_struct::max_dns_ptr, MECH_A, MECH_ALL, MECH_EXISTS, SPF_record_struct::mech_first, MECH_INCLUDE, MECH_IP4, MECH_IP6, MECH_MX, MECH_PTR, MECH_REDIRECT, SPF_mech_t::mech_type, SPF_dns_rr_data_t::mx, ns_t_a, ns_t_aaaa, ns_t_mx, ns_t_ptr, NULL, SPF_response_struct::num_dns_mech, SPF_record_struct::num_mech, SPF_dns_rr_t::num_rr, PREFIX_FAIL, PREFIX_SOFTFAIL, SPF_mech_t::prefix_type, PREFIX_UNKNOWN, SPF_dns_rr_data_t::ptr, SPF_response_struct::reason, SPF_server_struct::resolver, SPF_response_struct::result, SPF_dns_rr_t::rr, SPF_dns_rr_t::rr_type, SPF_ADD_DNS_MECH, SPF_ASSERT_NOTNULL, SPF_debugf, SPF_dns_lookup(), SPF_dns_rlookup(), SPF_dns_rlookup6(), SPF_dns_rr_free(), SPF_E_BIG_DNS, SPF_E_DNS_ERROR, SPF_E_INCLUDE_RETURNED_NONE, SPF_E_NO_MEMORY, SPF_E_NOT_CONFIG, SPF_E_RECURSIVE, SPF_E_SUCCESS, SPF_E_UNKNOWN_MECH, SPF_FREE_LOOKUP_DATA, SPF_GET_LOOKUP_DATA, SPF_MAYBE_SKIP_CIDR, SPF_REASON_DEFAULT, SPF_REASON_LOCALHOST, SPF_REASON_MECH, SPF_REASON_NONE, SPF_response_struct::spf_record_exp, SPF_record_expand_data(), SPF_record_free(), SPF_record_interpret(), SPF_request_is_loopback(), SPF_response_errcode(), SPF_response_free(), SPF_response_new(), SPF_response_result(), SPF_RESULT_FAIL, SPF_RESULT_INVALID, SPF_RESULT_NEUTRAL, SPF_RESULT_NONE, SPF_RESULT_PASS, SPF_RESULT_PERMERROR, SPF_RESULT_SOFTFAIL, SPF_RESULT_TEMPERROR, SPF_record_struct::spf_server, SPF_server_get_record(), SPF_strerror(), SPF_strreason(), SPF_strresult(), TRUE, TRY_AGAIN, and SPF_request_struct::use_local_policy.

Referenced by SPF_record_interpret().

Here is the call graph for this function:

SPF_record_t* SPF_record_new ( SPF_server_t spf_server,
const char *  text 
)

Definition at line 48 of file spf_record.c.

References SPF_record_struct::spf_server.

Referenced by SPF_record_compile().

SPF_errcode_t SPF_record_print ( SPF_record_t spf_record  ) 

Definition at line 45 of file spf_print.c.

References SPF_record_struct::mech_len, SPF_record_struct::mod_len, NULL, SPF_record_struct::num_mech, SPF_record_struct::num_mod, SPF_E_RESULT_UNKNOWN, SPF_E_SUCCESS, SPF_info, SPF_infof, SPF_record_stringify(), SPF_strerror(), and SPF_record_struct::version.

Referenced by main().

Here is the call graph for this function:

SPF_errcode_t SPF_record_stringify ( SPF_record_t spf_record,
char **  bufp,
size_t *  buflenp 
)

Definition at line 245 of file spf_id2str.c.

References SPF_data_t::dc, FALSE, MECH_A, MECH_ALL, MECH_EXISTS, SPF_record_struct::mech_first, MECH_INCLUDE, MECH_IP4, MECH_IP6, SPF_mech_t::mech_len, SPF_record_struct::mech_len, MECH_MX, MECH_PTR, MECH_REDIRECT, SPF_mech_t::mech_type, SPF_record_struct::mod_first, SPF_record_struct::mod_len, SPF_mod_t::name_len, NULL, SPF_record_struct::num_mech, SPF_record_struct::num_mod, PARM_CIDR, SPF_data_cidr_t::parm_type, PREFIX_FAIL, PREFIX_NEUTRAL, PREFIX_PASS, PREFIX_SOFTFAIL, SPF_mech_t::prefix_type, PREFIX_UNKNOWN, SPF_ASSERT_NOTNULL, SPF_debugf, SPF_E_INTERNAL_ERROR, SPF_E_INVALID_PREFIX, SPF_E_RESULT_UNKNOWN, SPF_E_SUCCESS, SPF_E_UNKNOWN_MECH, SPF_realloc(), SPF_VER_STR, TRUE, and SPF_record_struct::version.

Referenced by SPF_record_print().

Here is the call graph for this function:


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