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
29 #ifndef GNUNET_GNS_SERVICE_H
30 #define GNUNET_GNS_SERVICE_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_dnsparser_lib.h"
34 #include "gnunet_namestore_service.h"
39 #if 0 /* keep Emacsens' auto-indent happy */
46 * Connection to the GNS service.
48 struct GNUNET_GNS_Handle;
51 * Handle to control a lookup operation.
53 struct GNUNET_GNS_LookupRequest;
56 * Handle to control a shorten operation.
58 struct GNUNET_GNS_ShortenRequest;
61 * Handle to control a get authority operation
63 struct GNUNET_GNS_GetAuthRequest;
67 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
69 enum GNUNET_GNS_RecordType
73 GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
76 GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
79 GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
82 GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
85 GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
88 GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
91 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
94 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
97 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
100 /* struct GNUNET_CRYPTO_ShortHashCode */
101 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
104 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
105 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
108 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
110 /* struct vpn_data */
111 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
112 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
117 * Initialize the connection with the GNS service.
119 * @param cfg configuration to use
121 * @return handle to the GNS service, or NULL on error
123 struct GNUNET_GNS_Handle *
124 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
128 * Shutdown connection with the GNS service.
130 * @param handle connection to shut down
133 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
136 /* *************** Standard API: lookup ******************* */
139 * Iterator called on obtained result for a GNS
143 * @param rd_count number of records
144 * @param rd the records in reply
146 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
148 const struct GNUNET_NAMESTORE_RecordData *rd);
153 * Perform an asynchronous lookup operation on the GNS
154 * in the default zone.
156 * @param handle handle to the GNS service
157 * @param name the name to look up
158 * @param type the GNUNET_GNS_RecordType to look for
159 * @param only_cached GNUNET_NO to only check locally not DHT for performance
160 * @param shorten_key the private key of the shorten zone (can be NULL)
161 * @param proc function to call on result
162 * @param proc_cls closure for processor
164 * @return handle to the queued request
166 struct GNUNET_GNS_LookupRequest*
167 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
169 enum GNUNET_GNS_RecordType type,
171 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
172 GNUNET_GNS_LookupResultProcessor proc,
177 * Perform an asynchronous lookup operation on the GNS
178 * in the zone specified by 'zone'.
180 * @param handle handle to the GNS service
181 * @param name the name to look up
182 * @param zone the zone to start the resolution in
183 * @param type the GNUNET_GNS_RecordType to look for
184 * @param only_cached GNUNET_YES to only check locally not DHT for performance
185 * @param shorten_key the private key of the shorten zone (can be NULL)
186 * @param proc function to call on result
187 * @param proc_cls closure for processor
189 * @return handle to the queued request
191 struct GNUNET_GNS_LookupRequest*
192 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
194 struct GNUNET_CRYPTO_ShortHashCode *zone,
195 enum GNUNET_GNS_RecordType type,
197 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
198 GNUNET_GNS_LookupResultProcessor proc,
203 * Cancel pending lookup request
205 * @param lr the lookup request to cancel
208 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
210 /* *************** Standard API: shorten ******************* */
214 * Processor called on for a name shortening result
218 * @param short_name the shortened name or NULL if no result / error
220 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
221 const char* short_name);
225 * Perform a name shortening operation on the GNS.
227 * @param handle handle to the GNS service
228 * @param name the name to look up
229 * @param private_zone the public zone of the private zone
230 * @param shorten_zone the public zone of the shorten zone
231 * @param proc function to call on result
232 * @param proc_cls closure for processor
233 * @return handle to the operation
235 struct GNUNET_GNS_ShortenRequest*
236 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
238 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
239 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
240 GNUNET_GNS_ShortenResultProcessor proc,
245 * Perform a name shortening operation on the GNS.
247 * @param handle handle to the GNS service
248 * @param name the name to look up
249 * @param private_zone the public zone of the private zone
250 * @param shorten_zone the public zone of the shorten zone
251 * @param zone the zone to start the resolution in
252 * @param proc function to call on result
253 * @param proc_cls closure for processor
254 * @return handle to the operation
256 struct GNUNET_GNS_ShortenRequest*
257 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
259 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
260 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
261 struct GNUNET_CRYPTO_ShortHashCode *zone,
262 GNUNET_GNS_ShortenResultProcessor proc,
267 * Cancel pending shorten request
269 * @param sr the lookup request to cancel
272 GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr);
275 /* *************** Standard API: get authority ******************* */
279 * Processor called on for a name shortening result
283 * @param auth_name the name of the auhtority or NULL
285 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
286 const char* short_name);
290 * Perform an authority lookup for a given name.
292 * @param handle handle to the GNS service
293 * @param name the name to look up authority for
294 * @param proc function to call on result
295 * @param proc_cls closure for processor
296 * @return handle to the operation
298 struct GNUNET_GNS_GetAuthRequest*
299 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
301 GNUNET_GNS_GetAuthResultProcessor proc,
306 * Cancel pending get auth request
308 * @param gar the lookup request to cancel
311 GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
313 #if 0 /* keep Emacsens' auto-indent happy */
322 /* gnunet_gns_service.h */