1 /*
2 ** Copyright 2004 Double Precision, Inc.
3 ** See COPYING for distribution information.
4 */
5 
6 #ifndef	rfc1035_spf_h
7 #define	rfc1035_spf_h
8 
9 static const char rfc1035_spf_h_rcsid[]="$Id: spf.h,v 1.1 2004/08/15 16:41:02 mrsam Exp $";
10 
11 #include "rfc1035/rfc1035.h"
12 
13 #ifdef  __cplusplus
14 extern "C" {
15 #endif
16 
17 /*
18    An SPF client evaluates an SPF record and produces one of seven
19    results:
20 
21      None: The domain does not publish SPF data.
22 
23      Neutral (?): The SPF client MUST proceed as if a domain did not
24      publish SPF data.  This result occurs if the domain explicitly
25      specifies a "?" value, or if processing "falls off the end" of
26      the SPF record.
27 
28      Pass (+): the message meets the publishing domain's definition of
29      legitimacy.  MTAs proceed to apply local policy and MAY accept or
30      reject the message accordingly.
31 
32      Fail (-): the message does not meet a domain's definition of
33      legitimacy.  MTAs MAY reject the message using a permanent
34      failure reply code.  (Code 550 is RECOMMENDED.  See [RFC2821]
35      section 7.1.)
36 
37      Softfail (~): the message does not meet a domain's strict
38      definition of legitimacy, but the domain cannot confidently state
39      that the message is a forgery.  MTAs SHOULD accept the message
40      but MAY subject it to a higher transaction cost, deeper scrutiny,
41      or an unfavourable score.
42 
43    There are two error conditions, one temporary and one permanent.
44 
45      Error: indicates an error during lookup; an MTA SHOULD reject the
46      message using a transient failure code, such as 450.
47 
48      Unknown: indicates incomplete processing: an MTA MUST proceed as
49      if a domain did not publish SPF data.
50 */
51 
52 #define SPF_NONE 0
53 #define SPF_NEUTRAL '?'
54 #define SPF_PASS '+'
55 #define SPF_FAIL '-'
56 #define SPF_SOFTFAIL '~'
57 #define SPF_ERROR '4'
58 
59 	/* Everything else is SPF_UNKNOWN */
60 #define SPF_UNKNOWN '5'
61 
62 char rfc1035_spf_lookup(const char *mailfrom,
63 			const char *tcpremoteip,
64 			const char *tcpremotehost,
65 			const char *helodomain,
66 			const char *mydomain,
67 			char *errmsg_buf,
68 			size_t errmsg_buf_size);
69 
70 
71 struct rfc1035_spf_info {
72 	const char *mailfrom;
73 	const char *current_domain;
74 	const char *tcpremoteip;
75 	const char *tcpremotehost;
76 	const char *helodomain;
77 	const char *mydomain;
78 	char *errmsg_buf;
79 	size_t errmsg_buf_size;
80 
81 	size_t *lookup_cnt;
82 };
83 
84 #ifdef  __cplusplus
85 }
86 #endif
87 
88 #endif
89