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_dns_service.h
23 * @brief API to access the DNS service. Not finished at all,
24 * currently only contains the structs for the IPC, which
25 * don't even belong here (legacy code in transition)
26 * @author Philipp Toelke
28 #ifndef GNUNET_DNS_SERVICE_H
29 #define GNUNET_DNS_SERVICE_H
31 #include "gnunet_common.h"
32 #include "gnunet_util_lib.h"
34 GNUNET_NETWORK_STRUCT_BEGIN
38 struct GNUNET_MessageHeader hdr;
41 * The IP-Address this query was originally sent to
45 * The IP-Address this query was originally sent from
49 * The UDP-Portthis query was originally sent from
52 uint16_t src_port GNUNET_PACKED;
54 unsigned char data[1]; /* The DNS-Packet */
57 struct query_packet_list
59 struct query_packet_list *next GNUNET_PACKED;
60 struct query_packet_list *prev GNUNET_PACKED;
61 struct query_packet pkt;
64 enum GNUNET_DNS_ANSWER_Subtype
67 * Answers of this type contain a dns-packet that just has to be transmitted
69 GNUNET_DNS_ANSWER_TYPE_IP,
72 * Answers of this type contain an incomplete dns-packet. The IP-Address
73 * is all 0s. The addroffset points to it.
75 GNUNET_DNS_ANSWER_TYPE_SERVICE,
78 * Answers of this type contain an incomplete dns-packet as answer to a
79 * PTR-Query. The resolved name is not allocated. The addroffset points to it.
81 GNUNET_DNS_ANSWER_TYPE_REV,
84 * Answers of this type contains an IP6-Address but traffic to this IP should
85 * be routed through the GNUNet.
87 GNUNET_DNS_ANSWER_TYPE_REMOTE_AAAA,
90 * Answers of this type contains an IP4-Address but traffic to this IP should
91 * be routed through the GNUNet.
93 GNUNET_DNS_ANSWER_TYPE_REMOTE_A
96 struct GNUNET_vpn_service_descriptor
98 GNUNET_HashCode peer GNUNET_PACKED;
99 GNUNET_HashCode service_descriptor GNUNET_PACKED;
100 uint64_t ports GNUNET_PACKED;
101 uint32_t service_type GNUNET_PACKED;
107 struct GNUNET_MessageHeader hdr;
108 enum GNUNET_DNS_ANSWER_Subtype subtype GNUNET_PACKED;
113 unsigned dst_port:16 GNUNET_PACKED;
116 /* Data for GNUNET_DNS_ANSWER_TYPE_SERVICE */
117 struct GNUNET_vpn_service_descriptor service_descr;
120 /* Data for GNUNET_DNS_ANSWER_TYPE_REV */
121 /* The offsett in octets from the beginning of the struct to the field
122 * in data where the IP-Address has to go. */
123 uint16_t addroffset GNUNET_PACKED;
126 /* Data for GNUNET_DNS_ANSWER_TYPE_REMOTE */
129 unsigned char addr[16];
132 unsigned char data[1];
135 struct answer_packet_list
137 struct answer_packet_list *next GNUNET_PACKED;
138 struct answer_packet_list *prev GNUNET_PACKED;
139 struct GNUNET_SERVER_Client *client;
140 struct answer_packet pkt;
142 GNUNET_NETWORK_STRUCT_END
144 struct GNUNET_DNS_Handle;
147 * Connect to the service-dns
149 struct GNUNET_DNS_Handle *
150 GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
151 GNUNET_SCHEDULER_Task cb,
155 GNUNET_DNS_restart_hijack (struct GNUNET_DNS_Handle *h);
159 * FIXME: we should not expost our internal structures like this.
160 * Just a quick initial hack.
163 GNUNET_DNS_queue_request (struct GNUNET_DNS_Handle *h,
164 struct query_packet_list *q);
167 GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *h);