libspf2  1.2.10
spf_dns.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of either:
4  *
5  * a) The GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 2.1, or (at your option) any
7  * later version,
8  *
9  * OR
10  *
11  * b) The two-clause BSD license.
12  *
13  * These licenses can be found with the distribution in the file LICENSES
14  */
15 
16 
17 
18 
19 #ifndef INC_SPF_DNS
20 #define INC_SPF_DNS
21 
22 
67 /*
68  * For those who don't have <arpa/nameserv.h>
69  */
70 
71 /* XXX This should use a more sensible define. */
72 #if !defined( HAVE_NS_TYPE )
73 
74 #define ns_t_invalid 0
75 #define ns_t_a 1
76 #define ns_t_ns 2
77 #define ns_t_cname 5
78 #define ns_t_ptr 12
79 #define ns_t_mx 15
80 #define ns_t_txt 16
81 #define ns_t_aaaa 28
82 /* #define ns_t_a6 38 */
83 #define ns_t_any 255
85 typedef int ns_type;
86 #endif
87 
88 #if ! HAVE_DECL_NS_T_SPF
89 #define ns_t_spf 99
90 #endif
91 
92 #if ! HAVE_DECL_NS_T_INVALID
93 #define ns_t_invalid 0
94 #endif
95 
96 
97 /*
98  * For those who don't have <netdb.h>
99  */
100 
101 #if !defined(HAVE_NETDB_H) && !defined(_WIN32)
102 #define NETDB_SUCCESS 0
103 #define HOST_NOT_FOUND 1
104 #define TRY_AGAIN 2
105 #define NO_RECOVERY 3
106 #define NO_DATA 4
107 #endif
108 typedef int SPF_dns_stat_t;
109 
110 typedef struct SPF_dns_server_struct SPF_dns_server_t;
111 
112 #include "spf_request.h"
113 #include "spf_dns_rr.h"
114 
115 /*
116  * bundle up the info needed to use a dns method
117  */
118 
119 typedef void (*SPF_dns_destroy_t)(SPF_dns_server_t *spf_dns_server);
120 typedef SPF_dns_rr_t *(*SPF_dns_lookup_t)(
121  SPF_dns_server_t *spf_dns_server,
122  const char *domain,
123  ns_type ns_type, int should_cache
124  );
125 typedef SPF_errcode_t (*SPF_dns_get_spf_t)( SPF_server_t *spf_server,
126  SPF_request_t *spf_request,
127  SPF_response_t *spf_response,
128  SPF_record_t **spf_recordp);
129 typedef SPF_errcode_t (*SPF_dns_get_exp_t)( SPF_server_t *spf_server,
130  const char *domain,
131  char **buf, size_t *buf_len );
132 typedef int (*SPF_dns_add_cache_t)( SPF_server_t *spf_server,
133  SPF_dns_rr_t spfrr );
134 
136 {
143 
148 
149  /* the next DNS layer down to call if this layer can't give an answer */
150  SPF_dns_server_t *layer_below;
151 
152  const char *name; /* name of the layer */
153  int debug;
154  void *hook; /* server-specific data */
155 };
156 
157 
158 void SPF_dns_free( SPF_dns_server_t *spf_dns_server );
159 SPF_dns_rr_t *SPF_dns_lookup( SPF_dns_server_t *spf_dns_server,
160  const char *domain, ns_type rr_type,
161  int should_cache );
162 SPF_dns_rr_t *SPF_dns_rlookup( SPF_dns_server_t *spf_dns_server,
163  struct in_addr ipv4, ns_type rr_type,
164  int should_cache );
165 SPF_dns_rr_t *SPF_dns_rlookup6( SPF_dns_server_t *spf_dns_server,
166  struct in6_addr ipv6, ns_type rr_type,
167  int should_cache );
168 
169 
177 char *SPF_dns_get_client_dom(SPF_dns_server_t *spf_dns_server,
178  SPF_request_t *sr);
179 
180 
181 #endif