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;
100 * Message in linked list we should send to the service. The
101 * actual binary message follows this struct.
103 struct PendingMessage
109 struct PendingMessage *next;
114 struct PendingMessage *prev;
117 * Size of the message.
122 * Is this the 'START' message?
129 * Connection to the NAMESTORE service.
131 struct GNUNET_NAMESTORE_Handle
135 * Configuration to use.
137 const struct GNUNET_CONFIGURATION_Handle *cfg;
140 * Socket (if available).
142 struct GNUNET_CLIENT_Connection *client;
145 * Currently pending transmission request (or NULL).
147 struct GNUNET_CLIENT_TransmitHandle *th;
152 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
155 * Pending messages to send to the service
158 struct PendingMessage * pending_head;
159 struct PendingMessage * pending_tail;
162 * Should we reconnect to service due to some serious error?
168 * Pending namestore queue entries
170 struct GNUNET_NAMESTORE_QueueEntry * op_head;
171 struct GNUNET_NAMESTORE_QueueEntry * op_tail;
176 * Pending namestore zone iterator entries
178 struct GNUNET_NAMESTORE_ZoneIterator * z_head;
179 struct GNUNET_NAMESTORE_ZoneIterator * z_tail;
182 struct GNUNET_NAMESTORE_SimpleRecord
187 struct GNUNET_NAMESTORE_SimpleRecord *next;
192 struct GNUNET_NAMESTORE_SimpleRecord *prev;
195 const GNUNET_HashCode *zone;
196 uint32_t record_type;
197 struct GNUNET_TIME_Absolute expiration;
198 enum GNUNET_NAMESTORE_RecordFlags flags;
206 * Convert a type name (i.e. "AAAA") to the corresponding number.
208 * @param typename name to convert
209 * @return corresponding number, UINT32_MAX on error
212 GNUNET_NAMESTORE_typename_to_number (const char *typename)
218 { "A", GNUNET_DNSPARSER_TYPE_A },
219 { "NS", GNUNET_DNSPARSER_TYPE_NS },
220 { "CNAME", GNUNET_DNSPARSER_TYPE_CNAME },
221 { "SOA", GNUNET_DNSPARSER_TYPE_SOA },
222 { "PTR", GNUNET_DNSPARSER_TYPE_PTR },
223 { "MX", GNUNET_DNSPARSER_TYPE_MX },
224 { "TXT", GNUNET_DNSPARSER_TYPE_TXT },
225 { "AAAA", GNUNET_DNSPARSER_TYPE_AAAA },
226 { "PKEY", GNUNET_NAMESTORE_TYPE_PKEY },
227 { "PSEU", GNUNET_NAMESTORE_TYPE_PSEU },
233 while ( (map[i].name != NULL) &&
234 (0 != strcasecmp (typename, map[i].name)) )
236 return map[i].number;
241 * Disconnect from service and then reconnect.
243 * @param h our handle
246 force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
249 handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
250 struct LookupNameResponseMessage * msg,
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
254 "LOOKUP_NAME_RESPONSE");
256 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
260 struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
261 struct GNUNET_TIME_Absolute expire;
262 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp;
267 int contains_sig = GNUNET_NO;
270 rd_len = ntohs (msg->rd_len);
271 rd_count = ntohs (msg->rd_count);
272 msg_len = ntohs (msg->gns_header.header.size);
273 name_len = ntohs (msg->name_len);
274 contains_sig = ntohs (msg->contains_sig);
275 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
277 exp_msg_len = sizeof (struct LookupNameResponseMessage) +
278 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
281 if (msg_len != exp_msg_len)
283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
284 msg_len, exp_msg_len);
289 name = (char *) &msg[1];
290 rd_tmp = &name[name_len];
292 /* deserialize records */
293 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
294 GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd);
296 /* reset values if values not contained */
297 if (contains_sig == GNUNET_NO)
300 signature = &msg->signature;
305 public_key_tmp = &msg->public_key;
307 public_key_tmp = NULL;
309 if (qe->proc != NULL)
311 qe->proc (qe->proc_cls, public_key_tmp, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature);
314 /* Operation done, remove */
315 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
321 handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
322 struct RecordPutResponseMessage* msg,
325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
326 "RECORD_PUT_RESPONSE");
327 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
328 int res = ntohl (msg->op_result);
330 if (res == GNUNET_OK)
332 if (qe->cont != NULL)
334 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
338 else if (res == GNUNET_SYSERR)
340 if (qe->cont != NULL)
342 qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
351 /* Operation done, remove */
352 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
359 handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
360 struct RecordCreateResponseMessage* msg,
363 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
364 "RECORD_CREATE_RESPONSE");
365 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
366 int res = ntohl (msg->op_result);
368 if (res == GNUNET_YES)
370 if (qe->cont != NULL)
372 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
376 else if (res == GNUNET_NO)
378 if (qe->cont != NULL)
380 qe->cont (qe->cont_cls, res, _("Namestore record already existed"));
385 if (qe->cont != NULL)
387 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Namestore failed to add record\n"));
391 /* Operation done, remove */
392 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
399 handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
400 struct RecordRemoveResponseMessage* msg,
403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
404 "RECORD_REMOVE_RESPONSE");
406 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
407 int res = ntohl (msg->op_result);
412 * 1 : No records for entry
413 * 2 : Could not find record to remove
414 * 3 : Failed to create new signature
415 * 4 : Failed to put new set of records in database
419 if (qe->cont != NULL)
421 qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
426 if (qe->cont != NULL)
428 qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
433 if (qe->cont != NULL)
435 qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
440 if (qe->cont != NULL)
442 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
447 if (qe->cont != NULL)
449 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
457 /* Operation done, remove */
458 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
464 handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
465 struct ZoneToNameResponseMessage* msg,
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
469 "ZONE_TO_NAME_RESPONSE");
471 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
472 int res = ntohs (msg->res);
474 struct GNUNET_TIME_Absolute expire;
477 unsigned int rd_count;
482 if (res == GNUNET_SYSERR)
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n");
485 if (qe->proc != NULL)
486 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
488 else if (res == GNUNET_NO)
490 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n");
491 if (qe->proc != NULL)
492 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
494 else if (res == GNUNET_YES)
496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has result for zone to name mapping \n");
498 name_len = ntohs (msg->name_len);
499 rd_count = ntohs (msg->rd_count);
500 rd_ser_len = ntohs (msg->rd_len);
501 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
503 name_tmp = (char *) &msg[1];
504 rd_tmp = &name_tmp[name_len];
506 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
507 GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd);
509 if (qe->proc != NULL)
510 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
515 /* Operation done, remove */
516 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
522 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
523 const struct GNUNET_MessageHeader *msg,
524 int type, size_t size)
527 /* handle different message type */
529 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
530 if (size < sizeof (struct LookupNameResponseMessage))
535 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
537 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
538 if (size != sizeof (struct RecordPutResponseMessage))
543 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
545 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
546 if (size != sizeof (struct RecordCreateResponseMessage))
551 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
553 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
554 if (size != sizeof (struct RecordRemoveResponseMessage))
559 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
561 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
562 if (size < sizeof (struct ZoneToNameResponseMessage))
567 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
576 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
577 struct ZoneIterationResponseMessage *msg,
580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
581 "ZONE_ITERATION_RESPONSE");
583 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
585 size_t exp_msg_len = 0;
588 unsigned rd_count = 0;
592 struct GNUNET_TIME_Absolute expire;
594 msg_len = ntohs (msg->gns_header.header.size);
595 rd_len = ntohs (msg->rd_len);
596 rd_count = ntohs (msg->rd_count);
597 name_len = ntohs (msg->name_len);
598 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
600 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
601 if (msg_len != exp_msg_len)
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
604 msg_len, exp_msg_len);
608 if (0 != ntohs (msg->reserved))
614 memset (&pubdummy, '\0', sizeof (pubdummy));
615 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
619 if (ze->proc != NULL)
620 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
622 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
627 name_tmp = (char *) &msg[1];
628 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
633 rd_ser_tmp = (char *) &name_tmp[name_len];
634 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
635 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
641 if (ze->proc != NULL)
642 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
647 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
648 const struct GNUNET_MessageHeader *msg,
649 int type, size_t size)
652 /* handle different message type */
654 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
655 if (size < sizeof (struct ZoneIterationResponseMessage))
660 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
669 * Type of a function to call when we receive a message
672 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
673 * @param msg message received, NULL on timeout or fatal error
676 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
678 struct GNUNET_NAMESTORE_Handle *h = cls;
679 struct GNUNET_NAMESTORE_Header * gm;
680 struct GNUNET_NAMESTORE_QueueEntry *qe;
681 struct GNUNET_NAMESTORE_ZoneIterator *ze;
684 uint32_t r_id = UINT32_MAX;
692 size = ntohs (msg->size);
693 type = ntohs (msg->type);
695 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
698 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
699 GNUNET_TIME_UNIT_FOREVER_REL);
703 gm = (struct GNUNET_NAMESTORE_Header *) msg;
704 r_id = ntohl (gm->r_id);
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
708 /* Find matching operation */
711 /* No matching pending operation found */
713 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
714 GNUNET_TIME_UNIT_FOREVER_REL);
718 /* Is it a record related operation ? */
719 for (qe = h->op_head; qe != NULL; qe = qe->next)
721 if (qe->op_id == r_id)
726 manage_record_operations (qe, msg, type, size);
729 /* Is it a zone iteration operation ? */
730 for (ze = h->z_head; ze != NULL; ze = ze->next)
732 if (ze->op_id == r_id)
737 manage_zone_operations (ze, msg, type, size);
740 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
741 GNUNET_TIME_UNIT_FOREVER_REL);
743 if (GNUNET_YES == h->reconnect)
750 * Transmit messages from the message queue to the service
751 * (if there are any, and if we are not already trying).
753 * @param h handle to use
756 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
760 * We can now transmit a message to NAMESTORE. Do it.
762 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
763 * @param size number of bytes we can transmit
764 * @param buf where to copy the messages
765 * @return number of bytes copied into buf
768 transmit_message_to_namestore (void *cls, size_t size, void *buf)
770 struct GNUNET_NAMESTORE_Handle *h = cls;
771 struct PendingMessage *p;
776 if ((size == 0) || (buf == NULL))
783 while ((NULL != (p = h->pending_head)) && (p->size <= size))
785 memcpy (&cbuf[ret], &p[1], p->size);
788 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
789 if (GNUNET_YES == p->is_init)
790 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
791 GNUNET_TIME_UNIT_FOREVER_REL);
800 * Transmit messages from the message queue to the service
801 * (if there are any, and if we are not already trying).
803 * @param h handle to use
806 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
808 struct PendingMessage *p;
812 if (NULL == (p = h->pending_head))
814 if (NULL == h->client)
815 return; /* currently reconnecting */
817 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
818 GNUNET_TIME_UNIT_FOREVER_REL,
819 GNUNET_NO, &transmit_message_to_namestore,
825 * Reconnect to namestore service.
827 * @param h the handle to the namestore service
830 reconnect (struct GNUNET_NAMESTORE_Handle *h)
832 struct PendingMessage *p;
833 struct StartMessage *init;
835 GNUNET_assert (NULL == h->client);
836 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
837 GNUNET_assert (NULL != h->client);
839 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
841 p = GNUNET_malloc (sizeof (struct PendingMessage) +
842 sizeof (struct StartMessage));
843 p->size = sizeof (struct StartMessage);
844 p->is_init = GNUNET_YES;
845 init = (struct StartMessage *) &p[1];
846 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
847 init->header.size = htons (sizeof (struct StartMessage));
848 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
854 * Re-establish the connection to the service.
856 * @param cls handle to use to re-connect.
857 * @param tc scheduler context
860 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
862 struct GNUNET_NAMESTORE_Handle *h = cls;
864 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
870 * Disconnect from service and then reconnect.
872 * @param h our handle
875 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
877 h->reconnect = GNUNET_NO;
878 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
880 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
886 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
888 uint32_t op_id = h->op_id;
894 * Initialize the connection with the NAMESTORE service.
896 * @param cfg configuration to use
897 * @return handle to the GNS service, or NULL on error
899 struct GNUNET_NAMESTORE_Handle *
900 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
902 struct GNUNET_NAMESTORE_Handle *h;
904 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
906 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
912 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
914 struct PendingMessage *p;
915 struct GNUNET_NAMESTORE_QueueEntry *q;
916 struct GNUNET_NAMESTORE_ZoneIterator *z;
917 struct GNUNET_NAMESTORE_Handle *h = cls;
918 GNUNET_assert (h != NULL);
919 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
920 while (NULL != (p = h->pending_head))
922 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
926 while (NULL != (q = h->op_head))
929 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
933 while (NULL != (z = h->z_head))
935 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
939 if (NULL != h->client)
941 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
944 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
946 GNUNET_SCHEDULER_cancel (h->reconnect_task);
947 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
954 * Disconnect from the namestore service (and free associated
957 * @param h handle to the namestore
958 * @param drop set to GNUNET_YES to delete all data in namestore (!)
961 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
963 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
964 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
969 * Store an item in the namestore. If the item is already present,
970 * the expiration time is updated to the max of the existing time and
971 * the new time. This API is used when we cache signatures from other
974 * @param h handle to the namestore
975 * @param zone_key public key of the zone
976 * @param name name that is being mapped (at most 255 characters long)
977 * @param expire when does the corresponding block in the DHT expire (until
978 * when should we never do a DHT lookup for the same name again)?
979 * @param rd_count number of entries in 'rd' array
980 * @param rd array of records with data to store
981 * @param signature signature for all the records in the zone under the given name
982 * @param cont continuation to call when done
983 * @param cont_cls closure for cont
984 * @return handle to abort the request
986 struct GNUNET_NAMESTORE_QueueEntry *
987 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
988 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
990 struct GNUNET_TIME_Absolute expire,
991 unsigned int rd_count,
992 const struct GNUNET_NAMESTORE_RecordData *rd,
993 const struct GNUNET_CRYPTO_RsaSignature *signature,
994 GNUNET_NAMESTORE_ContinuationWithStatus cont,
997 struct GNUNET_NAMESTORE_QueueEntry *qe;
998 struct PendingMessage *pe;
1000 /* pointer to elements */
1004 size_t msg_size = 0;
1005 size_t name_len = 0;
1006 size_t rd_ser_len = 0;
1009 GNUNET_assert (NULL != h);
1010 GNUNET_assert (NULL != zone_key);
1011 GNUNET_assert (NULL != name);
1012 GNUNET_assert (NULL != rd);
1013 GNUNET_assert (NULL != signature);
1015 name_len = strlen(name) + 1;
1023 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1026 qe->cont_cls = cont_cls;
1028 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1031 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1032 char rd_ser[rd_ser_len];
1033 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1035 struct RecordPutMessage * msg;
1036 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1038 /* create msg here */
1039 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1040 pe->size = msg_size;
1041 pe->is_init = GNUNET_NO;
1042 msg = (struct RecordPutMessage *) &pe[1];
1043 name_tmp = (char *) &msg[1];
1044 rd_tmp = &name_tmp[name_len];
1046 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1047 msg->gns_header.header.size = htons (msg_size);
1048 msg->gns_header.r_id = htonl (rid);
1049 msg->signature = *signature;
1050 msg->name_len = htons (name_len);
1051 msg->expire = GNUNET_TIME_absolute_hton (expire);
1052 msg->rd_len = htons (rd_ser_len);
1053 msg->rd_count = htons (rd_count);
1055 msg->public_key = *zone_key;
1056 memcpy (name_tmp, name, name_len);
1057 memcpy (rd_tmp, rd_ser, rd_ser_len);
1059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1061 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1069 * Check if a signature is valid. This API is used by the GNS Block
1070 * to validate signatures received from the network.
1072 * @param public_key public key of the zone
1073 * @param name name that is being mapped (at most 255 characters long)
1074 * @param rd_count number of entries in 'rd' array
1075 * @param rd array of records with data to store
1076 * @param signature signature for all the records in the zone under the given name
1077 * @return GNUNET_OK if the signature is valid
1080 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1082 unsigned int rd_count,
1083 const struct GNUNET_NAMESTORE_RecordData *rd,
1084 const struct GNUNET_CRYPTO_RsaSignature *signature)
1086 int res = GNUNET_SYSERR;
1087 size_t rd_ser_len = 0;
1088 size_t name_len = 0;
1091 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1093 GNUNET_assert (public_key != NULL);
1094 GNUNET_assert (name != NULL);
1095 GNUNET_assert (rd != NULL);
1096 GNUNET_assert (signature != NULL);
1099 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1100 char rd_ser[rd_ser_len];
1101 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1103 name_len = strlen (name) + 1;
1107 return GNUNET_SYSERR;
1110 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len + name_len);
1111 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1112 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1113 name_tmp = (char *) &sig_purpose[1];
1114 rd_tmp = &name_tmp[name_len];
1115 memcpy (name_tmp, name, name_len);
1116 memcpy (rd_tmp, rd_ser, rd_ser_len);
1118 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1120 GNUNET_free (sig_purpose);
1126 * Store an item in the namestore. If the item is already present,
1127 * the expiration time is updated to the max of the existing time and
1128 * the new time. This API is used by the authority of a zone.
1130 * @param h handle to the namestore
1131 * @param pkey private key of the zone
1132 * @param name name that is being mapped (at most 255 characters long)
1133 * @param rd record data to store
1134 * @param cont continuation to call when done
1135 * @param cont_cls closure for cont
1136 * @return handle to abort the request
1138 struct GNUNET_NAMESTORE_QueueEntry *
1139 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1140 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1142 const struct GNUNET_NAMESTORE_RecordData *rd,
1143 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1146 struct GNUNET_NAMESTORE_QueueEntry *qe;
1147 struct PendingMessage *pe;
1151 size_t rd_ser_len = 0;
1152 size_t msg_size = 0;
1153 size_t name_len = 0;
1157 GNUNET_assert (NULL != h);
1158 GNUNET_assert (NULL != pkey);
1159 GNUNET_assert (NULL != name);
1160 GNUNET_assert (NULL != rd);
1162 name_len = strlen(name) + 1;
1170 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1173 qe->cont_cls = cont_cls;
1175 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1178 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1179 GNUNET_assert (pkey_enc != NULL);
1180 key_len = ntohs (pkey_enc->len);
1182 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1183 char rd_ser[rd_ser_len];
1184 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1186 struct RecordCreateMessage * msg;
1187 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1189 /* create msg here */
1190 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1191 pe->size = msg_size;
1192 pe->is_init = GNUNET_NO;
1193 msg = (struct RecordCreateMessage *) &pe[1];
1195 pkey_tmp = (char *) &msg[1];
1196 name_tmp = &pkey_tmp[key_len];
1197 rd_tmp = &name_tmp[name_len];
1199 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1200 msg->gns_header.header.size = htons (msg_size);
1201 msg->gns_header.r_id = htonl (rid);
1202 msg->name_len = htons (name_len);
1203 msg->rd_count = htons (1);
1204 msg->rd_len = htons (rd_ser_len);
1205 msg->pkey_len = htons (key_len);
1206 memcpy (pkey_tmp, pkey_enc, key_len);
1207 memcpy (name_tmp, name, name_len);
1208 memcpy (rd_tmp, rd_ser, rd_ser_len);
1209 GNUNET_free (pkey_enc);
1211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1213 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1220 * Explicitly remove some content from the database. The
1221 * "cont"inuation will be called with status "GNUNET_OK" if content
1222 * was removed, "GNUNET_NO" if no matching entry was found and
1223 * "GNUNET_SYSERR" on all other types of errors.
1224 * This API is used by the authority of a zone.
1226 * @param h handle to the namestore
1227 * @param pkey private key of the zone
1228 * @param name name that is being mapped (at most 255 characters long)
1229 * @param rd record data
1230 * @param cont continuation to call when done
1231 * @param cont_cls closure for cont
1232 * @return handle to abort the request
1234 struct GNUNET_NAMESTORE_QueueEntry *
1235 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1236 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1238 const struct GNUNET_NAMESTORE_RecordData *rd,
1239 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1242 struct GNUNET_NAMESTORE_QueueEntry *qe;
1243 struct PendingMessage *pe;
1247 size_t rd_ser_len = 0;
1248 size_t msg_size = 0;
1249 size_t name_len = 0;
1253 GNUNET_assert (NULL != h);
1256 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1259 qe->cont_cls = cont_cls;
1261 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1264 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1265 GNUNET_assert (pkey_enc != NULL);
1266 key_len = ntohs (pkey_enc->len);
1268 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1269 char rd_ser[rd_ser_len];
1270 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1272 name_len = strlen (name) + 1;
1274 struct RecordRemoveMessage * msg;
1275 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1277 /* create msg here */
1278 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1279 pe->size = msg_size;
1280 pe->is_init = GNUNET_NO;
1281 msg = (struct RecordRemoveMessage *) &pe[1];
1283 pkey_tmp = (char *) &msg[1];
1284 name_tmp = &pkey_tmp[key_len];
1285 rd_tmp = &name_tmp[name_len];
1287 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1288 msg->gns_header.header.size = htons (msg_size);
1289 msg->gns_header.r_id = htonl (rid);
1290 msg->name_len = htons (name_len);
1291 msg->rd_len = htons (rd_ser_len);
1292 msg->rd_count = htons (1);
1293 msg->pkey_len = htons (key_len);
1294 memcpy (pkey_tmp, pkey_enc, key_len);
1295 memcpy (name_tmp, name, name_len);
1296 memcpy (rd_tmp, rd_ser, rd_ser_len);
1298 GNUNET_free (pkey_enc);
1300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1302 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1309 * Get a result for a particular key from the namestore. The processor
1310 * will only be called once.
1312 * @param h handle to the namestore
1313 * @param zone zone to look up a record from
1314 * @param name name to look up
1315 * @param record_type desired record type, 0 for all
1316 * @param proc function to call on the matching records, or with
1317 * NULL (rd_count == 0) if there are no matching records
1318 * @param proc_cls closure for proc
1319 * @return a handle that can be used to
1322 struct GNUNET_NAMESTORE_QueueEntry *
1323 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1324 const GNUNET_HashCode *zone,
1326 uint32_t record_type,
1327 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1329 struct GNUNET_NAMESTORE_QueueEntry *qe;
1330 struct PendingMessage *pe;
1331 size_t msg_size = 0;
1332 size_t name_len = 0;
1335 GNUNET_assert (NULL != h);
1336 GNUNET_assert (NULL != zone);
1337 GNUNET_assert (NULL != name);
1339 name_len = strlen (name) + 1;
1340 if ((name_len == 0) || (name_len > 256))
1347 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1350 qe->proc_cls = proc_cls;
1352 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1355 msg_size = sizeof (struct LookupNameMessage) + name_len;
1356 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1358 /* create msg here */
1359 struct LookupNameMessage * msg;
1360 pe->size = msg_size;
1361 pe->is_init = GNUNET_NO;
1362 msg = (struct LookupNameMessage *) &pe[1];
1363 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1364 msg->gns_header.header.size = htons (msg_size);
1365 msg->gns_header.r_id = htonl (rid);
1366 msg->record_type = htonl (record_type);
1367 msg->name_len = htonl (name_len);
1369 memcpy (&msg[1], name, name_len);
1371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1373 /* transmit message */
1374 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1382 * Look for an existing PKEY delegation record for a given public key.
1383 * Returns at most one result to the processor.
1385 * @param h handle to the namestore
1386 * @param zone hash of public key of the zone to look up in, never NULL
1387 * @param value_zone hash of the public key of the target zone (value), never NULL
1388 * @param proc function to call on the matching records, or with
1389 * NULL (rd_count == 0) if there are no matching records
1390 * @param proc_cls closure for proc
1391 * @return a handle that can be used to
1394 struct GNUNET_NAMESTORE_QueueEntry *
1395 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1396 const GNUNET_HashCode *zone,
1397 const GNUNET_HashCode *value_zone,
1398 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1400 struct GNUNET_NAMESTORE_QueueEntry *qe;
1401 struct PendingMessage *pe;
1402 size_t msg_size = 0;
1405 GNUNET_assert (NULL != h);
1406 GNUNET_assert (NULL != zone);
1407 GNUNET_assert (NULL != value_zone);
1410 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1413 qe->proc_cls = proc_cls;
1415 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1418 msg_size = sizeof (struct ZoneToNameMessage);
1419 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1421 /* create msg here */
1422 struct ZoneToNameMessage * msg;
1423 pe->size = msg_size;
1424 pe->is_init = GNUNET_NO;
1425 msg = (struct ZoneToNameMessage *) &pe[1];
1426 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1427 msg->gns_header.header.size = htons (msg_size);
1428 msg->gns_header.r_id = htonl (rid);
1430 msg->value_zone = *value_zone;
1432 char * z_tmp = strdup (GNUNET_h2s (zone));
1433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1434 "NAMESTORE_ZONE_TO_NAME",
1436 GNUNET_h2s (value_zone));
1437 GNUNET_free (z_tmp);
1439 /* transmit message */
1440 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1449 * Starts a new zone iteration (used to periodically PUT all of our
1450 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1451 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1452 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1453 * immediately, and then again after
1454 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1456 * @param h handle to the namestore
1457 * @param zone zone to access, NULL for all zones
1458 * @param must_have_flags flags that must be set for the record to be returned
1459 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1460 * @param proc function to call on each name from the zone; it
1461 * will be called repeatedly with a value (if available)
1462 * and always once at the end with a name of NULL.
1463 * @param proc_cls closure for proc
1464 * @return an iterator handle to use for iteration
1466 struct GNUNET_NAMESTORE_ZoneIterator *
1467 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1468 const GNUNET_HashCode *zone,
1469 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1470 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1471 GNUNET_NAMESTORE_RecordProcessor proc,
1474 struct GNUNET_NAMESTORE_ZoneIterator *it;
1475 struct PendingMessage *pe;
1476 size_t msg_size = 0;
1479 GNUNET_assert (NULL != h);
1483 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1486 it->proc_cls = proc;
1489 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1492 msg_size = sizeof (struct ZoneIterationStartMessage);
1493 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1495 /* create msg here */
1496 struct ZoneIterationStartMessage * msg;
1497 pe->size = msg_size;
1498 pe->is_init = GNUNET_NO;
1499 msg = (struct ZoneIterationStartMessage *) &pe[1];
1500 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1501 msg->gns_header.header.size = htons (msg_size);
1502 msg->gns_header.r_id = htonl (rid);
1506 memset (&msg->zone, '\0', sizeof (msg->zone));
1507 msg->must_have_flags = ntohs (must_have_flags);
1508 msg->must_not_have_flags = ntohs (must_not_have_flags);
1510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
1512 /* transmit message */
1513 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1521 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1522 * for the next record.
1524 * @param it the iterator
1527 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1529 struct GNUNET_NAMESTORE_Handle *h;
1530 struct PendingMessage *pe;
1531 size_t msg_size = 0;
1533 GNUNET_assert (NULL != it);
1537 msg_size = sizeof (struct ZoneIterationNextMessage);
1538 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1540 /* create msg here */
1541 struct ZoneIterationNextMessage * msg;
1542 pe->size = msg_size;
1543 pe->is_init = GNUNET_NO;
1544 msg = (struct ZoneIterationNextMessage *) &pe[1];
1545 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1546 msg->gns_header.header.size = htons (msg_size);
1547 msg->gns_header.r_id = htonl (it->op_id);
1549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_NEXT", GNUNET_h2s(&it->zone));
1551 /* transmit message */
1552 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1558 * Stops iteration and releases the namestore handle for further calls.
1560 * @param it the iterator
1563 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1565 GNUNET_assert (NULL != it);
1566 struct PendingMessage *pe;
1567 size_t msg_size = 0;
1568 struct GNUNET_NAMESTORE_Handle *h = it->h;
1571 msg_size = sizeof (struct ZoneIterationStopMessage);
1572 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1574 /* create msg here */
1575 struct ZoneIterationStopMessage * msg;
1576 pe->size = msg_size;
1577 pe->is_init = GNUNET_NO;
1578 msg = (struct ZoneIterationStopMessage *) &pe[1];
1579 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1580 msg->gns_header.header.size = htons (msg_size);
1581 msg->gns_header.r_id = htonl (it->op_id);
1583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
1585 /* transmit message */
1586 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1592 * Cancel a namestore operation. The final callback from the
1593 * operation must not have been done yet.
1595 * @param qe operation to cancel
1598 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1600 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1602 GNUNET_assert (qe != NULL);
1604 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1609 /* end of namestore_api.c */