ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libspf/docs/API/doxygen/html/spf_8h-source.html
Revision: 1.1
Committed: Tue Nov 13 00:51:29 2007 UTC (18 years, 10 months ago) by root
Content type: text/html
Branch: MAIN
CVS Tags: HEAD
Log Message:
initial import of libspf-1.0.0-p5 from freebsd ports

File Contents

# User Rev Content
1 root 1.1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2     <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3     <title>libSPF v1.0: spf.h Source File</title>
4     <link href="doxygen.css" rel="stylesheet" type="text/css">
5     </head><body>
6     <!-- Generated by Doxygen 1.3.8 -->
7     <div class="qindex"> <form class="search" action="search.php" method="get">
8     <a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
9     <h1>spf.h</h1><a href="spf_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="comment">/* libspf - Sender Policy Framework library</span>
10     00002 <span class="comment">*</span>
11     00003 <span class="comment">* ANSI C implementation of spf-draft-200405.txt</span>
12     00004 <span class="comment">*</span>
13     00005 <span class="comment">* Author: James Couzens &lt;jcouzens@codeshare.ca&gt;</span>
14     00006 <span class="comment">* Author: Sean Comeau &lt;scomeau@obscurity.org&gt;</span>
15     00007 <span class="comment">*</span>
16     00008 <span class="comment">* FILE: spf.h</span>
17     00009 <span class="comment">* DESC: main library header file</span>
18     00010 <span class="comment">*</span>
19     00011 <span class="comment">* License:</span>
20     00012 <span class="comment">*</span>
21     00013 <span class="comment">* The libspf Software License, Version 1.0</span>
22     00014 <span class="comment">*</span>
23     00015 <span class="comment">* Copyright (c) 2004 James Couzens &amp; Sean Comeau All rights</span>
24     00016 <span class="comment">* reserved.</span>
25     00017 <span class="comment">*</span>
26     00018 <span class="comment">* Redistribution and use in source and binary forms, with or without</span>
27     00019 <span class="comment">* modification, are permitted provided that the following conditions</span>
28     00020 <span class="comment">* are met:</span>
29     00021 <span class="comment">*</span>
30     00022 <span class="comment">* 1. Redistributions of source code must retain the above copyright</span>
31     00023 <span class="comment">* notice, this list of conditions and the following disclaimer.</span>
32     00024 <span class="comment">*</span>
33     00025 <span class="comment">* 2. Redistributions in binary form must reproduce the above copyright</span>
34     00026 <span class="comment">* notice, this list of conditions and the following disclaimer in</span>
35     00027 <span class="comment">* the documentation and/or other materials provided with the</span>
36     00028 <span class="comment">* distribution.</span>
37     00029 <span class="comment">*</span>
38     00030 <span class="comment">* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</span>
39     00031 <span class="comment">* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</span>
40     00032 <span class="comment">* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</span>
41     00033 <span class="comment">* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS MAKING USE OF THIS LICESEN</span>
42     00034 <span class="comment">* OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
43     00035 <span class="comment">* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
44     00036 <span class="comment">* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</span>
45     00037 <span class="comment">* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span>
46     00038 <span class="comment">* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</span>
47     00039 <span class="comment">* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</span>
48     00040 <span class="comment">* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
49     00041 <span class="comment">* SUCH DAMAGE.</span>
50     00042 <span class="comment">*</span>
51     00043 <span class="comment">*/</span>
52     00044
53     00045
54     00046 <span class="preprocessor">#ifndef _SPF_H</span>
55     <a name="l00047"></a><a class="code" href="spf_8h.html#a0">00047</a> <span class="preprocessor"></span><span class="preprocessor">#define _SPF_H 1</span>
56     00048 <span class="preprocessor"></span>
57     00049 <span class="preprocessor">#include &lt;sys/types.h&gt;</span> <span class="comment">/* typedefs */</span>
58     00050 <span class="preprocessor">#include &lt;netinet/in.h&gt;</span> <span class="comment">/* in_addr struct fBSD */</span>
59     00051 <span class="preprocessor">#include &lt;arpa/inet.h&gt;</span> <span class="comment">/* in_addr struct */</span>
60     00052
61     00053 __BEGIN_DECLS
62     00054
63     00055
64     00056 <span class="comment">/* spf protocol version we support */</span>
65     <a name="l00057"></a><a class="code" href="spf_8h.html#a1">00057</a> <span class="preprocessor">#define SPF_VERSION 1</span>
66     00058 <span class="preprocessor"></span>
67     00059 <span class="comment">/*</span>
68     00060 <span class="comment">* For reference purposes commented out are the constants based on</span>
69     00061 <span class="comment">* RFC 883, RFC 1034, RFC 1035.</span>
70     00062 <span class="comment">*</span>
71     00063 <span class="comment">* #define PACKETSZ 512 max response packet size</span>
72     00064 <span class="comment">* #define MAXDNAME 1025 max uncompressed IN_TXT record</span>
73     00065 <span class="comment">* #define MAXCDNAME 255 max compressed IN_TXT record</span>
74     00066 <span class="comment">*</span>
75     00067 <span class="comment">*/</span>
76     00068
77     <a name="l00069"></a><a class="code" href="spf_8h.html#a2">00069</a> <span class="preprocessor">#define SPF_MAX_CNAME 5 </span><span class="comment">/* we follow up max CNAMEs */</span>
78     <a name="l00070"></a><a class="code" href="spf_8h.html#a3">00070</a> <span class="preprocessor">#define SPF_MAX_DEBUG 2048 </span><span class="comment">/* maximum for debug code to malloc */</span>
79     <a name="l00071"></a><a class="code" href="spf_8h.html#a4">00071</a> <span class="preprocessor">#define SPF_MAX_MACRO 1024 </span><span class="comment">/* max length of an expanded macro */</span>
80     <a name="l00072"></a><a class="code" href="spf_8h.html#a5">00072</a> <span class="preprocessor">#define SPF_MAX_STR 4096 </span><span class="comment">/* max length of any dynamically allocated string */</span>
81     <a name="l00073"></a><a class="code" href="spf_8h.html#a6">00073</a> <span class="preprocessor">#define SPF_MAX_DELIM 255 </span><span class="comment">/* used by UTIL_count_delim() */</span>
82     00074
83     <a name="l00075"></a><a class="code" href="spf_8h.html#a7">00075</a> <span class="preprocessor">#define SPF_MAX_LOCAL_PART 256 </span><span class="comment">/* local-part, text before @ in email addy */</span>
84     <a name="l00076"></a><a class="code" href="spf_8h.html#a8">00076</a> <span class="preprocessor">#define SPF_MAX_ENV_SENDER 512 </span><span class="comment">/* entire FROM: string passed by MTA */</span>
85     <a name="l00077"></a><a class="code" href="spf_8h.html#a9">00077</a> <span class="preprocessor">#define SPF_MAX_CUR_DOM 256 </span><span class="comment">/* text after @ in email addy for cur query */</span>
86     <a name="l00078"></a><a class="code" href="spf_8h.html#a10">00078</a> <span class="preprocessor">#define SPF_MAX_UTC_TIME 22 </span><span class="comment">/* time since epoch */</span>
87     <a name="l00079"></a><a class="code" href="spf_8h.html#a11">00079</a> <span class="preprocessor">#define SPF_MAX_IP_ADDR 17 </span><span class="comment">/* ip of remote peer - DON'T CHANGE FROM 17!! */</span>
88     <a name="l00080"></a><a class="code" href="spf_8h.html#a12">00080</a> <span class="preprocessor">#define SPF_MAX_IP_VER 8 </span><span class="comment">/* ip protocol version */</span>
89     <a name="l00081"></a><a class="code" href="spf_8h.html#a13">00081</a> <span class="preprocessor">#define SPF_MAX_ENV_HELO 512 </span><span class="comment">/* entire HELO string passed by MTA */</span>
90     00082
91     <a name="l00083"></a><a class="code" href="spf_8h.html#a14">00083</a> <span class="preprocessor">#define SPF_MAX_HNAME 256 </span><span class="comment">/* hostname of MTA */</span>
92     <a name="l00084"></a><a class="code" href="spf_8h.html#a15">00084</a> <span class="preprocessor">#define SPF_MAX_RESULT 64 </span><span class="comment">/* human readable SPF result */</span>
93     <a name="l00085"></a><a class="code" href="spf_8h.html#a16">00085</a> <span class="preprocessor">#define SPF_MAX_ERROR 96 </span><span class="comment">/* human readable error reason */</span>
94     <a name="l00086"></a><a class="code" href="spf_8h.html#a17">00086</a> <span class="preprocessor">#define SPF_MAX_EXPLAIN_S 256 </span><span class="comment">/* change to EXPLAIN when cleaning up */</span>
95     <a name="l00087"></a><a class="code" href="spf_8h.html#a18">00087</a> <span class="preprocessor">#define SPF_MAX_ENV_RECV 512 </span><span class="comment">/* maximum length of RFC2821 header string */</span>
96     <a name="l00088"></a><a class="code" href="spf_8h.html#a19">00088</a> <span class="preprocessor">#define SPF_MAX_RES_STR 12 </span><span class="comment">/* maximum legnth of a res str eg: "pass" */</span>
97     00089
98     <a name="l00090"></a><a class="code" href="spf_8h.html#a20">00090</a> <span class="preprocessor">#define SPF_MAX_MECHANISM 256 </span><span class="comment">/* maximum length of a mechanism */</span>
99     <a name="l00091"></a><a class="code" href="spf_8h.html#a21">00091</a> <span class="preprocessor">#define SPF_MAX_HEADER 512 </span><span class="comment">/* maximum length of header for prepend */</span>
100     <a name="l00092"></a><a class="code" href="spf_8h.html#a22">00092</a> <span class="preprocessor">#define SPF_MAX_SMTP_RES 256 </span><span class="comment">/* maximum length of smtp resonse string */</span>
101     00093
102     00094 <span class="comment">/* human readable string equivalents of spf responses */</span>
103     <a name="l00095"></a><a class="code" href="spf_8h.html#a23">00095</a> <span class="preprocessor">#define HR_RFC2822 "Received-SPF: "</span>
104     <a name="l00096"></a><a class="code" href="spf_8h.html#a24">00096</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_PASS "pass"</span>
105     <a name="l00097"></a><a class="code" href="spf_8h.html#a25">00097</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_NONE "none"</span>
106     <a name="l00098"></a><a class="code" href="spf_8h.html#a26">00098</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_S_FAIL "softfail"</span>
107     <a name="l00099"></a><a class="code" href="spf_8h.html#a27">00099</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_H_FAIL "fail"</span>
108     <a name="l00100"></a><a class="code" href="spf_8h.html#a28">00100</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_ERROR "error"</span>
109     <a name="l00101"></a><a class="code" href="spf_8h.html#a29">00101</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_NEUTRAL "neutral"</span>
110     <a name="l00102"></a><a class="code" href="spf_8h.html#a30">00102</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_UNKNOWN "unknown"</span>
111     <a name="l00103"></a><a class="code" href="spf_8h.html#a31">00103</a> <span class="preprocessor"></span><span class="preprocessor">#define HR_UNMECH "unknown mechanism"</span>
112     00104 <span class="preprocessor"></span>
113     00105 <span class="comment">/* default explanation */</span>
114     <a name="l00106"></a><a class="code" href="spf_8h.html#a32">00106</a> <span class="preprocessor">#define SPF_EXPLAIN "See http://spf.pobox.com/why.html?sender=%{S}&amp;" \</span>
115     00107 <span class="preprocessor"> "ip=%{I}&amp;receiver=%{xR}"</span>
116     00108 <span class="preprocessor"></span>
117     00109 <span class="comment">/* default best guess */</span>
118     <a name="l00110"></a><a class="code" href="spf_8h.html#a33">00110</a> <span class="preprocessor">#define SPF_GUESS "v=spf1 a/24 mx/24 ptr "</span>
119     00111 <span class="preprocessor"></span>
120     00112 <span class="comment">/* trusted forwarder */</span>
121     <a name="l00113"></a><a class="code" href="spf_8h.html#a34">00113</a> <span class="preprocessor">#define SPF_TRUSTED "v=spf1 include:spf.trusted-forwarder.org "</span>
122     00114 <span class="preprocessor"></span>
123     00115
124     00116 <span class="comment">/* SPF_BOOL</span>
125     00117 <span class="comment">*</span>
126     00118 <span class="comment">* Our own internal boolean enumeration, simple true or false.</span>
127     00119 <span class="comment">*</span>
128     00120 <span class="comment">* Sendmail has issues because it makes use of SPF_FALSE and SPF_TRUE</span>
129     00121 <span class="comment">* Simple way around it iis to simply check and see if they are</span>
130     00122 <span class="comment">* defined or not since we're declaring this enumeration</span>
131     00123 <span class="comment">* globally.</span>
132     00124 <span class="comment">*</span>
133     00125 <span class="comment">* A more graceful fix has been implemented in libspf 3.0 where</span>
134     00126 <span class="comment">* we now make use of SPF_SPF_TRUE and SPF_SPF_FALSE to steer clear of</span>
135     00127 <span class="comment">* problems such as this elsewhere.</span>
136     00128 <span class="comment">*</span>
137     00129 <span class="comment">*/</span>
138     00130
139     <a name="l00131"></a><a class="code" href="spf_8h.html#a87">00131</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a>
140     00132 {
141     00133 <a class="code" href="spf_8h.html#a87a49">SPF_FALSE</a> = 0,
142     00134 <a class="code" href="spf_8h.html#a87a50">SPF_TRUE</a>
143     00135 } <a class="code" href="spf_8h.html#a35">SPF_BOOL</a>;
144     00136
145     00137
146     00138 <span class="comment">/* SPF_RESULT</span>
147     00139 <span class="comment">*</span>
148     00140 <span class="comment">* Error codes representing the result of an SPF policy examination</span>
149     00141 <span class="comment">*</span>
150     00142 <span class="comment">* sucessful parse (some match was made) (+all)</span>
151     00143 <span class="comment">* not participating (no SPF/TXT records)</span>
152     00144 <span class="comment">* ~all</span>
153     00145 <span class="comment">* failed parse (no match made) (-all)</span>
154     00146 <span class="comment">* dns problem / error</span>
155     00147 <span class="comment">* ?all</span>
156     00148 <span class="comment">* permanent parsing error during record examination</span>
157     00149 <span class="comment">*</span>
158     00150 <span class="comment">*/</span>
159     <a name="l00151"></a><a class="code" href="spf_8h.html#a88">00151</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a>
160     00152 {
161     00153 <a class="code" href="spf_8h.html#a88a51">SPF_PASS</a> = 0, <span class="comment">/* + */</span>
162     00154 <a class="code" href="spf_8h.html#a88a52">SPF_NONE</a>,
163     00155 <a class="code" href="spf_8h.html#a88a53">SPF_S_FAIL</a>, <span class="comment">/* ~ */</span>
164     00156 <a class="code" href="spf_8h.html#a88a54">SPF_H_FAIL</a>, <span class="comment">/* - */</span>
165     00157 <a class="code" href="spf_8h.html#a88a55">SPF_ERROR</a>,
166     00158 <a class="code" href="spf_8h.html#a88a56">SPF_NEUTRAL</a>, <span class="comment">/* ? */</span>
167     00159 <a class="code" href="spf_8h.html#a88a57">SPF_UNKNOWN</a>,
168     00160 <a class="code" href="spf_8h.html#a88a58">SPF_UNMECH</a> <span class="comment">/* unknown mechanism */</span>
169     00161 } <a class="code" href="spf_8h.html#a36">SPF_RESULT</a>;
170     00162
171     00163
172     00164 <span class="comment">/* SPF_ACTION</span>
173     00165 <span class="comment">*</span>
174     00166 <span class="comment">* Error codes representing the the action to be taken as a result</span>
175     00167 <span class="comment">* of the response the library was able to obtain whilst trying to</span>
176     00168 <span class="comment">* obtain or examin an SPF policy</span>
177     00169 <span class="comment">*</span>
178     00170 <span class="comment">*/</span>
179     <a name="l00171"></a><a class="code" href="spf_8h.html#a89">00171</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="spf_8h.html#a37">SPF_ACTION</a>
180     00172 {
181     00173 <a class="code" href="spf_8h.html#a89a59">DEFER</a> = 0,
182     00174 <a class="code" href="spf_8h.html#a89a60">TARPIT</a>,
183     00175 <a class="code" href="spf_8h.html#a89a61">ALLOW</a>,
184     00176 <a class="code" href="spf_8h.html#a89a62">REJECT</a>
185     00177 } <a class="code" href="spf_8h.html#a37">SPF_ACTION</a>;
186     00178
187     00179
188     00180 <span class="comment">/* SPF_MECHANISM</span>
189     00181 <span class="comment">*</span>
190     00182 <span class="comment">* Error codes representing the various mechanism types employed</span>
191     00183 <span class="comment">* as defined in the RFC</span>
192     00184 <span class="comment">*</span>
193     00185 <span class="comment">*/</span>
194     00186 <span class="preprocessor">#undef VERSION </span><span class="comment">/* autoconf */</span>
195     <a name="l00187"></a><a class="code" href="spf_8h.html#a90">00187</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="spf_8h.html#a38">SPF_MECHANISM</a>
196     00188 {
197     00189 <a class="code" href="spf_8h.html#a90a63">NO_POLICY</a> = 0,
198     00190 <a class="code" href="spf_8h.html#a90a64">VERSION</a>,
199     00191 <a class="code" href="spf_8h.html#a90a65">ALL</a>,
200     00192 <a class="code" href="spf_8h.html#a90a66">INCLUDE</a>,
201     00193 <a class="code" href="spf_8h.html#a90a67">A</a>,
202     00194 <a class="code" href="spf_8h.html#a90a68">MX</a>,
203     00195 <a class="code" href="spf_8h.html#a90a69">PTR</a>,
204     00196 <a class="code" href="spf_8h.html#a90a70">IP4</a>,
205     00197 <a class="code" href="spf_8h.html#a90a71">IP6</a>,
206     00198 <a class="code" href="spf_8h.html#a90a72">EXISTS</a>,
207     00199 <a class="code" href="spf_8h.html#a90a73">REDIRECT</a>,
208     00200 <a class="code" href="spf_8h.html#a90a74">EXPLAIN</a>,
209     00201 <a class="code" href="spf_8h.html#a90a75">DEFAULT</a>, <span class="comment">/* this is OLD school for early adopters = ~,?,+,- */</span>
210     00202 <a class="code" href="spf_8h.html#a90a76">UNMECH</a>
211     00203 } <a class="code" href="spf_8h.html#a38">SPF_MECHANISM</a>;
212     00204
213     00205
214     00206 <span class="comment">/* spf_result_t</span>
215     00207 <span class="comment">*</span>
216     00208 <span class="comment">* Storage container used to store the result of an SPF parse.</span>
217     00209 <span class="comment">*</span>
218     00210 <span class="comment">*/</span>
219     <a name="l00211"></a><a class="code" href="structspf__result__t.html">00211</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structspf__result__t.html">spf_result_t</a>
220     00212 {
221     <a name="l00213"></a><a class="code" href="structspf__result__t.html#o0">00213</a> size_t <a class="code" href="structspf__result__t.html#o0">sl</a>; <span class="comment">/* spf result string length */</span>
222     <a name="l00214"></a><a class="code" href="structspf__result__t.html#o1">00214</a> <span class="keywordtype">char</span> <a class="code" href="structspf__result__t.html#o1">s</a>[32]; <span class="comment">/* spf result type string */</span>
223     <a name="l00215"></a><a class="code" href="structspf__result__t.html#o2">00215</a> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="structspf__result__t.html#o2">i</a>; <span class="comment">/* spf result type */</span>
224     <a name="l00216"></a><a class="code" href="structspf__result__t.html#o3">00216</a> size_t <a class="code" href="structspf__result__t.html#o3">hl</a>; <span class="comment">/* length of header string */</span>
225     <a name="l00217"></a><a class="code" href="structspf__result__t.html#o4">00217</a> <span class="keywordtype">char</span> <a class="code" href="structspf__result__t.html#o4">h</a>[512]; <span class="comment">/* Received-SPF: header string */</span>
226     <a name="l00218"></a><a class="code" href="structspf__result__t.html#o5">00218</a> <span class="keywordtype">char</span> <a class="code" href="structspf__result__t.html#o5">p</a>; <span class="comment">/* prefix identifier */</span>
227     00219 } <a class="code" href="structspf__result__t.html">spf_result_t</a>;
228     00220
229     00221
230     00222 <span class="comment">/* policy_addr_t</span>
231     00223 <span class="comment">*</span>
232     00224 <span class="comment">* Storage container used to store parsed out ip addresses in their</span>
233     00225 <span class="comment">* binary format (in_addr struct) and an unsigned integer containing</span>
234     00226 <span class="comment">* the netmask</span>
235     00227 <span class="comment">*</span>
236     00228 <span class="comment">*/</span>
237     <a name="l00229"></a><a class="code" href="structpolicy__addr__s.html">00229</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structpolicy__addr__s.html">policy_addr_s</a>
238     00230 {
239     <a name="l00231"></a><a class="code" href="structpolicy__addr__s.html#o0">00231</a> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="structpolicy__addr__s.html#o0">prefix</a>; <span class="comment">/* spf prefix (-,+,~,?) */</span>
240     <a name="l00232"></a><a class="code" href="structpolicy__addr__s.html#o1">00232</a> int8_t <a class="code" href="structpolicy__addr__s.html#o1">cidr</a>; <span class="comment">/* address cidr length */</span>
241     <a name="l00233"></a><a class="code" href="structpolicy__addr__s.html#o2">00233</a> <span class="keyword">struct </span>in_addr addr; <span class="comment">/* in_addr struct (unsigned long) */</span>
242     00234 } <a class="code" href="structpolicy__addr__s.html">policy_addr_t</a>;
243     00235
244     00236
245     00237 <span class="comment">/* spf_config_t</span>
246     00238 <span class="comment">*</span>
247     00239 <span class="comment">* Global config structure</span>
248     00240 <span class="comment">*</span>
249     00241 <span class="comment">*/</span>
250     <a name="l00242"></a><a class="code" href="structspf__config__s.html">00242</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structspf__config__s.html">spf_config_s</a>
251     00243 {
252     <a name="l00244"></a><a class="code" href="structspf__config__s.html#o0">00244</a> <span class="keywordtype">int</span> <a class="code" href="structspf__config__s.html#o0">level</a>; <span class="comment">/* debug level bit */</span>
253     00245 } <a class="code" href="structspf__config__s.html">spf_config_t</a>;
254     00246
255     00247
256     00248 <span class="comment">/* split_str_node_t</span>
257     00249 <span class="comment">*</span>
258     00250 <span class="comment">* This structure is used to store where the head and tail are when</span>
259     00251 <span class="comment">* creating a list of split_str_node_t structures.</span>
260     00252 <span class="comment">*</span>
261     00253 <span class="comment">*/</span>
262     <a name="l00254"></a><a class="code" href="structstrbuf__node__s.html">00254</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structstrbuf__node__s.html">strbuf_node_s</a>
263     00255 {
264     <a name="l00256"></a><a class="code" href="structstrbuf__node__s.html#o0">00256</a> size_t <a class="code" href="structstrbuf__node__s.html#o0">len</a>; <span class="comment">/* length of string */</span>
265     <a name="l00257"></a><a class="code" href="structstrbuf__node__s.html#o1">00257</a> <span class="keywordtype">char</span> *<a class="code" href="structstrbuf__node__s.html#o1">s</a>; <span class="comment">/* expanded string macro */</span>
266     <a name="l00258"></a><a class="code" href="structstrbuf__node__s.html#o2">00258</a> <span class="keyword">struct </span><a class="code" href="structstrbuf__node__s.html">strbuf_node_s</a> *<a class="code" href="structstrbuf__node__s.html#o2">next</a>; <span class="comment">/* pointer to next node */</span>
267     00259 } <a class="code" href="structstrbuf__node__s.html">strbuf_node_t</a>;
268     00260
269     00261
270     00262 <span class="comment">/* strbuf_t</span>
271     00263 <span class="comment">*</span>
272     00264 <span class="comment">* This structure is used exclusively by marco.c functions and is used</span>
273     00265 <span class="comment">* to store macros during parsing.</span>
274     00266 <span class="comment">*</span>
275     00267 <span class="comment">*/</span>
276     <a name="l00268"></a><a class="code" href="structstrbuf__s.html">00268</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structstrbuf__s.html">strbuf_s</a>
277     00269 {
278     <a name="l00270"></a><a class="code" href="structstrbuf__s.html#o0">00270</a> <a class="code" href="structstrbuf__node__s.html">strbuf_node_t</a> *<a class="code" href="structstrbuf__s.html#o0">head</a>; <span class="comment">/* head node */</span>
279     <a name="l00271"></a><a class="code" href="structstrbuf__s.html#o1">00271</a> u_int8_t <a class="code" href="structstrbuf__s.html#o1">elements</a>; <span class="comment">/* number of nodes in list */</span>
280     00272 } <a class="code" href="structstrbuf__s.html">strbuf_t</a>;
281     00273
282     00274
283     00275 <span class="comment">/* split_str_node_t</span>
284     00276 <span class="comment">*</span>
285     00277 <span class="comment">* This structure is used to store where the head and tail are when</span>
286     00278 <span class="comment">* creating a list of split_str_node_t structures.</span>
287     00279 <span class="comment">*</span>
288     00280 <span class="comment">*/</span>
289     <a name="l00281"></a><a class="code" href="structsplit__str__node__s.html">00281</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structsplit__str__node__s.html">split_str_node_s</a>
290     00282 {
291     <a name="l00283"></a><a class="code" href="structsplit__str__node__s.html#o0">00283</a> size_t <a class="code" href="structsplit__str__node__s.html#o0">len</a>; <span class="comment">/* length of string */</span>
292     <a name="l00284"></a><a class="code" href="structsplit__str__node__s.html#o1">00284</a> <span class="keywordtype">char</span> *<a class="code" href="structsplit__str__node__s.html#o1">s</a>; <span class="comment">/* expanded string macro */</span>
293     <a name="l00285"></a><a class="code" href="structsplit__str__node__s.html#o2">00285</a> <span class="keyword">struct </span><a class="code" href="structsplit__str__node__s.html">split_str_node_s</a> *<a class="code" href="structsplit__str__node__s.html#o2">next</a>; <span class="comment">/* pointer to next node */</span>
294     00286 } <a class="code" href="structsplit__str__node__s.html">split_str_node_t</a>;
295     00287
296     00288
297     00289 <span class="comment">/* split_str_t</span>
298     00290 <span class="comment">*</span>
299     00291 <span class="comment">* This structure is used exclusively by the UTIL_reverse function and is</span>
300     00292 <span class="comment">* used to reverse a string using a semi-arbitrary delimiter (see</span>
301     00293 <span class="comment">* UTIL_is_spf_delim for valid delimiters, or the SPF RFC)</span>
302     00294 <span class="comment">*/</span>
303     <a name="l00295"></a><a class="code" href="structsplit__str__s.html">00295</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structsplit__str__s.html">split_str_s</a>
304     00296 {
305     <a name="l00297"></a><a class="code" href="structsplit__str__s.html#o0">00297</a> <a class="code" href="structsplit__str__node__s.html">split_str_node_t</a> *<a class="code" href="structsplit__str__s.html#o0">head</a>; <span class="comment">/* head node */</span>
306     <a name="l00298"></a><a class="code" href="structsplit__str__s.html#o1">00298</a> <a class="code" href="structsplit__str__node__s.html">split_str_node_t</a> *<a class="code" href="structsplit__str__s.html#o1">tail</a>; <span class="comment">/* tail node */</span>
307     <a name="l00299"></a><a class="code" href="structsplit__str__s.html#o2">00299</a> <span class="keywordtype">int</span> <a class="code" href="structsplit__str__s.html#o2">elements</a>; <span class="comment">/* number of nodes in list */</span>
308     00300 } <a class="code" href="structsplit__str__s.html">split_str_t</a>;
309     00301
310     00302
311     00303 <span class="comment">/* peer_info_t</span>
312     00304 <span class="comment">*</span>
313     00305 <span class="comment">* Used to store information about the connected peer. Only one of</span>
314     00306 <span class="comment">* SMTP protocol specific three strings will be necessarily be</span>
315     00307 <span class="comment">* populated in the following order of precedence: FROM, EHLO, HELO.</span>
316     00308 <span class="comment">*</span>
317     00309 <span class="comment">* The ip_ver string will contain 'in-addr' if the connecting peer</span>
318     00310 <span class="comment">* is using IPv4, or 'ip6' if the connect</span>
319     00311 <span class="comment">*</span>
320     00312 <span class="comment">* Various political and technical pressures have recently led to</span>
321     00313 <span class="comment">* the deprecation of the IP6.INT name space in favour of IP6.ARPA.</span>
322     00314 <span class="comment">* This makes IPv6 PTR data management difficult, since interim</span>
323     00315 <span class="comment">* clients will search IP6.INT while standard clients will search</span>
324     00316 <span class="comment">* IP6.ARPA. We present a simple method based on DNAME RR's</span>
325     00317 <span class="comment">* (see [RFC2672]) and ISC BIND9 whereby zone information can be</span>
326     00318 <span class="comment">* managed in a single location and then made visible in two</span>
327     00319 <span class="comment">* namespaces. (http://www.isc.org/tn/isc-tn-2002-1.html)</span>
328     00320 <span class="comment">*</span>
329     00321 <span class="comment">* RFC 937 (POP) states: The maximum length of a command line is 512</span>
330     00322 <span class="comment">* characters (including the command word and the CRLF).</span>
331     00323 <span class="comment">* POLICY_MATCH = SPF_TRUE</span>
332     00324 <span class="comment">*</span>
333     00325 <span class="comment">* Note: from can be removed and just work on local_part@cur_dom</span>
334     00326 <span class="comment">*</span>
335     00327 <span class="comment">*/</span>
336     <a name="l00328"></a><a class="code" href="structpeer__info__s.html">00328</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structpeer__info__s.html">peer_info_s</a>
337     00329 {
338     <a name="l00330"></a><a class="code" href="structpeer__info__s.html#o0">00330</a> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="structpeer__info__s.html#o0">ALL</a>; <span class="comment">/* Was 'all' mechanism parsed */</span>
339     00331
340     <a name="l00332"></a><a class="code" href="structpeer__info__s.html#o1">00332</a> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="structpeer__info__s.html#o1">RES</a>; <span class="comment">/* SPF error codes for result */</span>
341     <a name="l00333"></a><a class="code" href="structpeer__info__s.html#o2">00333</a> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="structpeer__info__s.html#o2">RES_P</a>; <span class="comment">/* prefix behaviour */</span>
342     00334
343     <a name="l00335"></a><a class="code" href="structpeer__info__s.html#o3">00335</a> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="structpeer__info__s.html#o3">use_trust</a>; <span class="comment">/* T / F trustedfwder */</span>
344     <a name="l00336"></a><a class="code" href="structpeer__info__s.html#o4">00336</a> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="structpeer__info__s.html#o4">use_guess</a>; <span class="comment">/* T / F best guess */</span>
345     00337
346     <a name="l00338"></a><a class="code" href="structpeer__info__s.html#o5">00338</a> u_int8_t <a class="code" href="structpeer__info__s.html#o5">spf_ver</a>; <span class="comment">/* version of SPF */</span>
347     00339
348     <a name="l00340"></a><a class="code" href="structpeer__info__s.html#o6">00340</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o6">p</a>; <span class="comment">/* prefix from all mechanism */</span>
349     <a name="l00341"></a><a class="code" href="structpeer__info__s.html#o7">00341</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o7">rs</a>; <span class="comment">/* ptr str result of SPF query */</span>
350     <a name="l00342"></a><a class="code" href="structpeer__info__s.html#o8">00342</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o8">helo</a>; <span class="comment">/* HELO string */</span>
351     <a name="l00343"></a><a class="code" href="structpeer__info__s.html#o9">00343</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o9">ehlo</a>; <span class="comment">/* pointer to HELO string */</span>
352     <a name="l00344"></a><a class="code" href="structpeer__info__s.html#o10">00344</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o10">from</a>; <span class="comment">/* FROM string */</span>
353     <a name="l00345"></a><a class="code" href="structpeer__info__s.html#o11">00345</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o11">explain</a>; <span class="comment">/* Result of an explain query */</span>
354     <a name="l00346"></a><a class="code" href="structpeer__info__s.html#o12">00346</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o12">guess</a>; <span class="comment">/* Query if result is TF fails */</span>
355     <a name="l00347"></a><a class="code" href="structpeer__info__s.html#o13">00347</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o13">trusted</a>; <span class="comment">/* Query if primary result is none */</span>
356     <a name="l00348"></a><a class="code" href="structpeer__info__s.html#o14">00348</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o14">ptr_mhost</a>; <span class="comment">/* validate against during ptr mech */</span>
357     <a name="l00349"></a><a class="code" href="structpeer__info__s.html#o15">00349</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o15">current_domain</a>; <span class="comment">/* @domain of the current query */</span>
358     <a name="l00350"></a><a class="code" href="structpeer__info__s.html#o16">00350</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o16">mta_hname</a>; <span class="comment">/* ptr to MTA hname eg: mail.foo.org */</span>
359     <a name="l00351"></a><a class="code" href="structpeer__info__s.html#o17">00351</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o17">r_ip</a>; <span class="comment">/* pointer to remote ip from MTA */</span>
360     <a name="l00352"></a><a class="code" href="structpeer__info__s.html#o18">00352</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o18">r_vhname</a>; <span class="comment">/* validated hostname of remotehost */</span>
361     <a name="l00353"></a><a class="code" href="structpeer__info__s.html#o19">00353</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o19">cur_eaddr</a>; <span class="comment">/* current email address */</span>
362     00354
363     <a name="l00355"></a><a class="code" href="structpeer__info__s.html#o20">00355</a> <span class="keywordtype">char</span> <a class="code" href="structpeer__info__s.html#o20">ip_ver</a>[<a class="code" href="spf_8h.html#a12">SPF_MAX_IP_VER</a>]; <span class="comment">/* IP Protocol Version */</span>
364     <a name="l00356"></a><a class="code" href="structpeer__info__s.html#o21">00356</a> <span class="keywordtype">char</span> <a class="code" href="structpeer__info__s.html#o21">local_part</a>[<a class="code" href="spf_8h.html#a7">SPF_MAX_LOCAL_PART</a>]; <span class="comment">/* local part of address (user) */</span>
365     <a name="l00357"></a><a class="code" href="structpeer__info__s.html#o22">00357</a> <span class="keywordtype">char</span> <a class="code" href="structpeer__info__s.html#o22">utc_time</a>[<a class="code" href="spf_8h.html#a10">SPF_MAX_UTC_TIME</a>]; <span class="comment">/* The number of seconds since the Epoch */</span>
366     <a name="l00358"></a><a class="code" href="structpeer__info__s.html#o23">00358</a> <span class="keywordtype">char</span> <a class="code" href="structpeer__info__s.html#o23">last_m</a>[<a class="code" href="spf_8h.html#a20">SPF_MAX_MECHANISM</a>]; <span class="comment">/* last mechanism parsed */</span>
367     <a name="l00359"></a><a class="code" href="structpeer__info__s.html#o24">00359</a> <span class="keywordtype">char</span> <a class="code" href="structpeer__info__s.html#o24">error</a>[<a class="code" href="spf_8h.html#a16">SPF_MAX_ERROR</a>]; <span class="comment">/* error (if any) that caused failure */</span>
368     00360
369     <a name="l00361"></a><a class="code" href="structpeer__info__s.html#o25">00361</a> <a class="code" href="structspf__result__t.html">spf_result_t</a> *<a class="code" href="structpeer__info__s.html#o25">spf_result</a>; <span class="comment">/* table of str, see spf_result_t */</span>
370     00362
371     <a name="l00363"></a><a class="code" href="structpeer__info__s.html#o26">00363</a> <span class="keyword">struct </span>in_addr addr; <span class="comment">/* IP of the remote host (peer) */</span>
372     00364
373     00365 <span class="comment">/*</span>
374     00366 <span class="comment"> * Vars below here are specific to recursion through layers of SPF queries</span>
375     00367 <span class="comment"> * stemming from 'include' and 'redirect' use. In addition there is a</span>
376     00368 <span class="comment"> * also a buffer for CNAME records.</span>
377     00369 <span class="comment"> */</span>
378     00370
379     <a name="l00371"></a><a class="code" href="structpeer__info__s.html#o27">00371</a> uint8_t <a class="code" href="structpeer__info__s.html#o27">spf_rlevel</a>; <span class="comment">/* recursion level */</span>
380     00372
381     <a name="l00373"></a><a class="code" href="structpeer__info__s.html#o28">00373</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o28">cname_buf</a>; <span class="comment">/* buf for CNAME records */</span>
382     <a name="l00374"></a><a class="code" href="structpeer__info__s.html#o29">00374</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o29">include_buf</a>; <span class="comment">/* buf for 'include' instances */</span>
383     <a name="l00375"></a><a class="code" href="structpeer__info__s.html#o30">00375</a> <span class="keywordtype">char</span> *<a class="code" href="structpeer__info__s.html#o30">redirect_buf</a>; <span class="comment">/* buf for 'redirect' instances */</span>
384     00376
385     00377 } <a class="code" href="structpeer__info__s.html">peer_info_t</a>;
386     00378
387     00379 <span class="keyword">extern</span> <a class="code" href="structspf__config__s.html">spf_config_t</a> <a class="code" href="main_8c.html#a0">confg</a>;
388     00380 <span class="keyword">extern</span> u_int8_t <a class="code" href="spf_8h.html#a48">spf_rlevel</a>;
389     00381
390     00382 <span class="comment">/* Main library functions (main.c) */</span>
391     00383 <span class="keyword">extern</span> <a class="code" href="structpeer__info__s.html">peer_info_t</a> *<a class="code" href="spf_8h.html#a77">SPF_init</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *,
392     00384 <span class="keyword">const</span> <span class="keywordtype">char</span> *, u_int32_t, u_int32_t);
393     00385 <span class="keyword">extern</span> <a class="code" href="structpeer__info__s.html">peer_info_t</a> *<a class="code" href="spf_8h.html#a78">SPF_close</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
394     00386 <span class="keyword">extern</span> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="spf_8h.html#a79">SPF_policy_main</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
395     00387 <span class="keyword">extern</span> <a class="code" href="spf_8h.html#a36">SPF_RESULT</a> <a class="code" href="spf_8h.html#a80">SPF_policy_main_rec</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
396     00388 <span class="keyword">extern</span> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="spf_8h.html#a81">SPF_parse_policy</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *);
397     00389 <span class="keyword">extern</span> <span class="keywordtype">char</span> *<a class="code" href="spf_8h.html#a82">SPF_result</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
398     00390 <span class="keyword">extern</span> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="spf_8h.html#a83">SPF_smtp_from</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *);
399     00391 <span class="keyword">extern</span> <a class="code" href="spf_8h.html#a35">SPF_BOOL</a> <a class="code" href="spf_8h.html#a84">SPF_smtp_helo</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *, <span class="keyword">const</span> <span class="keywordtype">char</span> *);
400     00392
401     00393 <span class="comment">/* Functions that alter headers (header.c) */</span>
402     00394 <span class="keyword">extern</span> <span class="keywordtype">char</span> *<a class="code" href="spf_8h.html#a85">SPF_build_header</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
403     00395 <span class="keyword">extern</span> <span class="keywordtype">char</span> *<a class="code" href="spf_8h.html#a86">SPF_get_explain</a>(<a class="code" href="structpeer__info__s.html">peer_info_t</a> *);
404     00396
405     00397
406     00398
407     00399 __END_DECLS <span class="comment">/* _SPF_H */</span>
408     00400
409     00401 <span class="preprocessor">#endif </span><span class="comment">/* spf.h */</span>
410     </div></pre><hr size="1"><address style="align: right;"><small>Generated on Thu Sep 16 18:10:47 2004 for libSPF v1.0 by
411     <a href="http://www.doxygen.org/index.html">
412     <img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
413     </body>
414     </html>