2 This file is part of GNUnet
3 (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_dnsparse_lib.h
23 * @brief API for helper library to parse DNS packets.
24 * @author Philipp Toelke
26 #ifndef GNUNET_DNSPARSER_LIB_H
27 #define GNUNET_DNSPARSER_LIB_H
30 #include "gnunet_common.h"
33 * A few common DNS types.
35 #define GNUNET_DNS_TYPE_A 1
36 #define GNUNET_DNS_TYPE_NS 2
37 #define GNUNET_DNS_TYPE_CNAME 5
38 #define GNUNET_DNS_TYPE_SOA 6
39 #define GNUNET_DNS_TYPE_PTR 12
40 #define GNUNET_DNS_TYPE_MX 15
41 #define GNUNET_DNS_TYPE_TXT 16
42 #define GNUNET_DNS_TYPE_AAAA 28
43 #define GNUNET_DNS_TYPE_IXFR 251
44 #define GNUNET_DNS_TYPE_AXFR 252
47 * A few common DNS classes (ok, only one is common, but I list a
48 * couple more to make it clear what we're talking about here).
50 #define GNUNET_DNS_CLASS_INTERNET 1
51 #define GNUNET_DNS_CLASS_CHAOS 3
52 #define GNUNET_DNS_CLASS_HESIOD 4
56 GNUNET_NETWORK_STRUCT_BEGIN
60 uint16_t id GNUNET_PACKED;
62 unsigned rd:1 GNUNET_PACKED; // recursion desired (client -> server)
63 unsigned tc:1 GNUNET_PACKED; // message is truncated
64 unsigned aa:1 GNUNET_PACKED; // authoritative answer
65 unsigned op:4 GNUNET_PACKED; // query:0, inverse q.:1, status: 2
66 unsigned qr:1 GNUNET_PACKED; // query:0, response:1
68 unsigned rcode:4 GNUNET_PACKED; // 0 No error
74 unsigned z:3 GNUNET_PACKED; // reserved
75 unsigned ra:1 GNUNET_PACKED; // recursion available (server -> client)
77 uint16_t qdcount GNUNET_PACKED; // number of questions
78 uint16_t ancount GNUNET_PACKED; // number of answers
79 uint16_t nscount GNUNET_PACKED; // number of authority-records
80 uint16_t arcount GNUNET_PACKED; // number of additional records
82 GNUNET_NETWORK_STRUCT_END
87 unsigned char data[1];
93 struct dns_query **queries;
94 struct dns_record **answers;
95 struct dns_record **nameservers;
96 struct dns_record **additional;
108 unsigned char namelen;
113 struct dns_record_line
125 unsigned char namelen;
134 struct dns_pkt_parsed *
135 parse_dns_packet (struct dns_pkt *pkt);
138 unparse_dns_packet (struct dns_pkt_parsed *pkt);
141 free_parsed_dns_packet (struct dns_pkt_parsed *ppkt);