s/qmail 4.3.17
Next generation secure email transport
Loading...
Searching...
No Matches
Macros | Functions | Variables
spf.h File Reference
#include "stralloc.h"
#include "ipalloc.h"
Include dependency graph for spf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SPF_INIT   -1
 
#define SPF_EXT   -2 /* x */
 
#define SPF_ME   -3
 
#define SPF_EXHAUST   -4
 
#define SPF_LOOP   -5
 
#define SPF_MULTIRR   -6
 
#define SPF_LOCAL   -7
 
#define SPF_ERROR   -8
 
#define SPF_NOMEM   -9
 
#define SPF_SYNTAX   -10 /* Setup problem */
 
#define SPF_OK   0 /* + Pass */
 
#define SPF_NONE   1 /* o None */
 
#define SPF_UNKNOWN   2 /* u Unknown method */
 
#define SPF_NEUTRAL   3 /* ? Neutral */
 
#define SPF_SOFTFAIL   4 /* ~ Softfail */
 
#define SPF_FAIL   5 /* - Not Permitted */
 
#define SPF_DNSSOFT   6 /* d From DNS; not used */
 
#define LOOKUP_LIMIT   10
 
#define SPF_DEFEXP   "See http://%{d}/why.html?sender=%{s}&ip=%{i}&receiver=%{r}"
 
#define WSPACE(x)   ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n')
 
#define NXTOK(b, p, a)
 

Functions

int match_ip4 (unsigned char[4], int, char[4])
 match_ip compares IPv4/IPv6 addreses up to prefix length
 
int match_ip6 (unsigned char[16], int, char[16])
 
int get_prefix (char *)
 get_prefix return integer value of prefix length
 
int spf_records (stralloc *, stralloc *)
 spf_records get TXT records for domain and extract SPF information
 
int spf_include (char *, char *)
 spf_include deals with recursive evaluation of SPF record [RFC7208 Sec. 5.2]
 
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_mx (char *, char *)
 spf_mx (mx; mx:domain; mx:domain/24) compares MX records for SPF info and client host
 
int spf_ptr (char *, char *)
 spf_ptr (ptr; ptr:fqdn) compares PTR records from SPF info and client host
 
int spf_ip4 (char *, char *)
 spf_ip4 (ip4; ip4:fqdn; ip4:fqdn/24) compares A records for SPF info and client host
 
int spf_ip6 (char *, char *)
 spf_ip6 (ip6; ip6:fqdn; ip6:fqdn/56) compares AAAA records for SPF info and client host
 
int spf_exists (char *, char *)
 spf_exists (exists; exists:fqdn) simply looks for a A records only for SPF info and client host
 
int spf_query (const char *, const char *, const char *, const char *, const int)
 spf_query prepares the SPF TXT record query
 
int spf_lookup (stralloc *)
 spf_lookup calles the actual (recursive) SPF DNS query
 
int spf_mechanism (char *, char *, char *, char *)
 spf_mechanism evaluates the provided mechanisms in the SPF record [RFC7208 Sec 5.]
 
int spf_parse (stralloc *, char *, char *)
 spf_parse parses the substructure of the SPF record and calls spf_macros
 
int spf_macros (stralloc *, char *, char *)
 spf_macros deals with macros in the SPF specificaton [RFC7208 Sec. 7ff]
 
int spf_info (char *, const char *)
 

Variables

int flagip6
 
stralloc spfmf
 
stralloc spfhelo
 
stralloc spfinfo
 
stralloc spfdomain
 
stralloc dnsname
 
stralloc spflocalrules
 
stralloc spfrecord
 
stralloc expdomain
 
stralloc spfexplain
 
stralloc spfexpmsg
 

Macro Definition Documentation

◆ LOOKUP_LIMIT

#define LOOKUP_LIMIT   10

Definition at line 30 of file spf.h.

◆ NXTOK

#define NXTOK (   b,
  p,
 
)
Value:
do { (b) = (p); \
while((p) < (a)->len && !WSPACE((a)->s[(p)])) ++(p); \
while((p) < (a)->len && WSPACE((a)->s[(p)])) (a)->s[(p)++] = 0; \
} while(0)
buffer b
Definition: auto-gid.c:10
void p(char *, char *, int, int, int)
Definition: install.c:49
#define WSPACE(x)
Definition: spf.h:81

Definition at line 82 of file spf.h.

◆ SPF_DEFEXP

#define SPF_DEFEXP   "See http://%{d}/why.html?sender=%{s}&ip=%{i}&receiver=%{r}"

Definition at line 34 of file spf.h.

◆ SPF_DNSSOFT

#define SPF_DNSSOFT   6 /* d From DNS; not used */

Definition at line 28 of file spf.h.

◆ SPF_ERROR

#define SPF_ERROR   -8

Definition at line 16 of file spf.h.

◆ SPF_EXHAUST

#define SPF_EXHAUST   -4

Definition at line 12 of file spf.h.

◆ SPF_EXT

#define SPF_EXT   -2 /* x */

Definition at line 10 of file spf.h.

◆ SPF_FAIL

#define SPF_FAIL   5 /* - Not Permitted */

Definition at line 27 of file spf.h.

◆ SPF_INIT

#define SPF_INIT   -1

Definition at line 9 of file spf.h.

◆ SPF_LOCAL

#define SPF_LOCAL   -7

Definition at line 15 of file spf.h.

◆ SPF_LOOP

#define SPF_LOOP   -5

Definition at line 13 of file spf.h.

◆ SPF_ME

#define SPF_ME   -3

Definition at line 11 of file spf.h.

◆ SPF_MULTIRR

#define SPF_MULTIRR   -6

Definition at line 14 of file spf.h.

◆ SPF_NEUTRAL

#define SPF_NEUTRAL   3 /* ? Neutral */

Definition at line 25 of file spf.h.

◆ SPF_NOMEM

#define SPF_NOMEM   -9

Definition at line 17 of file spf.h.

◆ SPF_NONE

#define SPF_NONE   1 /* o None */

Definition at line 23 of file spf.h.

◆ SPF_OK

#define SPF_OK   0 /* + Pass */

Definition at line 22 of file spf.h.

◆ SPF_SOFTFAIL

#define SPF_SOFTFAIL   4 /* ~ Softfail */

Definition at line 26 of file spf.h.

◆ SPF_SYNTAX

#define SPF_SYNTAX   -10 /* Setup problem */

Definition at line 18 of file spf.h.

◆ SPF_UNKNOWN

#define SPF_UNKNOWN   2 /* u Unknown method */

Definition at line 24 of file spf.h.

◆ WSPACE

#define WSPACE (   x)    ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n')

Definition at line 81 of file spf.h.

Function Documentation

◆ get_prefix()

int get_prefix ( char *  prefix)

get_prefix return integer value of prefix length

Parameters
inputpointer to prefix
Returns
(int) length of prefix

Definition at line 65 of file spfdnsip.c.

Here is the caller graph for this function:

◆ match_ip4()

int match_ip4 ( unsigned char  ip1[4],
int  prefix,
char  ip2[4] 
)

match_ip compares IPv4/IPv6 addreses up to prefix length

Parameters
inputip_address1,prefix length, ip_address2
Returns
1 ok; 0 failure

Definition at line 30 of file spfdnsip.c.

Here is the caller graph for this function:

◆ match_ip6()

int match_ip6 ( unsigned char  ip1[16],
int  prefix,
char  ip2[16] 
)

Definition at line 44 of file spfdnsip.c.

Here is the caller graph for this function:

◆ spf_a()

int spf_a ( char *  spfspec,
char *  prefix 
)

spf_a (a; a:fqdns; a:fqdns/56) compares A + AAAA records for SPF info and client host

Parameters
inputpointer to spfspecification, pointer to prefix
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 145 of file spfdnsip.c.

Here is the call graph for this function:

◆ spf_exists()

int spf_exists ( char *  spfspec,
char *  prefix 
)

spf_exists (exists; exists:fqdn) simply looks for a A records only for SPF info and client host

Parameters
inputpointer to spfspecification, prefix not used
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 391 of file spfdnsip.c.

Here is the call graph for this function:

◆ spf_include()

int spf_include ( char *  spfspec,
char *  prefix 
)

spf_include deals with recursive evaluation of SPF record [RFC7208 Sec. 5.2]

Parameters
inputpointer to included SPF specification; CIDR prefix length
Returns
int r = 1 ok; 0 failure

Definition at line 431 of file spf.c.

Here is the call graph for this function:

◆ spf_info()

int spf_info ( char *  s,
const char *  t 
)

Definition at line 640 of file spf.c.

Here is the caller graph for this function:

◆ spf_ip4()

int spf_ip4 ( char *  spfspec,
char *  prefix 
)

spf_ip4 (ip4; ip4:fqdn; ip4:fqdn/24) compares A records for SPF info and client host

Parameters
inputpointer to spfspecification, pointer to prefix
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 345 of file spfdnsip.c.

Here is the call graph for this function:

◆ spf_ip6()

int spf_ip6 ( char *  spfspec,
char *  prefix 
)

spf_ip6 (ip6; ip6:fqdn; ip6:fqdn/56) compares AAAA records for SPF info and client host

Parameters
inputpointer to spfspecification, pointer to prefix
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 368 of file spfdnsip.c.

Here is the call graph for this function:

◆ spf_lookup()

int spf_lookup ( stralloc *  domain)

spf_lookup calles the actual (recursive) SPF DNS query

Parameters
inputpointer to stralloc domain (fqdn) @input stralloc spflocalrules (if provided – for artificial results) @output stralloc spfdata with RDATA (+ artificial information)
Returns
int r = SPF return code

Definition at line 158 of file spf.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_macros()

int spf_macros ( stralloc *  expand,
char *  macro,
char *  domain 
)

spf_macros deals with macros in the SPF specificaton [RFC7208 Sec. 7ff]

Parameters
inputpointer to SPF macro, pointer to domain output: pointer to stralloc expand(ed information)
Returns
int r = 1 ok; 0 failure

Definition at line 502 of file spf.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_mechanism()

int spf_mechanism ( char *  mechanism,
char *  spfspec,
char *  prefix,
char *  domain 
)

spf_mechanism evaluates the provided mechanisms in the SPF record [RFC7208 Sec 5.]

Parameters
inputpointer to mechanism, SPF specification from record, CIDR prefix length, domain @input stralloc spflocalrules (if provided) @output pointer to spfspec: data evaluated
Returns
int r

Definition at line 391 of file spf.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_mx()

int spf_mx ( char *  spfspec,
char *  prefix 
)

spf_mx (mx; mx:domain; mx:domain/24) compares MX records for SPF info and client host

Parameters
inputpointer to spfspecification, pointer to prefix
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 192 of file spfdnsip.c.

Here is the call graph for this function:

◆ spf_parse()

int spf_parse ( stralloc *  sa,
char *  spfspec,
char *  domain 
)

spf_parse parses the substructure of the SPF record and calls spf_macros

Parameters
inputpointer to SPF specification, pointer to domain output: stralloc sa – @output pointer to spfspec: with found data
Returns
int r = 1 ok; 0 failure

Definition at line 461 of file spf.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_ptr()

int spf_ptr ( char *  spfspec,
char *  prefix 
)

spf_ptr (ptr; ptr:fqdn) compares PTR records from SPF info and client host

Parameters
inputpointer to spfspecification; prefix not used
Returns
SPF_OK, SPF_NONE; SPF_DNSSOFT, SPF_NOMEM

Definition at line 235 of file spfdnsip.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_query()

int spf_query ( const char *  remoteip,
const char *  helo,
const char *  mf,
const char *  local,
const int  flagip 
)

spf_query prepares the SPF TXT record query

Parameters
inputpointer to remoteip, helo, mf, localhost, and flagIP6
Returns
int r = SPF return code

Definition at line 58 of file spf.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spf_records()

int spf_records ( stralloc *  spfrec,
stralloc *  domain 
)

spf_records get TXT records for domain and extract SPF information

Parameters
inputpointer stralloc domain output: pointer to stralloc spf records
Returns
SPF_OK, SPF_NONE; SPF_MULTIRR, SPF_DNSSOFT, SPF_NOMEM

Definition at line 93 of file spfdnsip.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ dnsname

stralloc dnsname
extern

Definition at line 27 of file spf.c.

◆ expdomain

stralloc expdomain
extern

Definition at line 31 of file spf.c.

◆ flagip6

int flagip6
extern

Definition at line 32 of file spf.c.

◆ spfdomain

stralloc spfdomain
extern

◆ spfexplain

stralloc spfexplain
extern

Definition at line 23 of file spf.c.

◆ spfexpmsg

stralloc spfexpmsg
extern

Definition at line 30 of file spf.c.

◆ spfhelo

stralloc spfhelo
extern

Definition at line 26 of file spf.c.

◆ spfinfo

stralloc spfinfo
extern

Definition at line 17 of file spf.c.

◆ spflocalrules

stralloc spflocalrules
extern

Definition at line 22 of file spf.c.

◆ spfmf

stralloc spfmf
extern

Definition at line 25 of file spf.c.

◆ spfrecord

stralloc spfrecord
extern

Definition at line 18 of file spf.c.