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
85 * Initialize the connection with the GNS service.
86 * FIXME: Do we need the ht_len?
88 * @param cfg configuration to use
89 * @param ht_len size of the internal hash table to use for parallel lookups
90 * @return NULL on error
92 struct GNUNET_GNS_Handle *
93 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
98 * Shutdown connection with the GNS service.
100 * @param handle connection to shut down
103 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
106 /* *************** Standard API: lookup ******************* */
109 * Iterator called on each result obtained for a GNS
113 * @param name "name" of the original lookup
114 * @param rd_count number of records
115 * @param rd the records in reply
117 typedef void (*GNUNET_GNS_LookupIterator) (void *cls,
120 const struct GNUNET_NAMESTORE_RecordData *rd);
125 * Perform an asynchronous lookup operation on the GNS.
127 * @param handle handle to the GNS service
128 * @param name the name to look up
129 * @param type the GNUNET_GNS_RecordType to look for
130 * @param iter function to call on each result
131 * @param iter_cls closure for iter
133 * @return handle to stop the async lookup
135 struct GNUNET_GNS_LookupHandle *
136 GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle,
138 enum GNUNET_GNS_RecordType type,
139 GNUNET_GNS_LookupIterator iter,
144 * Stop async GNS lookup. Frees associated resources.
146 * @param lookup_handle lookup operation to stop.
148 * On return lookup_handle will no longer be valid, caller
149 * must not use again!!!
152 GNUNET_GNS_lookup_stop (struct GNUNET_GNS_LookupHandle *lookup_handle);
154 /* *************** Standard API: shorten ******************* */
158 * Processor called on for a name shortening result
162 * @param name "name" of the original lookup
163 * @param short_name the shortened name or NULL if no result
165 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
167 const char* short_name);
171 * Perform a shorten operation on name using the GNS.
173 * @param handle handle to the GNS service
174 * @param name the name to shorten
175 * @param proc processor to call on result
176 * @param iter_cls closure for processor
178 * @return handle to the shorten operation
180 struct GNUNET_GNS_ShortenHandle *
181 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
183 GNUNET_GNS_ShortenResultProcessor proc,
185 #if 0 /* keep Emacsens' auto-indent happy */
194 /* gnunet_gns_service.h */