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"
41 #if 0 /* keep Emacsens' auto-indent happy */
48 * Connection to the GNS service.
50 struct GNUNET_GNS_Handle;
53 * Handle to control a get operation.
55 struct GNUNET_GNS_LookupHandle;
58 * A single GNS record.
60 struct GNUNET_GNS_Record;
65 enum GNUNET_GNS_RecordType
67 // FIXME: should be based on GNUNET_DNSPARSER_TYPE's (standard DNS),
68 // and then maybe our extensions in the area > 255?
70 GNUNET_GNS_RECORD_AAAA,
72 GNUNET_GNS_RECORD_PKEY
76 * Initialize the connection with the GNS service.
78 * @param cfg configuration to use
79 * @param ht_len size of the internal hash table to use for parallel lookups
80 * @return NULL on error
82 struct GNUNET_GNS_Handle *
83 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
88 * Shutdown connection with the GNS service.
90 * @param handle connection to shut down
93 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
96 /* *************** Standard API: add and lookup ******************* */
99 * Perform an add operation storing records in the GNS.
101 * FIXME: Yes, we need this kind of API, but should it not be with the
102 * NameDataStore, rather than the GNS-service?
104 * @param handle handle to GNS service
105 * @param name the key to store under
106 * // FIXME: need to be precise here what 'name' is. Does it
107 // include '.gnunet'? What happens if we specify 'a.b.c.gnunet'
108 // but 'b.c.gnunet' has been delegated? (error?)
109 * @param desired_replication_level estimate of how many
110 * nearest peers this request should reach
111 * @param options routing options for this message
112 // FIXME: which are? where is the arg?
113 // FIXME: we should probably distinguish between 'private' and 'public'
115 * @param type type of the value
116 * @param size number of bytes in data; must be less than 64k
117 * @param data the data to store
118 // FIXME: what is the exact format of data?
119 * @param exp desired expiration time for the value
120 * @param timeout how long to wait for transmission of this request
121 * @param cont continuation to call when done (transmitting request to service)
122 * @param cont_cls closure for cont
123 * // FIXME: where are the continuations?
126 GNUNET_GNS_add_record (struct GNUNET_GNS_Handle *handle,
128 enum GNUNET_GNS_RecordType type,
129 size_t size, const char *data,
130 struct GNUNET_TIME_Absolute exp,
131 struct GNUNET_TIME_Relative timeout);
135 * Iterator called on each result obtained for a GNS
136 * operation that expects a reply TODO: eh?
140 * @param exp when will this value expire
141 * @param key key of the result
142 * // how does the key relate to the name exactly? Why not give the name?
143 * @param record the records in reply
144 * // FIXME: shouldn't this then be an array of pointers?
145 * @param num_records the number of records in reply
146 * @param type type of the result
147 * // FIXME: not in signature
149 typedef void (*GNUNET_GNS_LookupIterator) (void *cls,
150 const GNUNET_HashCode * key,
151 const struct GNUNET_GNS_Record *record,
152 unsigned int num_records);
157 * Perform an asynchronous lookup operation on the GNS.
159 * @param handle handle to the GNS service
160 * @param timeout how long to wait for transmission of this request to the service
161 * // FIXME: what happens afterwards?
162 * @param type expected type of the response object
163 * @param key the key to look up
164 * // FIXME: key, name, what format?
165 * @param desired_replication_level estimate of how many
166 nearest peers this request should reach
167 * @param options routing options for this message
168 * //FIXME: missmatch between documented and actual options...
169 * @param xquery extended query data (can be NULL, depending on type)
170 * @param xquery_size number of bytes in xquery
171 * @param iter function to call on each result
172 * @param iter_cls closure for iter
174 * @return handle to stop the async get
176 struct GNUNET_GNS_LookupHandle *
177 GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle,
178 struct GNUNET_TIME_Relative timeout,
180 enum GNUNET_GNS_RecordType type,
181 GNUNET_GNS_LookupIterator iter,
186 * Stop async GNS lookup. Frees associated resources.
188 * @param lookup_handle lookup operation to stop.
190 * On return lookup_handle will no longer be valid, caller
191 * must not use again!!!
194 GNUNET_GNS_lookup_stop (struct GNUNET_GNS_LookupHandle *lookup_handle);
197 #if 0 /* keep Emacsens' auto-indent happy */
206 /* gnunet_gns_service.h */