2 This file is part of GNUnet
3 (C) 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-new.h
23 * @brief API to access the DNS service.
24 * @author Christian Grothoff
26 #ifndef GNUNET_DNS_SERVICE_NEW_H
27 #define GNUNET_DNS_SERVICE_NEW_H
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.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
58 struct GNUNET_DNS_Handle;
61 * Handle to identify an individual DNS request.
63 struct GNUNET_DNS_RequestHandle;
67 * Signature of a function that is called whenever the DNS service
68 * encounters a DNS request and needs to do something with it. The
69 * function has then the chance to generate or modify the response by
70 * calling one of the three "GNUNET_DNS_request_*" continuations.
72 * When a request is intercepted, this function is called first to
73 * give the client a chance to do the complete address resolution;
74 * "rdata" will be NULL for this first call for a DNS request, unless
75 * some other client has already filled in a response.
77 * If multiple clients exist, all of them are called before the global
78 * DNS. The global DNS is only called if all of the clients'
79 * functions call GNUNET_DNS_request_forward. Functions that call
80 * GNUNET_DNS_request_forward will be called again before a final
81 * response is returned to the application. If any of the clients'
82 * functions call GNUNET_DNS_request_drop, the response is dropped.
85 * @param name name of the node to which the record pertains
86 * @param dns_type type of RR
87 * @param dns_class class code
88 * @param dns_ttl seconds that the RR stays valid, can be updated
89 * @param rdata_length size of rdata, can be updated
90 * @param rdata record data, can be updated
92 typedef void (*GNUNET_DNS_RequestHandler)(void *cls,
93 struct GNUNET_DNS_RequestHandle *rh,
98 uint16_t rdata_length,
103 * If a GNUNET_DNS_RequestHandler calls this function, the request is
104 * given to other clients or the global DNS for resolution. Once a
105 * global response has been obtained, the request handler is AGAIN
106 * called to give it a chance to observe and modify the response after
107 * the "normal" resolution. It is not legal for the request handler
108 * to call this function if a response is already present.
110 * @param rh request that should now be forwarded
113 GNUNET_DNS_request_forward (struct GNUNET_DNS_RequestHandle *rh);
117 * If a GNUNET_DNS_RequestHandler calls this function, the request is
118 * to be dropped and no response should be generated.
120 * @param rh request that should now be dropped
123 GNUNET_DNS_request_drop (struct GNUNET_DNS_RequestHandle *rh);
127 * If a GNUNET_DNS_RequestHandler calls this function, the request is supposed to
128 * be answered with the data provided to this call (with the modifications the function might have made).
130 * @param rh request that should now be answered
131 * @param dns_ttl seconds that the RR stays valid, can be updated
132 * @param rdata_length size of rdata, can be updated
133 * @param rdata record data, can be updated
136 GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh,
138 uint16_t rdata_length,
143 * Connect to the service-dns
145 * @param cfg configuration to use
146 * @param rh function to call with DNS requests
147 * @param rh_cls closure to pass to rh
150 struct GNUNET_DNS_Handle *
151 GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
152 GNUNET_DNS_RequestHandler rh,
157 * Disconnect from the DNS service.
159 * @param dh DNS handle
162 GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *dh);