aboutsummaryrefslogtreecommitdiff
path: root/src/namecache/namecache_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namecache/namecache_api.c')
-rw-r--r--src/namecache/namecache_api.c363
1 files changed, 179 insertions, 184 deletions
diff --git a/src/namecache/namecache_api.c b/src/namecache/namecache_api.c
index b91c1ac8f..9cf9eca77 100644
--- a/src/namecache/namecache_api.c
+++ b/src/namecache/namecache_api.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file namecache/namecache_api.c 22 * @file namecache/namecache_api.c
@@ -37,16 +37,14 @@
37#include "namecache.h" 37#include "namecache.h"
38 38
39 39
40#define LOG(kind,...) GNUNET_log_from (kind, "namecache-api",__VA_ARGS__) 40#define LOG(kind, ...) GNUNET_log_from(kind, "namecache-api", __VA_ARGS__)
41 41
42 42
43/** 43/**
44 * An QueueEntry used to store information for a pending 44 * An QueueEntry used to store information for a pending
45 * NAMECACHE record operation 45 * NAMECACHE record operation
46 */ 46 */
47struct GNUNET_NAMECACHE_QueueEntry 47struct GNUNET_NAMECACHE_QueueEntry {
48{
49
50 /** 48 /**
51 * Kept in a DLL. 49 * Kept in a DLL.
52 */ 50 */
@@ -86,16 +84,13 @@ struct GNUNET_NAMECACHE_QueueEntry
86 * The operation id this zone iteration operation has 84 * The operation id this zone iteration operation has
87 */ 85 */
88 uint32_t op_id; 86 uint32_t op_id;
89
90}; 87};
91 88
92 89
93/** 90/**
94 * Connection to the NAMECACHE service. 91 * Connection to the NAMECACHE service.
95 */ 92 */
96struct GNUNET_NAMECACHE_Handle 93struct GNUNET_NAMECACHE_Handle {
97{
98
99 /** 94 /**
100 * Configuration to use. 95 * Configuration to use.
101 */ 96 */
@@ -140,7 +135,6 @@ struct GNUNET_NAMECACHE_Handle
140 * The last operation id used for a NAMECACHE operation 135 * The last operation id used for a NAMECACHE operation
141 */ 136 */
142 uint32_t last_op_id_used; 137 uint32_t last_op_id_used;
143
144}; 138};
145 139
146 140
@@ -150,7 +144,7 @@ struct GNUNET_NAMECACHE_Handle
150 * @param h our handle 144 * @param h our handle
151 */ 145 */
152static void 146static void
153force_reconnect (struct GNUNET_NAMECACHE_Handle *h); 147force_reconnect(struct GNUNET_NAMECACHE_Handle *h);
154 148
155 149
156/** 150/**
@@ -161,21 +155,21 @@ force_reconnect (struct GNUNET_NAMECACHE_Handle *h);
161 * @return NULL if not found, otherwise the queue entry (removed from the queue) 155 * @return NULL if not found, otherwise the queue entry (removed from the queue)
162 */ 156 */
163static struct GNUNET_NAMECACHE_QueueEntry * 157static struct GNUNET_NAMECACHE_QueueEntry *
164find_qe (struct GNUNET_NAMECACHE_Handle *h, 158find_qe(struct GNUNET_NAMECACHE_Handle *h,
165 uint32_t rid) 159 uint32_t rid)
166{ 160{
167 struct GNUNET_NAMECACHE_QueueEntry *qe; 161 struct GNUNET_NAMECACHE_QueueEntry *qe;
168 162
169 for (qe = h->op_head; qe != NULL; qe = qe->next) 163 for (qe = h->op_head; qe != NULL; qe = qe->next)
170 {
171 if (qe->op_id == rid)
172 { 164 {
173 GNUNET_CONTAINER_DLL_remove (h->op_head, 165 if (qe->op_id == rid)
174 h->op_tail, 166 {
175 qe); 167 GNUNET_CONTAINER_DLL_remove(h->op_head,
176 return qe; 168 h->op_tail,
169 qe);
170 return qe;
171 }
177 } 172 }
178 }
179 return NULL; 173 return NULL;
180} 174}
181 175
@@ -188,8 +182,8 @@ find_qe (struct GNUNET_NAMECACHE_Handle *h,
188 * @param msg the message we received 182 * @param msg the message we received
189 */ 183 */
190static int 184static int
191check_lookup_block_response (void *cls, 185check_lookup_block_response(void *cls,
192 const struct LookupBlockResponseMessage *msg) 186 const struct LookupBlockResponseMessage *msg)
193{ 187{
194 /* any length will do, format validation is in handler */ 188 /* any length will do, format validation is in handler */
195 return GNUNET_OK; 189 return GNUNET_OK;
@@ -204,62 +198,62 @@ check_lookup_block_response (void *cls,
204 * @param msg the message we received 198 * @param msg the message we received
205 */ 199 */
206static void 200static void
207handle_lookup_block_response (void *cls, 201handle_lookup_block_response(void *cls,
208 const struct LookupBlockResponseMessage *msg) 202 const struct LookupBlockResponseMessage *msg)
209{ 203{
210 struct GNUNET_NAMECACHE_Handle *h = cls; 204 struct GNUNET_NAMECACHE_Handle *h = cls;
211 size_t size; 205 size_t size;
212 struct GNUNET_NAMECACHE_QueueEntry *qe; 206 struct GNUNET_NAMECACHE_QueueEntry *qe;
213 207
214 LOG (GNUNET_ERROR_TYPE_DEBUG, 208 LOG(GNUNET_ERROR_TYPE_DEBUG,
215 "Received LOOKUP_BLOCK_RESPONSE\n"); 209 "Received LOOKUP_BLOCK_RESPONSE\n");
216 qe = find_qe (h, 210 qe = find_qe(h,
217 ntohl (msg->gns_header.r_id)); 211 ntohl(msg->gns_header.r_id));
218 if (NULL == qe) 212 if (NULL == qe)
219 return; 213 return;
220 if (0 == GNUNET_TIME_absolute_ntoh (msg->expire).abs_value_us) 214 if (0 == GNUNET_TIME_absolute_ntoh(msg->expire).abs_value_us)
221 { 215 {
222 /* no match found */ 216 /* no match found */
223 if (NULL != qe->block_proc) 217 if (NULL != qe->block_proc)
224 qe->block_proc (qe->block_proc_cls, 218 qe->block_proc(qe->block_proc_cls,
225 NULL); 219 NULL);
226 GNUNET_free (qe); 220 GNUNET_free(qe);
227 return; 221 return;
228 } 222 }
229 size = ntohs (msg->gns_header.header.size) 223 size = ntohs(msg->gns_header.header.size)
230 - sizeof (struct LookupBlockResponseMessage); 224 - sizeof(struct LookupBlockResponseMessage);
231 { 225 {
232 char buf[size + sizeof (struct GNUNET_GNSRECORD_Block)] GNUNET_ALIGN; 226 char buf[size + sizeof(struct GNUNET_GNSRECORD_Block)] GNUNET_ALIGN;
233 struct GNUNET_GNSRECORD_Block *block; 227 struct GNUNET_GNSRECORD_Block *block;
234 228
235 block = (struct GNUNET_GNSRECORD_Block *) buf; 229 block = (struct GNUNET_GNSRECORD_Block *)buf;
236 block->signature = msg->signature; 230 block->signature = msg->signature;
237 block->derived_key = msg->derived_key; 231 block->derived_key = msg->derived_key;
238 block->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); 232 block->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
239 block->purpose.size = htonl (size + 233 block->purpose.size = htonl(size +
240 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 234 sizeof(struct GNUNET_TIME_AbsoluteNBO) +
241 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); 235 sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose));
242 block->expiration_time = msg->expire; 236 block->expiration_time = msg->expire;
243 GNUNET_memcpy (&block[1], 237 GNUNET_memcpy(&block[1],
244 &msg[1], 238 &msg[1],
245 size); 239 size);
246 if (GNUNET_OK != 240 if (GNUNET_OK !=
247 GNUNET_GNSRECORD_block_verify (block)) 241 GNUNET_GNSRECORD_block_verify(block))
248 { 242 {
249 GNUNET_break (0); 243 GNUNET_break(0);
250 if (NULL != qe->block_proc) 244 if (NULL != qe->block_proc)
251 qe->block_proc (qe->block_proc_cls, 245 qe->block_proc(qe->block_proc_cls,
252 NULL); 246 NULL);
253 force_reconnect (h); 247 force_reconnect(h);
254 } 248 }
255 else 249 else
256 { 250 {
257 if (NULL != qe->block_proc) 251 if (NULL != qe->block_proc)
258 qe->block_proc (qe->block_proc_cls, 252 qe->block_proc(qe->block_proc_cls,
259 block); 253 block);
260 } 254 }
261 } 255 }
262 GNUNET_free (qe); 256 GNUNET_free(qe);
263} 257}
264 258
265 259
@@ -273,28 +267,28 @@ handle_lookup_block_response (void *cls,
273 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and we did NOT notify the client 267 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and we did NOT notify the client
274 */ 268 */
275static void 269static void
276handle_block_cache_response (void *cls, 270handle_block_cache_response(void *cls,
277 const struct BlockCacheResponseMessage *msg) 271 const struct BlockCacheResponseMessage *msg)
278{ 272{
279 struct GNUNET_NAMECACHE_Handle *h = cls; 273 struct GNUNET_NAMECACHE_Handle *h = cls;
280 struct GNUNET_NAMECACHE_QueueEntry *qe; 274 struct GNUNET_NAMECACHE_QueueEntry *qe;
281 int res; 275 int res;
282 276
283 LOG (GNUNET_ERROR_TYPE_DEBUG, 277 LOG(GNUNET_ERROR_TYPE_DEBUG,
284 "Received BLOCK_CACHE_RESPONSE\n"); 278 "Received BLOCK_CACHE_RESPONSE\n");
285 qe = find_qe (h, 279 qe = find_qe(h,
286 ntohl (msg->gns_header.r_id)); 280 ntohl(msg->gns_header.r_id));
287 if (NULL == qe) 281 if (NULL == qe)
288 return; 282 return;
289 res = ntohl (msg->op_result); 283 res = ntohl(msg->op_result);
290 /* TODO: add actual error message from namecache to response... */ 284 /* TODO: add actual error message from namecache to response... */
291 if (NULL != qe->cont) 285 if (NULL != qe->cont)
292 qe->cont (qe->cont_cls, 286 qe->cont(qe->cont_cls,
293 res, 287 res,
294 (GNUNET_OK == res) 288 (GNUNET_OK == res)
295 ? NULL 289 ? NULL
296 : _("Namecache failed to cache block")); 290 : _("Namecache failed to cache block"));
297 GNUNET_free (qe); 291 GNUNET_free(qe);
298} 292}
299 293
300 294
@@ -307,12 +301,12 @@ handle_block_cache_response (void *cls,
307 * @param error error code 301 * @param error error code
308 */ 302 */
309static void 303static void
310mq_error_handler (void *cls, 304mq_error_handler(void *cls,
311 enum GNUNET_MQ_Error error) 305 enum GNUNET_MQ_Error error)
312{ 306{
313 struct GNUNET_NAMECACHE_Handle *h = cls; 307 struct GNUNET_NAMECACHE_Handle *h = cls;
314 308
315 force_reconnect (h); 309 force_reconnect(h);
316} 310}
317 311
318 312
@@ -322,25 +316,26 @@ mq_error_handler (void *cls,
322 * @param h the handle to the NAMECACHE service 316 * @param h the handle to the NAMECACHE service
323 */ 317 */
324static void 318static void
325reconnect (struct GNUNET_NAMECACHE_Handle *h) 319reconnect(struct GNUNET_NAMECACHE_Handle *h)
326{ 320{
327 struct GNUNET_MQ_MessageHandler handlers[] = { 321 struct GNUNET_MQ_MessageHandler handlers[] = {
328 GNUNET_MQ_hd_var_size (lookup_block_response, 322 GNUNET_MQ_hd_var_size(lookup_block_response,
329 GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE, 323 GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE,
330 struct LookupBlockResponseMessage, 324 struct LookupBlockResponseMessage,
331 h), 325 h),
332 GNUNET_MQ_hd_fixed_size (block_cache_response, 326 GNUNET_MQ_hd_fixed_size(block_cache_response,
333 GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE, 327 GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE,
334 struct BlockCacheResponseMessage, 328 struct BlockCacheResponseMessage,
335 h), 329 h),
336 GNUNET_MQ_handler_end () 330 GNUNET_MQ_handler_end()
337 }; 331 };
338 GNUNET_assert (NULL == h->mq); 332
339 h->mq = GNUNET_CLIENT_connect (h->cfg, 333 GNUNET_assert(NULL == h->mq);
340 "namecache", 334 h->mq = GNUNET_CLIENT_connect(h->cfg,
341 handlers, 335 "namecache",
342 &mq_error_handler, 336 handlers,
343 h); 337 &mq_error_handler,
338 h);
344} 339}
345 340
346 341
@@ -350,12 +345,12 @@ reconnect (struct GNUNET_NAMECACHE_Handle *h)
350 * @param cls handle to use to re-connect. 345 * @param cls handle to use to re-connect.
351 */ 346 */
352static void 347static void
353reconnect_task (void *cls) 348reconnect_task(void *cls)
354{ 349{
355 struct GNUNET_NAMECACHE_Handle *h = cls; 350 struct GNUNET_NAMECACHE_Handle *h = cls;
356 351
357 h->reconnect_task = NULL; 352 h->reconnect_task = NULL;
358 reconnect (h); 353 reconnect(h);
359} 354}
360 355
361 356
@@ -365,30 +360,30 @@ reconnect_task (void *cls)
365 * @param h our handle 360 * @param h our handle
366 */ 361 */
367static void 362static void
368force_reconnect (struct GNUNET_NAMECACHE_Handle *h) 363force_reconnect(struct GNUNET_NAMECACHE_Handle *h)
369{ 364{
370 struct GNUNET_NAMECACHE_QueueEntry *qe; 365 struct GNUNET_NAMECACHE_QueueEntry *qe;
371 366
372 h->reconnect = GNUNET_NO; 367 h->reconnect = GNUNET_NO;
373 GNUNET_MQ_destroy (h->mq); 368 GNUNET_MQ_destroy(h->mq);
374 h->mq = NULL; 369 h->mq = NULL;
375 while (NULL != (qe = h->op_head)) 370 while (NULL != (qe = h->op_head))
376 { 371 {
377 GNUNET_CONTAINER_DLL_remove (h->op_head, 372 GNUNET_CONTAINER_DLL_remove(h->op_head,
378 h->op_tail, 373 h->op_tail,
379 qe); 374 qe);
380 if (NULL != qe->cont) 375 if (NULL != qe->cont)
381 qe->cont (qe->cont_cls, 376 qe->cont(qe->cont_cls,
382 GNUNET_SYSERR, 377 GNUNET_SYSERR,
383 _("Error communicating with namecache service")); 378 _("Error communicating with namecache service"));
384 GNUNET_free (qe); 379 GNUNET_free(qe);
385 } 380 }
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 381 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
387 "Reconnecting to namecache\n"); 382 "Reconnecting to namecache\n");
388 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); 383 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF(h->reconnect_delay);
389 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, 384 h->reconnect_task = GNUNET_SCHEDULER_add_delayed(h->reconnect_delay,
390 &reconnect_task, 385 &reconnect_task,
391 h); 386 h);
392} 387}
393 388
394 389
@@ -399,7 +394,7 @@ force_reconnect (struct GNUNET_NAMECACHE_Handle *h)
399 * @return next operation id to use 394 * @return next operation id to use
400 */ 395 */
401static uint32_t 396static uint32_t
402get_op_id (struct GNUNET_NAMECACHE_Handle *h) 397get_op_id(struct GNUNET_NAMECACHE_Handle *h)
403{ 398{
404 return h->last_op_id_used++; 399 return h->last_op_id_used++;
405} 400}
@@ -412,18 +407,18 @@ get_op_id (struct GNUNET_NAMECACHE_Handle *h)
412 * @return handle to the GNS service, or NULL on error 407 * @return handle to the GNS service, or NULL on error
413 */ 408 */
414struct GNUNET_NAMECACHE_Handle * 409struct GNUNET_NAMECACHE_Handle *
415GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) 410GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
416{ 411{
417 struct GNUNET_NAMECACHE_Handle *h; 412 struct GNUNET_NAMECACHE_Handle *h;
418 413
419 h = GNUNET_new (struct GNUNET_NAMECACHE_Handle); 414 h = GNUNET_new(struct GNUNET_NAMECACHE_Handle);
420 h->cfg = cfg; 415 h->cfg = cfg;
421 reconnect (h); 416 reconnect(h);
422 if (NULL == h->mq) 417 if (NULL == h->mq)
423 { 418 {
424 GNUNET_free (h); 419 GNUNET_free(h);
425 return NULL; 420 return NULL;
426 } 421 }
427 return h; 422 return h;
428} 423}
429 424
@@ -435,29 +430,29 @@ GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
435 * @param h handle to the namecache 430 * @param h handle to the namecache
436 */ 431 */
437void 432void
438GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h) 433GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
439{ 434{
440 struct GNUNET_NAMECACHE_QueueEntry *q; 435 struct GNUNET_NAMECACHE_QueueEntry *q;
441 436
442 GNUNET_break (NULL == h->op_head); 437 GNUNET_break(NULL == h->op_head);
443 while (NULL != (q = h->op_head)) 438 while (NULL != (q = h->op_head))
444 { 439 {
445 GNUNET_CONTAINER_DLL_remove (h->op_head, 440 GNUNET_CONTAINER_DLL_remove(h->op_head,
446 h->op_tail, 441 h->op_tail,
447 q); 442 q);
448 GNUNET_free (q); 443 GNUNET_free(q);
449 } 444 }
450 if (NULL != h->mq) 445 if (NULL != h->mq)
451 { 446 {
452 GNUNET_MQ_destroy (h->mq); 447 GNUNET_MQ_destroy(h->mq);
453 h->mq = NULL; 448 h->mq = NULL;
454 } 449 }
455 if (NULL != h->reconnect_task) 450 if (NULL != h->reconnect_task)
456 { 451 {
457 GNUNET_SCHEDULER_cancel (h->reconnect_task); 452 GNUNET_SCHEDULER_cancel(h->reconnect_task);
458 h->reconnect_task = NULL; 453 h->reconnect_task = NULL;
459 } 454 }
460 GNUNET_free (h); 455 GNUNET_free(h);
461} 456}
462 457
463 458
@@ -472,10 +467,10 @@ GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h)
472 * @return handle to abort the request, NULL on error 467 * @return handle to abort the request, NULL on error
473 */ 468 */
474struct GNUNET_NAMECACHE_QueueEntry * 469struct GNUNET_NAMECACHE_QueueEntry *
475GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h, 470GNUNET_NAMECACHE_block_cache(struct GNUNET_NAMECACHE_Handle *h,
476 const struct GNUNET_GNSRECORD_Block *block, 471 const struct GNUNET_GNSRECORD_Block *block,
477 GNUNET_NAMECACHE_ContinuationWithStatus cont, 472 GNUNET_NAMECACHE_ContinuationWithStatus cont,
478 void *cont_cls) 473 void *cont_cls)
479{ 474{
480 struct GNUNET_NAMECACHE_QueueEntry *qe; 475 struct GNUNET_NAMECACHE_QueueEntry *qe;
481 struct BlockCacheMessage *msg; 476 struct BlockCacheMessage *msg;
@@ -485,33 +480,33 @@ GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h,
485 480
486 if (NULL == h->mq) 481 if (NULL == h->mq)
487 return NULL; 482 return NULL;
488 blen = ntohl (block->purpose.size); 483 blen = ntohl(block->purpose.size);
489 GNUNET_assert (blen > (sizeof (struct GNUNET_TIME_AbsoluteNBO) + 484 GNUNET_assert(blen > (sizeof(struct GNUNET_TIME_AbsoluteNBO) +
490 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose))); 485 sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)));
491 blen -= (sizeof (struct GNUNET_TIME_AbsoluteNBO) + 486 blen -= (sizeof(struct GNUNET_TIME_AbsoluteNBO) +
492 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); 487 sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose));
493 rid = get_op_id (h); 488 rid = get_op_id(h);
494 qe = GNUNET_new (struct GNUNET_NAMECACHE_QueueEntry); 489 qe = GNUNET_new(struct GNUNET_NAMECACHE_QueueEntry);
495 qe->nsh = h; 490 qe->nsh = h;
496 qe->cont = cont; 491 qe->cont = cont;
497 qe->cont_cls = cont_cls; 492 qe->cont_cls = cont_cls;
498 qe->op_id = rid; 493 qe->op_id = rid;
499 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 494 GNUNET_CONTAINER_DLL_insert_tail(h->op_head,
500 h->op_tail, 495 h->op_tail,
501 qe); 496 qe);
502 /* send msg */ 497 /* send msg */
503 env = GNUNET_MQ_msg_extra (msg, 498 env = GNUNET_MQ_msg_extra(msg,
504 blen, 499 blen,
505 GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE); 500 GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE);
506 msg->gns_header.r_id = htonl (rid); 501 msg->gns_header.r_id = htonl(rid);
507 msg->expire = block->expiration_time; 502 msg->expire = block->expiration_time;
508 msg->signature = block->signature; 503 msg->signature = block->signature;
509 msg->derived_key = block->derived_key; 504 msg->derived_key = block->derived_key;
510 GNUNET_memcpy (&msg[1], 505 GNUNET_memcpy(&msg[1],
511 &block[1], 506 &block[1],
512 blen); 507 blen);
513 GNUNET_MQ_send (h->mq, 508 GNUNET_MQ_send(h->mq,
514 env); 509 env);
515 return qe; 510 return qe;
516} 511}
517 512
@@ -528,10 +523,10 @@ GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h,
528 * @return a handle that can be used to cancel, NULL on error 523 * @return a handle that can be used to cancel, NULL on error
529 */ 524 */
530struct GNUNET_NAMECACHE_QueueEntry * 525struct GNUNET_NAMECACHE_QueueEntry *
531GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h, 526GNUNET_NAMECACHE_lookup_block(struct GNUNET_NAMECACHE_Handle *h,
532 const struct GNUNET_HashCode *derived_hash, 527 const struct GNUNET_HashCode *derived_hash,
533 GNUNET_NAMECACHE_BlockProcessor proc, 528 GNUNET_NAMECACHE_BlockProcessor proc,
534 void *proc_cls) 529 void *proc_cls)
535{ 530{
536 struct GNUNET_NAMECACHE_QueueEntry *qe; 531 struct GNUNET_NAMECACHE_QueueEntry *qe;
537 struct LookupBlockMessage *msg; 532 struct LookupBlockMessage *msg;
@@ -540,24 +535,24 @@ GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h,
540 535
541 if (NULL == h->mq) 536 if (NULL == h->mq)
542 return NULL; 537 return NULL;
543 LOG (GNUNET_ERROR_TYPE_DEBUG, 538 LOG(GNUNET_ERROR_TYPE_DEBUG,
544 "Looking for block under %s\n", 539 "Looking for block under %s\n",
545 GNUNET_h2s (derived_hash)); 540 GNUNET_h2s(derived_hash));
546 rid = get_op_id (h); 541 rid = get_op_id(h);
547 qe = GNUNET_new (struct GNUNET_NAMECACHE_QueueEntry); 542 qe = GNUNET_new(struct GNUNET_NAMECACHE_QueueEntry);
548 qe->nsh = h; 543 qe->nsh = h;
549 qe->block_proc = proc; 544 qe->block_proc = proc;
550 qe->block_proc_cls = proc_cls; 545 qe->block_proc_cls = proc_cls;
551 qe->op_id = rid; 546 qe->op_id = rid;
552 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 547 GNUNET_CONTAINER_DLL_insert_tail(h->op_head,
553 h->op_tail, 548 h->op_tail,
554 qe); 549 qe);
555 env = GNUNET_MQ_msg (msg, 550 env = GNUNET_MQ_msg(msg,
556 GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK); 551 GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK);
557 msg->gns_header.r_id = htonl (rid); 552 msg->gns_header.r_id = htonl(rid);
558 msg->query = *derived_hash; 553 msg->query = *derived_hash;
559 GNUNET_MQ_send (h->mq, 554 GNUNET_MQ_send(h->mq,
560 env); 555 env);
561 return qe; 556 return qe;
562} 557}
563 558
@@ -569,13 +564,13 @@ GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h,
569 * @param qe operation to cancel 564 * @param qe operation to cancel
570 */ 565 */
571void 566void
572GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe) 567GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
573{ 568{
574 struct GNUNET_NAMECACHE_Handle *h = qe->nsh; 569 struct GNUNET_NAMECACHE_Handle *h = qe->nsh;
575 570
576 GNUNET_CONTAINER_DLL_remove (h->op_head, 571 GNUNET_CONTAINER_DLL_remove(h->op_head,
577 h->op_tail, 572 h->op_tail,
578 qe); 573 qe);
579 GNUNET_free(qe); 574 GNUNET_free(qe);
580} 575}
581 576