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"
44 #if 0 /* keep Emacsens' auto-indent happy */
51 * String we use to indicate an empty label (top-level
52 * entry in the zone). DNS uses "@", so do we.
54 #define GNUNET_GNS_EMPTY_LABEL_AT "@"
57 * Connection to the GNS service.
59 struct GNUNET_GNS_Handle;
62 * Handle to control a lookup operation.
64 struct GNUNET_GNS_LookupRequest;
67 * Handle to control a lookup operation where the
68 * TLD is resolved to a zone as part of the lookup operation.
70 struct GNUNET_GNS_LookupWithTldRequest;
74 * Initialize the connection with the GNS service.
76 * @param cfg configuration to use
77 * @return handle to the GNS service, or NULL on error
79 struct GNUNET_GNS_Handle *
80 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
84 * Shutdown connection with the GNS service.
86 * @param handle connection to shut down
89 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
93 * Iterator called on obtained result for a GNS lookup.
96 * @param rd_count number of records in @a rd
97 * @param rd the records in reply
100 (*GNUNET_GNS_LookupResultProcessor) (void *cls,
102 const struct GNUNET_GNSRECORD_Data *rd);
106 * Options for the GNS lookup.
108 enum GNUNET_GNS_LocalOptions
111 * Defaults, look in cache, then in DHT.
113 GNUNET_GNS_LO_DEFAULT = 0,
116 * Never look in the DHT, keep request to local cache.
118 GNUNET_GNS_LO_NO_DHT = 1,
121 * For the rightmost label, only look in the cache (it
122 * is our local namestore), for the others, the DHT is OK.
124 GNUNET_GNS_LO_LOCAL_MASTER = 2
130 * Perform an asynchronous lookup operation on the GNS.
132 * @param handle handle to the GNS service
133 * @param name the name to look up
134 * @param zone zone to look in
135 * @param type the GNS record type to look for
136 * @param options local options for the lookup
137 * @param proc function to call on result
138 * @param proc_cls closure for @a proc
139 * @return handle to the queued request
141 struct GNUNET_GNS_LookupRequest *
142 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
144 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
146 enum GNUNET_GNS_LocalOptions options,
147 GNUNET_GNS_LookupResultProcessor proc,
152 * Cancel pending lookup request
154 * @param lr the lookup request to cancel
155 * @return closure from the lookup result processor
158 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
162 * Iterator called on obtained result for a GNS lookup
163 * where "not GNS" is a valid answer.
166 * @param gns_tld #GNUNET_YES if a GNS lookup was attempted,
167 * #GNUNET_NO if the TLD is not configured for GNS
168 * @param rd_count number of records in @a rd
169 * @param rd the records in the reply
172 (*GNUNET_GNS_LookupResultProcessor2) (void *cls,
175 const struct GNUNET_GNSRECORD_Data *rd);
179 * Perform an asynchronous lookup operation on the GNS,
180 * determining the zone using the TLD of the given name
181 * and the current configuration to resolve TLDs to zones.
183 * @param handle handle to the GNS service
184 * @param name the name to look up, including TLD
185 * @param type the record type to look up
186 * @param options local options for the lookup
187 * @param proc processor to call on result
188 * @param proc_cls closure for @a proc
189 * @return handle to the get request
191 struct GNUNET_GNS_LookupWithTldRequest*
192 GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
195 enum GNUNET_GNS_LocalOptions options,
196 GNUNET_GNS_LookupResultProcessor2 proc,
201 * Cancel pending lookup request
203 * @param ltr the lookup request to cancel
204 * @return closure from the lookup result processor
207 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr);
210 #if 0 /* keep Emacsens' auto-indent happy */
219 /** @} */ /* end of group */