2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file namestore/namestore_api.c
23 * @brief API to access the NAMESTORE service
24 * @author Martin Schanzenbach
25 * @author Matthias Wachs
29 #include "gnunet_util_lib.h"
30 #include "gnunet_crypto_lib.h"
31 #include "gnunet_constants.h"
32 #include "gnunet_dnsparser_lib.h"
33 #include "gnunet_arm_service.h"
34 #include "gnunet_signatures.h"
35 #include "gnunet_namestore_service.h"
36 #include "namestore.h"
38 #define DEBUG_GNS_API GNUNET_EXTRA_LOGGING
40 #define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
45 struct GNUNET_NAMESTORE_QueueEntry
51 struct GNUNET_NAMESTORE_QueueEntry *next;
56 struct GNUNET_NAMESTORE_QueueEntry *prev;
58 struct GNUNET_NAMESTORE_Handle *nsh;
62 GNUNET_NAMESTORE_ContinuationWithStatus cont;
65 GNUNET_NAMESTORE_RecordProcessor proc;
68 char *data; /*stub data pointer*/
75 struct GNUNET_NAMESTORE_ZoneIterator
81 struct GNUNET_NAMESTORE_ZoneIterator *next;
86 struct GNUNET_NAMESTORE_ZoneIterator *prev;
90 struct GNUNET_NAMESTORE_Handle *h;
91 GNUNET_NAMESTORE_RecordProcessor proc;
101 * Message in linked list we should send to the service. The
102 * actual binary message follows this struct.
104 struct PendingMessage
110 struct PendingMessage *next;
115 struct PendingMessage *prev;
118 * Size of the message.
123 * Is this the 'START' message?
130 * Connection to the NAMESTORE service.
132 struct GNUNET_NAMESTORE_Handle
136 * Configuration to use.
138 const struct GNUNET_CONFIGURATION_Handle *cfg;
141 * Socket (if available).
143 struct GNUNET_CLIENT_Connection *client;
146 * Currently pending transmission request (or NULL).
148 struct GNUNET_CLIENT_TransmitHandle *th;
153 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
156 * Pending messages to send to the service
159 struct PendingMessage * pending_head;
160 struct PendingMessage * pending_tail;
163 * Should we reconnect to service due to some serious error?
169 * Pending namestore queue entries
171 struct GNUNET_NAMESTORE_QueueEntry * op_head;
172 struct GNUNET_NAMESTORE_QueueEntry * op_tail;
177 * Pending namestore zone iterator entries
179 struct GNUNET_NAMESTORE_ZoneIterator * z_head;
180 struct GNUNET_NAMESTORE_ZoneIterator * z_tail;
183 struct GNUNET_NAMESTORE_SimpleRecord
188 struct GNUNET_NAMESTORE_SimpleRecord *next;
193 struct GNUNET_NAMESTORE_SimpleRecord *prev;
196 const GNUNET_HashCode *zone;
197 uint32_t record_type;
198 struct GNUNET_TIME_Absolute expiration;
199 enum GNUNET_NAMESTORE_RecordFlags flags;
207 * Convert a type name (i.e. "AAAA") to the corresponding number.
209 * @param typename name to convert
210 * @return corresponding number, UINT32_MAX on error
213 GNUNET_NAMESTORE_typename_to_number (const char *typename)
219 { "A", GNUNET_DNSPARSER_TYPE_A },
220 { "NS", GNUNET_DNSPARSER_TYPE_NS },
221 { "CNAME", GNUNET_DNSPARSER_TYPE_CNAME },
222 { "SOA", GNUNET_DNSPARSER_TYPE_SOA },
223 { "PTR", GNUNET_DNSPARSER_TYPE_PTR },
224 { "MX", GNUNET_DNSPARSER_TYPE_MX },
225 { "TXT", GNUNET_DNSPARSER_TYPE_TXT },
226 { "AAAA", GNUNET_DNSPARSER_TYPE_AAAA },
227 { "PKEY", GNUNET_NAMESTORE_TYPE_PKEY },
228 { "PSEU", GNUNET_NAMESTORE_TYPE_PSEU },
234 while ( (map[i].name != NULL) &&
235 (0 != strcasecmp (typename, map[i].name)) )
237 return map[i].number;
242 * Disconnect from service and then reconnect.
244 * @param h our handle
247 force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
250 handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
251 struct LookupNameResponseMessage * msg,
254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
255 "LOOKUP_NAME_RESPONSE");
257 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
261 struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
262 struct GNUNET_TIME_Absolute expire;
263 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp;
268 int contains_sig = GNUNET_NO;
271 rd_len = ntohs (msg->rd_len);
272 rd_count = ntohs (msg->rd_count);
273 msg_len = ntohs (msg->gns_header.header.size);
274 name_len = ntohs (msg->name_len);
275 contains_sig = ntohs (msg->contains_sig);
276 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
278 exp_msg_len = sizeof (struct LookupNameResponseMessage) +
279 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
282 if (msg_len != exp_msg_len)
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
285 msg_len, exp_msg_len);
290 name = (char *) &msg[1];
291 rd_tmp = &name[name_len];
293 /* deserialize records */
294 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
295 GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd);
297 /* reset values if values not contained */
298 if (contains_sig == GNUNET_NO)
301 signature = &msg->signature;
306 public_key_tmp = &msg->public_key;
308 public_key_tmp = NULL;
310 if (qe->proc != NULL)
312 qe->proc (qe->proc_cls, public_key_tmp, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature);
315 /* Operation done, remove */
316 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
322 handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
323 struct RecordPutResponseMessage* msg,
326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
327 "RECORD_PUT_RESPONSE");
328 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
329 int res = ntohl (msg->op_result);
331 if (res == GNUNET_OK)
333 if (qe->cont != NULL)
335 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
339 else if (res == GNUNET_SYSERR)
341 if (qe->cont != NULL)
343 qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
352 /* Operation done, remove */
353 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
360 handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
361 struct RecordCreateResponseMessage* msg,
364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
365 "RECORD_CREATE_RESPONSE");
366 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
367 int res = ntohl (msg->op_result);
369 if (res == GNUNET_YES)
371 if (qe->cont != NULL)
373 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
377 else if (res == GNUNET_NO)
379 if (qe->cont != NULL)
381 qe->cont (qe->cont_cls, res, _("Namestore record already existed"));
386 if (qe->cont != NULL)
388 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Namestore failed to add record\n"));
392 /* Operation done, remove */
393 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
400 handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
401 struct RecordRemoveResponseMessage* msg,
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
405 "RECORD_REMOVE_RESPONSE");
407 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
408 int res = ntohl (msg->op_result);
413 * 1 : No records for entry
414 * 2 : Could not find record to remove
415 * 3 : Failed to create new signature
416 * 4 : Failed to put new set of records in database
420 if (qe->cont != NULL)
422 qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
427 if (qe->cont != NULL)
429 qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
434 if (qe->cont != NULL)
436 qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
441 if (qe->cont != NULL)
443 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
448 if (qe->cont != NULL)
450 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
458 /* Operation done, remove */
459 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
465 handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
466 struct ZoneToNameResponseMessage* msg,
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
470 "ZONE_TO_NAME_RESPONSE");
472 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
473 int res = ntohs (msg->res);
475 struct GNUNET_TIME_Absolute expire;
478 unsigned int rd_count;
483 if (res == GNUNET_SYSERR)
485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n");
486 if (qe->proc != NULL)
487 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
489 else if (res == GNUNET_NO)
491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n");
492 if (qe->proc != NULL)
493 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
495 else if (res == GNUNET_YES)
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has result for zone to name mapping \n");
499 name_len = ntohs (msg->name_len);
500 rd_count = ntohs (msg->rd_count);
501 rd_ser_len = ntohs (msg->rd_len);
502 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
504 name_tmp = (char *) &msg[1];
505 rd_tmp = &name_tmp[name_len];
507 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
508 GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd);
510 if (qe->proc != NULL)
511 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
516 /* Operation done, remove */
517 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
523 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
524 const struct GNUNET_MessageHeader *msg,
525 int type, size_t size)
528 /* handle different message type */
530 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
531 if (size < sizeof (struct LookupNameResponseMessage))
536 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
538 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
539 if (size != sizeof (struct RecordPutResponseMessage))
544 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
546 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
547 if (size != sizeof (struct RecordCreateResponseMessage))
552 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
554 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
555 if (size != sizeof (struct RecordRemoveResponseMessage))
560 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
562 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
563 if (size < sizeof (struct ZoneToNameResponseMessage))
568 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
577 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
578 struct ZoneIterationResponseMessage *msg,
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
582 "ZONE_ITERATION_RESPONSE");
584 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
586 size_t exp_msg_len = 0;
589 unsigned rd_count = 0;
593 struct GNUNET_TIME_Absolute expire;
595 msg_len = ntohs (msg->gns_header.header.size);
596 rd_len = ntohs (msg->rd_len);
597 rd_count = ntohs (msg->rd_count);
598 name_len = ntohs (msg->name_len);
599 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
601 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
602 if (msg_len != exp_msg_len)
604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
605 msg_len, exp_msg_len);
609 if (0 != ntohs (msg->reserved))
615 memset (&pubdummy, '\0', sizeof (pubdummy));
616 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
620 if (ze->proc != NULL)
621 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
623 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
628 name_tmp = (char *) &msg[1];
629 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
634 rd_ser_tmp = (char *) &name_tmp[name_len];
635 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
636 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
642 if (ze->proc != NULL)
643 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
648 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
649 const struct GNUNET_MessageHeader *msg,
650 int type, size_t size)
653 /* handle different message type */
655 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
656 if (size < sizeof (struct ZoneIterationResponseMessage))
661 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
670 * Type of a function to call when we receive a message
673 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
674 * @param msg message received, NULL on timeout or fatal error
677 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
679 struct GNUNET_NAMESTORE_Handle *h = cls;
680 struct GNUNET_NAMESTORE_Header * gm;
681 struct GNUNET_NAMESTORE_QueueEntry *qe;
682 struct GNUNET_NAMESTORE_ZoneIterator *ze;
685 uint32_t r_id = UINT32_MAX;
693 size = ntohs (msg->size);
694 type = ntohs (msg->type);
696 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
699 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
700 GNUNET_TIME_UNIT_FOREVER_REL);
704 gm = (struct GNUNET_NAMESTORE_Header *) msg;
705 r_id = ntohl (gm->r_id);
707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
709 /* Find matching operation */
712 /* No matching pending operation found */
714 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
715 GNUNET_TIME_UNIT_FOREVER_REL);
719 /* Is it a record related operation ? */
720 for (qe = h->op_head; qe != NULL; qe = qe->next)
722 if (qe->op_id == r_id)
727 manage_record_operations (qe, msg, type, size);
730 /* Is it a zone iteration operation ? */
731 for (ze = h->z_head; ze != NULL; ze = ze->next)
733 if (ze->op_id == r_id)
738 manage_zone_operations (ze, msg, type, size);
741 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
742 GNUNET_TIME_UNIT_FOREVER_REL);
744 if (GNUNET_YES == h->reconnect)
751 * Transmit messages from the message queue to the service
752 * (if there are any, and if we are not already trying).
754 * @param h handle to use
757 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
761 * We can now transmit a message to NAMESTORE. Do it.
763 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
764 * @param size number of bytes we can transmit
765 * @param buf where to copy the messages
766 * @return number of bytes copied into buf
769 transmit_message_to_namestore (void *cls, size_t size, void *buf)
771 struct GNUNET_NAMESTORE_Handle *h = cls;
772 struct PendingMessage *p;
777 if ((size == 0) || (buf == NULL))
784 while ((NULL != (p = h->pending_head)) && (p->size <= size))
786 memcpy (&cbuf[ret], &p[1], p->size);
789 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
790 if (GNUNET_YES == p->is_init)
791 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
792 GNUNET_TIME_UNIT_FOREVER_REL);
801 * Transmit messages from the message queue to the service
802 * (if there are any, and if we are not already trying).
804 * @param h handle to use
807 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
809 struct PendingMessage *p;
813 if (NULL == (p = h->pending_head))
815 if (NULL == h->client)
816 return; /* currently reconnecting */
818 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
819 GNUNET_TIME_UNIT_FOREVER_REL,
820 GNUNET_NO, &transmit_message_to_namestore,
826 * Reconnect to namestore service.
828 * @param h the handle to the namestore service
831 reconnect (struct GNUNET_NAMESTORE_Handle *h)
833 struct PendingMessage *p;
834 struct StartMessage *init;
836 GNUNET_assert (NULL == h->client);
837 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
838 GNUNET_assert (NULL != h->client);
840 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
842 p = GNUNET_malloc (sizeof (struct PendingMessage) +
843 sizeof (struct StartMessage));
844 p->size = sizeof (struct StartMessage);
845 p->is_init = GNUNET_YES;
846 init = (struct StartMessage *) &p[1];
847 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
848 init->header.size = htons (sizeof (struct StartMessage));
849 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
855 * Re-establish the connection to the service.
857 * @param cls handle to use to re-connect.
858 * @param tc scheduler context
861 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
863 struct GNUNET_NAMESTORE_Handle *h = cls;
865 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
871 * Disconnect from service and then reconnect.
873 * @param h our handle
876 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
878 h->reconnect = GNUNET_NO;
879 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
881 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
887 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
889 uint32_t op_id = h->op_id;
895 * Initialize the connection with the NAMESTORE service.
897 * @param cfg configuration to use
898 * @return handle to the GNS service, or NULL on error
900 struct GNUNET_NAMESTORE_Handle *
901 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
903 struct GNUNET_NAMESTORE_Handle *h;
905 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
907 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
913 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
915 struct PendingMessage *p;
916 struct GNUNET_NAMESTORE_QueueEntry *q;
917 struct GNUNET_NAMESTORE_ZoneIterator *z;
918 struct GNUNET_NAMESTORE_Handle *h = cls;
919 GNUNET_assert (h != NULL);
920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
921 while (NULL != (p = h->pending_head))
923 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
927 while (NULL != (q = h->op_head))
930 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
934 while (NULL != (z = h->z_head))
936 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
940 if (NULL != h->client)
942 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
945 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
947 GNUNET_SCHEDULER_cancel (h->reconnect_task);
948 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
955 * Disconnect from the namestore service (and free associated
958 * @param h handle to the namestore
959 * @param drop set to GNUNET_YES to delete all data in namestore (!)
962 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
965 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
970 * Store an item in the namestore. If the item is already present,
971 * the expiration time is updated to the max of the existing time and
972 * the new time. This API is used when we cache signatures from other
975 * @param h handle to the namestore
976 * @param zone_key public key of the zone
977 * @param name name that is being mapped (at most 255 characters long)
978 * @param expire when does the corresponding block in the DHT expire (until
979 * when should we never do a DHT lookup for the same name again)?
980 * @param rd_count number of entries in 'rd' array
981 * @param rd array of records with data to store
982 * @param signature signature for all the records in the zone under the given name
983 * @param cont continuation to call when done
984 * @param cont_cls closure for cont
985 * @return handle to abort the request
987 struct GNUNET_NAMESTORE_QueueEntry *
988 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
989 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
991 struct GNUNET_TIME_Absolute expire,
992 unsigned int rd_count,
993 const struct GNUNET_NAMESTORE_RecordData *rd,
994 const struct GNUNET_CRYPTO_RsaSignature *signature,
995 GNUNET_NAMESTORE_ContinuationWithStatus cont,
998 struct GNUNET_NAMESTORE_QueueEntry *qe;
999 struct PendingMessage *pe;
1001 /* pointer to elements */
1005 size_t msg_size = 0;
1006 size_t name_len = 0;
1007 size_t rd_ser_len = 0;
1010 GNUNET_assert (NULL != h);
1011 GNUNET_assert (NULL != zone_key);
1012 GNUNET_assert (NULL != name);
1013 GNUNET_assert (NULL != rd);
1014 GNUNET_assert (NULL != signature);
1016 name_len = strlen(name) + 1;
1024 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1027 qe->cont_cls = cont_cls;
1029 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1032 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1033 char rd_ser[rd_ser_len];
1034 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1036 struct RecordPutMessage * msg;
1037 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1039 /* create msg here */
1040 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1041 pe->size = msg_size;
1042 pe->is_init = GNUNET_NO;
1043 msg = (struct RecordPutMessage *) &pe[1];
1044 name_tmp = (char *) &msg[1];
1045 rd_tmp = &name_tmp[name_len];
1047 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1048 msg->gns_header.header.size = htons (msg_size);
1049 msg->gns_header.r_id = htonl (rid);
1050 msg->signature = *signature;
1051 msg->name_len = htons (name_len);
1052 msg->expire = GNUNET_TIME_absolute_hton (expire);
1053 msg->rd_len = htons (rd_ser_len);
1054 msg->rd_count = htons (rd_count);
1056 msg->public_key = *zone_key;
1057 memcpy (name_tmp, name, name_len);
1058 memcpy (rd_tmp, rd_ser, rd_ser_len);
1060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1062 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1070 * Check if a signature is valid. This API is used by the GNS Block
1071 * to validate signatures received from the network.
1073 * @param public_key public key of the zone
1074 * @param name name that is being mapped (at most 255 characters long)
1075 * @param rd_count number of entries in 'rd' array
1076 * @param rd array of records with data to store
1077 * @param signature signature for all the records in the zone under the given name
1078 * @return GNUNET_OK if the signature is valid
1081 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1083 unsigned int rd_count,
1084 const struct GNUNET_NAMESTORE_RecordData *rd,
1085 const struct GNUNET_CRYPTO_RsaSignature *signature)
1087 int res = GNUNET_SYSERR;
1088 size_t rd_ser_len = 0;
1089 size_t name_len = 0;
1092 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1094 GNUNET_assert (public_key != NULL);
1095 GNUNET_assert (name != NULL);
1096 GNUNET_assert (rd != NULL);
1097 GNUNET_assert (signature != NULL);
1100 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1101 char rd_ser[rd_ser_len];
1102 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1104 name_len = strlen (name) + 1;
1108 return GNUNET_SYSERR;
1111 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len + name_len);
1112 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1113 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1114 name_tmp = (char *) &sig_purpose[1];
1115 rd_tmp = &name_tmp[name_len];
1116 memcpy (name_tmp, name, name_len);
1117 memcpy (rd_tmp, rd_ser, rd_ser_len);
1119 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1121 GNUNET_free (sig_purpose);
1127 * Store an item in the namestore. If the item is already present,
1128 * the expiration time is updated to the max of the existing time and
1129 * the new time. This API is used by the authority of a zone.
1131 * @param h handle to the namestore
1132 * @param pkey private key of the zone
1133 * @param name name that is being mapped (at most 255 characters long)
1134 * @param rd record data to store
1135 * @param cont continuation to call when done
1136 * @param cont_cls closure for cont
1137 * @return handle to abort the request
1139 struct GNUNET_NAMESTORE_QueueEntry *
1140 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1141 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1143 const struct GNUNET_NAMESTORE_RecordData *rd,
1144 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1147 struct GNUNET_NAMESTORE_QueueEntry *qe;
1148 struct PendingMessage *pe;
1152 size_t rd_ser_len = 0;
1153 size_t msg_size = 0;
1154 size_t name_len = 0;
1158 GNUNET_assert (NULL != h);
1159 GNUNET_assert (NULL != pkey);
1160 GNUNET_assert (NULL != name);
1161 GNUNET_assert (NULL != rd);
1163 name_len = strlen(name) + 1;
1171 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1174 qe->cont_cls = cont_cls;
1176 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1179 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1180 GNUNET_assert (pkey_enc != NULL);
1181 key_len = ntohs (pkey_enc->len);
1183 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1184 char rd_ser[rd_ser_len];
1185 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1187 struct RecordCreateMessage * msg;
1188 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1190 /* create msg here */
1191 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1192 pe->size = msg_size;
1193 pe->is_init = GNUNET_NO;
1194 msg = (struct RecordCreateMessage *) &pe[1];
1196 pkey_tmp = (char *) &msg[1];
1197 name_tmp = &pkey_tmp[key_len];
1198 rd_tmp = &name_tmp[name_len];
1200 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1201 msg->gns_header.header.size = htons (msg_size);
1202 msg->gns_header.r_id = htonl (rid);
1203 msg->name_len = htons (name_len);
1204 msg->rd_count = htons (1);
1205 msg->rd_len = htons (rd_ser_len);
1206 msg->pkey_len = htons (key_len);
1207 memcpy (pkey_tmp, pkey_enc, key_len);
1208 memcpy (name_tmp, name, name_len);
1209 memcpy (rd_tmp, rd_ser, rd_ser_len);
1210 GNUNET_free (pkey_enc);
1212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1214 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1221 * Explicitly remove some content from the database. The
1222 * "cont"inuation will be called with status "GNUNET_OK" if content
1223 * was removed, "GNUNET_NO" if no matching entry was found and
1224 * "GNUNET_SYSERR" on all other types of errors.
1225 * This API is used by the authority of a zone.
1227 * @param h handle to the namestore
1228 * @param pkey private key of the zone
1229 * @param name name that is being mapped (at most 255 characters long)
1230 * @param rd record data
1231 * @param cont continuation to call when done
1232 * @param cont_cls closure for cont
1233 * @return handle to abort the request
1235 struct GNUNET_NAMESTORE_QueueEntry *
1236 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1237 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1239 const struct GNUNET_NAMESTORE_RecordData *rd,
1240 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1243 struct GNUNET_NAMESTORE_QueueEntry *qe;
1244 struct PendingMessage *pe;
1248 size_t rd_ser_len = 0;
1249 size_t msg_size = 0;
1250 size_t name_len = 0;
1254 GNUNET_assert (NULL != h);
1257 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1260 qe->cont_cls = cont_cls;
1262 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1265 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1266 GNUNET_assert (pkey_enc != NULL);
1267 key_len = ntohs (pkey_enc->len);
1269 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1270 char rd_ser[rd_ser_len];
1271 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1273 name_len = strlen (name) + 1;
1275 struct RecordRemoveMessage * msg;
1276 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1278 /* create msg here */
1279 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1280 pe->size = msg_size;
1281 pe->is_init = GNUNET_NO;
1282 msg = (struct RecordRemoveMessage *) &pe[1];
1284 pkey_tmp = (char *) &msg[1];
1285 name_tmp = &pkey_tmp[key_len];
1286 rd_tmp = &name_tmp[name_len];
1288 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1289 msg->gns_header.header.size = htons (msg_size);
1290 msg->gns_header.r_id = htonl (rid);
1291 msg->name_len = htons (name_len);
1292 msg->rd_len = htons (rd_ser_len);
1293 msg->rd_count = htons (1);
1294 msg->pkey_len = htons (key_len);
1295 memcpy (pkey_tmp, pkey_enc, key_len);
1296 memcpy (name_tmp, name, name_len);
1297 memcpy (rd_tmp, rd_ser, rd_ser_len);
1299 GNUNET_free (pkey_enc);
1301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1303 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1310 * Get a result for a particular key from the namestore. The processor
1311 * will only be called once.
1313 * @param h handle to the namestore
1314 * @param zone zone to look up a record from
1315 * @param name name to look up
1316 * @param record_type desired record type, 0 for all
1317 * @param proc function to call on the matching records, or with
1318 * NULL (rd_count == 0) if there are no matching records
1319 * @param proc_cls closure for proc
1320 * @return a handle that can be used to
1323 struct GNUNET_NAMESTORE_QueueEntry *
1324 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1325 const GNUNET_HashCode *zone,
1327 uint32_t record_type,
1328 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1330 struct GNUNET_NAMESTORE_QueueEntry *qe;
1331 struct PendingMessage *pe;
1332 size_t msg_size = 0;
1333 size_t name_len = 0;
1336 GNUNET_assert (NULL != h);
1337 GNUNET_assert (NULL != zone);
1338 GNUNET_assert (NULL != name);
1340 name_len = strlen (name) + 1;
1341 if ((name_len == 0) || (name_len > 256))
1348 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1351 qe->proc_cls = proc_cls;
1353 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1356 msg_size = sizeof (struct LookupNameMessage) + name_len;
1357 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1359 /* create msg here */
1360 struct LookupNameMessage * msg;
1361 pe->size = msg_size;
1362 pe->is_init = GNUNET_NO;
1363 msg = (struct LookupNameMessage *) &pe[1];
1364 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1365 msg->gns_header.header.size = htons (msg_size);
1366 msg->gns_header.r_id = htonl (rid);
1367 msg->record_type = htonl (record_type);
1368 msg->name_len = htonl (name_len);
1370 memcpy (&msg[1], name, name_len);
1372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1374 /* transmit message */
1375 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1383 * Look for an existing PKEY delegation record for a given public key.
1384 * Returns at most one result to the processor.
1386 * @param h handle to the namestore
1387 * @param zone hash of public key of the zone to look up in, never NULL
1388 * @param value_zone hash of the public key of the target zone (value), never NULL
1389 * @param proc function to call on the matching records, or with
1390 * NULL (rd_count == 0) if there are no matching records
1391 * @param proc_cls closure for proc
1392 * @return a handle that can be used to
1395 struct GNUNET_NAMESTORE_QueueEntry *
1396 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1397 const GNUNET_HashCode *zone,
1398 const GNUNET_HashCode *value_zone,
1399 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1401 struct GNUNET_NAMESTORE_QueueEntry *qe;
1402 struct PendingMessage *pe;
1403 size_t msg_size = 0;
1406 GNUNET_assert (NULL != h);
1407 GNUNET_assert (NULL != zone);
1408 GNUNET_assert (NULL != value_zone);
1411 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1414 qe->proc_cls = proc_cls;
1416 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1419 msg_size = sizeof (struct ZoneToNameMessage);
1420 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1422 /* create msg here */
1423 struct ZoneToNameMessage * msg;
1424 pe->size = msg_size;
1425 pe->is_init = GNUNET_NO;
1426 msg = (struct ZoneToNameMessage *) &pe[1];
1427 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1428 msg->gns_header.header.size = htons (msg_size);
1429 msg->gns_header.r_id = htonl (rid);
1431 msg->value_zone = *value_zone;
1433 char * z_tmp = strdup (GNUNET_h2s (zone));
1434 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1435 "NAMESTORE_ZONE_TO_NAME",
1437 GNUNET_h2s (value_zone));
1438 GNUNET_free (z_tmp);
1440 /* transmit message */
1441 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1450 * Starts a new zone iteration (used to periodically PUT all of our
1451 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1452 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1453 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1454 * immediately, and then again after
1455 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1457 * @param h handle to the namestore
1458 * @param zone zone to access, NULL for all zones
1459 * @param must_have_flags flags that must be set for the record to be returned
1460 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1461 * @param proc function to call on each name from the zone; it
1462 * will be called repeatedly with a value (if available)
1463 * and always once at the end with a name of NULL.
1464 * @param proc_cls closure for proc
1465 * @return an iterator handle to use for iteration
1467 struct GNUNET_NAMESTORE_ZoneIterator *
1468 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1469 const GNUNET_HashCode *zone,
1470 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1471 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1472 GNUNET_NAMESTORE_RecordProcessor proc,
1475 struct GNUNET_NAMESTORE_ZoneIterator *it;
1476 struct PendingMessage *pe;
1477 size_t msg_size = 0;
1480 GNUNET_assert (NULL != h);
1484 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1487 it->proc_cls = proc;
1493 it->has_zone = GNUNET_YES;
1497 memset (&it->zone, '\0', sizeof (it->zone));
1498 it->has_zone = GNUNET_NO;
1500 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1503 msg_size = sizeof (struct ZoneIterationStartMessage);
1504 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1506 /* create msg here */
1507 struct ZoneIterationStartMessage * msg;
1508 pe->size = msg_size;
1509 pe->is_init = GNUNET_NO;
1510 msg = (struct ZoneIterationStartMessage *) &pe[1];
1511 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1512 msg->gns_header.header.size = htons (msg_size);
1513 msg->gns_header.r_id = htonl (rid);
1517 memset (&msg->zone, '\0', sizeof (msg->zone));
1518 msg->must_have_flags = ntohs (must_have_flags);
1519 msg->must_not_have_flags = ntohs (must_not_have_flags);
1521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
1523 /* transmit message */
1524 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1532 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1533 * for the next record.
1535 * @param it the iterator
1538 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1540 struct GNUNET_NAMESTORE_Handle *h;
1541 struct PendingMessage *pe;
1542 size_t msg_size = 0;
1544 GNUNET_assert (NULL != it);
1548 msg_size = sizeof (struct ZoneIterationNextMessage);
1549 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1551 /* create msg here */
1552 struct ZoneIterationNextMessage * msg;
1553 pe->size = msg_size;
1554 pe->is_init = GNUNET_NO;
1555 msg = (struct ZoneIterationNextMessage *) &pe[1];
1556 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1557 msg->gns_header.header.size = htons (msg_size);
1558 msg->gns_header.r_id = htonl (it->op_id);
1560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_NEXT", GNUNET_h2s(&it->zone));
1562 /* transmit message */
1563 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1569 * Stops iteration and releases the namestore handle for further calls.
1571 * @param it the iterator
1574 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1576 GNUNET_assert (NULL != it);
1577 struct PendingMessage *pe;
1578 size_t msg_size = 0;
1579 struct GNUNET_NAMESTORE_Handle *h = it->h;
1582 msg_size = sizeof (struct ZoneIterationStopMessage);
1583 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1585 /* create msg here */
1586 struct ZoneIterationStopMessage * msg;
1587 pe->size = msg_size;
1588 pe->is_init = GNUNET_NO;
1589 msg = (struct ZoneIterationStopMessage *) &pe[1];
1590 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1591 msg->gns_header.header.size = htons (msg_size);
1592 msg->gns_header.r_id = htonl (it->op_id);
1594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
1596 /* transmit message */
1597 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1603 * Cancel a namestore operation. The final callback from the
1604 * operation must not have been done yet.
1606 * @param qe operation to cancel
1609 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1611 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1613 GNUNET_assert (qe != NULL);
1615 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1620 /* end of namestore_api.c */