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) 2002-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 _DNS_H
029
2005-11-29
pbug
#define _DNS_H
030
2005-11-29
pbug
031
2005-11-29
pbug
032
2005-11-29
pbug
/* RFC 1035 - page 26 */
033
2005-11-29
pbug
034
2005-11-29
pbug
struct dns_header {
035
2005-11-29
pbug
u_int16_t id; /* ID of header */
036
2005-11-29
pbug
u_int16_t query;
037
2005-11-29
pbug
u_int16_t question; /* # of question entries */
038
2005-11-29
pbug
u_int16_t answer; /* # of answer RR's */
039
2005-11-29
pbug
u_int16_t nsrr; /* # of NS RR's */
040
2005-11-29
pbug
u_int16_t additional; /* # additional RR's */
041
2005-11-29
pbug
};
042
2005-11-29
pbug
043
2005-11-29
pbug
struct dns_hints {
044
2005-11-29
pbug
int proto;
045
2005-11-29
pbug
u_int16_t id;
046
2005-11-29
pbug
u_int16_t query;
047
2005-11-29
pbug
u_int16_t question;
048
2005-11-29
pbug
u_int16_t answer;
049
2005-11-29
pbug
u_int16_t nsrr;
050
2005-11-29
pbug
u_int16_t additional;
051
2005-11-29
pbug
};
052
2005-11-29
pbug
053
2005-11-29
pbug
/*
054
2005-11-29
pbug
* resource record structure
055
2005-11-29
pbug
* RFC 1035 - page 9
056
2005-11-29
pbug
*/
057
2005-11-29
pbug
058
2005-11-29
pbug
struct dns_rr {
059
2005-11-29
pbug
char *name; /* name of zone */
060
2005-11-29
pbug
char *question; /* pointer to question */
061
2005-11-29
pbug
u_int16_t type; /* type of RR */
062
2005-11-29
pbug
u_int16_t class; /* class of reply */
063
2005-11-29
pbug
u_int32_t ttl; /* ttl of record */
064
2005-11-29
pbug
u_int16_t rdlen; /* length of record */
065
2005-11-29
pbug
char *rdata; /* data of record */
066
2005-11-29
pbug
};
067
2005-11-29
pbug
068
2014-05-09
pjp
/*
069
2014-05-09
pjp
* EDNS0 OPT RR, based on dns_rr
070
2014-05-09
pjp
* RFC 6891 - page 7
071
2014-05-09
pjp
*/
072
2014-05-09
pjp
073
2014-05-09
pjp
struct dns_optrr {
074
2014-05-10
pjp
char name[1]; /* always 0 */
075
2014-05-09
pjp
u_int16_t type; /* must be 41 */
076
2014-05-09
pjp
u_int16_t class; /* UDP payload size (4096) */
077
2014-05-09
pjp
u_int32_t ttl; /* extended RCODE */
078
2014-05-09
pjp
u_int16_t rdlen; /* length of all RDATA */
079
2014-05-10
pjp
char rdata[0]; /* attribute, value pairs */
080
2014-05-10
pjp
}__attribute__((packed));
081
2014-05-09
pjp
082
2005-11-29
pbug
/* RFC 1035 - page 28 */
083
2005-11-29
pbug
struct dns_question_hdr {
084
2005-11-29
pbug
char *name;
085
2005-11-29
pbug
u_int namelen;
086
2005-11-29
pbug
u_int16_t qtype;
087
2005-11-29
pbug
u_int16_t qclass;
088
2005-11-29
pbug
};
089
2005-11-29
pbug
090
2005-11-29
pbug
091
2005-11-29
pbug
092
2005-11-29
pbug
/*
093
2005-11-29
pbug
* flags RFC 1035, page 26
094
2005-11-29
pbug
*/
095
2005-11-29
pbug
096
2005-11-29
pbug
#define DNS_REPLY 0x8000 /* if set response if not set query */
097
2014-05-17
pjp
#define DNS_NOTIFY 0x2000 /* a NOTIFY query RFC 1996 */
098
2005-11-29
pbug
#define DNS_SREQ 0x1000 /* if set a server status request (STATUS) */
099
2005-11-29
pbug
#define DNS_INV 0x800 /* if set an inverse query */
100
2005-11-29
pbug
#define DNS_AUTH 0x400 /* Authoritative Answer (AA) in replies */
101
2005-11-29
pbug
#define DNS_TRUNC 0x200 /* Truncated (TC) */
102
2005-11-29
pbug
#define DNS_RECURSE 0x100 /* if set Recursion Desired (RD) */
103
2005-11-29
pbug
#define DNS_RECAVAIL 0x80 /* if set Recursion Available (RA) */
104
2014-09-20
pjp
#define DNS_BADTIME 0x12 /* RCODE (18) BADTIME RFC 2845 p. 3 */
105
2014-09-20
pjp
#define DNS_BADKEY 0x11 /* RCODE (17) BADKEY RFC 2845 p. 3 */
106
2014-09-20
pjp
#define DNS_BADSIG 0x10 /* RCODE (16) BADSIG RFC 2845 p. 3 */
107
2005-11-29
pbug
#define DNS_REFUSED 0x5 /* RCODE - Refused */
108
2005-11-29
pbug
#define DNS_NOTIMPL 0x4 /* RCODE - Not Implemented */
109
2009-03-06
pbug
#define DNS_NAMEERR 0x3 /* RCODE - Name Error, NXDOMAIN */
110
2005-11-29
pbug
#define DNS_SERVFAIL 0x2 /* RCODE - Server Failure */
111
2005-11-29
pbug
#define DNS_FORMATERR 0x1 /* RCODE - Format Error */
112
2005-11-29
pbug
#define DNS_NOERR 0x0 /* RCODE - No error */
113
2005-11-29
pbug
114
2005-11-29
pbug
/*
115
2005-11-29
pbug
* macros to set flags (must be converted to network byte order after)
116
2005-11-29
pbug
*/
117
2005-11-29
pbug
118
2005-11-29
pbug
#define SET_DNS_REPLY(x) ((x)->query |= (DNS_REPLY))
119
2010-09-16
pbug
#define SET_DNS_QUERY(x) ((x)->query &= ~(DNS_REPLY))
120
2014-05-17
pjp
#define SET_DNS_NOTIFY(x) ((x)->query |= (DNS_NOTIFY))
121
2005-11-29
pbug
#define SET_DNS_STATUS_REQ(x) ((x)->query |= (DNS_SREQ))
122
2005-11-29
pbug
#define SET_DNS_INVERSE_QUERY(x) ((x)->query |= (DNS_INV))
123
2005-11-29
pbug
#define SET_DNS_AUTHORITATIVE(x) ((x)->query |= (DNS_AUTH))
124
2005-11-29
pbug
#define SET_DNS_TRUNCATION(x) ((x)->query |= (DNS_TRUNC))
125
2005-11-29
pbug
#define SET_DNS_RECURSION(x) ((x)->query |= (DNS_RECURSE))
126
2005-11-29
pbug
#define SET_DNS_RECURSION_AVAIL(x) ((x)->query |= (DNS_RECAVAIL))
127
2005-11-29
pbug
#define SET_DNS_RCODE_REFUSED(x) ((x)->query |= (DNS_REFUSED))
128
2005-11-29
pbug
#define SET_DNS_RCODE_NOTIMPL(x) ((x)->query |= (DNS_NOTIMPL))
129
2005-11-29
pbug
#define SET_DNS_RCODE_NAMEERR(x) ((x)->query |= (DNS_NAMEERR))
130
2005-11-29
pbug
#define SET_DNS_RCODE_SERVFAIL(x) ((x)->query |= (DNS_SERVFAIL))
131
2005-12-01
pbug
#define SET_DNS_RCODE_FORMATERR(x) ((x)->query |= (DNS_FORMATERR))
132
2005-11-29
pbug
#define SET_DNS_RCODE_NOERR(x) ((x)->query |= (DNS_NOERR))
133
2005-11-29
pbug
134
2014-05-17
pjp
#define UNSET_DNS_NOTIFY(x) ((x)->query &= ~(DNS_NOTIFY))
135
2010-09-16
pbug
#define UNSET_DNS_STATUS_REQ(x) ((x)->query &= ~(DNS_SREQ))
136
2010-09-16
pbug
#define UNSET_DNS_INVERSE_QUERY(x) ((x)->query &= ~(DNS_INV))
137
2010-09-16
pbug
#define UNSET_DNS_AUTHORITATIVE(x) ((x)->query &= ~(DNS_AUTH))
138
2010-09-16
pbug
#define UNSET_DNS_TRUNCATION(x) ((x)->query &= ~(DNS_TRUNC))
139
2010-09-16
pbug
#define UNSET_DNS_RECURSION(x) ((x)->query &= ~(DNS_RECURSE))
140
2010-09-16
pbug
#define UNSET_DNS_RECURSION_AVAIL(x) ((x)->query &= ~(DNS_RECAVAIL))
141
2010-09-16
pbug
#define UNSET_DNS_RCODE_REFUSED(x) ((x)->query &= ~(DNS_REFUSED))
142
2010-09-16
pbug
#define UNSET_DNS_RCODE_NOTIMPL(x) ((x)->query &= ~(DNS_NOTIMPL))
143
2010-09-16
pbug
#define UNSET_DNS_RCODE_NAMEERR(x) ((x)->query &= ~(DNS_NAMEERR))
144
2010-09-16
pbug
#define UNSET_DNS_RCODE_SERVFAIL(x) ((x)->query &= ~(DNS_SERVFAIL))
145
2010-09-16
pbug
#define UNSET_DNS_RCODE_FORMATERR(x) ((x)->query &= ~(DNS_FORMATERR))
146
2010-09-16
pbug
#define UNSET_DNS_RCODE_NOERR(x) ((x)->query &= ~(DNS_NOERR))
147
2010-09-16
pbug
148
2014-05-09
pjp
/* DNSSEC/EDNS0 options RFC 3225 */
149
2014-05-09
pjp
150
2014-05-09
pjp
#define DNSSEC_OK 0x8000
151
2014-05-09
pjp
152
2014-05-09
pjp
#define SET_DNS_ERCODE_DNSSECOK(x) ((x)->ttl |= (DNSSEC_OK))
153
2014-05-09
pjp
#define UNSET_DNS_ERCODE_DNSSECOK(x) ((x)->ttl &= ~(DNSSEC_OK))
154
2014-05-09
pjp
155
2005-11-29
pbug
/* DNS types - RFC 1035 page 12 */
156
2005-11-29
pbug
157
2005-11-29
pbug
#define DNS_TYPE_A 1
158
2005-11-29
pbug
#define DNS_TYPE_NS 2
159
2005-11-29
pbug
#define DNS_TYPE_CNAME 5
160
2005-11-29
pbug
#define DNS_TYPE_SOA 6
161
2005-11-29
pbug
#define DNS_TYPE_PTR 12
162
2005-11-29
pbug
#define DNS_TYPE_MX 15
163
2005-11-29
pbug
#define DNS_TYPE_TXT 16
164
2005-11-29
pbug
165
2012-04-30
pbug
#define DNS_TYPE_SRV 33 /* RFC 2782, page 8 */
166
2014-05-11
pjp
#define DNS_TYPE_NAPTR 35 /* RFC 2915, page 3 */
167
2014-05-09
pjp
#define DNS_TYPE_OPT 41 /* RFC 6891, page 7 */
168
2014-04-21
pjp
#define DNS_TYPE_SSHFP 44 /* RFC 4255 */
169
2012-04-30
pbug
170
2014-04-21
pjp
#define DNS_TYPE_SPF 99 /* RFC 4408 */
171
2014-04-21
pjp
172
2012-01-27
pbug
#define DNS_TYPE_TSIG 250 /* RFC 2845, page 3 */
173
2011-09-22
pbug
#define DNS_TYPE_IXFR 251 /* RFC 1995, page 2 */
174
2011-09-19
pbug
#define DNS_TYPE_AXFR 252 /* RFC 5936, page 10 */
175
2010-12-27
pbug
#define DNS_TYPE_ANY 255
176
2010-12-27
pbug
177
2010-03-09
pbug
/* DNS types 0xff00 -> 0xfffe (private use) RFC 5395, page 8 */
178
2010-03-09
pbug
179
2010-03-18
pbug
#define DNS_TYPE_BALANCE 0xfffe /* split horizon dns */
180
2010-03-18
pbug
#define DNS_TYPE_DELEGATE 0xfffd /* ns delegations */
181
2010-04-01
pbug
#define DNS_TYPE_HINT 0xfffc /* root hint */
182
2010-03-09
pbug
183
2005-11-29
pbug
/* quad A - RFC 3596 */
184
2005-11-29
pbug
#define DNS_TYPE_AAAA 28
185
2005-11-29
pbug
186
2005-11-29
pbug
187
2005-11-29
pbug
/* DNS CLASSES - RFC 1035 page 13 */
188
2005-11-29
pbug
189
2005-11-29
pbug
#define DNS_CLASS_IN 1 /* internet */
190
2005-11-29
pbug
#define DNS_CLASS_CH 3 /* chaos */
191
2005-11-29
pbug
#define DNS_CLASS_HS 4 /* hesiod */
192
2005-11-29
pbug
193
2005-11-29
pbug
#define DNS_CLASS_ANY 255 /* any class */
194
2005-11-29
pbug
195
2005-11-29
pbug
/* limits */
196
2005-11-29
pbug
197
2005-11-29
pbug
#define DNS_MAXLABEL 63
198
2005-11-29
pbug
#define DNS_MAXNAME 255
199
2005-11-29
pbug
#define DNS_MAXUDP 512
200
2005-11-29
pbug
201
2014-04-21
pjp
/* SSHFP fingerprint sizes */
202
2005-11-29
pbug
203
2014-04-22
pjp
#define DNS_SSHFP_SIZE_SHA1 20 /* RFC 4255 */
204
2014-04-22
pjp
#define DNS_SSHFP_SIZE_SHA256 32 /* RFC 6594 */
205
2014-04-21
pjp
206
2014-04-21
pjp
207
2005-11-29
pbug
struct question {
208
2005-11-29
pbug
struct dns_question_hdr *hdr;
209
2005-11-29
pbug
char *converted_name;
210
2014-05-09
pjp
int edns0len;
211
2014-05-09
pjp
int dnssecok;
212
2005-11-29
pbug
};
213
2005-11-29
pbug
214
2005-11-29
pbug
#endif /* DNS_H */
repomaster@centroid.eu