2 This file is part of GNUnet
3 Copyright (C) 2012-2014, 2017 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Martin Schanzenbach
25 * API to the GNS service
27 * @defgroup gns GNS service
30 * @see [Documentation](https://gnunet.org/gns-implementation)
34 #ifndef GNUNET_GNS_SERVICE_H
35 #define GNUNET_GNS_SERVICE_H
37 #include "gnunet_util_lib.h"
38 #include "gnunet_dnsparser_lib.h"
39 #include "gnunet_namestore_service.h"
43 #if 0 /* keep Emacsens' auto-indent happy */
50 * String we use to indicate an empty label (top-level
51 * entry in the zone). DNS uses "@", so do we.
53 #define GNUNET_GNS_EMPTY_LABEL_AT "@"
56 * Connection to the GNS service.
58 struct GNUNET_GNS_Handle;
61 * Handle to control a lookup operation.
63 struct GNUNET_GNS_LookupRequest;
66 * Handle to control a lookup operation where the
67 * TLD is resolved to a zone as part of the lookup operation.
69 struct GNUNET_GNS_LookupWithTldRequest;
73 * Initialize the connection with the GNS service.
75 * @param cfg configuration to use
76 * @return handle to the GNS service, or NULL on error
78 struct GNUNET_GNS_Handle *
79 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
83 * Shutdown connection with the GNS service.
85 * @param handle connection to shut down
88 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
92 * Iterator called on obtained result for a GNS lookup.
95 * @param rd_count number of records in @a rd
96 * @param rd the records in reply
98 typedef void (*GNUNET_GNS_LookupResultProcessor) (
101 const struct GNUNET_GNSRECORD_Data *rd);
105 * Options for the GNS lookup.
107 enum GNUNET_GNS_LocalOptions
110 * Defaults, look in cache, then in DHT.
112 GNUNET_GNS_LO_DEFAULT = 0,
115 * Never look in the DHT, keep request to local cache.
117 GNUNET_GNS_LO_NO_DHT = 1,
120 * For the rightmost label, only look in the cache (it
121 * is our local namestore), for the others, the DHT is OK.
123 GNUNET_GNS_LO_LOCAL_MASTER = 2
128 * Perform an asynchronous lookup operation on the GNS.
130 * @param handle handle to the GNS service
131 * @param name the name to look up (in UTF-8 encoding)
132 * @param zone zone to look in
133 * @param type the GNS record type to look for
134 * @param options local options for the lookup
135 * @param proc function to call on result
136 * @param proc_cls closure for @a proc
137 * @return handle to the queued request
139 struct GNUNET_GNS_LookupRequest *
140 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
142 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
144 enum GNUNET_GNS_LocalOptions options,
145 GNUNET_GNS_LookupResultProcessor proc,
150 * Perform an asynchronous lookup operation on the GNS.
152 * @param handle handle to the GNS service
153 * @param name the name to look up (in UTF-8 encoding)
154 * @param zone zone to look in
155 * @param type the GNS record type to look for
156 * @param options local options for the lookup
157 * @param recursion_depth_limit maximum number of zones
158 * that the lookup may (still) traverse
159 * @param proc function to call on result
160 * @param proc_cls closure for @a proc
161 * @return handle to the queued request
163 struct GNUNET_GNS_LookupRequest *
164 GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle,
166 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
168 enum GNUNET_GNS_LocalOptions options,
169 uint16_t recursion_depth_limit,
170 GNUNET_GNS_LookupResultProcessor proc,
175 * Cancel pending lookup request
177 * @param lr the lookup request to cancel
178 * @return closure from the lookup result processor
181 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
185 * Iterator called on obtained result for a GNS lookup
186 * where "not GNS" is a valid answer.
189 * @param gns_tld #GNUNET_YES if a GNS lookup was attempted,
190 * #GNUNET_NO if the TLD is not configured for GNS
191 * @param rd_count number of records in @a rd
192 * @param rd the records in the reply
194 typedef void (*GNUNET_GNS_LookupResultProcessor2) (
198 const struct GNUNET_GNSRECORD_Data *rd);
202 * Perform an asynchronous lookup operation on the GNS,
203 * determining the zone using the TLD of the given name
204 * and the current configuration to resolve TLDs to zones.
206 * @param handle handle to the GNS service
207 * @param name the name to look up, including TLD (in UTF-8 encoding)
208 * @param type the record type to look up
209 * @param options local options for the lookup
210 * @param proc processor to call on result
211 * @param proc_cls closure for @a proc
212 * @return handle to the get request
214 struct GNUNET_GNS_LookupWithTldRequest *
215 GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
218 enum GNUNET_GNS_LocalOptions options,
219 GNUNET_GNS_LookupResultProcessor2 proc,
224 * Cancel pending lookup request
226 * @param ltr the lookup request to cancel
227 * @return closure from the lookup result processor
230 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr);
233 #if 0 /* keep Emacsens' auto-indent happy */
242 /** @} */ /* end of group */