spf.h File Reference

#include <sys/types.h>
#include <arpa/inet.h>

Go to the source code of this file.

Data Structures

struct  spf_result_t
struct  policy_addr_s
struct  spf_config_s
struct  strbuf_node_s
struct  strbuf_s
struct  split_str_node_s
struct  split_str_s
struct  peer_info_s

Defines

#define _SPF_H   1
#define SPF_VERSION   1
#define MAX_CNAME   5 /* we follow up max CNAMEs */
#define MAX_DEBUG_LEN   1024
#define MAX_MACRO_LEN   1024 /* max length of an expanded macro */
#define MAX_PLEN   1024 /* buffer to make UTIL_printf thread safe */
#define LOCAL_PART   256 /* local-part, text before @ in email addy */
#define ENV_SENDER   512 /* entire FROM: string passed by MTA */
#define CUR_DOM   256 /* text after @ in email addy for cur query */
#define UTC_TIME   22 /* time since epoch */
#define IP_ADDR   17 /* ip of remote peer - DON'T CHANGE FROM 17!! */
#define IP_VER   8 /* ip protocol version */
#define ENV_HELO   512 /* entire HELO string passed by MTA */
#define MAX_HNAME   256 /* hostname of MTA */
#define MAX_RESULT   64 /* human readable SPF result */
#define MAX_ERROR   96 /* human readable error reason */
#define EXPLAIN_S   256 /* change to EXPLAIN when cleaning up */
#define ENV_RECV   512 /* Received-SPF: header string */
#define MAX_RES_STR   12 /* maximum legnth of a res str eg: "pass" */
#define MAX_MECHANISM   256 /* maximum length of a mechanism */
#define MAX_HEADER   512 /* maximum length of header for prepend */
#define MAX_SMTP_RES   256 /* maximum length of smtp resonse string */
#define HR_PASS   "pass"
#define HR_NONE   "none"
#define HR_S_FAIL   "softfail"
#define HR_H_FAIL   "fail"
#define HR_ERROR   "error"
#define HR_NEUTRAL   "neutral"
#define HR_UNKNOWN   "unknown"
#define HR_UNMECH   "unknown mechanism"
#define SPF_EXPLAIN
#define SPF_GUESS   "v=spf1 a/24 mx/24 ptr "
#define SPF_TRUSTED   "v=spf1 include:spf.trusted-forwarder.org "

Typedefs

typedef enum SPF_BOOL SPF_BOOL
typedef enum SPF_RESULT SPF_RESULT
typedef enum SPF_ACTION SPF_ACTION
typedef enum SPF_MECHANISM SPF_MECHANISM
typedef spf_result_t spf_result_t
typedef policy_addr_s policy_addr_t
typedef spf_config_s spf_config_t
typedef strbuf_node_s strbuf_node_t
typedef strbuf_s strbuf_t
typedef split_str_node_s split_str_node_t
typedef split_str_s split_str_t
typedef peer_info_s peer_info_t

Enumerations

enum  SPF_BOOL { FALSE = 0, TRUE }
enum  SPF_RESULT {
  SPF_PASS = 0, SPF_NONE, SPF_S_FAIL, SPF_H_FAIL,
  SPF_ERROR, SPF_NEUTRAL, SPF_UNKNOWN, SPF_UNMECH
}
enum  SPF_ACTION { DEFER = 0, TARPIT, ALLOW, REJECT }
enum  SPF_MECHANISM {
  NO_POLICY = 0, VERSION, ALL, INCLUDE,
  A, MX, PTR, IP4,
  IP6, EXISTS, REDIRECT, EXPLAIN,
  DEFAULT, UNMECH
}

Functions

void SPF_dbg_level (int level)
peer_info_tSPF_init (const char *local, const char *rip, const char *expl, const char *tf, const char *guess, u_int32_t use_trust, u_int32_t use_guess)
peer_info_tSPF_close (peer_info_t *peer_info)
SPF_RESULT SPF_policy_main (peer_info_t *peer_info)
SPF_RESULT SPF_policy_main_rec (peer_info_t *peer_info, int rec)
SPF_BOOL SPF_parse_policy (peer_info_t *peer_info, const char *policy)
char * SPF_result (peer_info_t *peer_info)
SPF_BOOL SPF_smtp_from (peer_info_t *peer_info, const char *s)
SPF_BOOL SPF_smtp_helo (peer_info_t *peer_info, const char *s)
char * SPF_build_header (peer_info_t *peer_info)
char * SPF_get_explain (peer_info_t *peer_info)

Variables

spf_config_t confg
u_int8_t spf_rlevel


Define Documentation

#define _SPF_H   1
 

Definition at line 47 of file spf.h.

#define CUR_DOM   256 /* text after @ in email addy for cur query */
 

Definition at line 77 of file spf.h.

#define ENV_HELO   512 /* entire HELO string passed by MTA */
 

Definition at line 81 of file spf.h.

#define ENV_RECV   512 /* Received-SPF: header string */
 

Definition at line 87 of file spf.h.

#define ENV_SENDER   512 /* entire FROM: string passed by MTA */
 

Definition at line 76 of file spf.h.

#define EXPLAIN_S   256 /* change to EXPLAIN when cleaning up */
 

Definition at line 86 of file spf.h.

#define HR_ERROR   "error"
 

Definition at line 99 of file spf.h.

Referenced by SPF_init().

#define HR_H_FAIL   "fail"
 

Definition at line 98 of file spf.h.

Referenced by SPF_init().

#define HR_NEUTRAL   "neutral"
 

Definition at line 100 of file spf.h.

Referenced by SPF_init().

#define HR_NONE   "none"
 

Definition at line 96 of file spf.h.

Referenced by SPF_init().

#define HR_PASS   "pass"
 

Definition at line 95 of file spf.h.

Referenced by SPF_init().

#define HR_S_FAIL   "softfail"
 

Definition at line 97 of file spf.h.

Referenced by SPF_init().

#define HR_UNKNOWN   "unknown"
 

Definition at line 101 of file spf.h.

Referenced by SPF_init().

#define HR_UNMECH   "unknown mechanism"
 

Definition at line 102 of file spf.h.

Referenced by SPF_init().

#define IP_ADDR   17 /* ip of remote peer - DON'T CHANGE FROM 17!! */
 

Definition at line 79 of file spf.h.

Referenced by UTIL_cidr_cmp(), and UTIL_validate_hostname().

#define IP_VER   8 /* ip protocol version */
 

Definition at line 80 of file spf.h.

#define LOCAL_PART   256 /* local-part, text before @ in email addy */
 

Definition at line 75 of file spf.h.

Referenced by SPF_init(), and SPF_smtp_from().

#define MAX_CNAME   5 /* we follow up max CNAMEs */
 

Definition at line 69 of file spf.h.

Referenced by SPF_policy_main_rec().

#define MAX_DEBUG_LEN   1024
 

Definition at line 71 of file spf.h.

Referenced by _printf_dbg(), and UTIL_log_result().

#define MAX_ERROR   96 /* human readable error reason */
 

Definition at line 85 of file spf.h.

Referenced by DNS_query(), SPF_init(), SPF_policy_main_rec(), and UTIL_assoc_prefix().

#define MAX_HEADER   512 /* maximum length of header for prepend */
 

Definition at line 91 of file spf.h.

Referenced by SPF_build_header(), and SPF_result().

#define MAX_HNAME   256 /* hostname of MTA */
 

Definition at line 83 of file spf.h.

#define MAX_MACRO_LEN   1024 /* max length of an expanded macro */
 

Definition at line 73 of file spf.h.

#define MAX_MECHANISM   256 /* maximum length of a mechanism */
 

Definition at line 90 of file spf.h.

Referenced by SPF_init(), and SPF_parse_policy().

#define MAX_PLEN   1024 /* buffer to make UTIL_printf thread safe */
 

Definition at line 74 of file spf.h.

#define MAX_RES_STR   12 /* maximum legnth of a res str eg: "pass" */
 

Definition at line 88 of file spf.h.

#define MAX_RESULT   64 /* human readable SPF result */
 

Definition at line 84 of file spf.h.

#define MAX_SMTP_RES   256 /* maximum length of smtp resonse string */
 

Definition at line 92 of file spf.h.

Referenced by SPF_result().

#define SPF_EXPLAIN
 

Value:

"See http://spf.pobox.com/why.html?sender=%{S}&" \ "ip=%{I}&receiver=%{xR}"

Definition at line 105 of file spf.h.

Referenced by SPF_get_explain(), and SPF_policy_main_rec().

#define SPF_GUESS   "v=spf1 a/24 mx/24 ptr "
 

Definition at line 109 of file spf.h.

Referenced by SPF_init().

#define SPF_TRUSTED   "v=spf1 include:spf.trusted-forwarder.org "
 

Definition at line 112 of file spf.h.

Referenced by SPF_init().

#define SPF_VERSION   1
 

Definition at line 55 of file spf.h.

Referenced by SPF_parse_policy(), and UTIL_log_result().

#define UTC_TIME   22 /* time since epoch */
 

Definition at line 78 of file spf.h.

Referenced by MACRO_process().


Typedef Documentation

typedef struct peer_info_s peer_info_t
 

Referenced by DNS_query(), and SPF_init().

typedef struct policy_addr_s policy_addr_t
 

Referenced by SPF_parse_policy().

typedef enum SPF_ACTION SPF_ACTION
 

typedef enum SPF_BOOL SPF_BOOL
 

Referenced by DNS_ptr_answer(), MACRO_addbuf(), SPF_parse_policy(), SPF_smtp_from(), SPF_smtp_helo(), UTIL_a_cmp(), UTIL_addnode(), UTIL_assoc_prefix(), UTIL_cidr_cmp(), UTIL_is_ip(), UTIL_is_macro(), UTIL_is_spf_delim(), UTIL_is_spf_result(), UTIL_mx_cmp(), UTIL_ptr_cmp(), UTIL_validate_hostname(), and UTIL_validate_ptr().

typedef struct spf_config_s spf_config_t
 

typedef enum SPF_MECHANISM SPF_MECHANISM
 

Referenced by SPF_parse_policy(), and UTIL_get_policy_mech().

typedef enum SPF_RESULT SPF_RESULT
 

Referenced by SPF_parse_policy(), SPF_policy_main(), SPF_policy_main_rec(), and UTIL_get_mech_prefix().

typedef struct spf_result_t spf_result_t
 

typedef struct split_str_node_s split_str_node_t
 

typedef struct split_str_s split_str_t
 

typedef struct strbuf_node_s strbuf_node_t
 

Referenced by MACRO_expand().

typedef struct strbuf_s strbuf_t
 

Referenced by MACRO_expand().


Enumeration Type Documentation

enum SPF_ACTION
 

Enumeration values:
DEFER 
TARPIT 
ALLOW 
REJECT 

Definition at line 160 of file spf.h.

enum SPF_BOOL
 

Enumeration values:
FALSE 
TRUE 

Definition at line 120 of file spf.h.

enum SPF_MECHANISM
 

Enumeration values:
NO_POLICY 
VERSION 
ALL 
INCLUDE 
A 
MX 
PTR 
IP4 
IP6 
EXISTS 
REDIRECT 
EXPLAIN 
DEFAULT 
UNMECH 

Definition at line 175 of file spf.h.

enum SPF_RESULT
 

Enumeration values:
SPF_PASS 
SPF_NONE 
SPF_S_FAIL 
SPF_H_FAIL 
SPF_ERROR 
SPF_NEUTRAL 
SPF_UNKNOWN 
SPF_UNMECH 

Definition at line 140 of file spf.h.


Function Documentation

char* SPF_build_header peer_info_t peer_info  ) 
 

Definition at line 975 of file main.c.

References peer_info_s::cur_dom, peer_info_s::error, peer_info_s::from, peer_info_s::last_m, MAX_HEADER, peer_info_s::mta_hname, peer_info_s::r_ip, peer_info_s::RES, SPF_ERROR, SPF_H_FAIL, SPF_NEUTRAL, SPF_NONE, SPF_PASS, peer_info_s::spf_result, SPF_S_FAIL, SPF_UNKNOWN, SPF_UNMECH, xmalloc, and xvprintf.

peer_info_t* SPF_close peer_info_t peer_info  ) 
 

Definition at line 207 of file main.c.

References peer_info_s::cur_dom, peer_info_s::cur_eaddr, peer_info_s::explain, peer_info_s::from, peer_info_s::guess, peer_info_s::helo, peer_info_s::mta_hname, peer_info_s::ptr_mhost, peer_info_s::r_ip, peer_info_s::r_vhname, peer_info_s::trusted, xeprintf, and xfree.

Referenced by main().

void SPF_dbg_level int  level  ) 
 

char* SPF_get_explain peer_info_t peer_info  ) 
 

Definition at line 944 of file main.c.

References peer_info_s::explain, MACRO_expand(), SPF_EXPLAIN, and xprintf.

peer_info_t* SPF_init const char *  local,
const char *  rip,
const char *  expl,
const char *  tf,
const char *  guess,
u_int32_t  use_trust,
u_int32_t  use_guess
 

Definition at line 69 of file main.c.

References peer_info_s::addr, peer_info_s::ALL, peer_info_s::cur_dom, peer_info_s::cur_eaddr, peer_info_s::ehlo, peer_info_s::error, peer_info_s::explain, FALSE, peer_info_s::from, peer_info_s::guess, HDR_ERROR, HDR_H_FAIL, HDR_NEUTRAL, HDR_NONE, HDR_PASS, HDR_S_FAIL, HDR_UNKNOWN, HDR_UNMECH, peer_info_s::helo, HR_ERROR, HR_H_FAIL, HR_NEUTRAL, HR_NONE, HR_PASS, HR_S_FAIL, HR_UNKNOWN, HR_UNMECH, peer_info_s::ip_ver, peer_info_s::last_m, LOCAL_PART, peer_info_s::local_part, MAX_ERROR, MAX_MECHANISM, peer_info_s::mta_hname, peer_info_s::p, peer_info_t, peer_info_s::ptr_mhost, peer_info_s::r_ip, peer_info_s::r_vhname, SPF_ERROR, SPF_GUESS, SPF_H_FAIL, SPF_NEUTRAL, SPF_NONE, SPF_PASS, peer_info_s::spf_result, SPF_S_FAIL, SPF_TRUSTED, SPF_UNKNOWN, SPF_UNMECH, peer_info_s::spf_ver, TRUE, peer_info_s::trusted, peer_info_s::use_guess, peer_info_s::use_trust, peer_info_s::utc_time, UTIL_assoc_prefix(), xeprintf, xfree, xmalloc, xprintf, xstrndup, and xvprintf.

Referenced by main().

SPF_BOOL SPF_parse_policy peer_info_t peer_info,
const char *  policy
 

Definition at line 375 of file main.c.

References A, peer_info_s::addr, policy_addr_s::addr, peer_info_s::ALL, ALL, peer_info_s::cur_dom, DEFAULT, DNS_query(), EXISTS, peer_info_s::explain, EXPLAIN, FALSE, INCLUDE, IP4, IP6, peer_info_s::last_m, MACRO_expand(), MAX_MECHANISM, MX, NO_POLICY, policy_addr_t, PTR, peer_info_s::r_ip, REDIRECT, peer_info_s::RES, peer_info_s::RES_P, SPF_BOOL, SPF_ERROR, SPF_H_FAIL, SPF_MECHANISM, SPF_NEUTRAL, SPF_NONE, SPF_PASS, SPF_policy_main(), peer_info_s::spf_result, SPF_RESULT, spf_rlevel, SPF_S_FAIL, SPF_UNKNOWN, SPF_UNMECH, peer_info_s::spf_ver, SPF_VERSION, TRUE, UNMECH, UTIL_a_cmp(), UTIL_assoc_prefix(), UTIL_cidr_cmp(), UTIL_expand_ip(), UTIL_get_mech_prefix(), UTIL_get_policy_mech(), UTIL_index(), UTIL_is_macro(), UTIL_is_spf_result(), UTIL_mx_cmp(), UTIL_ptr_cmp(), VERSION, xeprintf, xfree, xprintf, xstrndup, and xvprintf.

Referenced by SPF_policy_main_rec().

SPF_RESULT SPF_policy_main peer_info_t peer_info  ) 
 

Definition at line 247 of file main.c.

References SPF_policy_main_rec(), and SPF_RESULT.

Referenced by main(), and SPF_parse_policy().

SPF_RESULT SPF_policy_main_rec peer_info_t peer_info,
int  rec
 

Definition at line 268 of file main.c.

References peer_info_s::addr, peer_info_s::cur_dom, DNS_query(), peer_info_s::error, peer_info_s::explain, peer_info_s::guess, peer_info_s::last_m, MACRO_expand(), MAX_CNAME, MAX_ERROR, peer_info_s::RES, peer_info_s::rs, SPF_ERROR, SPF_EXPLAIN, SPF_NONE, SPF_parse_policy(), SPF_PASS, SPF_RECURSE, SPF_RESULT, spf_rlevel, SPF_UNKNOWN, TRUE, peer_info_s::trusted, peer_info_s::use_guess, peer_info_s::use_trust, UTIL_assoc_prefix(), UTIL_log_result(), xeprintf, xfree, xprintf, and xvprintf.

Referenced by SPF_policy_main().

char* SPF_result peer_info_t peer_info  ) 
 

Definition at line 886 of file main.c.

References peer_info_s::from, MAX_HEADER, MAX_SMTP_RES, peer_info_s::r_ip, peer_info_s::RES, RES_ERROR, RES_H_FAIL, RES_NEUTRAL, RES_NONE, RES_PASS, RES_S_FAIL, RES_UNKNOWN, RES_UNMECH, SPF_ERROR, SPF_H_FAIL, SPF_NEUTRAL, SPF_NONE, SPF_PASS, SPF_S_FAIL, SPF_UNKNOWN, SPF_UNMECH, xmalloc, and xprintf.

SPF_BOOL SPF_smtp_from peer_info_t peer_info,
const char *  s
 

Definition at line 1077 of file main.c.

References peer_info_s::cur_dom, FALSE, peer_info_s::from, peer_info_s::helo, peer_info_s::local_part, LOCAL_PART, SPF_BOOL, TRUE, xfree, xprintf, xstrdup, and xvprintf.

Referenced by main().

SPF_BOOL SPF_smtp_helo peer_info_t peer_info,
const char *  s
 

Definition at line 1043 of file main.c.

References peer_info_s::ehlo, peer_info_s::helo, SPF_BOOL, xfree, xprintf, and xstrdup.

Referenced by main().


Variable Documentation

spf_config_t confg
 

Definition at line 353 of file spf.h.

Referenced by _printf_dbg(), and main().

u_int8_t spf_rlevel
 

Definition at line 354 of file spf.h.

Referenced by SPF_parse_policy(), SPF_policy_main_rec(), UTIL_assoc_prefix(), UTIL_get_mech_prefix(), and UTIL_log_result().


Generated on Thu Jul 1 14:05:44 2004 for libspf v1.0 by doxygen 1.3.7