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 * Disconnect from service and then reconnect.
209 * @param h our handle
212 force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
215 handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
216 struct LookupNameResponseMessage * msg,
219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
220 "LOOKUP_NAME_RESPONSE");
222 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
224 /* Operation done, remove */
225 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
231 struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
232 struct GNUNET_TIME_Absolute expire;
233 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp;
238 int contains_sig = GNUNET_NO;
241 rd_len = ntohs (msg->rd_len);
242 rd_count = ntohs (msg->rd_count);
243 msg_len = ntohs (msg->gns_header.header.size);
244 name_len = ntohs (msg->name_len);
245 contains_sig = ntohs (msg->contains_sig);
246 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
248 exp_msg_len = sizeof (struct LookupNameResponseMessage) +
249 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
252 if (msg_len != exp_msg_len)
254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
255 msg_len, exp_msg_len);
260 name = (char *) &msg[1];
261 rd_tmp = &name[name_len];
263 /* deserialize records */
264 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
265 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd))
272 /* reset values if values not contained */
273 if (contains_sig == GNUNET_NO)
276 signature = &msg->signature;
281 public_key_tmp = &msg->public_key;
283 public_key_tmp = NULL;
285 if (qe->proc != NULL)
287 qe->proc (qe->proc_cls, public_key_tmp, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature);
294 handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
295 struct RecordPutResponseMessage* msg,
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
299 "RECORD_PUT_RESPONSE");
301 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
302 /* Operation done, remove */
303 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
305 int res = ntohl (msg->op_result);
307 if (res == GNUNET_OK)
309 if (qe->cont != NULL)
311 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
315 else if (res == GNUNET_SYSERR)
317 if (qe->cont != NULL)
319 qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
333 handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
334 struct RecordCreateResponseMessage* msg,
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
338 "RECORD_CREATE_RESPONSE");
340 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
341 /* Operation done, remove */
342 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
344 int res = ntohl (msg->op_result);
345 if (res == GNUNET_YES)
347 if (qe->cont != NULL)
349 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
353 else if (res == GNUNET_NO)
355 if (qe->cont != NULL)
357 qe->cont (qe->cont_cls, res, _("Namestore record already existed"));
362 if (qe->cont != NULL)
364 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Namestore failed to add record\n"));
373 handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
374 struct RecordRemoveResponseMessage* msg,
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
378 "RECORD_REMOVE_RESPONSE");
380 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
381 /* Operation done, remove */
382 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
384 int res = ntohl (msg->op_result);
388 * 1 : No records for entry
389 * 2 : Could not find record to remove
390 * 3 : Failed to create new signature
391 * 4 : Failed to put new set of records in database
395 if (qe->cont != NULL)
397 qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
402 if (qe->cont != NULL)
404 qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
409 if (qe->cont != NULL)
411 qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
416 if (qe->cont != NULL)
418 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
423 if (qe->cont != NULL)
425 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
437 handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
438 struct ZoneToNameResponseMessage* msg,
441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
442 "ZONE_TO_NAME_RESPONSE");
444 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
445 /* Operation done, remove */
446 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
448 int res = ntohs (msg->res);
450 struct GNUNET_TIME_Absolute expire;
453 unsigned int rd_count;
458 if (res == GNUNET_SYSERR)
460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n");
461 if (qe->proc != NULL)
462 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
464 else if (res == GNUNET_NO)
466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n");
467 if (qe->proc != NULL)
468 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
470 else if (res == GNUNET_YES)
472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has result for zone to name mapping \n");
474 name_len = ntohs (msg->name_len);
475 rd_count = ntohs (msg->rd_count);
476 rd_ser_len = ntohs (msg->rd_len);
477 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
479 name_tmp = (char *) &msg[1];
480 rd_tmp = &name_tmp[name_len];
482 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
483 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd))
489 if (qe->proc != NULL)
490 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
500 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
501 const struct GNUNET_MessageHeader *msg,
502 int type, size_t size)
505 /* handle different message type */
507 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
508 if (size < sizeof (struct LookupNameResponseMessage))
513 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
515 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
516 if (size != sizeof (struct RecordPutResponseMessage))
521 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
523 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
524 if (size != sizeof (struct RecordCreateResponseMessage))
529 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
531 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
532 if (size != sizeof (struct RecordRemoveResponseMessage))
537 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
539 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
540 if (size < sizeof (struct ZoneToNameResponseMessage))
545 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
554 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
555 struct ZoneIterationResponseMessage *msg,
558 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
559 "ZONE_ITERATION_RESPONSE");
561 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
563 size_t exp_msg_len = 0;
566 unsigned rd_count = 0;
570 struct GNUNET_TIME_Absolute expire;
572 msg_len = ntohs (msg->gns_header.header.size);
573 rd_len = ntohs (msg->rd_len);
574 rd_count = ntohs (msg->rd_count);
575 name_len = ntohs (msg->name_len);
576 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
578 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
579 if (msg_len != exp_msg_len)
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
582 msg_len, exp_msg_len);
586 if (0 != ntohs (msg->reserved))
592 memset (&pubdummy, '\0', sizeof (pubdummy));
593 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
597 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
599 if (ze->proc != NULL)
600 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
606 name_tmp = (char *) &msg[1];
607 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
612 rd_ser_tmp = (char *) &name_tmp[name_len];
613 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
614 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
620 if (ze->proc != NULL)
621 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
626 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
627 const struct GNUNET_MessageHeader *msg,
628 int type, size_t size)
631 /* handle different message type */
633 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
634 if (size < sizeof (struct ZoneIterationResponseMessage))
639 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
648 * Type of a function to call when we receive a message
651 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
652 * @param msg message received, NULL on timeout or fatal error
655 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
657 struct GNUNET_NAMESTORE_Handle *h = cls;
658 struct GNUNET_NAMESTORE_Header * gm;
659 struct GNUNET_NAMESTORE_QueueEntry *qe;
660 struct GNUNET_NAMESTORE_ZoneIterator *ze;
663 uint32_t r_id = UINT32_MAX;
671 size = ntohs (msg->size);
672 type = ntohs (msg->type);
674 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
677 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
678 GNUNET_TIME_UNIT_FOREVER_REL);
682 gm = (struct GNUNET_NAMESTORE_Header *) msg;
683 r_id = ntohl (gm->r_id);
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
687 /* Find matching operation */
690 /* No matching pending operation found */
692 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
693 GNUNET_TIME_UNIT_FOREVER_REL);
697 /* Is it a record related operation ? */
698 for (qe = h->op_head; qe != NULL; qe = qe->next)
700 if (qe->op_id == r_id)
705 manage_record_operations (qe, msg, type, size);
708 /* Is it a zone iteration operation ? */
709 for (ze = h->z_head; ze != NULL; ze = ze->next)
711 if (ze->op_id == r_id)
716 manage_zone_operations (ze, msg, type, size);
719 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
720 GNUNET_TIME_UNIT_FOREVER_REL);
722 if (GNUNET_YES == h->reconnect)
729 * Transmit messages from the message queue to the service
730 * (if there are any, and if we are not already trying).
732 * @param h handle to use
735 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
739 * We can now transmit a message to NAMESTORE. Do it.
741 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
742 * @param size number of bytes we can transmit
743 * @param buf where to copy the messages
744 * @return number of bytes copied into buf
747 transmit_message_to_namestore (void *cls, size_t size, void *buf)
749 struct GNUNET_NAMESTORE_Handle *h = cls;
750 struct PendingMessage *p;
755 if ((size == 0) || (buf == NULL))
762 while ((NULL != (p = h->pending_head)) && (p->size <= size))
764 memcpy (&cbuf[ret], &p[1], p->size);
767 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
768 if (GNUNET_YES == p->is_init)
769 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
770 GNUNET_TIME_UNIT_FOREVER_REL);
779 * Transmit messages from the message queue to the service
780 * (if there are any, and if we are not already trying).
782 * @param h handle to use
785 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
787 struct PendingMessage *p;
791 if (NULL == (p = h->pending_head))
793 if (NULL == h->client)
794 return; /* currently reconnecting */
796 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
797 GNUNET_TIME_UNIT_FOREVER_REL,
798 GNUNET_NO, &transmit_message_to_namestore,
804 * Reconnect to namestore service.
806 * @param h the handle to the namestore service
809 reconnect (struct GNUNET_NAMESTORE_Handle *h)
811 struct PendingMessage *p;
812 struct StartMessage *init;
814 GNUNET_assert (NULL == h->client);
815 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
816 GNUNET_assert (NULL != h->client);
818 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
820 p = GNUNET_malloc (sizeof (struct PendingMessage) +
821 sizeof (struct StartMessage));
822 p->size = sizeof (struct StartMessage);
823 p->is_init = GNUNET_YES;
824 init = (struct StartMessage *) &p[1];
825 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
826 init->header.size = htons (sizeof (struct StartMessage));
827 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
833 * Re-establish the connection to the service.
835 * @param cls handle to use to re-connect.
836 * @param tc scheduler context
839 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
841 struct GNUNET_NAMESTORE_Handle *h = cls;
843 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
849 * Disconnect from service and then reconnect.
851 * @param h our handle
854 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
856 h->reconnect = GNUNET_NO;
857 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
859 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
865 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
867 uint32_t op_id = h->op_id;
873 * Initialize the connection with the NAMESTORE service.
875 * @param cfg configuration to use
876 * @return handle to the GNS service, or NULL on error
878 struct GNUNET_NAMESTORE_Handle *
879 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
881 struct GNUNET_NAMESTORE_Handle *h;
883 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
885 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
891 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
893 struct PendingMessage *p;
894 struct GNUNET_NAMESTORE_QueueEntry *q;
895 struct GNUNET_NAMESTORE_ZoneIterator *z;
896 struct GNUNET_NAMESTORE_Handle *h = cls;
897 GNUNET_assert (h != NULL);
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
899 while (NULL != (p = h->pending_head))
901 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
905 while (NULL != (q = h->op_head))
907 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
911 while (NULL != (z = h->z_head))
913 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
917 if (NULL != h->client)
919 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
922 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
924 GNUNET_SCHEDULER_cancel (h->reconnect_task);
925 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
932 * Disconnect from the namestore service (and free associated
935 * @param h handle to the namestore
936 * @param drop set to GNUNET_YES to delete all data in namestore (!)
939 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
941 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
942 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
947 * Store an item in the namestore. If the item is already present,
948 * the expiration time is updated to the max of the existing time and
949 * the new time. This API is used when we cache signatures from other
952 * @param h handle to the namestore
953 * @param zone_key public key of the zone
954 * @param name name that is being mapped (at most 255 characters long)
955 * @param expire when does the corresponding block in the DHT expire (until
956 * when should we never do a DHT lookup for the same name again)?
957 * @param rd_count number of entries in 'rd' array
958 * @param rd array of records with data to store
959 * @param signature signature for all the records in the zone under the given name
960 * @param cont continuation to call when done
961 * @param cont_cls closure for cont
962 * @return handle to abort the request
964 struct GNUNET_NAMESTORE_QueueEntry *
965 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
966 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
968 struct GNUNET_TIME_Absolute expire,
969 unsigned int rd_count,
970 const struct GNUNET_NAMESTORE_RecordData *rd,
971 const struct GNUNET_CRYPTO_RsaSignature *signature,
972 GNUNET_NAMESTORE_ContinuationWithStatus cont,
975 struct GNUNET_NAMESTORE_QueueEntry *qe;
976 struct PendingMessage *pe;
978 /* pointer to elements */
984 size_t rd_ser_len = 0;
987 GNUNET_assert (NULL != h);
988 GNUNET_assert (NULL != zone_key);
989 GNUNET_assert (NULL != name);
990 GNUNET_assert (NULL != rd);
991 GNUNET_assert (NULL != signature);
993 name_len = strlen(name) + 1;
1001 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1004 qe->cont_cls = cont_cls;
1006 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1009 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1010 char rd_ser[rd_ser_len];
1011 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1013 struct RecordPutMessage * msg;
1014 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1016 /* create msg here */
1017 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1018 pe->size = msg_size;
1019 pe->is_init = GNUNET_NO;
1020 msg = (struct RecordPutMessage *) &pe[1];
1021 name_tmp = (char *) &msg[1];
1022 rd_tmp = &name_tmp[name_len];
1024 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1025 msg->gns_header.header.size = htons (msg_size);
1026 msg->gns_header.r_id = htonl (rid);
1027 msg->signature = *signature;
1028 msg->name_len = htons (name_len);
1029 msg->expire = GNUNET_TIME_absolute_hton (expire);
1030 msg->rd_len = htons (rd_ser_len);
1031 msg->rd_count = htons (rd_count);
1033 msg->public_key = *zone_key;
1034 memcpy (name_tmp, name, name_len);
1035 memcpy (rd_tmp, rd_ser, rd_ser_len);
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1039 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1047 * Check if a signature is valid. This API is used by the GNS Block
1048 * to validate signatures received from the network.
1050 * @param public_key public key of the zone
1051 * @param expire block expiration
1052 * @param name name that is being mapped (at most 255 characters long)
1053 * @param rd_count number of entries in 'rd' array
1054 * @param rd array of records with data to store
1055 * @param signature signature for all the records in the zone under the given name
1056 * @return GNUNET_OK if the signature is valid
1059 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1060 const struct GNUNET_TIME_Absolute expire,
1062 unsigned int rd_count,
1063 const struct GNUNET_NAMESTORE_RecordData *rd,
1064 const struct GNUNET_CRYPTO_RsaSignature *signature)
1066 int res = GNUNET_SYSERR;
1067 size_t rd_ser_len = 0;
1068 size_t name_len = 0;
1071 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1072 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
1073 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
1075 GNUNET_assert (public_key != NULL);
1076 GNUNET_assert (name != NULL);
1077 GNUNET_assert (rd != NULL);
1078 GNUNET_assert (signature != NULL);
1081 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1082 char rd_ser[rd_ser_len];
1083 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1085 name_len = strlen (name) + 1;
1089 return GNUNET_SYSERR;
1092 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
1093 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1094 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1095 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
1096 name_tmp = (char *) &expire_tmp[1];
1097 rd_tmp = &name_tmp[name_len];
1098 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
1099 memcpy (name_tmp, name, name_len);
1100 memcpy (rd_tmp, rd_ser, rd_ser_len);
1102 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1104 GNUNET_free (sig_purpose);
1110 * Store an item in the namestore. If the item is already present,
1111 * the expiration time is updated to the max of the existing time and
1112 * the new time. This API is used by the authority of a zone.
1114 * @param h handle to the namestore
1115 * @param pkey private key of the zone
1116 * @param expire block expiration time
1117 * @param name name that is being mapped (at most 255 characters long)
1118 * @param rd record data to store
1119 * @param cont continuation to call when done
1120 * @param cont_cls closure for cont
1121 * @return handle to abort the request
1123 struct GNUNET_NAMESTORE_QueueEntry *
1124 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1125 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1127 const struct GNUNET_NAMESTORE_RecordData *rd,
1128 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1131 struct GNUNET_NAMESTORE_QueueEntry *qe;
1132 struct PendingMessage *pe;
1136 size_t rd_ser_len = 0;
1137 size_t msg_size = 0;
1138 size_t name_len = 0;
1142 GNUNET_assert (NULL != h);
1143 GNUNET_assert (NULL != pkey);
1144 GNUNET_assert (NULL != name);
1145 GNUNET_assert (NULL != rd);
1147 name_len = strlen(name) + 1;
1155 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1158 qe->cont_cls = cont_cls;
1160 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1163 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1164 GNUNET_assert (pkey_enc != NULL);
1165 key_len = ntohs (pkey_enc->len);
1167 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1168 char rd_ser[rd_ser_len];
1169 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1171 struct RecordCreateMessage * msg;
1172 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1174 /* create msg here */
1175 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1176 pe->size = msg_size;
1177 pe->is_init = GNUNET_NO;
1178 msg = (struct RecordCreateMessage *) &pe[1];
1180 pkey_tmp = (char *) &msg[1];
1181 name_tmp = &pkey_tmp[key_len];
1182 rd_tmp = &name_tmp[name_len];
1184 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1185 msg->gns_header.header.size = htons (msg_size);
1186 msg->gns_header.r_id = htonl (rid);
1187 msg->name_len = htons (name_len);
1188 msg->rd_count = htons (1);
1189 msg->rd_len = htons (rd_ser_len);
1190 msg->pkey_len = htons (key_len);
1191 msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever());
1192 memcpy (pkey_tmp, pkey_enc, key_len);
1193 memcpy (name_tmp, name, name_len);
1194 memcpy (rd_tmp, rd_ser, rd_ser_len);
1195 GNUNET_free (pkey_enc);
1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1199 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1206 * Explicitly remove some content from the database. The
1207 * "cont"inuation will be called with status "GNUNET_OK" if content
1208 * was removed, "GNUNET_NO" if no matching entry was found and
1209 * "GNUNET_SYSERR" on all other types of errors.
1210 * This API is used by the authority of a zone.
1212 * @param h handle to the namestore
1213 * @param pkey private key of the zone
1214 * @param name name that is being mapped (at most 255 characters long)
1215 * @param rd record data
1216 * @param cont continuation to call when done
1217 * @param cont_cls closure for cont
1218 * @return handle to abort the request
1220 struct GNUNET_NAMESTORE_QueueEntry *
1221 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1222 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1224 const struct GNUNET_NAMESTORE_RecordData *rd,
1225 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1228 struct GNUNET_NAMESTORE_QueueEntry *qe;
1229 struct PendingMessage *pe;
1233 size_t rd_ser_len = 0;
1234 size_t msg_size = 0;
1235 size_t name_len = 0;
1239 GNUNET_assert (NULL != h);
1242 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1245 qe->cont_cls = cont_cls;
1247 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1250 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1251 GNUNET_assert (pkey_enc != NULL);
1252 key_len = ntohs (pkey_enc->len);
1254 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1255 char rd_ser[rd_ser_len];
1256 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1258 name_len = strlen (name) + 1;
1260 struct RecordRemoveMessage * msg;
1261 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1263 /* create msg here */
1264 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1265 pe->size = msg_size;
1266 pe->is_init = GNUNET_NO;
1267 msg = (struct RecordRemoveMessage *) &pe[1];
1269 pkey_tmp = (char *) &msg[1];
1270 name_tmp = &pkey_tmp[key_len];
1271 rd_tmp = &name_tmp[name_len];
1273 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1274 msg->gns_header.header.size = htons (msg_size);
1275 msg->gns_header.r_id = htonl (rid);
1276 msg->name_len = htons (name_len);
1277 msg->rd_len = htons (rd_ser_len);
1278 msg->rd_count = htons (1);
1279 msg->pkey_len = htons (key_len);
1280 memcpy (pkey_tmp, pkey_enc, key_len);
1281 memcpy (name_tmp, name, name_len);
1282 memcpy (rd_tmp, rd_ser, rd_ser_len);
1284 GNUNET_free (pkey_enc);
1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1288 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1295 * Get a result for a particular key from the namestore. The processor
1296 * will only be called once.
1298 * @param h handle to the namestore
1299 * @param zone zone to look up a record from
1300 * @param name name to look up
1301 * @param record_type desired record type, 0 for all
1302 * @param proc function to call on the matching records, or with
1303 * NULL (rd_count == 0) if there are no matching records
1304 * @param proc_cls closure for proc
1305 * @return a handle that can be used to
1308 struct GNUNET_NAMESTORE_QueueEntry *
1309 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1310 const GNUNET_HashCode *zone,
1312 uint32_t record_type,
1313 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1315 struct GNUNET_NAMESTORE_QueueEntry *qe;
1316 struct PendingMessage *pe;
1317 size_t msg_size = 0;
1318 size_t name_len = 0;
1321 GNUNET_assert (NULL != h);
1322 GNUNET_assert (NULL != zone);
1323 GNUNET_assert (NULL != name);
1325 name_len = strlen (name) + 1;
1326 if ((name_len == 0) || (name_len > 256))
1333 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1336 qe->proc_cls = proc_cls;
1338 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1341 msg_size = sizeof (struct LookupNameMessage) + name_len;
1342 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1344 /* create msg here */
1345 struct LookupNameMessage * msg;
1346 pe->size = msg_size;
1347 pe->is_init = GNUNET_NO;
1348 msg = (struct LookupNameMessage *) &pe[1];
1349 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1350 msg->gns_header.header.size = htons (msg_size);
1351 msg->gns_header.r_id = htonl (rid);
1352 msg->record_type = htonl (record_type);
1353 msg->name_len = htonl (name_len);
1355 memcpy (&msg[1], name, name_len);
1357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1359 /* transmit message */
1360 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1368 * Look for an existing PKEY delegation record for a given public key.
1369 * Returns at most one result to the processor.
1371 * @param h handle to the namestore
1372 * @param zone hash of public key of the zone to look up in, never NULL
1373 * @param value_zone hash of the public key of the target zone (value), never NULL
1374 * @param proc function to call on the matching records, or with
1375 * NULL (rd_count == 0) if there are no matching records
1376 * @param proc_cls closure for proc
1377 * @return a handle that can be used to
1380 struct GNUNET_NAMESTORE_QueueEntry *
1381 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1382 const GNUNET_HashCode *zone,
1383 const GNUNET_HashCode *value_zone,
1384 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1386 struct GNUNET_NAMESTORE_QueueEntry *qe;
1387 struct PendingMessage *pe;
1388 size_t msg_size = 0;
1391 GNUNET_assert (NULL != h);
1392 GNUNET_assert (NULL != zone);
1393 GNUNET_assert (NULL != value_zone);
1396 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1399 qe->proc_cls = proc_cls;
1401 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1404 msg_size = sizeof (struct ZoneToNameMessage);
1405 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1407 /* create msg here */
1408 struct ZoneToNameMessage * msg;
1409 pe->size = msg_size;
1410 pe->is_init = GNUNET_NO;
1411 msg = (struct ZoneToNameMessage *) &pe[1];
1412 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1413 msg->gns_header.header.size = htons (msg_size);
1414 msg->gns_header.r_id = htonl (rid);
1416 msg->value_zone = *value_zone;
1418 char * z_tmp = strdup (GNUNET_h2s (zone));
1419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1420 "NAMESTORE_ZONE_TO_NAME",
1422 GNUNET_h2s (value_zone));
1423 GNUNET_free (z_tmp);
1425 /* transmit message */
1426 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1435 * Starts a new zone iteration (used to periodically PUT all of our
1436 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1437 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1438 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1439 * immediately, and then again after
1440 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1442 * @param h handle to the namestore
1443 * @param zone zone to access, NULL for all zones
1444 * @param must_have_flags flags that must be set for the record to be returned
1445 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1446 * @param proc function to call on each name from the zone; it
1447 * will be called repeatedly with a value (if available)
1448 * and always once at the end with a name of NULL.
1449 * @param proc_cls closure for proc
1450 * @return an iterator handle to use for iteration
1452 struct GNUNET_NAMESTORE_ZoneIterator *
1453 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1454 const GNUNET_HashCode *zone,
1455 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1456 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1457 GNUNET_NAMESTORE_RecordProcessor proc,
1460 struct GNUNET_NAMESTORE_ZoneIterator *it;
1461 struct PendingMessage *pe;
1462 size_t msg_size = 0;
1465 GNUNET_assert (NULL != h);
1469 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1472 it->proc_cls = proc;
1478 it->has_zone = GNUNET_YES;
1482 memset (&it->zone, '\0', sizeof (it->zone));
1483 it->has_zone = GNUNET_NO;
1485 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1488 msg_size = sizeof (struct ZoneIterationStartMessage);
1489 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1491 /* create msg here */
1492 struct ZoneIterationStartMessage * msg;
1493 pe->size = msg_size;
1494 pe->is_init = GNUNET_NO;
1495 msg = (struct ZoneIterationStartMessage *) &pe[1];
1496 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1497 msg->gns_header.header.size = htons (msg_size);
1498 msg->gns_header.r_id = htonl (rid);
1501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
1506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_START");
1507 memset (&msg->zone, '\0', sizeof (msg->zone));
1509 msg->must_have_flags = ntohs (must_have_flags);
1510 msg->must_not_have_flags = ntohs (must_not_have_flags);
1514 /* transmit message */
1515 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1523 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1524 * for the next record.
1526 * @param it the iterator
1529 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1531 struct GNUNET_NAMESTORE_Handle *h;
1532 struct PendingMessage *pe;
1533 size_t msg_size = 0;
1535 GNUNET_assert (NULL != it);
1539 msg_size = sizeof (struct ZoneIterationNextMessage);
1540 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1542 /* create msg here */
1543 struct ZoneIterationNextMessage * msg;
1544 pe->size = msg_size;
1545 pe->is_init = GNUNET_NO;
1546 msg = (struct ZoneIterationNextMessage *) &pe[1];
1547 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1548 msg->gns_header.header.size = htons (msg_size);
1549 msg->gns_header.r_id = htonl (it->op_id);
1551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT");
1553 /* transmit message */
1554 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1560 * Stops iteration and releases the namestore handle for further calls.
1562 * @param it the iterator
1565 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1567 GNUNET_assert (NULL != it);
1568 struct PendingMessage *pe;
1569 size_t msg_size = 0;
1570 struct GNUNET_NAMESTORE_Handle *h = it->h;
1573 msg_size = sizeof (struct ZoneIterationStopMessage);
1574 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1576 /* create msg here */
1577 struct ZoneIterationStopMessage * msg;
1578 pe->size = msg_size;
1579 pe->is_init = GNUNET_NO;
1580 msg = (struct ZoneIterationStopMessage *) &pe[1];
1581 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1582 msg->gns_header.header.size = htons (msg_size);
1583 msg->gns_header.r_id = htonl (it->op_id);
1585 if (GNUNET_YES == it->has_zone)
1586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
1588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
1590 /* transmit message */
1591 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1597 * Cancel a namestore operation. The final callback from the
1598 * operation must not have been done yet.
1600 * @param qe operation to cancel
1603 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1605 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1607 GNUNET_assert (qe != NULL);
1609 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1614 /* end of namestore_api.c */