djbdnscurve6 45
djbdnscurve6
Loading...
Searching...
No Matches
edns0.c
Go to the documentation of this file.
1/* (C) 2012 Peter Conrad <conrad@quisquis.de>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 3 as
5 * published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
15
16#include "ip.h"
17#include "dns.h"
18#include "response.h"
19#include "uint_t.h"
20
21unsigned int dns_packet_edns0(const char header[12], const char *buf, const int len, unsigned int pos)
22{
23 char opt_class[2];
24 char opt_ttl[4];
25 uint16 size;
26 uint16 min_len;
27 char nametype[3];
28
29 do_dnssec = 0;
30 if (!header[6] && !header[7] && !header[8] &&
31 !header[9] && !header[10] && header[11] == 1) {
32 pos = dns_packet_copy(buf,len,pos,nametype,3); if (!pos) return pos;
33 if (nametype[0] || nametype[1] || nametype[2] != DNS_T_OPT[1]) return pos;
34 pos = dns_packet_copy(buf,len,pos,opt_class,2); if (!pos) return pos;
35 pos = dns_packet_copy(buf,len,pos,opt_ttl,4); if (!pos) return pos;
36 if (opt_ttl[0]) return pos; // unsupported RCODE in query
37 if (opt_ttl[1]) return pos; // unsupported version
38 do_dnssec = opt_ttl[2] & 0x80;
39 uint16_unpack_big(opt_class,&size);
40 min_len = do_dnssec ? MSGSIZE : MINMSGSIZE;
41 max_response_len = size > MSGSIZE ? MSGSIZE : size;
42 if (max_response_len < min_len) { max_response_len = min_len; }
43 }
44 return pos;
45}
uint16 len
Definition: axfrdns.c:319
char buf[MSGSIZE]
Definition: axfrdns.c:318
#define MSGSIZE
Definition: dns.h:38
#define DNS_T_OPT
Definition: dns.h:71
#define MINMSGSIZE
Definition: dns.h:39
unsigned int dns_packet_copy(const char *buf, unsigned int len, unsigned int pos, char *out, unsigned int outlen)
Definition: dns_packet.c:8
unsigned int dns_packet_edns0(const char header[12], const char *buf, const int len, unsigned int pos)
Definition: edns0.c:21
unsigned int max_response_len
Definition: response.c:8
unsigned int do_dnssec
Definition: response.c:9