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 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.
17 * @author Martin Schanzenbach
20 * API to the GNS service
22 * @defgroup gns GNS service
25 * @see [Documentation](https://gnunet.org/gns-implementation)
29 #ifndef GNUNET_GNS_SERVICE_H
30 #define GNUNET_GNS_SERVICE_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_dnsparser_lib.h"
34 #include "gnunet_namestore_service.h"
39 #if 0 /* keep Emacsens' auto-indent happy */
46 * String we use to indicate an empty label (top-level
47 * entry in the zone). DNS uses "@", so do we.
49 #define GNUNET_GNS_EMPTY_LABEL_AT "@"
52 * Connection to the GNS service.
54 struct GNUNET_GNS_Handle;
57 * Handle to control a lookup operation.
59 struct GNUNET_GNS_LookupRequest;
62 * Handle to control a lookup operation where the
63 * TLD is resolved to a zone as part of the lookup operation.
65 struct GNUNET_GNS_LookupWithTldRequest;
69 * Initialize the connection with the GNS service.
71 * @param cfg configuration to use
72 * @return handle to the GNS service, or NULL on error
74 struct GNUNET_GNS_Handle *
75 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
79 * Shutdown connection with the GNS service.
81 * @param handle connection to shut down
84 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
88 * Iterator called on obtained result for a GNS lookup.
91 * @param rd_count number of records in @a rd
92 * @param rd the records in reply
95 (*GNUNET_GNS_LookupResultProcessor) (void *cls,
97 const struct GNUNET_GNSRECORD_Data *rd);
101 * Options for the GNS lookup.
103 enum GNUNET_GNS_LocalOptions
106 * Defaults, look in cache, then in DHT.
108 GNUNET_GNS_LO_DEFAULT = 0,
111 * Never look in the DHT, keep request to local cache.
113 GNUNET_GNS_LO_NO_DHT = 1,
116 * For the rightmost label, only look in the cache (it
117 * is our local namestore), for the others, the DHT is OK.
119 GNUNET_GNS_LO_LOCAL_MASTER = 2
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 zone zone to look in
130 * @param type the GNS record type to look for
131 * @param options local options for the lookup
132 * @param proc function to call on result
133 * @param proc_cls closure for @a proc
134 * @return handle to the queued request
136 struct GNUNET_GNS_LookupRequest *
137 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
139 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
141 enum GNUNET_GNS_LocalOptions options,
142 GNUNET_GNS_LookupResultProcessor proc,
147 * Cancel pending lookup request
149 * @param lr the lookup request to cancel
152 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
156 * Iterator called on obtained result for a GNS lookup
157 * where "not GNS" is a valid answer.
160 * @param gns_tld #GNUNET_YES if a GNS lookup was attempted,
161 * #GNUNET_NO if the TLD is not configured for GNS
162 * @param rd_count number of records in @a rd
163 * @param rd the records in the reply
166 (*GNUNET_GNS_LookupResultProcessor2) (void *cls,
169 const struct GNUNET_GNSRECORD_Data *rd);
173 * Perform an asynchronous lookup operation on the GNS,
174 * determining the zone using the TLD of the given name
175 * and the current configuration to resolve TLDs to zones.
177 * @param handle handle to the GNS service
178 * @param name the name to look up, including TLD
179 * @param type the record type to look up
180 * @param options local options for the lookup
181 * @param proc processor to call on result
182 * @param proc_cls closure for @a proc
183 * @return handle to the get request
185 struct GNUNET_GNS_LookupWithTldRequest*
186 GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
189 enum GNUNET_GNS_LocalOptions options,
190 GNUNET_GNS_LookupResultProcessor2 proc,
195 * Cancel pending lookup request
197 * @param ltr the lookup request to cancel
200 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr);
203 #if 0 /* keep Emacsens' auto-indent happy */
212 /** @} */ /* end of group */