gnunet_gns_service.h (6874B)
1 /* 2 This file is part of GNUnet 3 Copyright (C) 2012-2014, 2017 GNUnet e.V. 4 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. 9 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. 14 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/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 21 /** 22 * @addtogroup GNS 23 * @{ 24 * 25 * @author Martin Schanzenbach 26 * 27 * @file 28 * API to the GNS service 29 * 30 * @defgroup gns GNS service 31 * GNU Name System 32 * 33 * @see [Documentation](https://gnunet.org/gns-implementation) 34 * 35 * @{ 36 */ 37 #ifndef GNUNET_GNS_SERVICE_H 38 #define GNUNET_GNS_SERVICE_H 39 40 41 #include "gnunet_util_lib.h" 42 #include "gnunet_identity_service.h" 43 #include "gnunet_namestore_service.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #if 0 /* keep Emacsens' auto-indent happy */ 48 } 49 #endif 50 #endif 51 52 53 /** 54 * Connection to the GNS service. 55 */ 56 struct GNUNET_GNS_Handle; 57 58 /** 59 * Handle to control a lookup operation. 60 */ 61 struct GNUNET_GNS_LookupRequest; 62 63 /** 64 * Handle to control a lookup operation where the 65 * TLD is resolved to a zone as part of the lookup operation. 66 */ 67 struct GNUNET_GNS_LookupWithTldRequest; 68 69 70 /** 71 * Initialize the connection with the GNS service. 72 * 73 * @param cfg configuration to use 74 * @return handle to the GNS service, or NULL on error 75 */ 76 struct GNUNET_GNS_Handle * 77 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); 78 79 80 /** 81 * Shutdown connection with the GNS service. 82 * 83 * @param handle connection to shut down 84 */ 85 void 86 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle); 87 88 89 /** 90 * Iterator called on obtained result for a GNS lookup. 91 * 92 * @param cls closure 93 * @param rd_count number of records in @a rd 94 * @param rd the records in reply 95 */ 96 typedef void (*GNUNET_GNS_LookupResultProcessor) ( 97 void *cls, 98 uint32_t rd_count, 99 const struct GNUNET_GNSRECORD_Data *rd); 100 101 102 /** 103 * Options for the GNS lookup. 104 */ 105 enum GNUNET_GNS_LocalOptions 106 { 107 /** 108 * Defaults, look in cache, then in DHT. 109 */ 110 GNUNET_GNS_LO_DEFAULT = 0, 111 112 /** 113 * Never look in the DHT, keep request to local cache. 114 */ 115 GNUNET_GNS_LO_NO_DHT = 1, 116 117 /** 118 * For the rightmost label, only look in the cache (it 119 * is our local namestore), for the others, the DHT is OK. 120 */ 121 GNUNET_GNS_LO_LOCAL_MASTER = 2 122 }; 123 124 125 /** 126 * Perform an asynchronous lookup operation on the GNS. 127 * 128 * @param handle handle to the GNS service 129 * @param name the name to look up (in UTF-8 encoding) 130 * @param zone zone to look in 131 * @param type the GNS record type to look for 132 * @param options local options for the lookup 133 * @param proc function to call on result 134 * @param proc_cls closure for @a proc 135 * @return handle to the queued request 136 */ 137 struct GNUNET_GNS_LookupRequest * 138 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, 139 const char *name, 140 const struct GNUNET_CRYPTO_PublicKey *zone, 141 uint32_t type, 142 enum GNUNET_GNS_LocalOptions options, 143 GNUNET_GNS_LookupResultProcessor proc, 144 void *proc_cls); 145 146 147 /** 148 * Perform an asynchronous lookup operation on the GNS. 149 * 150 * @param handle handle to the GNS service 151 * @param name the name to look up (in UTF-8 encoding) 152 * @param zone zone to look in 153 * @param type the GNS record type to look for 154 * @param options local options for the lookup 155 * @param recursion_depth_limit maximum number of zones 156 * that the lookup may (still) traverse 157 * @param proc function to call on result 158 * @param proc_cls closure for @a proc 159 * @return handle to the queued request 160 */ 161 struct GNUNET_GNS_LookupRequest * 162 GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle, 163 const char *name, 164 const struct GNUNET_CRYPTO_PublicKey *zone, 165 uint32_t type, 166 enum GNUNET_GNS_LocalOptions options, 167 uint16_t recursion_depth_limit, 168 GNUNET_GNS_LookupResultProcessor proc, 169 void *proc_cls); 170 171 172 /** 173 * Cancel pending lookup request 174 * 175 * @param lr the lookup request to cancel 176 * @return closure from the lookup result processor 177 */ 178 void * 179 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr); 180 181 182 /** 183 * Iterator called on obtained result for a GNS lookup 184 * where "not GNS" is a valid answer. 185 * 186 * @param cls closure 187 * @param gns_tld #GNUNET_YES if a GNS lookup was attempted, 188 * #GNUNET_NO if the TLD is not configured for GNS 189 * @param rd_count number of records in @a rd 190 * @param rd the records in the reply 191 */ 192 typedef void (*GNUNET_GNS_LookupResultProcessor2) ( 193 void *cls, 194 int gns_tld, 195 uint32_t rd_count, 196 const struct GNUNET_GNSRECORD_Data *rd); 197 198 199 /** 200 * Perform an asynchronous lookup operation on the GNS, 201 * determining the zone using the TLD of the given name 202 * and the current configuration to resolve TLDs to zones. 203 * 204 * @param handle handle to the GNS service 205 * @param name the name to look up, including TLD (in UTF-8 encoding) 206 * @param type the record type to look up 207 * @param options local options for the lookup 208 * @param proc processor to call on result 209 * @param proc_cls closure for @a proc 210 * @return handle to the get request 211 */ 212 struct GNUNET_GNS_LookupWithTldRequest * 213 GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle, 214 const char *name, 215 uint32_t type, 216 enum GNUNET_GNS_LocalOptions options, 217 GNUNET_GNS_LookupResultProcessor2 proc, 218 void *proc_cls); 219 220 221 /** 222 * Cancel pending lookup request 223 * 224 * @param ltr the lookup request to cancel 225 * @return closure from the lookup result processor 226 */ 227 void * 228 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr); 229 230 /** 231 * Try to parse the zTLD into a public key. 232 * 233 * @param[in] name the name to parse 234 * @param[out] ztld_key the identity key (must be allocated by caller). Only set of #GNUNET_OK is returned. 235 * @return GNUNET_OK on success. 236 */ 237 enum GNUNET_GenericReturnValue 238 GNUNET_GNS_parse_ztld (const char *name, 239 struct GNUNET_CRYPTO_PublicKey *ztld_key); 240 241 #if 0 /* keep Emacsens' auto-indent happy */ 242 { 243 #endif 244 #ifdef __cplusplus 245 } 246 #endif 247 248 #endif 249 250 /** @} */ /* end of group */ 251 252 /** @} */ /* end of group addition */