aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-22 16:12:41 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-22 16:12:41 +0000
commite4a21ca8d3ba23928afb162f351bd43dd98c5b3c (patch)
tree6f279a6390fb7fceaf027a5a887b9fb83e1b8673 /src
parentde024124ff68aa64039720bc7b4bcfc26a41f3f5 (diff)
downloadgnunet-e4a21ca8d3ba23928afb162f351bd43dd98c5b3c.tar.gz
gnunet-e4a21ca8d3ba23928afb162f351bd43dd98c5b3c.zip
-some dht stuff
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c105
1 files changed, 96 insertions, 9 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 108e58b31..adfa00470 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -160,7 +160,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
160 * not match our name. How do we check this? 160 * not match our name. How do we check this?
161 */ 161 */
162void 162void
163handle_dht_reply(void* cls, 163process_authority_dht_result(void* cls,
164 struct GNUNET_TIME_Absolute exp, 164 struct GNUNET_TIME_Absolute exp,
165 const GNUNET_HashCode * key, 165 const GNUNET_HashCode * key,
166 const struct GNUNET_PeerIdentity *get_path, 166 const struct GNUNET_PeerIdentity *get_path,
@@ -170,13 +170,105 @@ handle_dht_reply(void* cls,
170 enum GNUNET_BLOCK_Type type, 170 enum GNUNET_BLOCK_Type type,
171 size_t size, const void *data) 171 size_t size, const void *data)
172{ 172{
173 if (data == NULL)
174 return;
175
176 /**
177 * data is a searialized PKEY record (probably)
178 * parse, put into namestore
179 * namestore zone hash is in query.
180 * Then adjust query->name and call resolve_name
181 * with new zone (the one just received)
182 */
173} 183}
174 184
185/**
186 * Start DHT lookup for a name -> PKEY (compare NS) record in
187 * query->authority's zone
188 *
189 * @param query the pending gns query
190 * @param name the name of the PKEY record
191 */
175void 192void
176resolve_authority_dht(struct GNUNET_GNS_PendingQuery *query) 193resolve_authority_dht(struct GNUNET_GNS_PendingQuery *query, const char* name)
177{ 194{
195 enum GNUNET_GNS_RecordType rtype = GNUNET_GNS_RECORD_PKEY;
196 struct GNUNET_TIME_Relative timeout;
197 GNUNET_HashCode name_hash;
198 GNUNET_HashCode lookup_key;
199
200 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
201 GNUNET_CRYPTO_hash_xor(&name_hash, query->authority, &lookup_key);
202
203 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
204
205 //FIXME how long to wait for results?
206 GNUNET_DHT_get_start(dht_handle, timeout,
207 GNUNET_BLOCK_TYPE_TEST, //FIXME todo
208 &lookup_key,
209 5, //Replication level FIXME
210 GNUNET_DHT_RO_NONE,
211 &rtype, //xquery FIXME this is bad
212 sizeof(GNUNET_GNS_RECORD_PKEY),
213 &process_authority_dht_result,
214 query);
215
178} 216}
179 217
218void
219process_name_dht_result(void* cls,
220 struct GNUNET_TIME_Absolute exp,
221 const GNUNET_HashCode * key,
222 const struct GNUNET_PeerIdentity *get_path,
223 unsigned int get_path_length,
224 const struct GNUNET_PeerIdentity *put_path,
225 unsigned int put_path_length,
226 enum GNUNET_BLOCK_Type type,
227 size_t size, const void *data)
228{
229 if (data == NULL)
230 return;
231
232 /**
233 * data is a searialized GNS record of type
234 * query->record_type. Parse and put into namestore
235 * namestore zone hash is in query.
236 * Check if record type and name match in query and reply
237 * to dns!
238 */
239}
240
241/**
242 * Start DHT lookup for a name -> query->record_type record in
243 * query->authority's zone
244 *
245 * @param query the pending gns query
246 * @param name the name to query record
247 */
248void
249resolve_name_dht(struct GNUNET_GNS_PendingQuery *query, const char* name)
250{
251 struct GNUNET_TIME_Relative timeout;
252 GNUNET_HashCode name_hash;
253 GNUNET_HashCode lookup_key;
254
255 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
256 GNUNET_CRYPTO_hash_xor(&name_hash, query->authority, &lookup_key);
257
258 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
259
260 //FIXME how long to wait for results?
261 GNUNET_DHT_get_start(dht_handle, timeout,
262 GNUNET_BLOCK_TYPE_TEST, //FIXME todo
263 &lookup_key,
264 5, //Replication level FIXME
265 GNUNET_DHT_RO_NONE,
266 &query->type, //xquery
267 sizeof(query->type),
268 &process_name_dht_result,
269 query);
270
271}
180/** 272/**
181 * This is a callback function that should give us only PKEY 273 * This is a callback function that should give us only PKEY
182 * records. Used to iteratively query the namestore for 'closest' 274 * records. Used to iteratively query the namestore for 'closest'
@@ -229,7 +321,7 @@ process_authority_lookup(void* cls, const GNUNET_HashCode *zone,
229 return; 321 return;
230 } 322 }
231 323
232 resolve_authority_dht(query); 324 resolve_authority_dht(query, name);
233 return; 325 return;
234 } 326 }
235 327
@@ -314,11 +406,6 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer)
314 } 406 }
315} 407}
316 408
317void
318resolve_name_dht(struct GNUNET_GNS_PendingQuery *query)
319{
320}
321
322/** 409/**
323 * Namestore calls this function if we have an entry for this name. 410 * Namestore calls this function if we have an entry for this name.
324 * (or data=null to indicate the lookup has finished) 411 * (or data=null to indicate the lookup has finished)
@@ -371,7 +458,7 @@ process_authoritative_result(void* cls, const GNUNET_HashCode *zone,
371 if (!GNUNET_CRYPTO_hash_cmp(zone, zone_hash)) 458 if (!GNUNET_CRYPTO_hash_cmp(zone, zone_hash))
372 { 459 {
373 //FIXME todo 460 //FIXME todo
374 resolve_name_dht(query); 461 resolve_name_dht(query, name);
375 return; 462 return;
376 } 463 }
377 464