main.h

Go to the documentation of this file.
00001 /* libspf - Sender Policy Framework library 00002 * 00003 * ANSI C implementation of spf-draft-200405.txt 00004 * 00005 * Author: James Couzens <jcouzens@codeshare.ca> 00006 * Author: Sean Comeau <scomeau@obscurity.org> 00007 * 00008 * FILE: spf.h 00009 * DESC: main library header file 00010 * 00011 * License: 00012 * 00013 * The libspf Software License, Version 1.0 00014 * 00015 * Copyright (c) 2004 James Couzens & Sean Comeau All rights 00016 * reserved. 00017 * 00018 * Redistribution and use in source and binary forms, with or without 00019 * modification, are permitted provided that the following conditions 00020 * are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright 00023 * notice, this list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in 00027 * the documentation and/or other materials provided with the 00028 * distribution. 00029 * 00030 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00031 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00032 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00033 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS MAKING USE OF THIS LICESEN 00034 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00035 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00036 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00037 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00038 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00039 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00040 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00041 * SUCH DAMAGE. 00042 * 00043 */ 00044 00045 00046 #ifndef _MAIN_H 00047 #define _MAIN_H 1 00048 00049 #include <stdio.h> /* stdin / stdout */ 00050 #include <stdlib.h> /* malloc / free */ 00051 #include <string.h> /* strstr / strdup */ 00052 #include <stdarg.h> /* va_snprintf */ 00053 00054 #ifdef _WITH_OPENBSD 00055 #include <inttypes.h> /* uintptr_t */ 00056 #endif /* _WITH_OPENBBSD */ 00057 00058 #include "../../config.h" /* autoconf */ 00059 #include "spf.h" 00060 00061 00062 #ifdef HAVE__BEGIN_DECLS 00063 __BEGIN_DECLS 00064 #else 00065 # ifdef __cplusplus 00066 extern "C" { 00067 # endif /* __cplusplus */ 00068 #endif /* HAVE__BEGIN_DECLS */ 00069 00070 #define FL_A 2 /* normal debugging */ 00071 #define FL_B 4 /* verbose debugging */ 00072 #define FL_C 8 /* normal and verbose debugging */ 00073 #define FL_D 16 /* profile results */ 00074 #define FL_E 32 /* normal debug + profile results */ 00075 #define FL_F 64 /* verbose debug + profile results */ 00076 #define FL_G 128 /* normal + verbose + profile results */ 00077 00078 /* # limiting recursion */ 00079 #define SPF_MAX_RECURSE 20 00080 00081 /* spf MTA result strings */ 00082 #define RES_PASS "domain of %s designates %s as permitted sender\r\n" 00083 #define RES_NONE "domain of %s does not designate permitted sender " \ 00084 "hosts\r\n" 00085 #define RES_S_FAIL "transitioning domain of %s does not designate %s " \ 00086 "as permitted sender\r\n" 00087 #define RES_H_FAIL "domain of %s does not designate %s as permitted " \ 00088 "sender\r\n" 00089 #define RES_ERROR "encountered temporary error during SPF processing " \ 00090 "of %s\r\n" 00091 #define RES_NEUTRAL "%s is neither permitted nor denied by domain of " \ 00092 "%s\r\n" 00093 #define RES_UNKNOWN "error in processing during lookup of %s\r\n" 00094 #define RES_UNMECH "encountered unrecognized mechanism during SPF " \ 00095 "processing of domain of %s\r\n" 00096 00097 /* header strings */ 00098 #define HDR_PASS "Received-SPF: pass (%s: domain of %s designates " \ 00099 "%s as permitted sender) receiver=%s; client_ip=%s; " \ 00100 "envelope-from=%s;" 00101 00102 #define HDR_NONE "Received-SPF: none (%s: domain of %s does not " \ 00103 "designate permitted sender hosts)" 00104 00105 #define HDR_S_FAIL "Received-SPF: softfail (%s: domain of " \ 00106 "transitioning %s does not designate %s as " \ 00107 "permitted sender) receiver=%s; client_ip=%s; " \ 00108 "envelope-from=%s;" 00109 00110 #define HDR_H_FAIL "Received-SPF: fail (%s: domain of %s does not " \ 00111 "designate %s as permitted sender) receiver=%s; " \ 00112 "client_ip=%s; envelope-from=%s;" 00113 00114 #define HDR_ERROR "Received-SPF: error (%s: error in processing " \ 00115 "during lookup of %s: %s)" 00116 00117 #define HDR_NEUTRAL "Received-SPF: neutral (%s: domain of %s is " \ 00118 "neutral about designating %s as permitted sender)" 00119 00120 #define HDR_UNKNOWN "Received-SPF: unknown (%s: domain of %s " \ 00121 "encountered an error while parsing (check SPF " \ 00122 "record %s for errors))" 00123 00124 #define HDR_UNMECH "Received-SPF: unknown -extension:%s (%s: domain of " \ 00125 "%s uses a mechanism not recognized by this client)" 00126 00127 /* Deal with systems where these types are not used and define them where 00128 * they are found to be missing 00129 */ 00130 #ifndef HAVE_U_INT8_T 00131 # ifdef HAVE_UINT8_T 00132 typedef uint8_t u_int8_t; 00133 # else 00134 typedef unsigned char u_int8_t; 00135 # endif /* HAVE_UINT8_T */ 00136 #endif /* HAVE_U_INT8_T */ 00137 00138 #ifndef HAVE_U_INT16_T 00139 # ifdef HAVE_UINT16_T 00140 typedef uint16_t u_int16_t; 00141 # else 00142 typedef unsigned int u_int16_t; 00143 # endif /* HAVE_UINT16_T */ 00144 #endif /* HAVE_U_INT16_T */ 00145 00146 #ifndef HAVE_U_INT32_T 00147 # ifdef HAVE_UINT32_T 00148 typedef uint32_t u_int32_t; 00149 # else 00150 typedef unsigned int u_int32_t; 00151 # endif /* HAVE_UINT32_T */ 00152 #endif /* HAVE_U_INT32_T */ 00153 00154 #ifndef HAVE_UINTPTR_T 00155 typedef unsigned long int uintptr_t; 00156 #endif /* HAVE_UINTPTR_T */ 00157 00158 00159 /* Main library functions (main.c) */ 00160 peer_info_t *SPF_init(const char *, const char *, const char *, const char *, 00161 const char *, u_int32_t, u_int32_t); 00162 peer_info_t *SPF_close(peer_info_t *); 00163 SPF_RESULT SPF_policy_main(peer_info_t *); 00164 SPF_RESULT SPF_policy_main_rec(peer_info_t *); 00165 SPF_BOOL SPF_parse_policy(peer_info_t *, const char *); 00166 char *SPF_result(peer_info_t *); 00167 00168 SPF_BOOL SPF_smtp_from(peer_info_t *, const char *); 00169 SPF_BOOL SPF_smtp_helo(peer_info_t *, const char *); 00170 00171 char *SPF_build_header(peer_info_t *); 00172 char *SPF_get_explain(peer_info_t *); 00173 00174 00175 /* 00176 * private functions 00177 * 00178 */ 00179 /* 00180 static SPF_BOOL _SPF_clear_holdbufs(peer_info_t *); 00181 */ 00182 00183 00184 00185 #ifdef HAVE__BEGIN_DECLS 00186 __END_DECLS /* _MAIN_H */ 00187 #else 00188 # ifdef __cplusplus 00189 } 00190 # endif /* __cplusplus */ 00191 #endif /* HAVE__BEGIN_DECLS */ 00192 00193 00194 #endif /* main.h */

Generated on Thu Sep 16 18:10:46 2004 for libSPF v1.0 by doxygen 1.3.8