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
#include "include.h"
029
2005-11-29
pbug
#include "dns.h"
030
2005-11-29
pbug
#include "db.h"
031
2005-11-29
pbug
032
2005-11-29
pbug
int additional_a(char *, int, struct domain *, char *, int, int, int *);
033
2005-11-29
pbug
int additional_aaaa(char *, int, struct domain *, char *, int, int, int *);
034
2005-11-29
pbug
int additional_mx(char *, int, struct domain *, char *, int, int, int *);
035
2014-05-10
pjp
int additional_opt(struct question *, char *, int, int);
036
2014-05-18
pjp
int additional_ptr(char *, int, struct domain *, char *, int, int, int *);
037
2005-11-29
pbug
038
2010-04-15
pbug
extern int compress_label(u_char *, int, int);
039
2005-11-29
pbug
040
2014-05-18
pjp
static const char rcsid[] = "$Id: additional.c,v 1.17 2014/05/18 17:14:05 pjp Exp $";
041
2005-11-29
pbug
042
2008-04-15
pbug
043
2005-11-29
pbug
/*
044
2005-11-29
pbug
* ADDITIONAL_A - tag on an additional set of A records to packet
045
2005-11-29
pbug
*/
046
2005-11-29
pbug
047
2005-11-29
pbug
int
048
2005-11-29
pbug
additional_a(char *name, int namelen, struct domain *sd, char *reply, int replylen, int offset, int *retcount)
049
2005-11-29
pbug
{
050
2005-11-29
pbug
int a_count;
051
2005-11-29
pbug
int tmplen;
052
2005-11-29
pbug
int rroffset = offset;
053
2005-11-29
pbug
054
2005-11-29
pbug
struct answer {
055
2005-11-29
pbug
u_int16_t type;
056
2005-11-29
pbug
u_int16_t class;
057
2005-11-29
pbug
u_int32_t ttl;
058
2005-11-29
pbug
u_int16_t rdlength; /* 12 */
059
2005-11-29
pbug
in_addr_t rdata; /* 16 */
060
2005-11-29
pbug
} __attribute__((packed));
061
2005-11-29
pbug
062
2005-11-29
pbug
struct answer *answer;
063
2005-11-29
pbug
064
2005-11-29
pbug
*retcount = 0;
065
2005-11-29
pbug
066
2005-11-29
pbug
/*
067
2005-11-29
pbug
* We loop through our sd->a entries starting at the ptr offset
068
2005-11-29
pbug
* first in the first loop and at the beginning until the ptr
069
2005-11-29
pbug
* in the last loop. This will shift answers based on a_ptr.
070
2005-11-29
pbug
*/
071
2005-11-29
pbug
072
2005-11-29
pbug
for (a_count = sd->a_ptr; a_count < sd->a_count; a_count++) {
073
2005-11-29
pbug
rroffset = offset;
074
2005-11-29
pbug
if ((offset + namelen) > replylen)
075
2005-11-29
pbug
goto out;
076
2005-11-29
pbug
077
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
078
2005-11-29
pbug
offset += namelen;
079
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
080
2005-11-29
pbug
081
2005-11-29
pbug
if (tmplen != 0) {
082
2005-11-29
pbug
offset = tmplen;
083
2005-11-29
pbug
}
084
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
085
2005-11-29
pbug
offset = rroffset;
086
2005-11-29
pbug
goto out;
087
2005-11-29
pbug
}
088
2005-11-29
pbug
089
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
090
2005-11-29
pbug
091
2005-11-29
pbug
answer->type = htons(DNS_TYPE_A);
092
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
093
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
094
2005-11-29
pbug
095
2005-11-29
pbug
answer->rdlength = htons(sizeof(in_addr_t));
096
2005-11-29
pbug
097
2005-11-29
pbug
memcpy((char *)&answer->rdata, (char *)&sd->a[a_count], sizeof(in_addr_t));
098
2005-11-29
pbug
offset += sizeof(struct answer);
099
2005-11-29
pbug
(*retcount)++;
100
2005-11-29
pbug
101
2005-11-29
pbug
}
102
2005-11-29
pbug
103
2005-11-29
pbug
for (a_count = 0; a_count < sd->a_ptr; a_count++) {
104
2005-11-29
pbug
rroffset = offset;
105
2005-11-29
pbug
if ((offset + namelen) > replylen)
106
2005-11-29
pbug
goto out;
107
2005-11-29
pbug
108
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
109
2005-11-29
pbug
offset += namelen;
110
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
111
2005-11-29
pbug
112
2005-11-29
pbug
if (tmplen != 0) {
113
2005-11-29
pbug
offset = tmplen;
114
2005-11-29
pbug
}
115
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
116
2005-11-29
pbug
offset = rroffset;
117
2005-11-29
pbug
goto out;
118
2005-11-29
pbug
}
119
2005-11-29
pbug
120
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
121
2005-11-29
pbug
122
2005-11-29
pbug
answer->type = htons(DNS_TYPE_A);
123
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
124
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
125
2005-11-29
pbug
126
2005-11-29
pbug
answer->rdlength = htons(sizeof(in_addr_t));
127
2005-11-29
pbug
128
2005-11-29
pbug
memcpy((char *)&answer->rdata, (char *)&sd->a[a_count], sizeof(in_addr_t));
129
2005-11-29
pbug
offset += sizeof(struct answer);
130
2005-11-29
pbug
(*retcount)++;
131
2005-11-29
pbug
}
132
2005-11-29
pbug
133
2005-11-29
pbug
134
2005-11-29
pbug
out:
135
2005-11-29
pbug
return (offset);
136
2005-11-29
pbug
137
2005-11-29
pbug
}
138
2005-11-29
pbug
139
2005-11-29
pbug
/*
140
2005-11-29
pbug
* ADDITIONAL_AAAA - tag on an additional set of AAAA records to packet
141
2005-11-29
pbug
*/
142
2005-11-29
pbug
143
2005-11-29
pbug
int
144
2005-11-29
pbug
additional_aaaa(char *name, int namelen, struct domain *sd, char *reply, int replylen, int offset, int *retcount)
145
2005-11-29
pbug
{
146
2005-11-29
pbug
int aaaa_count;
147
2005-11-29
pbug
int tmplen;
148
2005-11-29
pbug
int rroffset = offset;
149
2005-11-29
pbug
150
2005-11-29
pbug
struct answer {
151
2005-11-29
pbug
u_int16_t type;
152
2005-11-29
pbug
u_int16_t class;
153
2005-11-29
pbug
u_int32_t ttl;
154
2005-11-29
pbug
u_int16_t rdlength;
155
2005-11-29
pbug
struct in6_addr rdata;
156
2005-11-29
pbug
} __attribute__((packed));
157
2005-11-29
pbug
158
2005-11-29
pbug
struct answer *answer;
159
2005-11-29
pbug
160
2005-11-29
pbug
*retcount = 0;
161
2005-11-29
pbug
162
2005-11-29
pbug
/*
163
2005-11-29
pbug
* We loop through our sd->aaaa entries starting at the ptr offset
164
2005-11-29
pbug
* first in the first loop and at the beginning until the ptr
165
2005-11-29
pbug
* in the last loop. This will shift answers based on a_ptr.
166
2005-11-29
pbug
*/
167
2005-11-29
pbug
168
2005-11-29
pbug
for (aaaa_count = sd->aaaa_ptr; aaaa_count < sd->aaaa_count; aaaa_count++) {
169
2005-11-29
pbug
rroffset = offset;
170
2005-11-29
pbug
if ((offset + namelen) > replylen)
171
2005-11-29
pbug
goto out;
172
2005-11-29
pbug
173
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
174
2005-11-29
pbug
offset += namelen;
175
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
176
2005-11-29
pbug
177
2005-11-29
pbug
if (tmplen != 0) {
178
2005-11-29
pbug
offset = tmplen;
179
2005-11-29
pbug
}
180
2005-11-29
pbug
181
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
182
2005-11-29
pbug
offset = rroffset;
183
2005-11-29
pbug
goto out;
184
2005-11-29
pbug
}
185
2005-11-29
pbug
186
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
187
2005-11-29
pbug
188
2005-11-29
pbug
answer->type = htons(DNS_TYPE_AAAA);
189
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
190
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
191
2005-11-29
pbug
192
2005-11-29
pbug
answer->rdlength = htons(sizeof(struct in6_addr));
193
2005-11-29
pbug
194
2011-09-19
pbug
memcpy((char *)&answer->rdata, (char *)&sd->aaaa[aaaa_count], sizeof(struct in6_addr));
195
2005-11-29
pbug
offset += sizeof(struct answer);
196
2005-11-29
pbug
(*retcount)++;
197
2005-11-29
pbug
198
2005-11-29
pbug
}
199
2005-11-29
pbug
200
2005-11-29
pbug
for (aaaa_count = 0; aaaa_count < sd->aaaa_ptr; aaaa_count++) {
201
2005-11-29
pbug
rroffset = offset;
202
2005-11-29
pbug
if ((offset + namelen) > replylen)
203
2005-11-29
pbug
goto out;
204
2005-11-29
pbug
205
2005-11-29
pbug
206
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
207
2005-11-29
pbug
offset += namelen;
208
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
209
2005-11-29
pbug
210
2005-11-29
pbug
if (tmplen != 0) {
211
2005-11-29
pbug
offset = tmplen;
212
2005-11-29
pbug
}
213
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
214
2005-11-29
pbug
offset = rroffset;
215
2005-11-29
pbug
goto out;
216
2005-11-29
pbug
}
217
2005-11-29
pbug
218
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
219
2005-11-29
pbug
220
2005-11-29
pbug
answer->type = htons(DNS_TYPE_AAAA);
221
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
222
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
223
2005-11-29
pbug
224
2005-11-29
pbug
answer->rdlength = htons(sizeof(struct in6_addr));
225
2005-11-29
pbug
226
2005-11-29
pbug
227
2011-09-19
pbug
memcpy((char *)&answer->rdata, (char *)&sd->aaaa[aaaa_count], sizeof(struct in6_addr));
228
2005-11-29
pbug
offset += sizeof(struct answer);
229
2005-11-29
pbug
(*retcount)++;
230
2005-11-29
pbug
}
231
2005-11-29
pbug
232
2005-11-29
pbug
233
2005-11-29
pbug
out:
234
2005-11-29
pbug
return (offset);
235
2005-11-29
pbug
236
2005-11-29
pbug
}
237
2005-11-29
pbug
238
2005-11-29
pbug
/*
239
2005-11-29
pbug
* ADDITIONAL_MX() - replies a DNS question (*q) on socket (so)
240
2005-11-29
pbug
*
241
2005-11-29
pbug
*/
242
2005-11-29
pbug
243
2005-11-29
pbug
int
244
2005-11-29
pbug
additional_mx(char *name, int namelen, struct domain *sd, char *reply, int replylen, int offset, int *retcount)
245
2005-11-29
pbug
{
246
2005-11-29
pbug
int mx_count;
247
2005-11-29
pbug
int tmplen;
248
2005-11-29
pbug
int rroffset = offset;
249
2005-11-29
pbug
250
2005-11-29
pbug
struct answer {
251
2005-11-29
pbug
u_int16_t type;
252
2005-11-29
pbug
u_int16_t class;
253
2005-11-29
pbug
u_int32_t ttl;
254
2005-11-29
pbug
u_int16_t rdlength;
255
2005-11-29
pbug
u_int16_t mx_priority;
256
2005-11-29
pbug
} __attribute__((packed));
257
2005-11-29
pbug
258
2005-11-29
pbug
struct answer *answer;
259
2005-11-29
pbug
260
2005-11-29
pbug
*retcount = 0;
261
2005-11-29
pbug
262
2005-11-29
pbug
/*
263
2005-11-29
pbug
* We loop through our sd->mx entries starting at the ptr offset
264
2005-11-29
pbug
* first in the first loop and at the beginning until the ptr
265
2005-11-29
pbug
* in the last loop. This will shift answers based on mx_ptr.
266
2005-11-29
pbug
*/
267
2005-11-29
pbug
268
2005-11-29
pbug
for (mx_count = sd->mx_ptr; mx_count < sd->mx_count; mx_count++) {
269
2005-11-29
pbug
rroffset = offset;
270
2005-11-29
pbug
271
2005-11-29
pbug
if ((offset + namelen) > replylen)
272
2005-11-29
pbug
goto out;
273
2005-11-29
pbug
274
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
275
2005-11-29
pbug
offset += namelen;
276
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
277
2005-11-29
pbug
278
2005-11-29
pbug
if (tmplen != 0) {
279
2005-11-29
pbug
offset = tmplen;
280
2005-11-29
pbug
}
281
2005-11-29
pbug
282
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
283
2005-11-29
pbug
offset = rroffset;
284
2005-11-29
pbug
goto out;
285
2005-11-29
pbug
}
286
2005-11-29
pbug
287
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
288
2005-11-29
pbug
289
2005-11-29
pbug
answer->type = htons(DNS_TYPE_MX);
290
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
291
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
292
2011-09-19
pbug
answer->mx_priority = htons(sd->mx[mx_count].preference);
293
2005-11-29
pbug
294
2005-11-29
pbug
offset += sizeof(struct answer);
295
2005-11-29
pbug
296
2011-09-19
pbug
if ((offset + sd->mx[mx_count].exchangelen) > replylen) {
297
2005-11-29
pbug
offset = rroffset;
298
2005-11-29
pbug
goto out;
299
2005-11-29
pbug
}
300
2005-11-29
pbug
301
2011-09-19
pbug
memcpy((char *)&reply[offset], (char *)sd->mx[mx_count].exchange, sd->mx[mx_count].exchangelen);
302
2005-11-29
pbug
303
2011-09-19
pbug
offset += sd->mx[mx_count].exchangelen;
304
2011-09-19
pbug
tmplen = compress_label((u_char*)reply, offset, sd->mx[mx_count].exchangelen);
305
2005-11-29
pbug
306
2005-11-29
pbug
if (tmplen != 0) {
307
2011-09-19
pbug
answer->rdlength = htons((sd->mx[mx_count].exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
308
2005-11-29
pbug
offset = tmplen;
309
2005-11-29
pbug
} else
310
2011-09-19
pbug
answer->rdlength = htons(sd->mx[mx_count].exchangelen + sizeof(u_int16_t));
311
2005-11-29
pbug
312
2005-11-29
pbug
313
2005-11-29
pbug
(*retcount)++;
314
2005-11-29
pbug
315
2005-11-29
pbug
}
316
2005-11-29
pbug
317
2005-11-29
pbug
for (mx_count = 0; mx_count < sd->mx_ptr; mx_count++) {
318
2005-11-29
pbug
rroffset = offset;
319
2005-11-29
pbug
320
2005-11-29
pbug
if ((offset + namelen) > replylen)
321
2005-11-29
pbug
goto out;
322
2005-11-29
pbug
323
2005-11-29
pbug
324
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
325
2005-11-29
pbug
offset += namelen;
326
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
327
2005-11-29
pbug
328
2005-11-29
pbug
if (tmplen != 0) {
329
2005-11-29
pbug
offset = tmplen;
330
2005-11-29
pbug
}
331
2005-11-29
pbug
332
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
333
2005-11-29
pbug
offset = rroffset;
334
2005-11-29
pbug
goto out;
335
2005-11-29
pbug
}
336
2005-11-29
pbug
337
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
338
2005-11-29
pbug
339
2005-11-29
pbug
answer->type = htons(DNS_TYPE_A);
340
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
341
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
342
2005-11-29
pbug
343
2005-11-29
pbug
offset += sizeof(struct answer);
344
2005-11-29
pbug
345
2011-09-19
pbug
if ((offset + sd->mx[mx_count].exchangelen) > replylen) {
346
2005-11-29
pbug
offset = rroffset;
347
2005-11-29
pbug
goto out;
348
2005-11-29
pbug
}
349
2005-11-29
pbug
350
2011-09-19
pbug
memcpy((char *)&reply[offset], (char *)sd->mx[mx_count].exchange, sd->mx[mx_count].exchangelen);
351
2005-11-29
pbug
352
2011-09-19
pbug
offset += sd->mx[mx_count].exchangelen;
353
2011-09-19
pbug
tmplen = compress_label((u_char *)reply, offset, sd->mx[mx_count].exchangelen);
354
2005-11-29
pbug
355
2005-11-29
pbug
if (tmplen != 0) {
356
2005-11-29
pbug
357
2011-09-19
pbug
answer->rdlength = htons((sd->mx[mx_count].exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
358
2005-11-29
pbug
offset = tmplen;
359
2005-11-29
pbug
} else
360
2011-09-19
pbug
answer->rdlength = htons(sd->mx[mx_count].exchangelen + sizeof(u_int16_t));
361
2005-11-29
pbug
362
2005-11-29
pbug
(*retcount)++;
363
2005-11-29
pbug
}
364
2005-11-29
pbug
365
2005-11-29
pbug
366
2005-11-29
pbug
out:
367
2005-11-29
pbug
return (offset);
368
2005-11-29
pbug
369
2005-11-29
pbug
}
370
2005-11-29
pbug
371
2005-11-29
pbug
/*
372
2005-11-29
pbug
* ADDITIONAL_PTR() - replies a DNS question (*q) on socket (so)
373
2005-11-29
pbug
*
374
2005-11-29
pbug
*/
375
2005-11-29
pbug
376
2005-11-29
pbug
377
2005-11-29
pbug
int
378
2005-11-29
pbug
additional_ptr(char *name, int namelen, struct domain *sd, char *reply, int replylen, int offset, int *retcount)
379
2005-11-29
pbug
{
380
2005-11-29
pbug
int tmplen;
381
2005-11-29
pbug
int rroffset = offset;
382
2005-11-29
pbug
383
2005-11-29
pbug
struct answer {
384
2005-11-29
pbug
u_int16_t type;
385
2005-11-29
pbug
u_int16_t class;
386
2005-11-29
pbug
u_int32_t ttl;
387
2005-11-29
pbug
u_int16_t rdlength;
388
2005-11-29
pbug
} __attribute__((packed));
389
2005-11-29
pbug
390
2005-11-29
pbug
struct answer *answer;
391
2005-11-29
pbug
392
2005-11-29
pbug
*retcount = 0;
393
2005-11-29
pbug
394
2005-11-29
pbug
395
2005-11-29
pbug
if ((offset + namelen) > replylen)
396
2005-11-29
pbug
goto out;
397
2005-11-29
pbug
398
2005-11-29
pbug
memcpy(&reply[offset], name, namelen);
399
2005-11-29
pbug
offset += namelen;
400
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, namelen);
401
2005-11-29
pbug
402
2005-11-29
pbug
if (tmplen != 0) {
403
2005-11-29
pbug
offset = tmplen;
404
2005-11-29
pbug
}
405
2005-11-29
pbug
406
2005-11-29
pbug
if ((offset + sizeof(struct answer)) > replylen) {
407
2005-11-29
pbug
offset = rroffset;
408
2005-11-29
pbug
goto out;
409
2005-11-29
pbug
}
410
2005-11-29
pbug
411
2005-11-29
pbug
answer = (struct answer *)&reply[offset];
412
2005-11-29
pbug
413
2005-11-29
pbug
answer->type = htons(DNS_TYPE_PTR);
414
2005-11-29
pbug
answer->class = htons(DNS_CLASS_IN);
415
2005-11-29
pbug
answer->ttl = htonl(sd->ttl);
416
2005-11-29
pbug
417
2005-11-29
pbug
offset += sizeof(struct answer);
418
2005-11-29
pbug
419
2005-11-29
pbug
if ((offset + sd->ptrlen) > replylen) {
420
2005-11-29
pbug
offset = rroffset;
421
2005-11-29
pbug
goto out;
422
2005-11-29
pbug
}
423
2005-11-29
pbug
424
2010-03-28
pbug
memcpy((char *)&reply[offset], (char *)sd->ptr, sd->ptrlen);
425
2005-11-29
pbug
426
2005-11-29
pbug
offset += sd->ptrlen;
427
2010-07-27
pbug
tmplen = compress_label((u_char*)reply, offset, sd->ptrlen);
428
2005-11-29
pbug
429
2005-11-29
pbug
if (tmplen != 0) {
430
2005-11-29
pbug
answer->rdlength = htons(sd->ptrlen - (offset - tmplen));
431
2005-11-29
pbug
offset = tmplen;
432
2005-11-29
pbug
} else
433
2005-11-29
pbug
answer->rdlength = htons(sd->ptrlen);
434
2005-11-29
pbug
435
2005-11-29
pbug
436
2005-11-29
pbug
(*retcount)++;
437
2014-05-10
pjp
438
2014-05-10
pjp
out:
439
2014-05-10
pjp
return (offset);
440
2014-05-10
pjp
441
2014-05-10
pjp
}
442
2014-05-10
pjp
443
2014-05-10
pjp
/*
444
2014-05-10
pjp
* ADDITIONAL_OPT - tag on an additional EDNS0 (OPT) record to packet
445
2014-05-10
pjp
*/
446
2014-05-10
pjp
447
2014-05-10
pjp
int
448
2014-05-10
pjp
additional_opt(struct question *question, char *reply, int replylen, int offset)
449
2014-05-10
pjp
{
450
2014-05-10
pjp
struct dns_optrr *answer;
451
2014-05-10
pjp
452
2014-05-10
pjp
if ((offset + sizeof(struct dns_optrr)) > replylen) {
453
2014-05-10
pjp
goto out;
454
2014-05-10
pjp
}
455
2014-05-10
pjp
456
2014-05-10
pjp
answer = (struct dns_optrr *)&reply[offset];
457
2014-05-10
pjp
458
2014-05-10
pjp
memset(answer->name, 0, sizeof(answer->name));
459
2014-05-10
pjp
answer->type = htons(DNS_TYPE_OPT);
460
2014-05-10
pjp
answer->class = htons(question->edns0len);
461
2014-05-10
pjp
answer->ttl = htonl(0);
462
2014-05-10
pjp
463
2014-05-10
pjp
answer->rdlen = htons(0);
464
2014-05-10
pjp
465
2014-05-10
pjp
offset += sizeof(struct dns_optrr);
466
2005-11-29
pbug
467
2005-11-29
pbug
out:
468
2005-11-29
pbug
return (offset);
469
2005-11-29
pbug
470
2005-11-29
pbug
}
repomaster@centroid.eu