30#define LOOKUP_LIMIT 10
34#define SPF_DEFEXP "See http://%{d}/why.html?sender=%{s}&ip=%{i}&receiver=%{r}"
51const static unsigned char urlchr_table[256] =
53 1, 1, 1, 1, 1, 1, 1, 1,
54 1, 1, 1, 1, 1, 1, 1, 1,
55 1, 1, 1, 1, 1, 1, 1, 1,
56 1, 1, 1, 1, 1, 1, 1, 1,
57 1, 0, 1, 1, 0, 1, 1, 0,
58 0, 0, 0, 1, 0, 0, 0, 1,
59 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 1, 1, 1, 1, 1, 1,
61 1, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0,
63 0, 0, 0, 0, 0, 0, 0, 0,
64 0, 0, 0, 1, 1, 1, 1, 0,
65 1, 0, 0, 0, 0, 0, 0, 0,
66 0, 0, 0, 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 1, 1, 1, 1, 1,
70 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
71 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
72 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
73 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
75 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
76 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
77 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
78 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
81#define WSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n')
82#define NXTOK(b, p, a) do { (b) = (p); \
83 while((p) < (a)->len && !WSPACE((a)->s[(p)])) ++(p); \
84 while((p) < (a)->len && WSPACE((a)->s[(p)])) (a)->s[(p)++] = 0; \
89int match_ip4(
unsigned char [4],
int,
char [4]);
90int match_ip6(
unsigned char [16],
int,
char [16]);
94int spf_a(
char *,
char *);
103int spf_query(
const char *,
const char *,
const char *,
const char *,
const int);
int spf_ip6(char *, char *)
spf_ip6 (ip6; ip6:fqdn; ip6:fqdn/56) compares AAAA records for SPF info and client host
int spf_a(char *, char *)
spf_a (a; a:fqdns; a:fqdns/56) compares A + AAAA records for SPF info and client host
int spf_lookup(stralloc *)
spf_lookup calles the actual (recursive) SPF DNS query
int match_ip4(unsigned char[4], int, char[4])
match_ip compares IPv4/IPv6 addreses up to prefix length
int get_prefix(char *)
get_prefix return integer value of prefix length
int spf_exists(char *, char *)
spf_exists (exists; exists:fqdn) simply looks for a A records only for SPF info and client host
int match_ip6(unsigned char[16], int, char[16])
int spf_mx(char *, char *)
spf_mx (mx; mx:domain; mx:domain/24) compares MX records for SPF info and client host
int spf_parse(stralloc *, char *, char *)
spf_parse parses the substructure of the SPF record and calls spf_macros
int spf_ip4(char *, char *)
spf_ip4 (ip4; ip4:fqdn; ip4:fqdn/24) compares A records for SPF info and client host
int spf_mechanism(char *, char *, char *, char *)
spf_mechanism evaluates the provided mechanisms in the SPF record [RFC7208 Sec 5.]
int spf_ptr(char *, char *)
spf_ptr (ptr; ptr:fqdn) compares PTR records from SPF info and client host
int spf_include(char *, char *)
spf_include deals with recursive evaluation of SPF record [RFC7208 Sec. 5.2]
int spf_macros(stralloc *, char *, char *)
spf_macros deals with macros in the SPF specificaton [RFC7208 Sec. 7ff]
int spf_query(const char *, const char *, const char *, const char *, const int)
spf_query prepares the SPF TXT record query
int spf_records(stralloc *, stralloc *)
spf_records get TXT records for domain and extract SPF information
int spf_info(char *, const char *)