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
27 * - decide what goes into storage API and what into GNS-service API
28 * - decide where to pass/expose/check keys / signatures
29 * - are GNS private keys per peer or per user?
33 #ifndef GNUNET_GNS_SERVICE_H
34 #define GNUNET_GNS_SERVICE_H
36 #include "gnunet_util_lib.h"
37 #include "gnunet_dnsparser_lib.h"
38 #include "gnunet_namestore_service.h"
43 #if 0 /* keep Emacsens' auto-indent happy */
50 * Connection to the GNS service.
52 struct GNUNET_GNS_Handle;
55 * Handle to control a lookup operation.
57 struct GNUNET_GNS_LookupRequest;
60 * Handle to control a shorten operation.
62 struct GNUNET_GNS_ShortenRequest;
65 * Handle to control a get authority operation
67 struct GNUNET_GNS_GetAuthRequest;
71 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
73 enum GNUNET_GNS_RecordType
77 GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
80 GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
83 GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
86 GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
89 GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
92 GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
95 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
98 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
100 /* struct in6_addr */
101 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
104 /* struct GNUNET_CRYPTO_ShortHashCode */
105 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
108 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
109 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
112 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
114 /* struct vpn_data */
115 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
116 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
120 * Initialize the connection with the GNS service.
122 * @param cfg configuration to use
124 * @return handle to the GNS service, or NULL on error
126 struct GNUNET_GNS_Handle *
127 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
131 * Shutdown connection with the GNS service.
133 * @param handle connection to shut down
136 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
139 /* *************** Standard API: lookup ******************* */
142 * Iterator called on obtained result for a GNS
146 * @param name "name" of the original lookup
147 * @param rd_count number of records
148 * @param rd the records in reply
150 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
152 const struct GNUNET_NAMESTORE_RecordData *rd);
157 * Perform an asynchronous lookup operation on the GNS
158 * in the default zone.
160 * @param handle handle to the GNS service
161 * @param name the name to look up
162 * @param type the GNUNET_GNS_RecordType to look for
163 * @param only_cached GNUNET_NO to only check locally not DHT for performance
164 * @param shorten_key the private key of the shorten zone (can be NULL)
165 * @param proc function to call on result
166 * @param proc_cls closure for processor
168 * @return handle to the queued request
170 struct GNUNET_GNS_LookupRequest*
171 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
173 enum GNUNET_GNS_RecordType type,
175 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
176 GNUNET_GNS_LookupResultProcessor proc,
180 * Perform an asynchronous lookup operation on the GNS
181 * in the zone specified by 'zone'.
183 * @param handle handle to the GNS service
184 * @param name the name to look up
185 * @param zone the zone to start the resolution in
186 * @param type the GNUNET_GNS_RecordType to look for
187 * @param only_cached GNUNET_YES to only check locally not DHT for performance
188 * @param shorten_key the private key of the shorten zone (can be NULL)
189 * @param proc function to call on result
190 * @param proc_cls closure for processor
192 * @return handle to the queued request
194 struct GNUNET_GNS_LookupRequest*
195 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
197 struct GNUNET_CRYPTO_ShortHashCode *zone,
198 enum GNUNET_GNS_RecordType type,
200 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
201 GNUNET_GNS_LookupResultProcessor proc,
206 * Cancel pending lookup request
208 * @param lr the lookup request to cancel
211 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
213 /* *************** Standard API: shorten ******************* */
217 * Processor called on for a name shortening result
221 * @param short_name the shortened name or NULL if no result
223 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
224 const char* short_name);
228 * Perform a name shortening operation on the GNS.
230 * @param handle handle to the GNS service
231 * @param name the name to look up
232 * @param private_zone the public zone of the private zone
233 * @param shorten_zone the public zone of the shorten zone
234 * @param proc function to call on result
235 * @param proc_cls closure for processor
236 * @return handle to the operation
238 struct GNUNET_GNS_ShortenRequest*
239 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
241 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
242 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
243 GNUNET_GNS_ShortenResultProcessor proc,
248 * Perform a name shortening operation on the GNS.
250 * @param handle handle to the GNS service
251 * @param name the name to look up
252 * @param private_zone the public zone of the private zone
253 * @param shorten_zone the public zone of the shorten zone
254 * @param zone the zone to start the resolution in
255 * @param proc function to call on result
256 * @param proc_cls closure for processor
257 * @return handle to the operation
259 struct GNUNET_GNS_ShortenRequest*
260 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
262 struct GNUNET_CRYPTO_ShortHashCode *private_zone,
263 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
264 struct GNUNET_CRYPTO_ShortHashCode *zone,
265 GNUNET_GNS_ShortenResultProcessor proc,
270 * Cancel pending shorten request
272 * @param sr the lookup request to cancel
275 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 */