Blame
Date:
Sat Nov 8 20:28:31 2014 UTC
Message:
0.9.0 is the last version of Wildcarddnsd, the succeeding project is called Delphinusdnsd and will have its first release around November 15th, 2015. The new project page is at http://delphinusdns.centroid.eu.
001
2005-11-29
pbug
/*
002
2014-04-13
pjp
* Copyright (c) 2005-2014 Peter J. Philipp
003
2005-11-29
pbug
* All rights reserved.
004
2005-11-29
pbug
*
005
2005-11-29
pbug
* Redistribution and use in source and binary forms, with or without
006
2005-11-29
pbug
* modification, are permitted provided that the following conditions
007
2005-11-29
pbug
* are met:
008
2005-11-29
pbug
* 1. Redistributions of source code must retain the above copyright
009
2005-11-29
pbug
* notice, this list of conditions and the following disclaimer.
010
2005-11-29
pbug
* 2. Redistributions in binary form must reproduce the above copyright
011
2005-11-29
pbug
* notice, this list of conditions and the following disclaimer in the
012
2005-11-29
pbug
* documentation and/or other materials provided with the distribution.
013
2005-11-29
pbug
* 3. The name of the author may not be used to endorse or promote products
014
2005-11-29
pbug
* derived from this software without specific prior written permission
015
2005-11-29
pbug
*
016
2005-11-29
pbug
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
017
2005-11-29
pbug
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
018
2005-11-29
pbug
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
019
2005-11-29
pbug
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
020
2005-11-29
pbug
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
021
2005-11-29
pbug
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
022
2005-11-29
pbug
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
023
2005-11-29
pbug
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024
2005-11-29
pbug
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
025
2005-11-29
pbug
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026
2005-11-29
pbug
*
027
2005-11-29
pbug
*/
028
2005-11-29
pbug
#ifndef _DB_H
029
2005-11-29
pbug
#define _DB_H
030
2005-11-29
pbug
031
2005-11-29
pbug
#define CONFFILE "/etc/wildcarddns.conf"
032
2011-06-28
pbug
#define DEFAULT_SOCKET 64
033
2005-11-29
pbug
034
2005-11-29
pbug
#define ERR_DROP 0x1
035
2005-11-29
pbug
#define ERR_NXDOMAIN 0x2
036
2009-03-07
pbug
#define ERR_NOERROR 0x4
037
2005-11-29
pbug
038
2010-04-01
pbug
#define RECORD_COUNT 20
039
2010-09-15
pbug
#define NEGATIVE_CACHE_TIME 600 /* DNS & Bind 3rd edition page 35 */
040
2010-04-01
pbug
041
2005-11-29
pbug
/* db stuff */
042
2005-11-29
pbug
043
2005-11-29
pbug
struct soa {
044
2005-11-29
pbug
char nsserver[DNS_MAXNAME];
045
2005-11-29
pbug
u_int8_t nsserver_len;
046
2005-11-29
pbug
char responsible_person[DNS_MAXNAME];
047
2005-11-29
pbug
u_int8_t rp_len;
048
2005-11-29
pbug
u_int32_t serial;
049
2005-11-29
pbug
u_int32_t refresh;
050
2005-11-29
pbug
u_int32_t retry;
051
2005-11-29
pbug
u_int32_t expire;
052
2005-11-29
pbug
u_int32_t minttl;
053
2005-11-29
pbug
} __attribute__((packed));
054
2005-11-29
pbug
055
2005-11-29
pbug
struct smx {
056
2008-07-12
pbug
u_int16_t preference; /* MX preference */
057
2008-07-12
pbug
char exchange[DNS_MAXNAME]; /* name of exchange server */
058
2010-03-28
pbug
int exchangelen; /* length of exchange server name */
059
2005-11-29
pbug
} __attribute__((packed));
060
2005-11-29
pbug
061
2005-11-29
pbug
struct ns {
062
2008-07-12
pbug
char nsserver[DNS_MAXNAME]; /* NS name */
063
2010-03-28
pbug
int nslen; /* length of NS */
064
2005-11-29
pbug
} __attribute__((packed));
065
2005-11-29
pbug
066
2012-04-30
pbug
struct srv {
067
2012-04-30
pbug
u_int16_t priority; /* SRV 16 bit priority */
068
2012-04-30
pbug
u_int16_t weight; /* 16 bit weight */
069
2012-04-30
pbug
u_int16_t port; /* 16 bit port */
070
2012-04-30
pbug
char target[DNS_MAXNAME]; /* SRV target name */
071
2012-04-30
pbug
int targetlen; /* SRV target name length */
072
2012-04-30
pbug
} __attribute__((packed));
073
2012-04-30
pbug
074
2014-04-21
pjp
struct sshfp {
075
2014-04-21
pjp
u_int8_t algorithm; /* SSHFP algorithm */
076
2014-04-21
pjp
u_int8_t fptype; /* SSHFP fingerprint type */
077
2014-04-21
pjp
char fingerprint[DNS_MAXNAME]; /* fingerprint */
078
2014-04-21
pjp
int fplen; /* fingerprint length */
079
2014-04-21
pjp
} __attribute__((packed));
080
2014-04-21
pjp
081
2014-05-11
pjp
struct naptr {
082
2014-05-11
pjp
u_int16_t order; /* NAPTR 16 bit order */
083
2014-05-11
pjp
u_int16_t preference; /* 16 bit preference */
084
2014-05-11
pjp
char flags[DNS_MAXNAME]; /* flags 255 bytes */
085
2014-05-11
pjp
int flagslen; /* flags length */
086
2014-05-11
pjp
char services[DNS_MAXNAME]; /* services */
087
2014-05-11
pjp
int serviceslen; /* services length */
088
2014-05-11
pjp
char regexp[DNS_MAXNAME]; /* regexp */
089
2014-05-11
pjp
int regexplen; /* regexp len */
090
2014-05-11
pjp
char replacement[DNS_MAXNAME]; /* replacement this is a domain */
091
2014-05-11
pjp
int replacementlen;
092
2014-05-11
pjp
} __attribute__((packed));
093
2014-05-11
pjp
094
2005-11-29
pbug
struct domain {
095
2011-09-19
pbug
char zone[DNS_MAXNAME]; /* name of zone in dns name format */
096
2009-11-03
pbug
int zonelen; /* length of zone, above */
097
2011-09-19
pbug
char zonename[DNS_MAXNAME + 1]; /* name of zone in human readable */
098
2014-04-21
pjp
u_int32_t flags; /* flags of zone */
099
2005-11-29
pbug
#define DOMAIN_HAVE_A 0x1
100
2005-11-29
pbug
#define DOMAIN_HAVE_SOA 0x2
101
2005-11-29
pbug
#define DOMAIN_HAVE_CNAME 0x4
102
2005-11-29
pbug
#define DOMAIN_HAVE_PTR 0x8
103
2005-11-29
pbug
#define DOMAIN_HAVE_MX 0x10
104
2005-11-29
pbug
#define DOMAIN_HAVE_AAAA 0x20
105
2005-11-29
pbug
#define DOMAIN_HAVE_NS 0x40
106
2010-03-27
pbug
#define DOMAIN_HAVE_TXT 0x80
107
2010-04-15
pbug
#define DOMAIN_STATIC_ZONE 0x100
108
2010-09-15
pbug
#define DOMAIN_NEGATIVE_CACHE 0x200
109
2012-04-30
pbug
#define DOMAIN_HAVE_SRV 0x400
110
2014-04-21
pjp
#define DOMAIN_HAVE_SPF 0x800
111
2014-04-21
pjp
#define DOMAIN_HAVE_SSHFP 0x1000
112
2014-05-11
pjp
#define DOMAIN_HAVE_NAPTR 0x2000
113
2011-09-19
pbug
struct soa soa; /* start of authority */
114
2008-07-12
pbug
u_int32_t ttl; /* time to live */
115
2010-04-15
pbug
time_t created; /* time created, for dynamic zones */
116
2010-04-01
pbug
in_addr_t a[RECORD_COUNT]; /* IP addresses */
117
2010-04-01
pbug
u_int8_t region[RECORD_COUNT]; /* region of IP address */
118
2008-07-12
pbug
int a_count; /* IP address count (max 10) */
119
2008-07-12
pbug
int a_ptr; /* pointer to last used address */
120
2011-09-19
pbug
struct in6_addr aaaa[RECORD_COUNT]; /* IPv6 addresses */
121
2008-07-12
pbug
int aaaa_count; /* IPv6 address count (max 10) */
122
2008-07-12
pbug
int aaaa_ptr; /* pointer to last used IPv6 address */
123
2011-09-19
pbug
struct smx mx[RECORD_COUNT]; /* MX addresses */
124
2008-07-12
pbug
int mx_count; /* MX address count, max 10 */
125
2008-07-12
pbug
int mx_ptr; /* pointer to last used MX adddress */
126
2011-09-19
pbug
struct ns ns[RECORD_COUNT]; /* NS resource records (max 10) */
127
2008-07-12
pbug
int ns_count; /* count of NS records, (max 10) */
128
2008-07-12
pbug
int ns_ptr; /* pointer to last used NS address */
129
2010-04-01
pbug
int ns_type; /* set if it's a delegation */
130
2010-04-01
pbug
#define NS_TYPE_DELEGATE 0x1
131
2010-04-01
pbug
#define NS_TYPE_HINT 0x2
132
2014-04-21
pjp
char cname[DNS_MAXNAME]; /* CNAME RR */
133
2014-04-21
pjp
int cnamelen; /* len of CNAME */
134
2014-04-21
pjp
char ptr[DNS_MAXNAME]; /* PTR RR */
135
2014-04-21
pjp
int ptrlen; /* len of PTR */
136
2014-04-21
pjp
char txt[DNS_MAXNAME]; /* TXT string */
137
2014-04-21
pjp
int txtlen; /* len of TXT */
138
2014-04-21
pjp
char spf[DNS_MAXNAME]; /* SPF string */
139
2014-04-21
pjp
int spflen; /* len of SPF */
140
2014-04-21
pjp
struct srv srv[RECORD_COUNT]; /* SRV resource record */
141
2014-04-21
pjp
int srv_count; /* count of SRV RR */
142
2014-04-21
pjp
struct sshfp sshfp[RECORD_COUNT]; /* SSHFP resource record */
143
2014-04-21
pjp
int sshfp_count; /* SSHFP RR count */
144
2014-05-11
pjp
struct naptr naptr[RECORD_COUNT]; /* NAPTR RR, eek 20K! */
145
2014-05-11
pjp
int naptr_count;
146
2005-11-29
pbug
} __attribute__((packed));
147
2005-11-29
pbug
148
2005-11-29
pbug
struct sreply {
149
2005-11-29
pbug
int so; /* socket */
150
2005-11-29
pbug
char *buf; /* question packet */
151
2005-11-29
pbug
int len; /* question packet length */
152
2005-11-29
pbug
struct question *q; /* struct question */
153
2005-11-29
pbug
struct sockaddr *sa; /* struct sockaddr of question */
154
2005-11-29
pbug
int salen; /* length of struct sockaddr */
155
2005-11-29
pbug
struct domain *sd1; /* first resolved domain */
156
2005-11-29
pbug
struct domain *sd2; /* CNAME to second resolved domain */
157
2010-03-09
pbug
u_int8_t region; /* region of question */
158
2010-03-12
pbug
int istcp; /* when set it's tcp */
159
2010-04-05
pbug
int wildcard; /* wildcarding boolean */
160
2010-09-19
pbug
struct recurses *sr; /* recurses struct for raw sockets */
161
2014-04-21
pjp
char *replybuf; /* reply buffer */
162
2005-11-29
pbug
};
163
2010-04-15
pbug
164
2010-04-15
pbug
struct srecurseheader {
165
2010-04-15
pbug
int af; /* address family */
166
2010-04-15
pbug
int proto; /* protocol UDP/TCP */
167
2010-04-15
pbug
struct sockaddr_storage source; /* source + port */
168
2010-04-15
pbug
struct sockaddr_storage dest; /* dest + port */
169
2010-04-15
pbug
int len; /* length of question */
170
2010-04-15
pbug
char buf[512]; /* question buffer */
171
2010-09-19
pbug
};
172
2010-09-19
pbug
173
2010-09-19
pbug
174
2010-09-19
pbug
SLIST_HEAD(listhead2, recurses) recurseshead;
175
2010-09-19
pbug
176
2010-09-19
pbug
struct recurses {
177
2010-09-19
pbug
char query[512]; /* the query we received */
178
2010-09-19
pbug
int len; /* length of query */
179
2010-09-19
pbug
180
2010-09-19
pbug
int isfake; /* received or faked */
181
2010-09-21
pbug
int launched; /* is launched */
182
2010-09-19
pbug
int replied; /* we replied to this question */
183
2010-09-25
pbug
int packetcount; /* packet count of requests */
184
2010-09-19
pbug
int af; /* address family */
185
2010-09-19
pbug
int proto; /* protocol UDP/TCP */
186
2010-09-19
pbug
struct sockaddr_storage source; /* source + port */
187
2010-09-19
pbug
struct sockaddr_storage dest; /* dest + port */
188
2010-09-19
pbug
189
2010-09-19
pbug
time_t received; /* received request time */
190
2010-09-19
pbug
time_t sent_last_query; /* the last time we did a lookup */
191
2010-09-19
pbug
192
2010-09-19
pbug
char upperlower[32]; /* uppercase / lowercase bitmap */
193
2010-09-19
pbug
int so; /* the socket we did a lookup with */
194
2010-09-19
pbug
u_short port; /* port used on outgoing */
195
2010-09-19
pbug
u_int16_t id; /* last id used */
196
2010-09-19
pbug
197
2010-09-19
pbug
/* the below get loaded from the database upon each lookup */
198
2010-09-19
pbug
in_addr_t a[RECORD_COUNT]; /* IPv4 addresses of nameservers */
199
2010-09-19
pbug
int a_count; /* IPv4 address count */
200
2010-09-19
pbug
int a_ptr; /* pointer to last used address */
201
2010-09-19
pbug
struct in6_addr aaaa[RECORD_COUNT]; /* IPv6 addresses of nameservers */
202
2010-09-19
pbug
int aaaa_count; /* IPv6 address count */
203
2010-09-19
pbug
int aaaa_ptr; /* pointer to last used IPv6 address */
204
2010-09-19
pbug
205
2010-09-19
pbug
/* the below is our indicator which part of the lookup we're at */
206
2010-09-19
pbug
207
2010-09-28
pbug
u_char *lookrecord; /* what zone lookup is it from */
208
2010-09-19
pbug
int indicator; /* indicator of ns lookup */
209
2010-09-25
pbug
int authoritative; /* last reply was authoritative, type */
210
2010-09-19
pbug
int hascallback; /* some request has callback don't remove */
211
2010-09-19
pbug
212
2010-09-19
pbug
struct question *question; /* question struct */
213
2014-05-01
pjp
SLIST_ENTRY(recurses) recurses_entry;
214
2010-09-19
pbug
struct recurses *callback; /* callback */
215
2010-09-21
pbug
} *sr, *sr1, *sr2;
216
2011-06-28
pbug
217
2011-06-28
pbug
struct logging {
218
2011-06-28
pbug
int active;
219
2011-06-28
pbug
char *hostname;
220
2011-06-28
pbug
int bind;
221
2011-06-28
pbug
char *loghost;
222
2011-06-28
pbug
struct sockaddr_storage loghost2;
223
2011-06-28
pbug
char *logport;
224
2011-06-28
pbug
u_int16_t logport2;
225
2011-06-28
pbug
char *logpasswd;
226
2011-06-28
pbug
};
227
2011-06-28
pbug
228
2011-06-28
pbug
struct cfg {
229
2011-06-28
pbug
int udp[DEFAULT_SOCKET]; /* udp sockets */
230
2011-06-28
pbug
int tcp[DEFAULT_SOCKET]; /* tcp socket */
231
2011-09-19
pbug
int axfr[DEFAULT_SOCKET]; /* axfr udp socket */
232
2011-06-28
pbug
char *ident[DEFAULT_SOCKET]; /* identification of interface */
233
2011-06-28
pbug
int recurse; /* recurse socket */
234
2011-06-28
pbug
int log; /* logging socket */
235
2011-06-28
pbug
int sockcount; /* set sockets */
236
2011-06-28
pbug
DB *db; /* database */
237
2011-06-28
pbug
};
238
2010-04-15
pbug
239
2010-04-05
pbug
240
2005-11-29
pbug
int parse_file(DB *db, char *);
241
2005-11-29
pbug
DB * opendatabase(DB *);
242
2005-11-29
pbug
243
2005-11-29
pbug
244
2005-11-29
pbug
#endif /* _DB_H */
repomaster@centroid.eu