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,
114 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
119 * Initialize the connection with the GNS service.
121 * @param cfg configuration to use
123 * @return handle to the GNS service, or NULL on error
125 struct GNUNET_GNS_Handle *
126 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
130 * Shutdown connection with the GNS service.
132 * @param handle connection to shut down
135 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
138 /* *************** Standard API: lookup ******************* */
141 * Iterator called on obtained result for a GNS
145 * @param rd_count number of records
146 * @param rd the records in reply
148 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
150 const struct GNUNET_NAMESTORE_RecordData *rd);
155 * Perform an asynchronous lookup operation on the GNS
156 * in the default zone.
158 * @param handle handle to the GNS service
159 * @param name the name to look up
160 * @param type the GNUNET_GNS_RecordType to look for
161 * @param only_cached GNUNET_NO to only check locally not DHT for performance
162 * @param shorten_key the private key of the shorten zone (can be NULL)
163 * @param proc function to call on result
164 * @param proc_cls closure for processor
166 * @return handle to the queued request
168 struct GNUNET_GNS_LookupRequest*
169 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
171 enum GNUNET_GNS_RecordType type,
173 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
174 GNUNET_GNS_LookupResultProcessor proc,
179 * Perform an asynchronous lookup operation on the GNS
180 * in the zone specified by 'zone'.
182 * @param handle handle to the GNS service
183 * @param name the name to look up
184 * @param zone the zone to start the resolution in
185 * @param type the GNUNET_GNS_RecordType to look for
186 * @param only_cached GNUNET_YES to only check locally not DHT for performance
187 * @param shorten_key the private key of the shorten zone (can be NULL)
188 * @param proc function to call on result
189 * @param proc_cls closure for processor
191 * @return handle to the queued request
193 struct GNUNET_GNS_LookupRequest*
194 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
196 struct GNUNET_CRYPTO_ShortHashCode *zone,
197 enum GNUNET_GNS_RecordType type,
199 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
200 GNUNET_GNS_LookupResultProcessor proc,
205 * Cancel pending lookup request
207 * @param lr the lookup request to cancel
210 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
212 /* *************** Standard API: shorten ******************* */
216 * Processor called on for a name shortening result
220 * @param short_name the shortened name or NULL if no result / error
222 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
223 const char* short_name);
227 * Perform a name shortening operation on the GNS.
229 * @param handle handle to the GNS service
230 * @param name the name to look up
231 * @param private_zone the public zone of the private zone
232 * @param shorten_zone the public zone of the shorten zone
233 * @param proc function to call on result
234 * @param proc_cls closure for processor
235 * @return handle to the operation
237 struct GNUNET_GNS_ShortenRequest*
238 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
240 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
241 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
242 GNUNET_GNS_ShortenResultProcessor proc,
247 * Perform a name shortening operation on the GNS.
249 * @param handle handle to the GNS service
250 * @param name the name to look up
251 * @param private_zone the public zone of the private zone
252 * @param shorten_zone the public zone of the shorten zone
253 * @param zone the zone to start the resolution in
254 * @param proc function to call on result
255 * @param proc_cls closure for processor
256 * @return handle to the operation
258 struct GNUNET_GNS_ShortenRequest*
259 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
261 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
262 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
263 struct GNUNET_CRYPTO_ShortHashCode *zone,
264 GNUNET_GNS_ShortenResultProcessor proc,
269 * Cancel pending shorten request
271 * @param sr the lookup request to cancel
274 GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr);
277 /* *************** Standard API: get authority ******************* */
281 * Processor called on for a name shortening result
285 * @param auth_name the name of the auhtority or NULL
287 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
288 const char* short_name);
292 * Perform an authority lookup for a given name.
294 * @param handle handle to the GNS service
295 * @param name the name to look up authority for
296 * @param proc function to call on result
297 * @param proc_cls closure for processor
298 * @return handle to the operation
300 struct GNUNET_GNS_GetAuthRequest*
301 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
303 GNUNET_GNS_GetAuthResultProcessor proc,
308 * Cancel pending get auth request
310 * @param gar the lookup request to cancel
313 GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
315 #if 0 /* keep Emacsens' auto-indent happy */
324 /* gnunet_gns_service.h */