2 This file is part of GNUnet.
3 Copyright (C) 2013 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 Liceidentity 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 Liceidentity for more details.
15 You should have received a copy of the GNU General Public Liceidentity
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file identity/identity_api.c
23 * @brief api to interact with the identity service
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_protocols.h"
30 #include "gnunet_identity_service.h"
33 #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__)
38 struct GNUNET_IDENTITY_Ego
41 * Private key associated with this ego.
43 struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
46 * Current name associated with this ego.
51 * Client context associated with this ego.
56 * Hash of the public key of this ego.
58 struct GNUNET_HashCode id;
63 * Handle for an operation with the identity service.
65 struct GNUNET_IDENTITY_Operation
69 * Main identity handle.
71 struct GNUNET_IDENTITY_Handle *h;
74 * We keep operations in a DLL.
76 struct GNUNET_IDENTITY_Operation *next;
79 * We keep operations in a DLL.
81 struct GNUNET_IDENTITY_Operation *prev;
84 * Message to send to the identity service.
85 * Allocated at the end of this struct.
87 const struct GNUNET_MessageHeader *msg;
90 * Continuation to invoke with the result of the transmission; @e cb
91 * will be NULL in this case.
93 GNUNET_IDENTITY_Continuation cont;
96 * Continuation to invoke with the result of the transmission for
97 * 'get' operations (@e cont will be NULL in this case).
99 GNUNET_IDENTITY_Callback cb;
102 * Closure for @e cont or @e cb.
110 * Handle for the service.
112 struct GNUNET_IDENTITY_Handle
115 * Configuration to use.
117 const struct GNUNET_CONFIGURATION_Handle *cfg;
120 * Socket (if available).
122 struct GNUNET_CLIENT_Connection *client;
125 * Hash map from the hash of the public key to the
126 * respective 'GNUNET_IDENTITY_Ego' handle.
128 struct GNUNET_CONTAINER_MultiHashMap *egos;
131 * Function to call when we receive updates.
133 GNUNET_IDENTITY_Callback cb;
141 * Head of active operations.
143 struct GNUNET_IDENTITY_Operation *op_head;
146 * Tail of active operations.
148 struct GNUNET_IDENTITY_Operation *op_tail;
151 * Currently pending transmission request, or NULL for none.
153 struct GNUNET_CLIENT_TransmitHandle *th;
156 * Task doing exponential back-off trying to reconnect.
158 struct GNUNET_SCHEDULER_Task * reconnect_task;
161 * Time for next connect retry.
163 struct GNUNET_TIME_Relative reconnect_delay;
166 * Are we polling for incoming messages right now?
174 * Obtain the ego representing 'anonymous' users.
176 * @return handle for the anonymous user, must not be freed
178 const struct GNUNET_IDENTITY_Ego *
179 GNUNET_IDENTITY_ego_get_anonymous ()
181 static struct GNUNET_IDENTITY_Ego anon;
182 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
186 anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
187 GNUNET_CRYPTO_ecdsa_key_get_public (anon.pk,
189 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id);
195 * Try again to connect to the identity service.
197 * @param cls handle to the identity service.
198 * @param tc scheduler context
201 reconnect (void *cls,
202 const struct GNUNET_SCHEDULER_TaskContext *tc);
206 * Reschedule a connect attempt to the service.
208 * @param h transport service to reconnect
211 reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
213 GNUNET_assert (h->reconnect_task == NULL);
217 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
220 if (NULL != h->client)
222 GNUNET_CLIENT_disconnect (h->client);
225 h->in_receive = GNUNET_NO;
226 LOG (GNUNET_ERROR_TYPE_DEBUG,
227 "Scheduling task to reconnect to identity service in %s.\n",
228 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
230 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
231 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
236 * Type of a function to call when we receive a message
240 * @param msg message received, NULL on timeout or fatal error
243 message_handler (void *cls,
244 const struct GNUNET_MessageHeader *msg)
246 struct GNUNET_IDENTITY_Handle *h = cls;
247 struct GNUNET_IDENTITY_Operation *op;
248 struct GNUNET_IDENTITY_Ego *ego;
249 const struct GNUNET_IDENTITY_ResultCodeMessage *rcm;
250 const struct GNUNET_IDENTITY_UpdateMessage *um;
251 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
252 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
253 struct GNUNET_HashCode id;
260 reschedule_connect (h);
263 LOG (GNUNET_ERROR_TYPE_DEBUG,
264 "Received message of type %d from identity service\n",
266 size = ntohs (msg->size);
267 switch (ntohs (msg->type))
269 case GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE:
270 if (size < sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
273 reschedule_connect (h);
276 rcm = (const struct GNUNET_IDENTITY_ResultCodeMessage *) msg;
277 str = (const char *) &rcm[1];
278 if ( (size > sizeof (struct GNUNET_IDENTITY_ResultCodeMessage)) &&
279 ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) - 1]) )
282 reschedule_connect (h);
285 if (size == sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
289 GNUNET_CONTAINER_DLL_remove (h->op_head,
292 GNUNET_CLIENT_receive (h->client, &message_handler, h,
293 GNUNET_TIME_UNIT_FOREVER_REL);
294 if (NULL != op->cont)
297 else if (NULL != op->cb)
298 op->cb (op->cls, NULL, NULL, NULL);
301 case GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE:
302 if (size < sizeof (struct GNUNET_IDENTITY_UpdateMessage))
305 reschedule_connect (h);
308 um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
309 name_len = ntohs (um->name_len);
311 str = (const char *) &um[1];
312 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
314 ('\0' != str[name_len - 1])) )
317 reschedule_connect (h);
320 if (GNUNET_YES == ntohs (um->end_of_list))
322 /* end of initial list of data */
323 GNUNET_CLIENT_receive (h->client, &message_handler, h,
324 GNUNET_TIME_UNIT_FOREVER_REL);
326 h->cb (h->cb_cls, NULL, NULL, NULL);
329 GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key,
331 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
335 str = (const char *) &um[1];
336 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
340 /* ego was created */
343 /* deletion of unknown ego? not allowed */
345 reschedule_connect (h);
348 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
349 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
350 *ego->pk = um->private_key;
351 ego->name = GNUNET_strdup (str);
353 GNUNET_assert (GNUNET_YES ==
354 GNUNET_CONTAINER_multihashmap_put (h->egos,
357 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
361 /* ego was deleted */
362 GNUNET_assert (GNUNET_YES ==
363 GNUNET_CONTAINER_multihashmap_remove (h->egos,
369 /* ego changed name */
370 GNUNET_free (ego->name);
371 ego->name = GNUNET_strdup (str);
373 GNUNET_CLIENT_receive (h->client, &message_handler, h,
374 GNUNET_TIME_UNIT_FOREVER_REL);
375 /* inform application about change */
383 GNUNET_free (ego->pk);
384 GNUNET_free (ego->name);
388 case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT:
389 if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
392 reschedule_connect (h);
395 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
396 GNUNET_break (0 == ntohs (sdm->reserved));
397 name_len = ntohs (sdm->name_len);
398 str = (const char *) &sdm[1];
399 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) ||
401 ('\0' != str[name_len - 1]) ) )
404 reschedule_connect (h);
407 /* Note: we know which service this should be for, so we're not
408 really using 'str' henceforth */
409 GNUNET_CRYPTO_ecdsa_key_get_public (&sdm->private_key,
411 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
412 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
417 reschedule_connect (h);
424 reschedule_connect (h);
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
428 "Received SET_DEFAULT message from identity service\n");
429 GNUNET_CONTAINER_DLL_remove (h->op_head,
432 GNUNET_CLIENT_receive (h->client, &message_handler, h,
433 GNUNET_TIME_UNIT_FOREVER_REL);
443 reschedule_connect (h);
450 * Schedule transmission of the next message from our queue.
452 * @param h identity handle
455 transmit_next (struct GNUNET_IDENTITY_Handle *h);
459 * Transmit next message to service.
461 * @param cls the `struct GNUNET_IDENTITY_Handle`.
462 * @param size number of bytes available in @a buf
463 * @param buf where to copy the message
464 * @return number of bytes copied to buf
467 send_next_message (void *cls,
471 struct GNUNET_IDENTITY_Handle *h = cls;
472 struct GNUNET_IDENTITY_Operation *op = h->op_head;
478 ret = ntohs (op->msg->size);
481 reschedule_connect (h);
484 LOG (GNUNET_ERROR_TYPE_DEBUG,
485 "Sending message of type %d to identity service\n",
486 ntohs (op->msg->type));
487 memcpy (buf, op->msg, ret);
488 if ( (NULL == op->cont) &&
491 GNUNET_CONTAINER_DLL_remove (h->op_head,
497 if (GNUNET_NO == h->in_receive)
499 h->in_receive = GNUNET_YES;
500 GNUNET_CLIENT_receive (h->client,
502 GNUNET_TIME_UNIT_FOREVER_REL);
509 * Schedule transmission of the next message from our queue.
511 * @param h identity handle
514 transmit_next (struct GNUNET_IDENTITY_Handle *h)
516 struct GNUNET_IDENTITY_Operation *op = h->op_head;
518 GNUNET_assert (NULL == h->th);
521 if (NULL == h->client)
523 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
524 ntohs (op->msg->size),
525 GNUNET_TIME_UNIT_FOREVER_REL,
533 * Try again to connect to the identity service.
535 * @param cls handle to the identity service.
536 * @param tc scheduler context
539 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
541 struct GNUNET_IDENTITY_Handle *h = cls;
542 struct GNUNET_IDENTITY_Operation *op;
543 struct GNUNET_MessageHeader msg;
545 h->reconnect_task = NULL;
546 LOG (GNUNET_ERROR_TYPE_DEBUG,
547 "Connecting to identity service.\n");
548 GNUNET_assert (NULL == h->client);
549 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
550 GNUNET_assert (NULL != h->client);
551 if ( (NULL == h->op_head) ||
552 (GNUNET_MESSAGE_TYPE_IDENTITY_START != ntohs (h->op_head->msg->type)) )
554 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
555 sizeof (struct GNUNET_MessageHeader));
557 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
558 msg.size = htons (sizeof (msg));
559 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
560 memcpy (&op[1], &msg, sizeof (msg));
561 GNUNET_CONTAINER_DLL_insert (h->op_head,
566 GNUNET_assert (NULL != h->th);
571 * Connect to the identity service.
573 * @param cfg the configuration to use
574 * @param cb function to call on all identity events, can be NULL
575 * @param cb_cls closure for @a cb
576 * @return handle to use
578 struct GNUNET_IDENTITY_Handle *
579 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
580 GNUNET_IDENTITY_Callback cb,
583 struct GNUNET_IDENTITY_Handle *h;
585 h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
589 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
590 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
591 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
597 * Obtain the ECC key associated with a ego.
600 * @return associated ECC key, valid as long as the ego is valid
602 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
603 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
610 * Get the identifier (public key) of an ego.
612 * @param ego identity handle with the private key
613 * @param pk set to ego's public key
616 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
617 struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
619 GNUNET_CRYPTO_ecdsa_key_get_public (ego->pk,
625 * Obtain the identity that is currently preferred/default
628 * @param id identity service to query
629 * @param service_name for which service is an identity wanted
630 * @param cb function to call with the result (will only be called once)
631 * @param cb_cls closure for @a cb
632 * @return handle to abort the operation
634 struct GNUNET_IDENTITY_Operation *
635 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
636 const char *service_name,
637 GNUNET_IDENTITY_Callback cb,
640 struct GNUNET_IDENTITY_Operation *op;
641 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
644 slen = strlen (service_name) + 1;
645 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
650 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
651 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
656 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
657 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
658 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
660 gdm->name_len = htons (slen);
661 gdm->reserved = htons (0);
662 memcpy (&gdm[1], service_name, slen);
663 op->msg = &gdm->header;
664 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
674 * Set the preferred/default identity for a service.
676 * @param id identity service to inform
677 * @param service_name for which service is an identity set
678 * @param ego new default identity to be set for this service
679 * @param cont function to call once the operation finished
680 * @param cont_cls closure for @a cont
681 * @return handle to abort the operation
683 struct GNUNET_IDENTITY_Operation *
684 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
685 const char *service_name,
686 struct GNUNET_IDENTITY_Ego *ego,
687 GNUNET_IDENTITY_Continuation cont,
690 struct GNUNET_IDENTITY_Operation *op;
691 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
694 slen = strlen (service_name) + 1;
695 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
700 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
701 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
706 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
707 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
708 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
710 sdm->name_len = htons (slen);
711 sdm->reserved = htons (0);
712 sdm->private_key = *ego->pk;
713 memcpy (&sdm[1], service_name, slen);
714 op->msg = &sdm->header;
715 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
725 * Create a new identity with the given name.
727 * @param id identity service to use
728 * @param name desired name
729 * @param cont function to call with the result (will only be called once)
730 * @param cont_cls closure for @a cont
731 * @return handle to abort the operation
733 struct GNUNET_IDENTITY_Operation *
734 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
736 GNUNET_IDENTITY_Continuation cont,
739 struct GNUNET_IDENTITY_Operation *op;
740 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
741 struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
744 slen = strlen (name) + 1;
745 pk = GNUNET_CRYPTO_ecdsa_key_create ();
747 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
753 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
754 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
759 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
760 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
761 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
763 crm->name_len = htons (slen);
764 crm->reserved = htons (0);
765 crm->private_key = *pk;
766 memcpy (&crm[1], name, slen);
767 op->msg = &crm->header;
768 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
779 * Renames an existing identity.
781 * @param id identity service to use
782 * @param old_name old name
783 * @param new_name desired new name
784 * @param cb function to call with the result (will only be called once)
785 * @param cb_cls closure for @a cb
786 * @return handle to abort the operation
788 struct GNUNET_IDENTITY_Operation *
789 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
790 const char *old_name,
791 const char *new_name,
792 GNUNET_IDENTITY_Continuation cb,
795 struct GNUNET_IDENTITY_Operation *op;
796 struct GNUNET_IDENTITY_RenameMessage *grm;
801 slen_old = strlen (old_name) + 1;
802 slen_new = strlen (new_name) + 1;
803 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
804 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
805 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
810 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
811 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
812 slen_old + slen_new);
816 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
817 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
818 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
819 slen_old + slen_new);
820 grm->old_name_len = htons (slen_old);
821 grm->new_name_len = htons (slen_new);
822 dst = (char *) &grm[1];
823 memcpy (dst, old_name, slen_old);
824 memcpy (&dst[slen_old], new_name, slen_new);
825 op->msg = &grm->header;
826 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
836 * Delete an existing identity.
838 * @param id identity service to use
839 * @param name name of the identity to delete
840 * @param cb function to call with the result (will only be called once)
841 * @param cb_cls closure for @a cb
842 * @return handle to abort the operation
844 struct GNUNET_IDENTITY_Operation *
845 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
847 GNUNET_IDENTITY_Continuation cb,
850 struct GNUNET_IDENTITY_Operation *op;
851 struct GNUNET_IDENTITY_DeleteMessage *gdm;
854 slen = strlen (name) + 1;
855 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
860 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
861 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
866 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
867 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
868 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
870 gdm->name_len = htons (slen);
871 gdm->reserved = htons (0);
872 memcpy (&gdm[1], name, slen);
873 op->msg = &gdm->header;
874 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
884 * Cancel an identity operation. Note that the operation MAY still
885 * be executed; this merely cancels the continuation; if the request
886 * was already transmitted, the service may still choose to complete
889 * @param op operation to cancel
892 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
894 struct GNUNET_IDENTITY_Handle *h = op->h;
896 if ( (h->op_head != op) ||
897 (NULL == h->client) )
899 /* request not active, can simply remove */
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
901 "Client aborted non-head operation, simply removing it\n");
902 GNUNET_CONTAINER_DLL_remove (h->op_head,
910 /* request active but not yet with service, can still abort */
911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
912 "Client aborted head operation prior to transmission, aborting it\n");
913 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
915 GNUNET_CONTAINER_DLL_remove (h->op_head,
922 /* request active with service, simply ensure continuations are not called */
923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
924 "Client aborted active request, NULLing continuation\n");
931 * Free ego from hash map.
933 * @param cls identity service handle
935 * @param value ego to free
936 * @return #GNUNET_OK (continue to iterate)
940 const struct GNUNET_HashCode *key,
943 struct GNUNET_IDENTITY_Handle *h = cls;
944 struct GNUNET_IDENTITY_Ego *ego = value;
951 GNUNET_free (ego->pk);
952 GNUNET_free (ego->name);
959 * Disconnect from identity service
961 * @param h handle to destroy
964 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
966 struct GNUNET_IDENTITY_Operation *op;
968 GNUNET_assert (NULL != h);
969 if (h->reconnect_task != NULL)
971 GNUNET_SCHEDULER_cancel (h->reconnect_task);
972 h->reconnect_task = NULL;
976 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
981 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
984 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
987 while (NULL != (op = h->op_head))
989 GNUNET_break (NULL == op->cont);
990 GNUNET_CONTAINER_DLL_remove (h->op_head,
995 if (NULL != h->client)
997 GNUNET_CLIENT_disconnect (h->client);
1003 /* end of identity_api.c */