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_UNIT_ZERO_ABS, 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_UNIT_ZERO_ABS, 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_UNIT_ZERO_ABS, 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;
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 freshness 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 freshness,
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 (freshness);
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 name name that is being mapped (at most 255 characters long)
1127 * @param rd record data to store
1128 * @param cont continuation to call when done
1129 * @param cont_cls closure for cont
1130 * @return handle to abort the request
1132 struct GNUNET_NAMESTORE_QueueEntry *
1133 GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
1134 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1136 const struct GNUNET_NAMESTORE_RecordData *rd,
1137 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1140 struct GNUNET_NAMESTORE_QueueEntry *qe;
1141 struct PendingMessage *pe;
1145 size_t rd_ser_len = 0;
1146 size_t msg_size = 0;
1147 size_t name_len = 0;
1151 GNUNET_assert (NULL != h);
1152 GNUNET_assert (NULL != pkey);
1153 GNUNET_assert (NULL != name);
1154 GNUNET_assert (NULL != rd);
1156 name_len = strlen(name) + 1;
1164 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
1167 qe->cont_cls = cont_cls;
1169 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
1172 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey);
1173 GNUNET_assert (pkey_enc != NULL);
1174 key_len = ntohs (pkey_enc->len);
1176 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd);
1177 char rd_ser[rd_ser_len];
1178 GNUNET_NAMESTORE_records_serialize(1, rd, rd_ser_len, rd_ser);
1180 struct RecordCreateMessage * msg;
1181 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len;
1183 /* create msg here */
1184 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1185 pe->size = msg_size;
1186 pe->is_init = GNUNET_NO;
1187 msg = (struct RecordCreateMessage *) &pe[1];
1189 pkey_tmp = (char *) &msg[1];
1190 name_tmp = &pkey_tmp[key_len];
1191 rd_tmp = &name_tmp[name_len];
1193 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
1194 msg->gns_header.header.size = htons (msg_size);
1195 msg->gns_header.r_id = htonl (rid);
1196 msg->name_len = htons (name_len);
1197 msg->rd_count = htons (1);
1198 msg->rd_len = htons (rd_ser_len);
1199 msg->pkey_len = htons (key_len);
1200 msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_UNIT_FOREVER_ABS);
1201 memcpy (pkey_tmp, pkey_enc, key_len);
1202 memcpy (name_tmp, name, name_len);
1203 memcpy (rd_tmp, rd_ser, rd_ser_len);
1204 GNUNET_free (pkey_enc);
1206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_CREATE", name, msg_size);
1208 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1215 * Explicitly remove some content from the database. The
1216 * "cont"inuation will be called with status "GNUNET_OK" if content
1217 * was removed, "GNUNET_NO" if no matching entry was found and
1218 * "GNUNET_SYSERR" on all other types of errors.
1219 * This API is used by the authority of a zone.
1221 * @param h handle to the namestore
1222 * @param pkey private key of the zone
1223 * @param name name that is being mapped (at most 255 characters long)
1224 * @param rd record data, remove specific record, NULL to remove the name and all records
1225 * @param cont continuation to call when done
1226 * @param cont_cls closure for cont
1227 * @return handle to abort the request
1229 struct GNUNET_NAMESTORE_QueueEntry *
1230 GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
1231 const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
1233 const struct GNUNET_NAMESTORE_RecordData *rd,
1234 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1237 struct GNUNET_NAMESTORE_QueueEntry *qe;
1238 struct PendingMessage *pe;
1242 size_t rd_ser_len = 0;
1243 size_t msg_size = 0;
1244 size_t name_len = 0;
1247 uint16_t rd_count = 1;
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);
1268 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
1269 char rd_ser[rd_ser_len];
1270 GNUNET_NAMESTORE_records_serialize (rd_count, 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 (rd_count);
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 struct GNUNET_CRYPTO_ShortHashCode *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 struct GNUNET_CRYPTO_ShortHashCode *zone,
1397 const struct GNUNET_CRYPTO_ShortHashCode *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 = GNUNET_strdup (GNUNET_short_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_short_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 struct GNUNET_CRYPTO_ShortHashCode *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_cls;
1492 it->has_zone = GNUNET_YES;
1496 memset (&it->zone, '\0', sizeof (it->zone));
1497 it->has_zone = GNUNET_NO;
1499 GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
1502 msg_size = sizeof (struct ZoneIterationStartMessage);
1503 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1505 /* create msg here */
1506 struct ZoneIterationStartMessage * msg;
1507 pe->size = msg_size;
1508 pe->is_init = GNUNET_NO;
1509 msg = (struct ZoneIterationStartMessage *) &pe[1];
1510 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1511 msg->gns_header.header.size = htons (msg_size);
1512 msg->gns_header.r_id = htonl (rid);
1515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_short_h2s(zone));
1520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_START");
1521 memset (&msg->zone, '\0', sizeof (msg->zone));
1523 msg->must_have_flags = ntohs (must_have_flags);
1524 msg->must_not_have_flags = ntohs (must_not_have_flags);
1528 /* transmit message */
1529 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1537 * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start
1538 * for the next record.
1540 * @param it the iterator
1543 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1545 struct GNUNET_NAMESTORE_Handle *h;
1546 struct PendingMessage *pe;
1547 size_t msg_size = 0;
1549 GNUNET_assert (NULL != it);
1551 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1559 GNUNET_assert (NULL != tmp);
1562 msg_size = sizeof (struct ZoneIterationNextMessage);
1563 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1565 /* create msg here */
1566 struct ZoneIterationNextMessage * msg;
1567 pe->size = msg_size;
1568 pe->is_init = GNUNET_NO;
1569 msg = (struct ZoneIterationNextMessage *) &pe[1];
1570 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1571 msg->gns_header.header.size = htons (msg_size);
1572 msg->gns_header.r_id = htonl (it->op_id);
1574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT");
1576 /* transmit message */
1577 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1583 * Stops iteration and releases the namestore handle for further calls.
1585 * @param it the iterator
1588 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
1590 GNUNET_assert (NULL != it);
1591 struct PendingMessage *pe;
1592 size_t msg_size = 0;
1593 struct GNUNET_NAMESTORE_Handle *h = it->h;
1594 struct GNUNET_NAMESTORE_ZoneIterator *tmp = it->h->z_head;
1602 GNUNET_assert (NULL != tmp);
1605 msg_size = sizeof (struct ZoneIterationStopMessage);
1606 pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
1608 /* create msg here */
1609 struct ZoneIterationStopMessage * msg;
1610 pe->size = msg_size;
1611 pe->is_init = GNUNET_NO;
1612 msg = (struct ZoneIterationStopMessage *) &pe[1];
1613 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
1614 msg->gns_header.header.size = htons (msg_size);
1615 msg->gns_header.r_id = htonl (it->op_id);
1617 if (GNUNET_YES == it->has_zone)
1618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_short_h2s(&it->zone));
1620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
1622 /* transmit message */
1623 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1629 * Cancel a namestore operation. The final callback from the
1630 * operation must not have been done yet.
1632 * @param qe operation to cancel
1635 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1637 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1639 GNUNET_assert (qe != NULL);
1641 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1646 /* end of namestore_api.c */