5 #include "gnunet_dht_service.h"
7 #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
8 #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT
9 #define DHT_GNS_REPLICATION_LEVEL 5
10 #define MAX_DNS_LABEL_LENGTH 63
13 * DLL to hold the authority chain
14 * we had to pass in the resolution process
18 struct AuthorityChain *prev;
20 struct AuthorityChain *next;
22 /* the zone hash of the authority */
25 /* (local) name of the authority */
28 /* was the ns entry fresh */
32 /* handle to a resolution process */
33 struct ResolverHandle;
37 * processor for a resultion result
39 * @param cls the closure
40 * @param rh the resolution handle
41 * @param rd_count number of results
42 * @pram rd resukt data
44 typedef void (*RecordLookupProcessor) (void *cls,
46 const struct GNUNET_NAMESTORE_RecordData *rd);
50 * processor for a shorten result
52 * @param cls the closure
53 * @param name shortened name
55 typedef void (*ShortenResultProcessor) (void *cls, const char* name);
59 * processor for an authority result
61 * @param cls the closure
64 typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name);
67 * processor for a resultion result
69 * @param cls the closure
70 * @param rh the resolution handle
71 * @param rd_count number of results
72 * @param rd result data
74 typedef void (*ResolutionResultProcessor) (void *cls,
75 struct ResolverHandle *rh,
77 const struct GNUNET_NAMESTORE_RecordData *rd);
81 * Resoltion status indicator
82 * EXISTS: the name to lookup exists
83 * EXPIRED: the name in the record expired
92 * Handle to a currenty pending resolution
96 /* The name to resolve */
99 /* has this query been answered? how many matches */
102 /* the authoritative zone to query */
103 GNUNET_HashCode authority;
105 /* the name of the authoritative zone to query */
106 char *authority_name;
109 * we have an authority in namestore that
110 * may be able to resolve
114 /* a handle for dht lookups. should be NULL if no lookups are in progress */
115 struct GNUNET_DHT_GetHandle *get_handle;
117 /* timeout task for dht lookups */
118 GNUNET_SCHEDULER_TaskIdentifier dht_timeout_task;
120 /* called when resolution phase finishes */
121 ResolutionResultProcessor proc;
123 /* closure passed to proc */
126 /* DLL to store the authority chain */
127 struct AuthorityChain *authority_chain_head;
129 /* DLL to store the authority chain */
130 struct AuthorityChain *authority_chain_tail;
132 /* status of the resolution result */
133 enum ResolutionStatus status;
135 struct GNUNET_CRYPTO_RsaPrivateKey *priv_key;
141 * Handle to a record lookup
143 struct RecordLookupHandle
145 /* the record type to look up */
146 enum GNUNET_GNS_RecordType record_type;
148 /* the name to look up */
151 /* Method to call on record resolution result */
152 RecordLookupProcessor proc;
154 /* closure to pass to proc */
161 * Handle to a shorten context
163 struct NameShortenHandle
167 /* Method to call on shorten result */
168 ShortenResultProcessor proc;
170 /* closure to pass to proc */
176 * Handle to a get authority context
178 struct GetNameAuthorityHandle
181 /* the name to look up authority for */
184 /* Method to call on result */
185 GetAuthorityResultProcessor proc;
187 /* closure to pass to proc */
193 * Handle to a pseu lookup
195 struct GetPseuAuthorityHandle
197 /* the name given from delegation */
200 /* name to store the pseu under */
203 /* the zone of discovered authority */
204 GNUNET_HashCode new_zone;
206 /* the zone of our authority */
207 GNUNET_HashCode zone;
209 /* the private key of the zone to store the pseu in */
210 struct GNUNET_CRYPTO_RsaPrivateKey *key;
212 /* a handle for dht lookups. should be NULL if no lookups are in progress */
213 struct GNUNET_DHT_GetHandle *get_handle;
215 /* timeout task for dht lookups */
216 GNUNET_SCHEDULER_TaskIdentifier dht_timeout;
220 * Initialize the resolver
222 * @param nh handle to the namestore
223 * @param dh handle to the dht
224 * @returns GNUNET_OK on success
227 gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
228 struct GNUNET_DHT_Handle *dh);
231 * Lookup of a record in a specific zone
232 * calls lookup result processor on result
234 * @param zone the root zone
235 * @param record_type the record type to look up
236 * @param name the name to look up
237 * @param key optional private key for authority caching
238 * @param proc the processor to call
239 * @param cls the closure to pass to proc
242 gns_resolver_lookup_record(GNUNET_HashCode zone,
243 uint32_t record_type,
245 struct GNUNET_CRYPTO_RsaPrivateKey *key,
246 RecordLookupProcessor proc,
250 gns_resolver_shorten_name(GNUNET_HashCode zone,
252 ShortenResultProcessor proc,
256 * Tries to resolve the authority for name
259 * @param zone the root zone to look up for
260 * @param name the name to lookup up
261 * @param proc the processor to call when finished
262 * @param cls the closure to pass to the processor
265 gns_resolver_get_authority(GNUNET_HashCode zone,
267 GetAuthorityResultProcessor proc,