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];
263 GNUNET_assert ('\0' == name[name_len -1]);
264 GNUNET_assert ((name_len - 1) == strlen(name));
266 rd_tmp = &name[name_len];
268 /* deserialize records */
269 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
270 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd))
277 /* reset values if values not contained */
278 if (contains_sig == GNUNET_NO)
281 signature = &msg->signature;
286 public_key_tmp = &msg->public_key;
288 public_key_tmp = NULL;
290 if (qe->proc != NULL)
292 qe->proc (qe->proc_cls, public_key_tmp, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature);
299 handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
300 struct RecordPutResponseMessage* msg,
303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
304 "RECORD_PUT_RESPONSE");
306 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
307 /* Operation done, remove */
308 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
310 int res = ntohl (msg->op_result);
312 if (res == GNUNET_OK)
314 if (qe->cont != NULL)
316 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
320 else if (res == GNUNET_SYSERR)
322 if (qe->cont != NULL)
324 qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
338 handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
339 struct RecordCreateResponseMessage* msg,
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
343 "RECORD_CREATE_RESPONSE");
345 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
346 /* Operation done, remove */
347 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
349 int res = ntohl (msg->op_result);
350 if (res == GNUNET_YES)
352 if (qe->cont != NULL)
354 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
358 else if (res == GNUNET_NO)
360 if (qe->cont != NULL)
362 qe->cont (qe->cont_cls, res, _("Namestore record already existed"));
367 if (qe->cont != NULL)
369 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Namestore failed to add record\n"));
378 handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
379 struct RecordRemoveResponseMessage* msg,
382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
383 "RECORD_REMOVE_RESPONSE");
385 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
386 /* Operation done, remove */
387 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
389 int res = ntohl (msg->op_result);
393 * 1 : No records for entry
394 * 2 : Could not find record to remove
395 * 3 : Failed to create new signature
396 * 4 : Failed to put new set of records in database
400 if (qe->cont != NULL)
402 qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
407 if (qe->cont != NULL)
409 qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
414 if (qe->cont != NULL)
416 qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
421 if (qe->cont != NULL)
423 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
428 if (qe->cont != NULL)
430 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
442 handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
443 struct ZoneToNameResponseMessage* msg,
446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
447 "ZONE_TO_NAME_RESPONSE");
449 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
450 /* Operation done, remove */
451 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
453 int res = ntohs (msg->res);
455 struct GNUNET_TIME_Absolute expire;
458 unsigned int rd_count;
463 if (res == GNUNET_SYSERR)
465 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n");
466 if (qe->proc != NULL)
467 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
469 else if (res == GNUNET_NO)
471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n");
472 if (qe->proc != NULL)
473 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
475 else if (res == GNUNET_YES)
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has result for zone to name mapping \n");
479 name_len = ntohs (msg->name_len);
480 rd_count = ntohs (msg->rd_count);
481 rd_ser_len = ntohs (msg->rd_len);
482 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
484 name_tmp = (char *) &msg[1];
487 GNUNET_assert ('\0' == name_tmp[name_len -1]);
488 GNUNET_assert (name_len -1 == strlen(name_tmp));
490 rd_tmp = &name_tmp[name_len];
492 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
493 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd))
499 if (qe->proc != NULL)
500 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
510 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
511 const struct GNUNET_MessageHeader *msg,
512 int type, size_t size)
515 /* handle different message type */
517 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
518 if (size < sizeof (struct LookupNameResponseMessage))
523 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
525 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
526 if (size != sizeof (struct RecordPutResponseMessage))
531 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
533 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
534 if (size != sizeof (struct RecordCreateResponseMessage))
539 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
541 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
542 if (size != sizeof (struct RecordRemoveResponseMessage))
547 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
549 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
550 if (size < sizeof (struct ZoneToNameResponseMessage))
555 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
564 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
565 struct ZoneIterationResponseMessage *msg,
568 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
569 "ZONE_ITERATION_RESPONSE");
571 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
573 size_t exp_msg_len = 0;
576 unsigned rd_count = 0;
580 struct GNUNET_TIME_Absolute expire;
582 msg_len = ntohs (msg->gns_header.header.size);
583 rd_len = ntohs (msg->rd_len);
584 rd_count = ntohs (msg->rd_count);
585 name_len = ntohs (msg->name_len);
586 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
588 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
589 if (msg_len != exp_msg_len)
591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
592 msg_len, exp_msg_len);
596 if (0 != ntohs (msg->reserved))
602 memset (&pubdummy, '\0', sizeof (pubdummy));
603 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
605 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
607 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
609 if (ze->proc != NULL)
610 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
616 name_tmp = (char *) &msg[1];
617 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
622 rd_ser_tmp = (char *) &name_tmp[name_len];
623 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
624 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
630 if (ze->proc != NULL)
631 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
636 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
637 const struct GNUNET_MessageHeader *msg,
638 int type, size_t size)
641 /* handle different message type */
643 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
644 if (size < sizeof (struct ZoneIterationResponseMessage))
649 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
658 * Type of a function to call when we receive a message
661 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
662 * @param msg message received, NULL on timeout or fatal error
665 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
667 struct GNUNET_NAMESTORE_Handle *h = cls;
668 struct GNUNET_NAMESTORE_Header * gm;
669 struct GNUNET_NAMESTORE_QueueEntry *qe;
670 struct GNUNET_NAMESTORE_ZoneIterator *ze;
673 uint32_t r_id = UINT32_MAX;
681 size = ntohs (msg->size);
682 type = ntohs (msg->type);
684 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
687 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
688 GNUNET_TIME_UNIT_FOREVER_REL);
692 gm = (struct GNUNET_NAMESTORE_Header *) msg;
693 r_id = ntohl (gm->r_id);
695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
697 /* Find matching operation */
700 /* No matching pending operation found */
702 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
703 GNUNET_TIME_UNIT_FOREVER_REL);
707 /* Is it a record related operation ? */
708 for (qe = h->op_head; qe != NULL; qe = qe->next)
710 if (qe->op_id == r_id)
715 manage_record_operations (qe, msg, type, size);
718 /* Is it a zone iteration operation ? */
719 for (ze = h->z_head; ze != NULL; ze = ze->next)
721 if (ze->op_id == r_id)
726 manage_zone_operations (ze, msg, type, size);
729 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
730 GNUNET_TIME_UNIT_FOREVER_REL);
732 if (GNUNET_YES == h->reconnect)
739 * Transmit messages from the message queue to the service
740 * (if there are any, and if we are not already trying).
742 * @param h handle to use
745 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
749 * We can now transmit a message to NAMESTORE. Do it.
751 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
752 * @param size number of bytes we can transmit
753 * @param buf where to copy the messages
754 * @return number of bytes copied into buf
757 transmit_message_to_namestore (void *cls, size_t size, void *buf)
759 struct GNUNET_NAMESTORE_Handle *h = cls;
760 struct PendingMessage *p;
765 if ((size == 0) || (buf == NULL))
772 while ((NULL != (p = h->pending_head)) && (p->size <= size))
774 memcpy (&cbuf[ret], &p[1], p->size);
777 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
778 if (GNUNET_YES == p->is_init)
779 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
780 GNUNET_TIME_UNIT_FOREVER_REL);
789 * Transmit messages from the message queue to the service
790 * (if there are any, and if we are not already trying).
792 * @param h handle to use
795 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
797 struct PendingMessage *p;
801 if (NULL == (p = h->pending_head))
803 if (NULL == h->client)
804 return; /* currently reconnecting */
806 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
807 GNUNET_TIME_UNIT_FOREVER_REL,
808 GNUNET_NO, &transmit_message_to_namestore,
814 * Reconnect to namestore service.
816 * @param h the handle to the namestore service
819 reconnect (struct GNUNET_NAMESTORE_Handle *h)
821 struct PendingMessage *p;
822 struct StartMessage *init;
824 GNUNET_assert (NULL == h->client);
825 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
826 GNUNET_assert (NULL != h->client);
828 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
830 p = GNUNET_malloc (sizeof (struct PendingMessage) +
831 sizeof (struct StartMessage));
832 p->size = sizeof (struct StartMessage);
833 p->is_init = GNUNET_YES;
834 init = (struct StartMessage *) &p[1];
835 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
836 init->header.size = htons (sizeof (struct StartMessage));
837 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
843 * Re-establish the connection to the service.
845 * @param cls handle to use to re-connect.
846 * @param tc scheduler context
849 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
851 struct GNUNET_NAMESTORE_Handle *h = cls;
853 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
859 * Disconnect from service and then reconnect.
861 * @param h our handle
864 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
866 h->reconnect = GNUNET_NO;
867 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
869 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
875 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
877 uint32_t op_id = h->op_id;
883 * Initialize the connection with the NAMESTORE service.
885 * @param cfg configuration to use
886 * @return handle to the GNS service, or NULL on error
888 struct GNUNET_NAMESTORE_Handle *
889 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
891 struct GNUNET_NAMESTORE_Handle *h;
893 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
895 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
901 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
903 struct PendingMessage *p;
904 struct GNUNET_NAMESTORE_QueueEntry *q;
905 struct GNUNET_NAMESTORE_ZoneIterator *z;
906 struct GNUNET_NAMESTORE_Handle *h = cls;
907 GNUNET_assert (h != NULL);
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
909 while (NULL != (p = h->pending_head))
911 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
915 while (NULL != (q = h->op_head))
917 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
921 while (NULL != (z = h->z_head))
923 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
927 if (NULL != h->client)
929 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
932 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
934 GNUNET_SCHEDULER_cancel (h->reconnect_task);
935 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
942 * Disconnect from the namestore service (and free associated
945 * @param h handle to the namestore
946 * @param drop set to GNUNET_YES to delete all data in namestore (!)
949 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
952 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
957 * Store an item in the namestore. If the item is already present,
958 * the expiration time is updated to the max of the existing time and
959 * the new time. This API is used when we cache signatures from other
962 * @param h handle to the namestore
963 * @param zone_key public key of the zone
964 * @param name name that is being mapped (at most 255 characters long)
965 * @param expire when does the corresponding block in the DHT expire (until
966 * when should we never do a DHT lookup for the same name again)?
967 * @param rd_count number of entries in 'rd' array
968 * @param rd array of records with data to store
969 * @param signature signature for all the records in the zone under the given name
970 * @param cont continuation to call when done
971 * @param cont_cls closure for cont
972 * @return handle to abort the request
974 struct GNUNET_NAMESTORE_QueueEntry *
975 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
976 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
978 struct GNUNET_TIME_Absolute expire,
979 unsigned int rd_count,
980 const struct GNUNET_NAMESTORE_RecordData *rd,
981 const struct GNUNET_CRYPTO_RsaSignature *signature,
982 GNUNET_NAMESTORE_ContinuationWithStatus cont,
985 struct GNUNET_NAMESTORE_QueueEntry *qe;
986 struct PendingMessage *pe;
988 /* pointer to elements */
994 size_t rd_ser_len = 0;
997 GNUNET_assert (NULL != h);
998 GNUNET_assert (NULL != zone_key);
999 GNUNET_assert (NULL != name);
1000 GNUNET_assert (NULL != rd);
1001 GNUNET_assert (NULL != signature);
1003 name_len = strlen(name) + 1;
1011 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1014 qe->cont_cls = cont_cls;
1016 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1019 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1020 char rd_ser[rd_ser_len];
1021 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1023 struct RecordPutMessage * msg;
1024 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1026 /* create msg here */
1027 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1028 pe->size = msg_size;
1029 pe->is_init = GNUNET_NO;
1030 msg = (struct RecordPutMessage *) &pe[1];
1031 name_tmp = (char *) &msg[1];
1032 rd_tmp = &name_tmp[name_len];
1034 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1035 msg->gns_header.header.size = htons (msg_size);
1036 msg->gns_header.r_id = htonl (rid);
1037 msg->signature = *signature;
1038 msg->name_len = htons (name_len);
1039 msg->expire = GNUNET_TIME_absolute_hton (expire);
1040 msg->rd_len = htons (rd_ser_len);
1041 msg->rd_count = htons (rd_count);
1043 msg->public_key = *zone_key;
1044 memcpy (name_tmp, name, name_len);
1045 memcpy (rd_tmp, rd_ser, rd_ser_len);
1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1049 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1057 * Check if a signature is valid. This API is used by the GNS Block
1058 * to validate signatures received from the network.
1060 * @param public_key public key of the zone
1061 * @param expire block expiration
1062 * @param name name that is being mapped (at most 255 characters long)
1063 * @param rd_count number of entries in 'rd' array
1064 * @param rd array of records with data to store
1065 * @param signature signature for all the records in the zone under the given name
1066 * @return GNUNET_OK if the signature is valid
1069 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1070 const struct GNUNET_TIME_Absolute expire,
1072 unsigned int rd_count,
1073 const struct GNUNET_NAMESTORE_RecordData *rd,
1074 const struct GNUNET_CRYPTO_RsaSignature *signature)
1076 int res = GNUNET_SYSERR;
1077 size_t rd_ser_len = 0;
1078 size_t name_len = 0;
1081 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1082 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
1083 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
1085 GNUNET_assert (public_key != NULL);
1086 GNUNET_assert (name != NULL);
1087 GNUNET_assert (rd != NULL);
1088 GNUNET_assert (signature != NULL);
1091 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1092 char rd_ser[rd_ser_len];
1093 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1095 name_len = strlen (name) + 1;
1099 return GNUNET_SYSERR;
1102 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
1103 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1104 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1105 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
1106 name_tmp = (char *) &expire_tmp[1];
1107 rd_tmp = &name_tmp[name_len];
1108 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
1109 memcpy (name_tmp, name, name_len);
1110 memcpy (rd_tmp, rd_ser, rd_ser_len);
1112 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1114 GNUNET_free (sig_purpose);
1120 * Store an item in the namestore. If the item is already present,
1121 * the expiration time is updated to the max of the existing time and
1122 * the new time. This API is used by the authority of a zone.
1124 * @param h handle to the namestore
1125 * @param pkey private key of the zone
1126 * @param expire block expiration time
1127 * @param name name that is being mapped (at most 255 characters long)
1128 * @param rd record data to store
1129 * @param cont continuation to call when done
1130 * @param cont_cls closure for cont
1131 * @return handle to abort the request
1133 struct GNUNET_NAMESTORE_QueueEntry *
1134 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1135 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1137 const struct GNUNET_NAMESTORE_RecordData *rd,
1138 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1141 struct GNUNET_NAMESTORE_QueueEntry *qe;
1142 struct PendingMessage *pe;
1146 size_t rd_ser_len = 0;
1147 size_t msg_size = 0;
1148 size_t name_len = 0;
1152 GNUNET_assert (NULL != h);
1153 GNUNET_assert (NULL != pkey);
1154 GNUNET_assert (NULL != name);
1155 GNUNET_assert (NULL != rd);
1157 name_len = strlen(name) + 1;
1165 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1168 qe->cont_cls = cont_cls;
1170 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1173 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1174 GNUNET_assert (pkey_enc != NULL);
1175 key_len = ntohs (pkey_enc->len);
1177 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1178 char rd_ser[rd_ser_len];
1179 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1181 struct RecordCreateMessage * msg;
1182 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1184 /* create msg here */
1185 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1186 pe->size = msg_size;
1187 pe->is_init = GNUNET_NO;
1188 msg = (struct RecordCreateMessage *) &pe[1];
1190 pkey_tmp = (char *) &msg[1];
1191 name_tmp = &pkey_tmp[key_len];
1192 rd_tmp = &name_tmp[name_len];
1194 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1195 msg->gns_header.header.size = htons (msg_size);
1196 msg->gns_header.r_id = htonl (rid);
1197 msg->name_len = htons (name_len);
1198 msg->rd_count = htons (1);
1199 msg->rd_len = htons (rd_ser_len);
1200 msg->pkey_len = htons (key_len);
1201 msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever());
1202 memcpy (pkey_tmp, pkey_enc, key_len);
1203 memcpy (name_tmp, name, name_len);
1204 memcpy (rd_tmp, rd_ser, rd_ser_len);
1205 GNUNET_free (pkey_enc);
1207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1209 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1216 * Explicitly remove some content from the database. The
1217 * "cont"inuation will be called with status "GNUNET_OK" if content
1218 * was removed, "GNUNET_NO" if no matching entry was found and
1219 * "GNUNET_SYSERR" on all other types of errors.
1220 * This API is used by the authority of a zone.
1222 * @param h handle to the namestore
1223 * @param pkey private key of the zone
1224 * @param name name that is being mapped (at most 255 characters long)
1225 * @param rd record data
1226 * @param cont continuation to call when done
1227 * @param cont_cls closure for cont
1228 * @return handle to abort the request
1230 struct GNUNET_NAMESTORE_QueueEntry *
1231 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1232 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1234 const struct GNUNET_NAMESTORE_RecordData *rd,
1235 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1238 struct GNUNET_NAMESTORE_QueueEntry *qe;
1239 struct PendingMessage *pe;
1243 size_t rd_ser_len = 0;
1244 size_t msg_size = 0;
1245 size_t name_len = 0;
1249 GNUNET_assert (NULL != h);
1252 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1255 qe->cont_cls = cont_cls;
1257 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1260 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1261 GNUNET_assert (pkey_enc != NULL);
1262 key_len = ntohs (pkey_enc->len);
1264 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1265 char rd_ser[rd_ser_len];
1266 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1268 name_len = strlen (name) + 1;
1270 struct RecordRemoveMessage * msg;
1271 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1273 /* create msg here */
1274 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1275 pe->size = msg_size;
1276 pe->is_init = GNUNET_NO;
1277 msg = (struct RecordRemoveMessage *) &pe[1];
1279 pkey_tmp = (char *) &msg[1];
1280 name_tmp = &pkey_tmp[key_len];
1281 rd_tmp = &name_tmp[name_len];
1283 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1284 msg->gns_header.header.size = htons (msg_size);
1285 msg->gns_header.r_id = htonl (rid);
1286 msg->name_len = htons (name_len);
1287 msg->rd_len = htons (rd_ser_len);
1288 msg->rd_count = htons (1);
1289 msg->pkey_len = htons (key_len);
1290 memcpy (pkey_tmp, pkey_enc, key_len);
1291 memcpy (name_tmp, name, name_len);
1292 memcpy (rd_tmp, rd_ser, rd_ser_len);
1294 GNUNET_free (pkey_enc);
1296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1298 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1305 * Get a result for a particular key from the namestore. The processor
1306 * will only be called once.
1308 * @param h handle to the namestore
1309 * @param zone zone to look up a record from
1310 * @param name name to look up
1311 * @param record_type desired record type, 0 for all
1312 * @param proc function to call on the matching records, or with
1313 * NULL (rd_count == 0) if there are no matching records
1314 * @param proc_cls closure for proc
1315 * @return a handle that can be used to
1318 struct GNUNET_NAMESTORE_QueueEntry *
1319 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1320 const GNUNET_HashCode *zone,
1322 uint32_t record_type,
1323 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1325 struct GNUNET_NAMESTORE_QueueEntry *qe;
1326 struct PendingMessage *pe;
1327 size_t msg_size = 0;
1328 size_t name_len = 0;
1331 GNUNET_assert (NULL != h);
1332 GNUNET_assert (NULL != zone);
1333 GNUNET_assert (NULL != name);
1335 name_len = strlen (name) + 1;
1336 if ((name_len == 0) || (name_len > 256))
1343 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1346 qe->proc_cls = proc_cls;
1348 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1351 msg_size = sizeof (struct LookupNameMessage) + name_len;
1352 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1354 /* create msg here */
1355 struct LookupNameMessage * msg;
1356 pe->size = msg_size;
1357 pe->is_init = GNUNET_NO;
1358 msg = (struct LookupNameMessage *) &pe[1];
1359 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1360 msg->gns_header.header.size = htons (msg_size);
1361 msg->gns_header.r_id = htonl (rid);
1362 msg->record_type = htonl (record_type);
1363 msg->name_len = htonl (name_len);
1365 memcpy (&msg[1], name, name_len);
1367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1369 /* transmit message */
1370 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1378 * Look for an existing PKEY delegation record for a given public key.
1379 * Returns at most one result to the processor.
1381 * @param h handle to the namestore
1382 * @param zone hash of public key of the zone to look up in, never NULL
1383 * @param value_zone hash of the public key of the target zone (value), never NULL
1384 * @param proc function to call on the matching records, or with
1385 * NULL (rd_count == 0) if there are no matching records
1386 * @param proc_cls closure for proc
1387 * @return a handle that can be used to
1390 struct GNUNET_NAMESTORE_QueueEntry *
1391 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1392 const GNUNET_HashCode *zone,
1393 const GNUNET_HashCode *value_zone,
1394 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1396 struct GNUNET_NAMESTORE_QueueEntry *qe;
1397 struct PendingMessage *pe;
1398 size_t msg_size = 0;
1401 GNUNET_assert (NULL != h);
1402 GNUNET_assert (NULL != zone);
1403 GNUNET_assert (NULL != value_zone);
1406 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1409 qe->proc_cls = proc_cls;
1411 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1414 msg_size = sizeof (struct ZoneToNameMessage);
1415 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1417 /* create msg here */
1418 struct ZoneToNameMessage * msg;
1419 pe->size = msg_size;
1420 pe->is_init = GNUNET_NO;
1421 msg = (struct ZoneToNameMessage *) &pe[1];
1422 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1423 msg->gns_header.header.size = htons (msg_size);
1424 msg->gns_header.r_id = htonl (rid);
1426 msg->value_zone = *value_zone;
1428 char * z_tmp = strdup (GNUNET_h2s (zone));
1429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1430 "NAMESTORE_ZONE_TO_NAME",
1432 GNUNET_h2s (value_zone));
1433 GNUNET_free (z_tmp);
1435 /* transmit message */
1436 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1445 * Starts a new zone iteration (used to periodically PUT all of our
1446 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1447 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1448 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1449 * immediately, and then again after
1450 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1452 * @param h handle to the namestore
1453 * @param zone zone to access, NULL for all zones
1454 * @param must_have_flags flags that must be set for the record to be returned
1455 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1456 * @param proc function to call on each name from the zone; it
1457 * will be called repeatedly with a value (if available)
1458 * and always once at the end with a name of NULL.
1459 * @param proc_cls closure for proc
1460 * @return an iterator handle to use for iteration
1462 struct GNUNET_NAMESTORE_ZoneIterator *
1463 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1464 const GNUNET_HashCode *zone,
1465 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1466 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1467 GNUNET_NAMESTORE_RecordProcessor proc,
1470 struct GNUNET_NAMESTORE_ZoneIterator *it;
1471 struct PendingMessage *pe;
1472 size_t msg_size = 0;
1475 GNUNET_assert (NULL != h);
1479 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1482 it->proc_cls = proc;
1488 it->has_zone = GNUNET_YES;
1492 memset (&it->zone, '\0', sizeof (it->zone));
1493 it->has_zone = GNUNET_NO;
1495 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1498 msg_size = sizeof (struct ZoneIterationStartMessage);
1499 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1501 /* create msg here */
1502 struct ZoneIterationStartMessage * msg;
1503 pe->size = msg_size;
1504 pe->is_init = GNUNET_NO;
1505 msg = (struct ZoneIterationStartMessage *) &pe[1];
1506 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1507 msg->gns_header.header.size = htons (msg_size);
1508 msg->gns_header.r_id = htonl (rid);
1511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
1516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_START");
1517 memset (&msg->zone, '\0', sizeof (msg->zone));
1519 msg->must_have_flags = ntohs (must_have_flags);
1520 msg->must_not_have_flags = ntohs (must_not_have_flags);
1524 /* transmit message */
1525 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1533 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1534 * for the next record.
1536 * @param it the iterator
1539 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1541 struct GNUNET_NAMESTORE_Handle *h;
1542 struct PendingMessage *pe;
1543 size_t msg_size = 0;
1545 GNUNET_assert (NULL != it);
1547 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1555 GNUNET_assert (NULL != tmp);
1558 msg_size = sizeof (struct ZoneIterationNextMessage);
1559 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1561 /* create msg here */
1562 struct ZoneIterationNextMessage * msg;
1563 pe->size = msg_size;
1564 pe->is_init = GNUNET_NO;
1565 msg = (struct ZoneIterationNextMessage *) &pe[1];
1566 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1567 msg->gns_header.header.size = htons (msg_size);
1568 msg->gns_header.r_id = htonl (it->op_id);
1570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT");
1572 /* transmit message */
1573 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1579 * Stops iteration and releases the namestore handle for further calls.
1581 * @param it the iterator
1584 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1586 GNUNET_assert (NULL != it);
1587 struct PendingMessage *pe;
1588 size_t msg_size = 0;
1589 struct GNUNET_NAMESTORE_Handle *h = it->h;
1590 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1598 GNUNET_assert (NULL != tmp);
1601 msg_size = sizeof (struct ZoneIterationStopMessage);
1602 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1604 /* create msg here */
1605 struct ZoneIterationStopMessage * msg;
1606 pe->size = msg_size;
1607 pe->is_init = GNUNET_NO;
1608 msg = (struct ZoneIterationStopMessage *) &pe[1];
1609 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1610 msg->gns_header.header.size = htons (msg_size);
1611 msg->gns_header.r_id = htonl (it->op_id);
1613 if (GNUNET_YES == it->has_zone)
1614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
1616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
1618 /* transmit message */
1619 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1625 * Cancel a namestore operation. The final callback from the
1626 * operation must not have been done yet.
1628 * @param qe operation to cancel
1631 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1633 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1635 GNUNET_assert (qe != NULL);
1637 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1642 /* end of namestore_api.c */