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 * Connection to the GNS service.
45 struct GNUNET_GNS_Handle;
48 * Handle to control a lookup operation.
50 struct GNUNET_GNS_LookupRequest;
53 * Handle to control a shorten operation.
55 struct GNUNET_GNS_ShortenRequest;
58 * Handle to control a get authority operation
60 struct GNUNET_GNS_GetAuthRequest;
64 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
66 enum GNUNET_GNS_RecordType
70 GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
73 GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
76 GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
79 GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
82 GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
85 GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
88 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
91 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
94 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
97 /* struct GNUNET_CRYPTO_ShortHashCode */
98 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
101 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
102 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
105 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
107 /* struct vpn_data */
108 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
111 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
116 * Initialize the connection with the GNS service.
118 * @param cfg configuration to use
120 * @return handle to the GNS service, or NULL on error
122 struct GNUNET_GNS_Handle *
123 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
127 * Shutdown connection with the GNS service.
129 * @param handle connection to shut down
132 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
135 /* *************** Standard API: lookup ******************* */
138 * Iterator called on obtained result for a GNS
142 * @param rd_count number of records
143 * @param rd the records in reply
145 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
147 const struct GNUNET_NAMESTORE_RecordData *rd);
152 * Perform an asynchronous lookup operation on the GNS
153 * in the default zone.
155 * @param handle handle to the GNS service
156 * @param name the name to look up
157 * @param type the GNUNET_GNS_RecordType to look for
158 * @param only_cached GNUNET_NO to only check locally not DHT for performance
159 * @param shorten_key the private key of the shorten zone (can be NULL)
160 * @param proc function to call on result
161 * @param proc_cls closure for processor
163 * @return handle to the queued request
165 struct GNUNET_GNS_LookupRequest*
166 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
168 enum GNUNET_GNS_RecordType type,
170 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
171 GNUNET_GNS_LookupResultProcessor proc,
176 * Perform an asynchronous lookup operation on the GNS
177 * in the zone specified by 'zone'.
179 * @param handle handle to the GNS service
180 * @param name the name to look up
181 * @param zone the zone to start the resolution in
182 * @param type the GNUNET_GNS_RecordType to look for
183 * @param only_cached GNUNET_YES to only check locally not DHT for performance
184 * @param shorten_key the private key of the shorten zone (can be NULL)
185 * @param proc function to call on result
186 * @param proc_cls closure for processor
188 * @return handle to the queued request
190 struct GNUNET_GNS_LookupRequest*
191 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
193 struct GNUNET_CRYPTO_ShortHashCode *zone,
194 enum GNUNET_GNS_RecordType type,
196 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
197 GNUNET_GNS_LookupResultProcessor proc,
202 * Cancel pending lookup request
204 * @param lr the lookup request to cancel
207 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
209 /* *************** Standard API: shorten ******************* */
213 * Processor called on for a name shortening result
217 * @param short_name the shortened name or NULL if no result / error
219 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
220 const char* short_name);
224 * Perform a name shortening operation on the GNS.
226 * @param handle handle to the GNS service
227 * @param name the name to look up
228 * @param private_zone the public zone of the private zone
229 * @param shorten_zone the public zone of the shorten zone
230 * @param proc function to call on result
231 * @param proc_cls closure for processor
232 * @return handle to the operation
234 struct GNUNET_GNS_ShortenRequest*
235 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
237 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
238 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
239 GNUNET_GNS_ShortenResultProcessor proc,
244 * Perform a name shortening operation on the GNS.
246 * @param handle handle to the GNS service
247 * @param name the name to look up
248 * @param private_zone the public zone of the private zone
249 * @param shorten_zone the public zone of the shorten zone
250 * @param zone the zone to start the resolution in
251 * @param proc function to call on result
252 * @param proc_cls closure for processor
253 * @return handle to the operation
255 struct GNUNET_GNS_ShortenRequest*
256 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
258 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
259 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
260 struct GNUNET_CRYPTO_ShortHashCode *zone,
261 GNUNET_GNS_ShortenResultProcessor proc,
266 * Cancel pending shorten request
268 * @param sr the lookup request to cancel
271 GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr);
274 /* *************** Standard API: get authority ******************* */
278 * Processor called on for a name shortening result
282 * @param auth_name the name of the auhtority or NULL
284 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
285 const char* short_name);
289 * Perform an authority lookup for a given name.
291 * @param handle handle to the GNS service
292 * @param name the name to look up authority for
293 * @param proc function to call on result
294 * @param proc_cls closure for processor
295 * @return handle to the operation
297 struct GNUNET_GNS_GetAuthRequest*
298 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
300 GNUNET_GNS_GetAuthResultProcessor proc,
305 * Cancel pending get auth request
307 * @param gar the lookup request to cancel
310 GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
312 #if 0 /* keep Emacsens' auto-indent happy */
321 /* gnunet_gns_service.h */