djbdnscurve6 53
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 "query.h"
19#include "response.h"
20#include "uint_t.h"
21
22unsigned int dns_packet_edns0(const char header[12], const char *buf, const int len, unsigned int pos)
23{
24 char opt_class[2];
25 char opt_ttl[4];
26 uint16 size;
27 int min_len;
28 char nametype[3];
29
30 do_dnssec = 0;
31 if (!header[6] && !header[7] && !header[8] &&
32 !header[9] && !header[10] && header[11] == 1) { // #AR = 1 set
33 pos = dns_packet_copy(buf,len,pos,nametype,3); if (!pos) return pos;
34 if (nametype[0]) return pos; // nametype[0] = 0
35 if (nametype[1] || nametype[2] != DNS_T_OPT[0]) return pos;
36 pos = dns_packet_copy(buf,len,pos,opt_class,2); if (!pos) return pos;
37 pos = dns_packet_copy(buf,len,pos,opt_ttl,4); if (!pos) return pos;
38 if (opt_ttl[0]) return pos; // unsupported RCODE in query
39 if (opt_ttl[1]) return pos; // unsupported version
40 do_dnssec = opt_ttl[2] & 0x80;
41 uint16_unpack_big(opt_class,&size);
42 min_len = do_dnssec ? udp_msgsize() : MINMSGSIZE;
43 max_response_len = size > udp_msgsize() ? udp_msgsize() : size;
44 if (max_response_len < min_len) { max_response_len = min_len; }
45 }
46 return pos;
47}
uint16 len
Definition: axfrdns.c:322
char buf[MSGSIZE]
Definition: axfrdns.c:321
unsigned int udp_msgsize(void)
Definition: curvedns.c:38
#define DNS_T_OPT
Definition: dns.h:80
#define MINMSGSIZE
Definition: dns.h:48
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:22
unsigned int max_response_len
Definition: response.c:8
unsigned int do_dnssec
Definition: response.c:9