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
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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
157 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
161 * Iterator called on obtained result for a GNS lookup
162 * where "not GNS" is a valid answer.
165 * @param gns_tld #GNUNET_YES if a GNS lookup was attempted,
166 * #GNUNET_NO if the TLD is not configured for GNS
167 * @param rd_count number of records in @a rd
168 * @param rd the records in the reply
171 (*GNUNET_GNS_LookupResultProcessor2) (void *cls,
174 const struct GNUNET_GNSRECORD_Data *rd);
178 * Perform an asynchronous lookup operation on the GNS,
179 * determining the zone using the TLD of the given name
180 * and the current configuration to resolve TLDs to zones.
182 * @param handle handle to the GNS service
183 * @param name the name to look up, including TLD
184 * @param type the record type to look up
185 * @param options local options for the lookup
186 * @param proc processor to call on result
187 * @param proc_cls closure for @a proc
188 * @return handle to the get request
190 struct GNUNET_GNS_LookupWithTldRequest*
191 GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
194 enum GNUNET_GNS_LocalOptions options,
195 GNUNET_GNS_LookupResultProcessor2 proc,
200 * Cancel pending lookup request
202 * @param ltr the lookup request to cancel
205 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr);
208 #if 0 /* keep Emacsens' auto-indent happy */
217 /** @} */ /* end of group */