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 get operation.
57 struct GNUNET_GNS_LookupHandle;
60 * Handle to control a shorten operation
65 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
67 enum GNUNET_GNS_RecordType
70 GNUNET_GNS_RECORD_TYPE_A = GNUNET_DNSPARSER_TYPE_A,
71 GNUNET_GNS_RECORD_TYPE_NS = GNUNET_DNSPARSER_TYPE_NS,
72 GNUNET_GNS_RECORD_TYPE_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
73 GNUNET_GNS_RECORD_TYPE_SOA = GNUNET_DNSPARSER_TYPE_SOA,
74 GNUNET_GNS_RECORD_TYPE_PTR = GNUNET_DNSPARSER_TYPE_PTR,
75 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
76 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
77 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
80 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
81 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
82 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
83 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
84 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
85 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
89 * Initialize the connection with the GNS service.
91 * @param cfg configuration to use
93 * @return handle to the GNS service, or NULL on error
95 struct GNUNET_GNS_Handle *
96 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
100 * Shutdown connection with the GNS service.
102 * @param handle connection to shut down
105 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
108 /* *************** Standard API: lookup ******************* */
111 * Iterator called on obtained result for a GNS
115 * @param name "name" of the original lookup
116 * @param rd_count number of records
117 * @param rd the records in reply
119 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
121 const struct GNUNET_NAMESTORE_RecordData *rd);
126 * Perform an asynchronous lookup operation on the GNS
127 * in the default zone.
129 * @param handle handle to the GNS service
130 * @param name the name to look up
131 * @param type the GNUNET_GNS_RecordType to look for
132 * @param only_cached GNUNET_NO to only check locally not DHT for performance
133 * @param shorten_key the private key of the shorten zone (can be NULL)
134 * @param proc function to call on result
135 * @param proc_cls closure for processor
137 * @return handle to the queued request
139 struct GNUNET_GNS_QueueEntry *
140 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
142 enum GNUNET_GNS_RecordType type,
144 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
145 GNUNET_GNS_LookupResultProcessor proc,
149 * Perform an asynchronous lookup operation on the GNS
150 * in the zone specified by 'zone'.
152 * @param handle handle to the GNS service
153 * @param name the name to look up
154 * @param zone the zone to start the resolution in
155 * @param type the GNUNET_GNS_RecordType to look for
156 * @param only_cached GNUNET_NO to only check locally not DHT for performance
157 * @param shorten_key the private key of the shorten zone (can be NULL)
158 * @param proc function to call on result
159 * @param proc_cls closure for processor
161 * @return handle to the queued request
163 struct GNUNET_GNS_QueueEntry *
164 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
166 struct GNUNET_CRYPTO_ShortHashCode *zone,
167 enum GNUNET_GNS_RecordType type,
169 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
170 GNUNET_GNS_LookupResultProcessor proc,
173 /* *************** Standard API: shorten ******************* */
177 * Processor called on for a name shortening result
181 * @param short_name the shortened name or NULL if no result
183 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
184 const char* short_name);
188 * Perform a name shortening operation on the GNS.
190 * @param handle handle to the GNS service
191 * @param name the name to look up
192 * @param proc function to call on result
193 * @param proc_cls closure for processor
194 * @return handle to the operation
196 struct GNUNET_GNS_QueueEntry *
197 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
199 GNUNET_GNS_ShortenResultProcessor proc,
204 * Perform a name shortening operation on the GNS.
206 * @param handle handle to the GNS service
207 * @param name the name to look up
208 * @param zone the zone to start the resolution in
209 * @param proc function to call on result
210 * @param proc_cls closure for processor
211 * @return handle to the operation
213 struct GNUNET_GNS_QueueEntry *
214 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
216 struct GNUNET_CRYPTO_ShortHashCode *zone,
217 GNUNET_GNS_ShortenResultProcessor proc,
220 /* *************** Standard API: get authority ******************* */
224 * Processor called on for a name shortening result
228 * @param auth_name the name of the auhtority or NULL
230 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
231 const char* short_name);
235 * Perform an authority lookup for a given name.
237 * @param handle handle to the GNS service
238 * @param name the name to look up authority for
239 * @param proc function to call on result
240 * @param proc_cls closure for processor
241 * @return handle to the operation
243 struct GNUNET_GNS_QueueEntry *
244 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
246 GNUNET_GNS_GetAuthResultProcessor proc,
249 #if 0 /* keep Emacsens' auto-indent happy */
258 /* gnunet_gns_service.h */