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 GNUNET_assert ('\0' == name_tmp[name_len]);
481 rd_tmp = &name_tmp[name_len];
483 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
484 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd))
490 if (qe->proc != NULL)
491 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
501 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
502 const struct GNUNET_MessageHeader *msg,
503 int type, size_t size)
506 /* handle different message type */
508 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
509 if (size < sizeof (struct LookupNameResponseMessage))
514 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
516 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
517 if (size != sizeof (struct RecordPutResponseMessage))
522 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
524 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
525 if (size != sizeof (struct RecordCreateResponseMessage))
530 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
532 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
533 if (size != sizeof (struct RecordRemoveResponseMessage))
538 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
540 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
541 if (size < sizeof (struct ZoneToNameResponseMessage))
546 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
555 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
556 struct ZoneIterationResponseMessage *msg,
559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
560 "ZONE_ITERATION_RESPONSE");
562 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
564 size_t exp_msg_len = 0;
567 unsigned rd_count = 0;
571 struct GNUNET_TIME_Absolute expire;
573 msg_len = ntohs (msg->gns_header.header.size);
574 rd_len = ntohs (msg->rd_len);
575 rd_count = ntohs (msg->rd_count);
576 name_len = ntohs (msg->name_len);
577 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
579 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
580 if (msg_len != exp_msg_len)
582 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
583 msg_len, exp_msg_len);
587 if (0 != ntohs (msg->reserved))
593 memset (&pubdummy, '\0', sizeof (pubdummy));
594 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
598 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
600 if (ze->proc != NULL)
601 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
607 name_tmp = (char *) &msg[1];
608 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
613 rd_ser_tmp = (char *) &name_tmp[name_len];
614 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
615 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
621 if (ze->proc != NULL)
622 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
627 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
628 const struct GNUNET_MessageHeader *msg,
629 int type, size_t size)
632 /* handle different message type */
634 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
635 if (size < sizeof (struct ZoneIterationResponseMessage))
640 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
649 * Type of a function to call when we receive a message
652 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
653 * @param msg message received, NULL on timeout or fatal error
656 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
658 struct GNUNET_NAMESTORE_Handle *h = cls;
659 struct GNUNET_NAMESTORE_Header * gm;
660 struct GNUNET_NAMESTORE_QueueEntry *qe;
661 struct GNUNET_NAMESTORE_ZoneIterator *ze;
664 uint32_t r_id = UINT32_MAX;
672 size = ntohs (msg->size);
673 type = ntohs (msg->type);
675 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
678 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
679 GNUNET_TIME_UNIT_FOREVER_REL);
683 gm = (struct GNUNET_NAMESTORE_Header *) msg;
684 r_id = ntohl (gm->r_id);
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
688 /* Find matching operation */
691 /* No matching pending operation found */
693 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
694 GNUNET_TIME_UNIT_FOREVER_REL);
698 /* Is it a record related operation ? */
699 for (qe = h->op_head; qe != NULL; qe = qe->next)
701 if (qe->op_id == r_id)
706 manage_record_operations (qe, msg, type, size);
709 /* Is it a zone iteration operation ? */
710 for (ze = h->z_head; ze != NULL; ze = ze->next)
712 if (ze->op_id == r_id)
717 manage_zone_operations (ze, msg, type, size);
720 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
721 GNUNET_TIME_UNIT_FOREVER_REL);
723 if (GNUNET_YES == h->reconnect)
730 * Transmit messages from the message queue to the service
731 * (if there are any, and if we are not already trying).
733 * @param h handle to use
736 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
740 * We can now transmit a message to NAMESTORE. Do it.
742 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
743 * @param size number of bytes we can transmit
744 * @param buf where to copy the messages
745 * @return number of bytes copied into buf
748 transmit_message_to_namestore (void *cls, size_t size, void *buf)
750 struct GNUNET_NAMESTORE_Handle *h = cls;
751 struct PendingMessage *p;
756 if ((size == 0) || (buf == NULL))
763 while ((NULL != (p = h->pending_head)) && (p->size <= size))
765 memcpy (&cbuf[ret], &p[1], p->size);
768 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
769 if (GNUNET_YES == p->is_init)
770 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
771 GNUNET_TIME_UNIT_FOREVER_REL);
780 * Transmit messages from the message queue to the service
781 * (if there are any, and if we are not already trying).
783 * @param h handle to use
786 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
788 struct PendingMessage *p;
792 if (NULL == (p = h->pending_head))
794 if (NULL == h->client)
795 return; /* currently reconnecting */
797 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
798 GNUNET_TIME_UNIT_FOREVER_REL,
799 GNUNET_NO, &transmit_message_to_namestore,
805 * Reconnect to namestore service.
807 * @param h the handle to the namestore service
810 reconnect (struct GNUNET_NAMESTORE_Handle *h)
812 struct PendingMessage *p;
813 struct StartMessage *init;
815 GNUNET_assert (NULL == h->client);
816 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
817 GNUNET_assert (NULL != h->client);
819 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
821 p = GNUNET_malloc (sizeof (struct PendingMessage) +
822 sizeof (struct StartMessage));
823 p->size = sizeof (struct StartMessage);
824 p->is_init = GNUNET_YES;
825 init = (struct StartMessage *) &p[1];
826 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
827 init->header.size = htons (sizeof (struct StartMessage));
828 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
834 * Re-establish the connection to the service.
836 * @param cls handle to use to re-connect.
837 * @param tc scheduler context
840 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
842 struct GNUNET_NAMESTORE_Handle *h = cls;
844 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
850 * Disconnect from service and then reconnect.
852 * @param h our handle
855 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
857 h->reconnect = GNUNET_NO;
858 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
860 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
866 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
868 uint32_t op_id = h->op_id;
874 * Initialize the connection with the NAMESTORE service.
876 * @param cfg configuration to use
877 * @return handle to the GNS service, or NULL on error
879 struct GNUNET_NAMESTORE_Handle *
880 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
882 struct GNUNET_NAMESTORE_Handle *h;
884 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
886 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
892 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
894 struct PendingMessage *p;
895 struct GNUNET_NAMESTORE_QueueEntry *q;
896 struct GNUNET_NAMESTORE_ZoneIterator *z;
897 struct GNUNET_NAMESTORE_Handle *h = cls;
898 GNUNET_assert (h != NULL);
899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
900 while (NULL != (p = h->pending_head))
902 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
906 while (NULL != (q = h->op_head))
908 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
912 while (NULL != (z = h->z_head))
914 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
918 if (NULL != h->client)
920 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
923 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
925 GNUNET_SCHEDULER_cancel (h->reconnect_task);
926 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
933 * Disconnect from the namestore service (and free associated
936 * @param h handle to the namestore
937 * @param drop set to GNUNET_YES to delete all data in namestore (!)
940 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
943 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
948 * Store an item in the namestore. If the item is already present,
949 * the expiration time is updated to the max of the existing time and
950 * the new time. This API is used when we cache signatures from other
953 * @param h handle to the namestore
954 * @param zone_key public key of the zone
955 * @param name name that is being mapped (at most 255 characters long)
956 * @param expire when does the corresponding block in the DHT expire (until
957 * when should we never do a DHT lookup for the same name again)?
958 * @param rd_count number of entries in 'rd' array
959 * @param rd array of records with data to store
960 * @param signature signature for all the records in the zone under the given name
961 * @param cont continuation to call when done
962 * @param cont_cls closure for cont
963 * @return handle to abort the request
965 struct GNUNET_NAMESTORE_QueueEntry *
966 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
967 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
969 struct GNUNET_TIME_Absolute expire,
970 unsigned int rd_count,
971 const struct GNUNET_NAMESTORE_RecordData *rd,
972 const struct GNUNET_CRYPTO_RsaSignature *signature,
973 GNUNET_NAMESTORE_ContinuationWithStatus cont,
976 struct GNUNET_NAMESTORE_QueueEntry *qe;
977 struct PendingMessage *pe;
979 /* pointer to elements */
985 size_t rd_ser_len = 0;
988 GNUNET_assert (NULL != h);
989 GNUNET_assert (NULL != zone_key);
990 GNUNET_assert (NULL != name);
991 GNUNET_assert (NULL != rd);
992 GNUNET_assert (NULL != signature);
994 name_len = strlen(name) + 1;
1002 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1005 qe->cont_cls = cont_cls;
1007 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1010 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1011 char rd_ser[rd_ser_len];
1012 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1014 struct RecordPutMessage * msg;
1015 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1017 /* create msg here */
1018 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1019 pe->size = msg_size;
1020 pe->is_init = GNUNET_NO;
1021 msg = (struct RecordPutMessage *) &pe[1];
1022 name_tmp = (char *) &msg[1];
1023 rd_tmp = &name_tmp[name_len];
1025 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1026 msg->gns_header.header.size = htons (msg_size);
1027 msg->gns_header.r_id = htonl (rid);
1028 msg->signature = *signature;
1029 msg->name_len = htons (name_len);
1030 msg->expire = GNUNET_TIME_absolute_hton (expire);
1031 msg->rd_len = htons (rd_ser_len);
1032 msg->rd_count = htons (rd_count);
1034 msg->public_key = *zone_key;
1035 memcpy (name_tmp, name, name_len);
1036 memcpy (rd_tmp, rd_ser, rd_ser_len);
1038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1040 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1048 * Check if a signature is valid. This API is used by the GNS Block
1049 * to validate signatures received from the network.
1051 * @param public_key public key of the zone
1052 * @param expire block expiration
1053 * @param name name that is being mapped (at most 255 characters long)
1054 * @param rd_count number of entries in 'rd' array
1055 * @param rd array of records with data to store
1056 * @param signature signature for all the records in the zone under the given name
1057 * @return GNUNET_OK if the signature is valid
1060 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1061 const struct GNUNET_TIME_Absolute expire,
1063 unsigned int rd_count,
1064 const struct GNUNET_NAMESTORE_RecordData *rd,
1065 const struct GNUNET_CRYPTO_RsaSignature *signature)
1067 int res = GNUNET_SYSERR;
1068 size_t rd_ser_len = 0;
1069 size_t name_len = 0;
1072 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1073 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
1074 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
1076 GNUNET_assert (public_key != NULL);
1077 GNUNET_assert (name != NULL);
1078 GNUNET_assert (rd != NULL);
1079 GNUNET_assert (signature != NULL);
1082 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1083 char rd_ser[rd_ser_len];
1084 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1086 name_len = strlen (name) + 1;
1090 return GNUNET_SYSERR;
1093 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
1094 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1095 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1096 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
1097 name_tmp = (char *) &expire_tmp[1];
1098 rd_tmp = &name_tmp[name_len];
1099 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
1100 memcpy (name_tmp, name, name_len);
1101 memcpy (rd_tmp, rd_ser, rd_ser_len);
1103 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1105 GNUNET_free (sig_purpose);
1111 * Store an item in the namestore. If the item is already present,
1112 * the expiration time is updated to the max of the existing time and
1113 * the new time. This API is used by the authority of a zone.
1115 * @param h handle to the namestore
1116 * @param pkey private key of the zone
1117 * @param expire block expiration time
1118 * @param name name that is being mapped (at most 255 characters long)
1119 * @param rd record data to store
1120 * @param cont continuation to call when done
1121 * @param cont_cls closure for cont
1122 * @return handle to abort the request
1124 struct GNUNET_NAMESTORE_QueueEntry *
1125 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1126 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1128 const struct GNUNET_NAMESTORE_RecordData *rd,
1129 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1132 struct GNUNET_NAMESTORE_QueueEntry *qe;
1133 struct PendingMessage *pe;
1137 size_t rd_ser_len = 0;
1138 size_t msg_size = 0;
1139 size_t name_len = 0;
1143 GNUNET_assert (NULL != h);
1144 GNUNET_assert (NULL != pkey);
1145 GNUNET_assert (NULL != name);
1146 GNUNET_assert (NULL != rd);
1148 name_len = strlen(name) + 1;
1156 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1159 qe->cont_cls = cont_cls;
1161 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1164 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1165 GNUNET_assert (pkey_enc != NULL);
1166 key_len = ntohs (pkey_enc->len);
1168 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1169 char rd_ser[rd_ser_len];
1170 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1172 struct RecordCreateMessage * msg;
1173 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1175 /* create msg here */
1176 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1177 pe->size = msg_size;
1178 pe->is_init = GNUNET_NO;
1179 msg = (struct RecordCreateMessage *) &pe[1];
1181 pkey_tmp = (char *) &msg[1];
1182 name_tmp = &pkey_tmp[key_len];
1183 rd_tmp = &name_tmp[name_len];
1185 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1186 msg->gns_header.header.size = htons (msg_size);
1187 msg->gns_header.r_id = htonl (rid);
1188 msg->name_len = htons (name_len);
1189 msg->rd_count = htons (1);
1190 msg->rd_len = htons (rd_ser_len);
1191 msg->pkey_len = htons (key_len);
1192 msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever());
1193 memcpy (pkey_tmp, pkey_enc, key_len);
1194 memcpy (name_tmp, name, name_len);
1195 memcpy (rd_tmp, rd_ser, rd_ser_len);
1196 GNUNET_free (pkey_enc);
1198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1200 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1207 * Explicitly remove some content from the database. The
1208 * "cont"inuation will be called with status "GNUNET_OK" if content
1209 * was removed, "GNUNET_NO" if no matching entry was found and
1210 * "GNUNET_SYSERR" on all other types of errors.
1211 * This API is used by the authority of a zone.
1213 * @param h handle to the namestore
1214 * @param pkey private key of the zone
1215 * @param name name that is being mapped (at most 255 characters long)
1216 * @param rd record data
1217 * @param cont continuation to call when done
1218 * @param cont_cls closure for cont
1219 * @return handle to abort the request
1221 struct GNUNET_NAMESTORE_QueueEntry *
1222 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1223 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1225 const struct GNUNET_NAMESTORE_RecordData *rd,
1226 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1229 struct GNUNET_NAMESTORE_QueueEntry *qe;
1230 struct PendingMessage *pe;
1234 size_t rd_ser_len = 0;
1235 size_t msg_size = 0;
1236 size_t name_len = 0;
1240 GNUNET_assert (NULL != h);
1243 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1246 qe->cont_cls = cont_cls;
1248 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1251 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1252 GNUNET_assert (pkey_enc != NULL);
1253 key_len = ntohs (pkey_enc->len);
1255 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1256 char rd_ser[rd_ser_len];
1257 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1259 name_len = strlen (name) + 1;
1261 struct RecordRemoveMessage * msg;
1262 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1264 /* create msg here */
1265 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1266 pe->size = msg_size;
1267 pe->is_init = GNUNET_NO;
1268 msg = (struct RecordRemoveMessage *) &pe[1];
1270 pkey_tmp = (char *) &msg[1];
1271 name_tmp = &pkey_tmp[key_len];
1272 rd_tmp = &name_tmp[name_len];
1274 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1275 msg->gns_header.header.size = htons (msg_size);
1276 msg->gns_header.r_id = htonl (rid);
1277 msg->name_len = htons (name_len);
1278 msg->rd_len = htons (rd_ser_len);
1279 msg->rd_count = htons (1);
1280 msg->pkey_len = htons (key_len);
1281 memcpy (pkey_tmp, pkey_enc, key_len);
1282 memcpy (name_tmp, name, name_len);
1283 memcpy (rd_tmp, rd_ser, rd_ser_len);
1285 GNUNET_free (pkey_enc);
1287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1289 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1296 * Get a result for a particular key from the namestore. The processor
1297 * will only be called once.
1299 * @param h handle to the namestore
1300 * @param zone zone to look up a record from
1301 * @param name name to look up
1302 * @param record_type desired record type, 0 for all
1303 * @param proc function to call on the matching records, or with
1304 * NULL (rd_count == 0) if there are no matching records
1305 * @param proc_cls closure for proc
1306 * @return a handle that can be used to
1309 struct GNUNET_NAMESTORE_QueueEntry *
1310 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1311 const GNUNET_HashCode *zone,
1313 uint32_t record_type,
1314 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1316 struct GNUNET_NAMESTORE_QueueEntry *qe;
1317 struct PendingMessage *pe;
1318 size_t msg_size = 0;
1319 size_t name_len = 0;
1322 GNUNET_assert (NULL != h);
1323 GNUNET_assert (NULL != zone);
1324 GNUNET_assert (NULL != name);
1326 name_len = strlen (name) + 1;
1327 if ((name_len == 0) || (name_len > 256))
1334 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1337 qe->proc_cls = proc_cls;
1339 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1342 msg_size = sizeof (struct LookupNameMessage) + name_len;
1343 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1345 /* create msg here */
1346 struct LookupNameMessage * msg;
1347 pe->size = msg_size;
1348 pe->is_init = GNUNET_NO;
1349 msg = (struct LookupNameMessage *) &pe[1];
1350 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1351 msg->gns_header.header.size = htons (msg_size);
1352 msg->gns_header.r_id = htonl (rid);
1353 msg->record_type = htonl (record_type);
1354 msg->name_len = htonl (name_len);
1356 memcpy (&msg[1], name, name_len);
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1360 /* transmit message */
1361 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1369 * Look for an existing PKEY delegation record for a given public key.
1370 * Returns at most one result to the processor.
1372 * @param h handle to the namestore
1373 * @param zone hash of public key of the zone to look up in, never NULL
1374 * @param value_zone hash of the public key of the target zone (value), never NULL
1375 * @param proc function to call on the matching records, or with
1376 * NULL (rd_count == 0) if there are no matching records
1377 * @param proc_cls closure for proc
1378 * @return a handle that can be used to
1381 struct GNUNET_NAMESTORE_QueueEntry *
1382 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1383 const GNUNET_HashCode *zone,
1384 const GNUNET_HashCode *value_zone,
1385 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1387 struct GNUNET_NAMESTORE_QueueEntry *qe;
1388 struct PendingMessage *pe;
1389 size_t msg_size = 0;
1392 GNUNET_assert (NULL != h);
1393 GNUNET_assert (NULL != zone);
1394 GNUNET_assert (NULL != value_zone);
1397 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1400 qe->proc_cls = proc_cls;
1402 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1405 msg_size = sizeof (struct ZoneToNameMessage);
1406 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1408 /* create msg here */
1409 struct ZoneToNameMessage * msg;
1410 pe->size = msg_size;
1411 pe->is_init = GNUNET_NO;
1412 msg = (struct ZoneToNameMessage *) &pe[1];
1413 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1414 msg->gns_header.header.size = htons (msg_size);
1415 msg->gns_header.r_id = htonl (rid);
1417 msg->value_zone = *value_zone;
1419 char * z_tmp = strdup (GNUNET_h2s (zone));
1420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1421 "NAMESTORE_ZONE_TO_NAME",
1423 GNUNET_h2s (value_zone));
1424 GNUNET_free (z_tmp);
1426 /* transmit message */
1427 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1436 * Starts a new zone iteration (used to periodically PUT all of our
1437 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1438 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1439 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1440 * immediately, and then again after
1441 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1443 * @param h handle to the namestore
1444 * @param zone zone to access, NULL for all zones
1445 * @param must_have_flags flags that must be set for the record to be returned
1446 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1447 * @param proc function to call on each name from the zone; it
1448 * will be called repeatedly with a value (if available)
1449 * and always once at the end with a name of NULL.
1450 * @param proc_cls closure for proc
1451 * @return an iterator handle to use for iteration
1453 struct GNUNET_NAMESTORE_ZoneIterator *
1454 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1455 const GNUNET_HashCode *zone,
1456 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1457 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1458 GNUNET_NAMESTORE_RecordProcessor proc,
1461 struct GNUNET_NAMESTORE_ZoneIterator *it;
1462 struct PendingMessage *pe;
1463 size_t msg_size = 0;
1466 GNUNET_assert (NULL != h);
1470 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1473 it->proc_cls = proc;
1479 it->has_zone = GNUNET_YES;
1483 memset (&it->zone, '\0', sizeof (it->zone));
1484 it->has_zone = GNUNET_NO;
1486 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1489 msg_size = sizeof (struct ZoneIterationStartMessage);
1490 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1492 /* create msg here */
1493 struct ZoneIterationStartMessage * msg;
1494 pe->size = msg_size;
1495 pe->is_init = GNUNET_NO;
1496 msg = (struct ZoneIterationStartMessage *) &pe[1];
1497 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1498 msg->gns_header.header.size = htons (msg_size);
1499 msg->gns_header.r_id = htonl (rid);
1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
1507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_START");
1508 memset (&msg->zone, '\0', sizeof (msg->zone));
1510 msg->must_have_flags = ntohs (must_have_flags);
1511 msg->must_not_have_flags = ntohs (must_not_have_flags);
1515 /* transmit message */
1516 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1524 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1525 * for the next record.
1527 * @param it the iterator
1530 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1532 struct GNUNET_NAMESTORE_Handle *h;
1533 struct PendingMessage *pe;
1534 size_t msg_size = 0;
1536 GNUNET_assert (NULL != it);
1540 msg_size = sizeof (struct ZoneIterationNextMessage);
1541 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1543 /* create msg here */
1544 struct ZoneIterationNextMessage * msg;
1545 pe->size = msg_size;
1546 pe->is_init = GNUNET_NO;
1547 msg = (struct ZoneIterationNextMessage *) &pe[1];
1548 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1549 msg->gns_header.header.size = htons (msg_size);
1550 msg->gns_header.r_id = htonl (it->op_id);
1552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT");
1554 /* transmit message */
1555 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1561 * Stops iteration and releases the namestore handle for further calls.
1563 * @param it the iterator
1566 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1568 GNUNET_assert (NULL != it);
1569 struct PendingMessage *pe;
1570 size_t msg_size = 0;
1571 struct GNUNET_NAMESTORE_Handle *h = it->h;
1574 msg_size = sizeof (struct ZoneIterationStopMessage);
1575 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1577 /* create msg here */
1578 struct ZoneIterationStopMessage * msg;
1579 pe->size = msg_size;
1580 pe->is_init = GNUNET_NO;
1581 msg = (struct ZoneIterationStopMessage *) &pe[1];
1582 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1583 msg->gns_header.header.size = htons (msg_size);
1584 msg->gns_header.r_id = htonl (it->op_id);
1586 if (GNUNET_YES == it->has_zone)
1587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
1589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
1591 /* transmit message */
1592 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1598 * Cancel a namestore operation. The final callback from the
1599 * operation must not have been done yet.
1601 * @param qe operation to cancel
1604 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1606 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1608 GNUNET_assert (qe != NULL);
1610 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1615 /* end of namestore_api.c */