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"
39 #define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
44 struct GNUNET_NAMESTORE_QueueEntry
50 struct GNUNET_NAMESTORE_QueueEntry *next;
55 struct GNUNET_NAMESTORE_QueueEntry *prev;
57 struct GNUNET_NAMESTORE_Handle *nsh;
61 GNUNET_NAMESTORE_ContinuationWithStatus cont;
64 GNUNET_NAMESTORE_RecordProcessor proc;
67 char *data; /*stub data pointer*/
74 struct GNUNET_NAMESTORE_ZoneIterator
80 struct GNUNET_NAMESTORE_ZoneIterator *next;
85 struct GNUNET_NAMESTORE_ZoneIterator *prev;
89 struct GNUNET_NAMESTORE_Handle *h;
90 GNUNET_NAMESTORE_RecordProcessor proc;
92 struct GNUNET_CRYPTO_ShortHashCode zone;
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 struct GNUNET_CRYPTO_ShortHashCode *zone;
196 uint32_t record_type;
197 struct GNUNET_TIME_Absolute expiration;
198 enum GNUNET_NAMESTORE_RecordFlags flags;
206 * Disconnect from service and then reconnect.
208 * @param h our handle
211 force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
214 handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
215 struct LookupNameResponseMessage * msg,
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
219 "LOOKUP_NAME_RESPONSE");
221 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
223 /* Operation done, remove */
224 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
230 struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
231 struct GNUNET_TIME_Absolute expire;
232 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp;
237 int contains_sig = GNUNET_NO;
240 rd_len = ntohs (msg->rd_len);
241 rd_count = ntohs (msg->rd_count);
242 msg_len = ntohs (msg->gns_header.header.size);
243 name_len = ntohs (msg->name_len);
244 contains_sig = ntohs (msg->contains_sig);
245 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
247 exp_msg_len = sizeof (struct LookupNameResponseMessage) +
248 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
251 if (msg_len != exp_msg_len)
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
254 msg_len, exp_msg_len);
259 name = (char *) &msg[1];
262 GNUNET_assert ('\0' == name[name_len -1]);
263 GNUNET_assert ((name_len - 1) == strlen(name));
265 rd_tmp = &name[name_len];
267 /* deserialize records */
268 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
269 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd))
276 /* reset values if values not contained */
277 if (contains_sig == GNUNET_NO)
280 signature = &msg->signature;
285 public_key_tmp = &msg->public_key;
287 public_key_tmp = NULL;
289 if (qe->proc != NULL)
291 qe->proc (qe->proc_cls, public_key_tmp, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature);
298 handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
299 struct RecordPutResponseMessage* msg,
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
303 "RECORD_PUT_RESPONSE");
305 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
306 /* Operation done, remove */
307 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
309 int res = ntohl (msg->op_result);
311 if (res == GNUNET_OK)
313 if (qe->cont != NULL)
315 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
319 else if (res == GNUNET_SYSERR)
321 if (qe->cont != NULL)
323 qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
337 handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
338 struct RecordCreateResponseMessage* msg,
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
342 "RECORD_CREATE_RESPONSE");
344 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
345 /* Operation done, remove */
346 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
348 int res = ntohl (msg->op_result);
349 if (res == GNUNET_YES)
351 if (qe->cont != NULL)
353 qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
357 else if (res == GNUNET_NO)
359 if (qe->cont != NULL)
361 qe->cont (qe->cont_cls, res, _("Namestore record already existed"));
366 if (qe->cont != NULL)
368 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Namestore failed to add record\n"));
377 handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
378 struct RecordRemoveResponseMessage* msg,
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
382 "RECORD_REMOVE_RESPONSE");
384 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
385 /* Operation done, remove */
386 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
388 int res = ntohl (msg->op_result);
392 * 1 : No records for entry
393 * 2 : Could not find record to remove
394 * 3 : Failed to create new signature
395 * 4 : Failed to put new set of records in database
399 if (qe->cont != NULL)
401 qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
406 if (qe->cont != NULL)
408 qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
413 if (qe->cont != NULL)
415 qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
420 if (qe->cont != NULL)
422 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
427 if (qe->cont != NULL)
429 qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
441 handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
442 struct ZoneToNameResponseMessage* msg,
445 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
446 "ZONE_TO_NAME_RESPONSE");
448 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
449 /* Operation done, remove */
450 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
452 int res = ntohs (msg->res);
454 struct GNUNET_TIME_Absolute expire;
457 unsigned int rd_count;
462 if (res == GNUNET_SYSERR)
464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n");
465 if (qe->proc != NULL)
466 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
468 else if (res == GNUNET_NO)
470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n");
471 if (qe->proc != NULL)
472 qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL);
474 else if (res == GNUNET_YES)
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has result for zone to name mapping \n");
478 name_len = ntohs (msg->name_len);
479 rd_count = ntohs (msg->rd_count);
480 rd_ser_len = ntohs (msg->rd_len);
481 expire = GNUNET_TIME_absolute_ntoh(msg->expire);
483 name_tmp = (char *) &msg[1];
486 GNUNET_assert ('\0' == name_tmp[name_len -1]);
487 GNUNET_assert (name_len -1 == strlen(name_tmp));
489 rd_tmp = &name_tmp[name_len];
491 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
492 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd))
498 if (qe->proc != NULL)
499 qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature);
509 manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
510 const struct GNUNET_MessageHeader *msg,
511 int type, size_t size)
514 /* handle different message type */
516 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
517 if (size < sizeof (struct LookupNameResponseMessage))
522 handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
524 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
525 if (size != sizeof (struct RecordPutResponseMessage))
530 handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
532 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
533 if (size != sizeof (struct RecordCreateResponseMessage))
538 handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
540 case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
541 if (size != sizeof (struct RecordRemoveResponseMessage))
546 handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
548 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE:
549 if (size < sizeof (struct ZoneToNameResponseMessage))
554 handle_zone_to_name_response (qe, (struct ZoneToNameResponseMessage *) msg, size);
563 handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
564 struct ZoneIterationResponseMessage *msg,
567 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
568 "ZONE_ITERATION_RESPONSE");
570 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy;
572 size_t exp_msg_len = 0;
575 unsigned rd_count = 0;
579 struct GNUNET_TIME_Absolute expire;
581 msg_len = ntohs (msg->gns_header.header.size);
582 rd_len = ntohs (msg->rd_len);
583 rd_count = ntohs (msg->rd_count);
584 name_len = ntohs (msg->name_len);
585 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
587 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len;
588 if (msg_len != exp_msg_len)
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n",
591 msg_len, exp_msg_len);
595 if (0 != ntohs (msg->reserved))
601 memset (&pubdummy, '\0', sizeof (pubdummy));
602 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n");
606 GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze);
608 if (ze->proc != NULL)
609 ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL);
615 name_tmp = (char *) &msg[1];
616 if ((name_tmp[name_len -1] != '\0') || (name_len > 256))
621 rd_ser_tmp = (char *) &name_tmp[name_len];
622 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
623 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd))
629 if (ze->proc != NULL)
630 ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature);
635 manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
636 const struct GNUNET_MessageHeader *msg,
637 int type, size_t size)
640 /* handle different message type */
642 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
643 if (size < sizeof (struct ZoneIterationResponseMessage))
648 handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
657 * Type of a function to call when we receive a message
660 * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
661 * @param msg message received, NULL on timeout or fatal error
664 process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
666 struct GNUNET_NAMESTORE_Handle *h = cls;
667 struct GNUNET_NAMESTORE_Header * gm;
668 struct GNUNET_NAMESTORE_QueueEntry *qe;
669 struct GNUNET_NAMESTORE_ZoneIterator *ze;
672 uint32_t r_id = UINT32_MAX;
680 size = ntohs (msg->size);
681 type = ntohs (msg->type);
683 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
686 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
687 GNUNET_TIME_UNIT_FOREVER_REL);
691 gm = (struct GNUNET_NAMESTORE_Header *) msg;
692 r_id = ntohl (gm->r_id);
694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
696 /* Find matching operation */
699 /* No matching pending operation found */
701 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
702 GNUNET_TIME_UNIT_FOREVER_REL);
706 /* Is it a record related operation ? */
707 for (qe = h->op_head; qe != NULL; qe = qe->next)
709 if (qe->op_id == r_id)
714 manage_record_operations (qe, msg, type, size);
717 /* Is it a zone iteration operation ? */
718 for (ze = h->z_head; ze != NULL; ze = ze->next)
720 if (ze->op_id == r_id)
725 manage_zone_operations (ze, msg, type, size);
728 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
729 GNUNET_TIME_UNIT_FOREVER_REL);
731 if (GNUNET_YES == h->reconnect)
738 * Transmit messages from the message queue to the service
739 * (if there are any, and if we are not already trying).
741 * @param h handle to use
744 do_transmit (struct GNUNET_NAMESTORE_Handle *h);
748 * We can now transmit a message to NAMESTORE. Do it.
750 * @param cls the 'struct GNUNET_NAMESTORE_Handle'
751 * @param size number of bytes we can transmit
752 * @param buf where to copy the messages
753 * @return number of bytes copied into buf
756 transmit_message_to_namestore (void *cls, size_t size, void *buf)
758 struct GNUNET_NAMESTORE_Handle *h = cls;
759 struct PendingMessage *p;
764 if ((size == 0) || (buf == NULL))
771 while ((NULL != (p = h->pending_head)) && (p->size <= size))
773 memcpy (&cbuf[ret], &p[1], p->size);
776 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
777 if (GNUNET_YES == p->is_init)
778 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
779 GNUNET_TIME_UNIT_FOREVER_REL);
788 * Transmit messages from the message queue to the service
789 * (if there are any, and if we are not already trying).
791 * @param h handle to use
794 do_transmit (struct GNUNET_NAMESTORE_Handle *h)
796 struct PendingMessage *p;
800 if (NULL == (p = h->pending_head))
802 if (NULL == h->client)
803 return; /* currently reconnecting */
805 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, p->size,
806 GNUNET_TIME_UNIT_FOREVER_REL,
807 GNUNET_NO, &transmit_message_to_namestore,
813 * Reconnect to namestore service.
815 * @param h the handle to the namestore service
818 reconnect (struct GNUNET_NAMESTORE_Handle *h)
820 struct PendingMessage *p;
821 struct StartMessage *init;
823 GNUNET_assert (NULL == h->client);
824 h->client = GNUNET_CLIENT_connect ("namestore", h->cfg);
825 GNUNET_assert (NULL != h->client);
827 if ((NULL == (p = h->pending_head)) || (GNUNET_YES != p->is_init))
829 p = GNUNET_malloc (sizeof (struct PendingMessage) +
830 sizeof (struct StartMessage));
831 p->size = sizeof (struct StartMessage);
832 p->is_init = GNUNET_YES;
833 init = (struct StartMessage *) &p[1];
834 init->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_START);
835 init->header.size = htons (sizeof (struct StartMessage));
836 GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
842 * Re-establish the connection to the service.
844 * @param cls handle to use to re-connect.
845 * @param tc scheduler context
848 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
850 struct GNUNET_NAMESTORE_Handle *h = cls;
852 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
858 * Disconnect from service and then reconnect.
860 * @param h our handle
863 force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
865 h->reconnect = GNUNET_NO;
866 GNUNET_CLIENT_disconnect (h->client);
868 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
874 get_op_id (struct GNUNET_NAMESTORE_Handle *h)
876 uint32_t op_id = h->op_id;
882 * Initialize the connection with the NAMESTORE service.
884 * @param cfg configuration to use
885 * @return handle to the GNS service, or NULL on error
887 struct GNUNET_NAMESTORE_Handle *
888 GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
890 struct GNUNET_NAMESTORE_Handle *h;
892 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
894 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
900 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
902 struct PendingMessage *p;
903 struct GNUNET_NAMESTORE_QueueEntry *q;
904 struct GNUNET_NAMESTORE_ZoneIterator *z;
905 struct GNUNET_NAMESTORE_Handle *h = cls;
906 GNUNET_assert (h != NULL);
907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
908 while (NULL != (p = h->pending_head))
910 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
914 while (NULL != (q = h->op_head))
916 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
920 while (NULL != (z = h->z_head))
922 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
926 if (NULL != h->client)
928 GNUNET_CLIENT_disconnect (h->client);
931 if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task)
933 GNUNET_SCHEDULER_cancel (h->reconnect_task);
934 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
941 * Disconnect from the namestore service (and free associated
944 * @param h handle to the namestore
945 * @param drop set to GNUNET_YES to delete all data in namestore (!)
948 GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
950 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
951 GNUNET_SCHEDULER_add_now (&clean_up_task, h);
956 * Store an item in the namestore. If the item is already present,
957 * the expiration time is updated to the max of the existing time and
958 * the new time. This API is used when we cache signatures from other
961 * @param h handle to the namestore
962 * @param zone_key public key of the zone
963 * @param name name that is being mapped (at most 255 characters long)
964 * @param freshness when does the corresponding block in the DHT expire (until
965 * when should we never do a DHT lookup for the same name again)?
966 * @param rd_count number of entries in 'rd' array
967 * @param rd array of records with data to store
968 * @param signature signature for all the records in the zone under the given name
969 * @param cont continuation to call when done
970 * @param cont_cls closure for cont
971 * @return handle to abort the request
973 struct GNUNET_NAMESTORE_QueueEntry *
974 GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
975 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
977 struct GNUNET_TIME_Absolute freshness,
978 unsigned int rd_count,
979 const struct GNUNET_NAMESTORE_RecordData *rd,
980 const struct GNUNET_CRYPTO_RsaSignature *signature,
981 GNUNET_NAMESTORE_ContinuationWithStatus cont,
984 struct GNUNET_NAMESTORE_QueueEntry *qe;
985 struct PendingMessage *pe;
987 /* pointer to elements */
993 size_t rd_ser_len = 0;
996 GNUNET_assert (NULL != h);
997 GNUNET_assert (NULL != zone_key);
998 GNUNET_assert (NULL != name);
999 GNUNET_assert (NULL != rd);
1000 GNUNET_assert (NULL != signature);
1002 name_len = strlen(name) + 1;
1010 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1013 qe->cont_cls = cont_cls;
1015 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1018 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1019 char rd_ser[rd_ser_len];
1020 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1022 struct RecordPutMessage * msg;
1023 msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
1025 /* create msg here */
1026 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1027 pe->size = msg_size;
1028 pe->is_init = GNUNET_NO;
1029 msg = (struct RecordPutMessage *) &pe[1];
1030 name_tmp = (char *) &msg[1];
1031 rd_tmp = &name_tmp[name_len];
1033 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
1034 msg->gns_header.header.size = htons (msg_size);
1035 msg->gns_header.r_id = htonl (rid);
1036 msg->signature = *signature;
1037 msg->name_len = htons (name_len);
1038 msg->expire = GNUNET_TIME_absolute_hton (freshness);
1039 msg->rd_len = htons (rd_ser_len);
1040 msg->rd_count = htons (rd_count);
1042 msg->public_key = *zone_key;
1043 memcpy (name_tmp, name, name_len);
1044 memcpy (rd_tmp, rd_ser, rd_ser_len);
1046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size);
1048 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1056 * Check if a signature is valid. This API is used by the GNS Block
1057 * to validate signatures received from the network.
1059 * @param public_key public key of the zone
1060 * @param expire block expiration
1061 * @param name name that is being mapped (at most 255 characters long)
1062 * @param rd_count number of entries in 'rd' array
1063 * @param rd array of records with data to store
1064 * @param signature signature for all the records in the zone under the given name
1065 * @return GNUNET_OK if the signature is valid
1068 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
1069 const struct GNUNET_TIME_Absolute expire,
1071 unsigned int rd_count,
1072 const struct GNUNET_NAMESTORE_RecordData *rd,
1073 const struct GNUNET_CRYPTO_RsaSignature *signature)
1075 int res = GNUNET_SYSERR;
1076 size_t rd_ser_len = 0;
1077 size_t name_len = 0;
1080 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
1081 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
1082 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
1084 GNUNET_assert (public_key != NULL);
1085 GNUNET_assert (name != NULL);
1086 GNUNET_assert (rd != NULL);
1087 GNUNET_assert (signature != NULL);
1090 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
1091 char rd_ser[rd_ser_len];
1092 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
1094 name_len = strlen (name) + 1;
1098 return GNUNET_SYSERR;
1101 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
1102 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
1103 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
1104 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
1105 name_tmp = (char *) &expire_tmp[1];
1106 rd_tmp = &name_tmp[name_len];
1107 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
1108 memcpy (name_tmp, name, name_len);
1109 memcpy (rd_tmp, rd_ser, rd_ser_len);
1111 res = GNUNET_CRYPTO_rsa_verify(GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key);
1113 GNUNET_free (sig_purpose);
1119 * Store an item in the namestore. If the item is already present,
1120 * the expiration time is updated to the max of the existing time and
1121 * the new time. This API is used by the authority of a zone.
1123 * @param h handle to the namestore
1124 * @param pkey private key of the zone
1125 * @param name name that is being mapped (at most 255 characters long)
1126 * @param rd record data to store
1127 * @param cont continuation to call when done
1128 * @param cont_cls closure for cont
1129 * @return handle to abort the request
1131 struct GNUNET_NAMESTORE_QueueEntry *
1132 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1133 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1135 const struct GNUNET_NAMESTORE_RecordData *rd,
1136 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1139 struct GNUNET_NAMESTORE_QueueEntry *qe;
1140 struct PendingMessage *pe;
1144 size_t rd_ser_len = 0;
1145 size_t msg_size = 0;
1146 size_t name_len = 0;
1150 GNUNET_assert (NULL != h);
1151 GNUNET_assert (NULL != pkey);
1152 GNUNET_assert (NULL != name);
1153 GNUNET_assert (NULL != rd);
1155 name_len = strlen(name) + 1;
1163 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1166 qe->cont_cls = cont_cls;
1168 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1171 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1172 GNUNET_assert (pkey_enc != NULL);
1173 key_len = ntohs (pkey_enc->len);
1175 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1176 char rd_ser[rd_ser_len];
1177 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1179 struct RecordCreateMessage * msg;
1180 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1182 /* create msg here */
1183 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1184 pe->size = msg_size;
1185 pe->is_init = GNUNET_NO;
1186 msg = (struct RecordCreateMessage *) &pe[1];
1188 pkey_tmp = (char *) &msg[1];
1189 name_tmp = &pkey_tmp[key_len];
1190 rd_tmp = &name_tmp[name_len];
1192 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1193 msg->gns_header.header.size = htons (msg_size);
1194 msg->gns_header.r_id = htonl (rid);
1195 msg->name_len = htons (name_len);
1196 msg->rd_count = htons (1);
1197 msg->rd_len = htons (rd_ser_len);
1198 msg->pkey_len = htons (key_len);
1199 msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever());
1200 memcpy (pkey_tmp, pkey_enc, key_len);
1201 memcpy (name_tmp, name, name_len);
1202 memcpy (rd_tmp, rd_ser, rd_ser_len);
1203 GNUNET_free (pkey_enc);
1205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1207 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1214 * Explicitly remove some content from the database. The
1215 * "cont"inuation will be called with status "GNUNET_OK" if content
1216 * was removed, "GNUNET_NO" if no matching entry was found and
1217 * "GNUNET_SYSERR" on all other types of errors.
1218 * This API is used by the authority of a zone.
1220 * @param h handle to the namestore
1221 * @param pkey private key of the zone
1222 * @param name name that is being mapped (at most 255 characters long)
1223 * @param rd record data, remove specific record, NULL to remove the name and all records
1224 * @param cont continuation to call when done
1225 * @param cont_cls closure for cont
1226 * @return handle to abort the request
1228 struct GNUNET_NAMESTORE_QueueEntry *
1229 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1230 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1232 const struct GNUNET_NAMESTORE_RecordData *rd,
1233 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1236 struct GNUNET_NAMESTORE_QueueEntry *qe;
1237 struct PendingMessage *pe;
1241 size_t rd_ser_len = 0;
1242 size_t msg_size = 0;
1243 size_t name_len = 0;
1246 uint16_t rd_count = 1;
1248 GNUNET_assert (NULL != h);
1251 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1254 qe->cont_cls = cont_cls;
1256 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1259 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1260 GNUNET_assert (pkey_enc != NULL);
1261 key_len = ntohs (pkey_enc->len);
1267 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
1268 char rd_ser[rd_ser_len];
1269 GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser);
1271 name_len = strlen (name) + 1;
1273 struct RecordRemoveMessage * msg;
1274 msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len;
1276 /* create msg here */
1277 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1278 pe->size = msg_size;
1279 pe->is_init = GNUNET_NO;
1280 msg = (struct RecordRemoveMessage *) &pe[1];
1282 pkey_tmp = (char *) &msg[1];
1283 name_tmp = &pkey_tmp[key_len];
1284 rd_tmp = &name_tmp[name_len];
1286 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
1287 msg->gns_header.header.size = htons (msg_size);
1288 msg->gns_header.r_id = htonl (rid);
1289 msg->name_len = htons (name_len);
1290 msg->rd_len = htons (rd_ser_len);
1291 msg->rd_count = htons (rd_count);
1292 msg->pkey_len = htons (key_len);
1293 memcpy (pkey_tmp, pkey_enc, key_len);
1294 memcpy (name_tmp, name, name_len);
1295 memcpy (rd_tmp, rd_ser, rd_ser_len);
1297 GNUNET_free (pkey_enc);
1299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_REMOVE", name, msg_size);
1301 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1308 * Get a result for a particular key from the namestore. The processor
1309 * will only be called once.
1311 * @param h handle to the namestore
1312 * @param zone zone to look up a record from
1313 * @param name name to look up
1314 * @param record_type desired record type, 0 for all
1315 * @param proc function to call on the matching records, or with
1316 * NULL (rd_count == 0) if there are no matching records
1317 * @param proc_cls closure for proc
1318 * @return a handle that can be used to
1321 struct GNUNET_NAMESTORE_QueueEntry *
1322 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
1323 const struct GNUNET_CRYPTO_ShortHashCode *zone,
1325 uint32_t record_type,
1326 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1328 struct GNUNET_NAMESTORE_QueueEntry *qe;
1329 struct PendingMessage *pe;
1330 size_t msg_size = 0;
1331 size_t name_len = 0;
1334 GNUNET_assert (NULL != h);
1335 GNUNET_assert (NULL != zone);
1336 GNUNET_assert (NULL != name);
1338 name_len = strlen (name) + 1;
1339 if ((name_len == 0) || (name_len > 256))
1346 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1349 qe->proc_cls = proc_cls;
1351 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1354 msg_size = sizeof (struct LookupNameMessage) + name_len;
1355 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1357 /* create msg here */
1358 struct LookupNameMessage * msg;
1359 pe->size = msg_size;
1360 pe->is_init = GNUNET_NO;
1361 msg = (struct LookupNameMessage *) &pe[1];
1362 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
1363 msg->gns_header.header.size = htons (msg_size);
1364 msg->gns_header.r_id = htonl (rid);
1365 msg->record_type = htonl (record_type);
1366 msg->name_len = htonl (name_len);
1368 memcpy (&msg[1], name, name_len);
1370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "NAMESTORE_LOOKUP_NAME", name);
1372 /* transmit message */
1373 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1381 * Look for an existing PKEY delegation record for a given public key.
1382 * Returns at most one result to the processor.
1384 * @param h handle to the namestore
1385 * @param zone hash of public key of the zone to look up in, never NULL
1386 * @param value_zone hash of the public key of the target zone (value), never NULL
1387 * @param proc function to call on the matching records, or with
1388 * NULL (rd_count == 0) if there are no matching records
1389 * @param proc_cls closure for proc
1390 * @return a handle that can be used to
1393 struct GNUNET_NAMESTORE_QueueEntry *
1394 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
1395 const struct GNUNET_CRYPTO_ShortHashCode *zone,
1396 const struct GNUNET_CRYPTO_ShortHashCode *value_zone,
1397 GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
1399 struct GNUNET_NAMESTORE_QueueEntry *qe;
1400 struct PendingMessage *pe;
1401 size_t msg_size = 0;
1404 GNUNET_assert (NULL != h);
1405 GNUNET_assert (NULL != zone);
1406 GNUNET_assert (NULL != value_zone);
1409 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1412 qe->proc_cls = proc_cls;
1414 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1417 msg_size = sizeof (struct ZoneToNameMessage);
1418 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1420 /* create msg here */
1421 struct ZoneToNameMessage * msg;
1422 pe->size = msg_size;
1423 pe->is_init = GNUNET_NO;
1424 msg = (struct ZoneToNameMessage *) &pe[1];
1425 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1426 msg->gns_header.header.size = htons (msg_size);
1427 msg->gns_header.r_id = htonl (rid);
1429 msg->value_zone = *value_zone;
1431 char * z_tmp = strdup (GNUNET_short_h2s (zone));
1432 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
1433 "NAMESTORE_ZONE_TO_NAME",
1435 GNUNET_short_h2s (value_zone));
1436 GNUNET_free (z_tmp);
1438 /* transmit message */
1439 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1448 * Starts a new zone iteration (used to periodically PUT all of our
1449 * records into our DHT). This MUST lock the GNUNET_NAMESTORE_Handle
1450 * for any other calls than GNUNET_NAMESTORE_zone_iterator_next and
1451 * GNUNET_NAMESTORE_zone_iteration_stop. "proc" will be called once
1452 * immediately, and then again after
1453 * "GNUNET_NAMESTORE_zone_iterator_next" is invoked.
1455 * @param h handle to the namestore
1456 * @param zone zone to access, NULL for all zones
1457 * @param must_have_flags flags that must be set for the record to be returned
1458 * @param must_not_have_flags flags that must NOT be set for the record to be returned
1459 * @param proc function to call on each name from the zone; it
1460 * will be called repeatedly with a value (if available)
1461 * and always once at the end with a name of NULL.
1462 * @param proc_cls closure for proc
1463 * @return an iterator handle to use for iteration
1465 struct GNUNET_NAMESTORE_ZoneIterator *
1466 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1467 const struct GNUNET_CRYPTO_ShortHashCode *zone,
1468 enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
1469 enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
1470 GNUNET_NAMESTORE_RecordProcessor proc,
1473 struct GNUNET_NAMESTORE_ZoneIterator *it;
1474 struct PendingMessage *pe;
1475 size_t msg_size = 0;
1478 GNUNET_assert (NULL != h);
1482 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1485 it->proc_cls = proc_cls;
1491 it->has_zone = GNUNET_YES;
1495 memset (&it->zone, '\0', sizeof (it->zone));
1496 it->has_zone = GNUNET_NO;
1498 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1501 msg_size = sizeof (struct ZoneIterationStartMessage);
1502 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1504 /* create msg here */
1505 struct ZoneIterationStartMessage * msg;
1506 pe->size = msg_size;
1507 pe->is_init = GNUNET_NO;
1508 msg = (struct ZoneIterationStartMessage *) &pe[1];
1509 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1510 msg->gns_header.header.size = htons (msg_size);
1511 msg->gns_header.r_id = htonl (rid);
1514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_short_h2s(zone));
1519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_START");
1520 memset (&msg->zone, '\0', sizeof (msg->zone));
1522 msg->must_have_flags = ntohs (must_have_flags);
1523 msg->must_not_have_flags = ntohs (must_not_have_flags);
1527 /* transmit message */
1528 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1536 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1537 * for the next record.
1539 * @param it the iterator
1542 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1544 struct GNUNET_NAMESTORE_Handle *h;
1545 struct PendingMessage *pe;
1546 size_t msg_size = 0;
1548 GNUNET_assert (NULL != it);
1550 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1558 GNUNET_assert (NULL != tmp);
1561 msg_size = sizeof (struct ZoneIterationNextMessage);
1562 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1564 /* create msg here */
1565 struct ZoneIterationNextMessage * msg;
1566 pe->size = msg_size;
1567 pe->is_init = GNUNET_NO;
1568 msg = (struct ZoneIterationNextMessage *) &pe[1];
1569 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1570 msg->gns_header.header.size = htons (msg_size);
1571 msg->gns_header.r_id = htonl (it->op_id);
1573 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT");
1575 /* transmit message */
1576 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1582 * Stops iteration and releases the namestore handle for further calls.
1584 * @param it the iterator
1587 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1589 GNUNET_assert (NULL != it);
1590 struct PendingMessage *pe;
1591 size_t msg_size = 0;
1592 struct GNUNET_NAMESTORE_Handle *h = it->h;
1593 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1601 GNUNET_assert (NULL != tmp);
1604 msg_size = sizeof (struct ZoneIterationStopMessage);
1605 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1607 /* create msg here */
1608 struct ZoneIterationStopMessage * msg;
1609 pe->size = msg_size;
1610 pe->is_init = GNUNET_NO;
1611 msg = (struct ZoneIterationStopMessage *) &pe[1];
1612 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1613 msg->gns_header.header.size = htons (msg_size);
1614 msg->gns_header.r_id = htonl (it->op_id);
1616 if (GNUNET_YES == it->has_zone)
1617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_short_h2s(&it->zone));
1619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
1621 /* transmit message */
1622 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1628 * Cancel a namestore operation. The final callback from the
1629 * operation must not have been done yet.
1631 * @param qe operation to cancel
1634 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1636 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1638 GNUNET_assert (qe != NULL);
1640 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1645 /* end of namestore_api.c */