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 * String we use to indicate the local master zone or a
44 * root entry in the current zone.
46 #define GNUNET_GNS_MASTERZONE_STR "+"
49 * Connection to the GNS service.
51 struct GNUNET_GNS_Handle;
54 * Handle to control a lookup operation.
56 struct GNUNET_GNS_LookupRequest;
59 * Handle to control a shorten operation.
61 struct GNUNET_GNS_ShortenRequest;
64 * Handle to control a get authority operation
66 struct GNUNET_GNS_GetAuthRequest;
70 * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
72 enum GNUNET_GNS_RecordType
77 GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
82 GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
87 GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
92 GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
97 GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
102 GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
105 * A 'uint16_t' and a 'char *'
107 GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
112 GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
115 * A 'struct in6_addr'
117 GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
121 * A 'struct GNUNET_CRYPTO_ShortHashCode'
123 GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
128 GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
129 GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
134 GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
137 * A 'struct vpn_data'
139 GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
142 * Revocation, no data.
144 GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV,
149 GNUNET_GNS_RECORD_PLACE = GNUNET_NAMESTORE_TYPE_PLACE
154 * Initialize the connection with the GNS service.
156 * @param cfg configuration to use
157 * @return handle to the GNS service, or NULL on error
159 struct GNUNET_GNS_Handle *
160 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
164 * Shutdown connection with the GNS service.
166 * @param handle connection to shut down
169 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
172 /* *************** Standard API: lookup ******************* */
175 * Iterator called on obtained result for a GNS
179 * @param rd_count number of records
180 * @param rd the records in reply
182 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
184 const struct GNUNET_NAMESTORE_RecordData *rd);
189 * Perform an asynchronous lookup operation on the GNS.
191 * @param handle handle to the GNS service
192 * @param name the name to look up
193 * @param zone zone to look in
194 * @param type the record type to look for
195 * @param only_cached #GNUNET_NO to only check locally (not in the DHT)
196 * @param shorten_zone_key the private key of the shorten zone (can be NULL);
197 * specify to enable automatic shortening (given a PSEU
198 * record, if a given pseudonym is not yet used in the
199 * shorten zone, we automatically add the respective zone
201 * @param proc function to call on result
202 * @param proc_cls closure for processor
203 * @return handle to the queued request
205 struct GNUNET_GNS_LookupRequest*
206 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
208 const struct GNUNET_CRYPTO_EccPublicKey *zone,
209 enum GNUNET_GNS_RecordType type,
211 struct GNUNET_CRYPTO_EccPrivateKey *shorten_zone_key,
212 GNUNET_GNS_LookupResultProcessor proc,
217 * Cancel pending lookup request
219 * @param lr the lookup request to cancel
222 GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr);
226 /* *************** Standard API: get authority ******************* */
230 * Processor called on for a name shortening result
234 * @param auth_name the name of the auhtority or NULL
236 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
237 const char* short_name);
241 * Perform an authority lookup for a given name.
243 * @param handle handle to the GNS service
244 * @param name the name to look up authority for
245 * @param proc function to call on result
246 * @param proc_cls closure for processor
247 * @return handle to the operation
249 struct GNUNET_GNS_GetAuthRequest*
250 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
252 GNUNET_GNS_GetAuthResultProcessor proc,
257 * Cancel pending get auth request
259 * @param gar the lookup request to cancel
262 GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
264 #if 0 /* keep Emacsens' auto-indent happy */
273 /* gnunet_gns_service.h */