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 3, 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_gns_service.h
23 * @brief API to the GNS service
24 * @author Martin Schanzenbach
26 #ifndef GNUNET_GNS_SERVICE_H
27 #define GNUNET_GNS_SERVICE_H
29 #include "gnunet_util_lib.h"
30 #include "gnunet_dnsparser_lib.h"
31 #include "gnunet_namestore_service.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * String we use to indicate the local master zone or a
44 * root entry in the current zone.
46 #define GNUNET_GNS_MASTERZONE_STR "+"
49 * Connection to the GNS service.
51 struct GNUNET_GNS_Handle;
54 * Handle to control a lookup operation.
56 struct GNUNET_GNS_LookupRequest;
59 * Handle to control a shorten operation.
61 struct GNUNET_GNS_ShortenRequest;
64 * Handle to control a get authority operation
66 struct GNUNET_GNS_GetAuthRequest;
70 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
72 enum GNUNET_GNS_RecordType
76 GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
79 GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
82 GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
85 GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
88 GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
91 GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
94 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
97 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
100 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
103 /* struct GNUNET_CRYPTO_ShortHashCode */
104 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
107 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
108 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
111 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
113 /* struct vpn_data */
114 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
117 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
122 * Initialize the connection with the GNS service.
124 * @param cfg configuration to use
126 * @return handle to the GNS service, or NULL on error
128 struct GNUNET_GNS_Handle *
129 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
133 * Shutdown connection with the GNS service.
135 * @param handle connection to shut down
138 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
141 /* *************** Standard API: lookup ******************* */
144 * Iterator called on obtained result for a GNS
148 * @param rd_count number of records
149 * @param rd the records in reply
151 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
153 const struct GNUNET_NAMESTORE_RecordData *rd);
158 * Perform an asynchronous lookup operation on the GNS
159 * in the default zone.
161 * @param handle handle to the GNS service
162 * @param name the name to look up
163 * @param type the GNUNET_GNS_RecordType to look for
164 * @param only_cached GNUNET_NO to only check locally not DHT for performance
165 * @param shorten_key the private key of the shorten zone (can be NULL)
166 * @param proc function to call on result
167 * @param proc_cls closure for processor
169 * @return handle to the queued request
171 struct GNUNET_GNS_LookupRequest*
172 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
174 enum GNUNET_GNS_RecordType type,
176 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
177 GNUNET_GNS_LookupResultProcessor proc,
182 * Perform an asynchronous lookup operation on the GNS
183 * in the zone specified by 'zone'.
185 * @param handle handle to the GNS service
186 * @param name the name to look up
187 * @param zone the zone to start the resolution in
188 * @param type the GNUNET_GNS_RecordType to look for
189 * @param only_cached GNUNET_YES to only check locally not DHT for performance
190 * @param shorten_key the private key of the shorten zone (can be NULL)
191 * @param proc function to call on result
192 * @param proc_cls closure for processor
194 * @return handle to the queued request
196 struct GNUNET_GNS_LookupRequest*
197 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
199 struct GNUNET_CRYPTO_ShortHashCode *zone,
200 enum GNUNET_GNS_RecordType type,
202 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
203 GNUNET_GNS_LookupResultProcessor proc,
208 * Cancel pending lookup request
210 * @param lr the lookup request to cancel
213 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
215 /* *************** Standard API: shorten ******************* */
219 * Processor called on for a name shortening result
223 * @param short_name the shortened name or NULL if no result / error
225 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
226 const char* short_name);
230 * Perform a name shortening operation on the GNS.
232 * @param handle handle to the GNS service
233 * @param name the name to look up
234 * @param private_zone the public zone of the private zone
235 * @param shorten_zone the public zone of the shorten zone
236 * @param proc function to call on result
237 * @param proc_cls closure for processor
238 * @return handle to the operation
240 struct GNUNET_GNS_ShortenRequest*
241 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
243 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
244 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
245 GNUNET_GNS_ShortenResultProcessor proc,
250 * Perform a name shortening operation on the GNS.
252 * @param handle handle to the GNS service
253 * @param name the name to look up
254 * @param private_zone the public zone of the private zone
255 * @param shorten_zone the public zone of the shorten zone
256 * @param zone the zone to start the resolution in
257 * @param proc function to call on result
258 * @param proc_cls closure for processor
259 * @return handle to the operation
261 struct GNUNET_GNS_ShortenRequest*
262 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
264 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
265 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
266 struct GNUNET_CRYPTO_ShortHashCode *zone,
267 GNUNET_GNS_ShortenResultProcessor proc,
272 * Cancel pending shorten request
274 * @param sr the lookup request to cancel
277 GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr);
280 /* *************** Standard API: get authority ******************* */
284 * Processor called on for a name shortening result
288 * @param auth_name the name of the auhtority or NULL
290 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
291 const char* short_name);
295 * Perform an authority lookup for a given name.
297 * @param handle handle to the GNS service
298 * @param name the name to look up authority for
299 * @param proc function to call on result
300 * @param proc_cls closure for processor
301 * @return handle to the operation
303 struct GNUNET_GNS_GetAuthRequest*
304 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
306 GNUNET_GNS_GetAuthResultProcessor proc,
311 * Cancel pending get auth request
313 * @param gar the lookup request to cancel
316 GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
318 #if 0 /* keep Emacsens' auto-indent happy */
327 /* gnunet_gns_service.h */