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 GNUNET_NETWORK_STRUCT_BEGIN
37 uint16_t id GNUNET_PACKED;
39 unsigned rd:1 GNUNET_PACKED; // recursion desired (client -> server)
40 unsigned tc:1 GNUNET_PACKED; // message is truncated
41 unsigned aa:1 GNUNET_PACKED; // authoritative answer
42 unsigned op:4 GNUNET_PACKED; // query:0, inverse q.:1, status: 2
43 unsigned qr:1 GNUNET_PACKED; // query:0, response:1
45 unsigned rcode:4 GNUNET_PACKED; // 0 No error
51 unsigned z:3 GNUNET_PACKED; // reserved
52 unsigned ra:1 GNUNET_PACKED; // recursion available (server -> client)
54 uint16_t qdcount GNUNET_PACKED; // number of questions
55 uint16_t ancount GNUNET_PACKED; // number of answers
56 uint16_t nscount GNUNET_PACKED; // number of authority-records
57 uint16_t arcount GNUNET_PACKED; // number of additional records
59 GNUNET_NETWORK_STRUCT_END
64 unsigned char data[1];
70 struct dns_query **queries;
71 struct dns_record **answers;
72 struct dns_record **nameservers;
73 struct dns_record **additional;
85 unsigned char namelen;
90 struct dns_record_line
102 unsigned char namelen;
111 struct dns_pkt_parsed *
112 parse_dns_packet (struct dns_pkt *pkt);
115 unparse_dns_packet (struct dns_pkt_parsed *pkt);
118 free_parsed_dns_packet (struct dns_pkt_parsed *ppkt);