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;
36 * processor for a resultion result
38 * @param cls the closure
39 * @param rh the resolution handle
40 * @param rd_count number of results
41 * @pram rd resukt data
43 typedef void (*RecordLookupProcessor) (void *cls,
45 const struct GNUNET_NAMESTORE_RecordData *rd);
49 * processor for a shorten result
51 * @param cls the closure
52 * @param name shortened name
54 typedef void (*ShortenResultProcessor) (void *cls, const char* name);
58 * processor for an authority result
60 * @param cls the closure
63 typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name);
66 * processor for a resultion result
68 * @param cls the closure
69 * @param rh the resolution handle
70 * @param rd_count number of results
71 * @param rd result data
73 typedef void (*ResolutionResultProcessor) (void *cls,
74 struct ResolverHandle *rh,
76 const struct GNUNET_NAMESTORE_RecordData *rd);
80 * Resoltion status indicator
81 * EXISTS: the name to lookup exists
82 * EXPIRED: the name in the record expired
91 * Handle to a currenty pending resolution
95 /* The name to resolve */
98 /* has this query been answered? how many matches */
101 /* the authoritative zone to query */
102 GNUNET_HashCode authority;
104 /* the name of the authoritative zone to query */
105 char *authority_name;
108 * we have an authority in namestore that
109 * may be able to resolve
113 /* a handle for dht lookups. should be NULL if no lookups are in progress */
114 struct GNUNET_DHT_GetHandle *get_handle;
116 /* timeout task for dht lookups */
117 GNUNET_SCHEDULER_TaskIdentifier dht_timeout_task;
119 /* called when resolution phase finishes */
120 ResolutionResultProcessor proc;
122 /* closure passed to proc */
125 /* DLL to store the authority chain */
126 struct AuthorityChain *authority_chain_head;
128 /* DLL to store the authority chain */
129 struct AuthorityChain *authority_chain_tail;
131 /* status of the resolution result */
132 enum ResolutionStatus status;
138 * Handle to a record lookup
140 struct RecordLookupHandle
142 /* the record type to look up */
143 enum GNUNET_GNS_RecordType record_type;
145 /* the name to look up */
148 /* Method to call on record resolution result */
149 RecordLookupProcessor proc;
151 /* closure to pass to proc */
158 * Handle to a shorten context
160 struct NameShortenHandle
164 /* Method to call on shorten result */
165 ShortenResultProcessor proc;
167 /* closure to pass to proc */
173 * Handle to a get authority context
175 struct GetNameAuthorityHandle
178 /* the name to look up authority for */
181 /* Method to call on result */
182 GetAuthorityResultProcessor proc;
184 /* closure to pass to proc */
190 * Initialize the resolver
192 * @param nh handle to the namestore
193 * @param dh handle to the dht
194 * @returns GNUNET_OK on success
197 gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
198 struct GNUNET_DHT_Handle *dh);
201 * Lookup of a record in a specific zone
202 * calls lookup result processor on result
204 * @param zone the root zone
205 * @param record_type the record type to look up
206 * @param proc the processor to call
207 * @param cls the closure to pass to proc
210 gns_resolver_lookup_record(GNUNET_HashCode zone,
211 uint32_t record_type,
213 RecordLookupProcessor proc,
217 gns_resolver_shorten_name(GNUNET_HashCode zone,
219 ShortenResultProcessor proc,
223 * Tries to resolve the authority for name
226 * @param zone the root zone to look up for
227 * @param name the name to lookup up
228 * @param proc the processor to call when finished
229 * @param cls the closure to pass to the processor
232 gns_resolver_get_authority(GNUNET_HashCode zone,
234 GetAuthorityResultProcessor proc,