2 This file is part of GNUnet.
3 (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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, 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_EccPrivateKey *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; '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 ('cont' will be NULL in this case).
99 GNUNET_IDENTITY_Callback cb;
102 * Closure for 'cont' or '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 GNUNET_SCHEDULER_TaskIdentifier 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_EccPublicSignKey pub;
186 anon.pk = (struct GNUNET_CRYPTO_EccPrivateKey *) GNUNET_CRYPTO_ecc_key_get_anonymous ();
187 GNUNET_CRYPTO_ecc_key_get_public_for_signature (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 == GNUNET_SCHEDULER_NO_TASK);
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_EccPublicSignKey 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_ecc_key_get_public_for_signature (&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_EccPrivateKey);
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_ecc_key_get_public_for_signature (&sdm->private_key,
411 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
412 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
417 reschedule_connect (h);
421 GNUNET_CONTAINER_DLL_remove (h->op_head,
424 GNUNET_CLIENT_receive (h->client, &message_handler, h,
425 GNUNET_TIME_UNIT_FOREVER_REL);
435 reschedule_connect (h);
442 * Schedule transmission of the next message from our queue.
444 * @param h identity handle
447 transmit_next (struct GNUNET_IDENTITY_Handle *h);
451 * Transmit next message to service.
453 * @param cls the `struct GNUNET_IDENTITY_Handle`.
454 * @param size number of bytes available in @a buf
455 * @param buf where to copy the message
456 * @return number of bytes copied to buf
459 send_next_message (void *cls,
463 struct GNUNET_IDENTITY_Handle *h = cls;
464 struct GNUNET_IDENTITY_Operation *op = h->op_head;
470 ret = ntohs (op->msg->size);
473 reschedule_connect (h);
476 LOG (GNUNET_ERROR_TYPE_DEBUG,
477 "Sending message of type %d to identity service\n",
478 ntohs (op->msg->type));
479 memcpy (buf, op->msg, ret);
480 if ( (NULL == op->cont) &&
483 GNUNET_CONTAINER_DLL_remove (h->op_head,
489 if (GNUNET_NO == h->in_receive)
491 h->in_receive = GNUNET_YES;
492 GNUNET_CLIENT_receive (h->client,
494 GNUNET_TIME_UNIT_FOREVER_REL);
501 * Schedule transmission of the next message from our queue.
503 * @param h identity handle
506 transmit_next (struct GNUNET_IDENTITY_Handle *h)
508 struct GNUNET_IDENTITY_Operation *op = h->op_head;
510 GNUNET_assert (NULL == h->th);
513 if (NULL == h->client)
515 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
516 ntohs (op->msg->size),
517 GNUNET_TIME_UNIT_FOREVER_REL,
525 * Try again to connect to the identity service.
527 * @param cls handle to the identity service.
528 * @param tc scheduler context
531 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
533 struct GNUNET_IDENTITY_Handle *h = cls;
534 struct GNUNET_IDENTITY_Operation *op;
535 struct GNUNET_MessageHeader msg;
537 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
538 LOG (GNUNET_ERROR_TYPE_DEBUG,
539 "Connecting to identity service.\n");
540 GNUNET_assert (NULL == h->client);
541 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
542 GNUNET_assert (NULL != h->client);
543 if ( (NULL == h->op_head) ||
544 (GNUNET_MESSAGE_TYPE_IDENTITY_START != ntohs (h->op_head->msg->type)) )
546 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
547 sizeof (struct GNUNET_MessageHeader));
549 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
550 msg.size = htons (sizeof (msg));
551 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
552 memcpy (&op[1], &msg, sizeof (msg));
553 GNUNET_CONTAINER_DLL_insert (h->op_head,
558 GNUNET_assert (NULL != h->th);
563 * Connect to the identity service.
565 * @param cfg the configuration to use
566 * @param cb function to call on all identity events, can be NULL
567 * @param cb_cls closure for @a cb
568 * @return handle to use
570 struct GNUNET_IDENTITY_Handle *
571 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
572 GNUNET_IDENTITY_Callback cb,
575 struct GNUNET_IDENTITY_Handle *h;
577 h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
581 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
582 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
583 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
589 * Obtain the ECC key associated with a ego.
592 * @return associated ECC key, valid as long as the ego is valid
594 const struct GNUNET_CRYPTO_EccPrivateKey *
595 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
602 * Get the identifier (public key) of an ego.
604 * @param ego identity handle with the private key
605 * @param pk set to ego's public key
608 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
609 struct GNUNET_CRYPTO_EccPublicSignKey *pk)
611 GNUNET_CRYPTO_ecc_key_get_public_for_signature (ego->pk,
617 * Obtain the identity that is currently preferred/default
620 * @param id identity service to query
621 * @param service_name for which service is an identity wanted
622 * @param cb function to call with the result (will only be called once)
623 * @param cb_cls closure for @a cb
624 * @return handle to abort the operation
626 struct GNUNET_IDENTITY_Operation *
627 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
628 const char *service_name,
629 GNUNET_IDENTITY_Callback cb,
632 struct GNUNET_IDENTITY_Operation *op;
633 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
636 slen = strlen (service_name) + 1;
637 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
642 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
643 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
648 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
649 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
650 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
652 gdm->name_len = htons (slen);
653 gdm->reserved = htons (0);
654 memcpy (&gdm[1], service_name, slen);
655 op->msg = &gdm->header;
656 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
666 * Set the preferred/default identity for a service.
668 * @param id identity service to inform
669 * @param service_name for which service is an identity set
670 * @param ego new default identity to be set for this service
671 * @param cont function to call once the operation finished
672 * @param cont_cls closure for @a cont
673 * @return handle to abort the operation
675 struct GNUNET_IDENTITY_Operation *
676 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
677 const char *service_name,
678 struct GNUNET_IDENTITY_Ego *ego,
679 GNUNET_IDENTITY_Continuation cont,
682 struct GNUNET_IDENTITY_Operation *op;
683 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
686 slen = strlen (service_name) + 1;
687 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
692 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
693 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
698 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
699 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
700 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
702 sdm->name_len = htons (slen);
703 sdm->reserved = htons (0);
704 sdm->private_key = *ego->pk;
705 memcpy (&sdm[1], service_name, slen);
706 op->msg = &sdm->header;
707 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
717 * Create a new identity with the given name.
719 * @param id identity service to use
720 * @param name desired name
721 * @param cont function to call with the result (will only be called once)
722 * @param cont_cls closure for @a cont
723 * @return handle to abort the operation
725 struct GNUNET_IDENTITY_Operation *
726 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
728 GNUNET_IDENTITY_Continuation cont,
731 struct GNUNET_IDENTITY_Operation *op;
732 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
733 struct GNUNET_CRYPTO_EccPrivateKey *pk;
736 slen = strlen (name) + 1;
737 pk = GNUNET_CRYPTO_ecc_key_create ();
739 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
745 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
746 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
751 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
752 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
753 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
755 crm->name_len = htons (slen);
756 crm->reserved = htons (0);
757 crm->private_key = *pk;
758 memcpy (&crm[1], name, slen);
759 op->msg = &crm->header;
760 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
771 * Renames an existing identity.
773 * @param id identity service to use
774 * @param old_name old name
775 * @param new_name desired new name
776 * @param cb function to call with the result (will only be called once)
777 * @param cb_cls closure for @a cb
778 * @return handle to abort the operation
780 struct GNUNET_IDENTITY_Operation *
781 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
782 const char *old_name,
783 const char *new_name,
784 GNUNET_IDENTITY_Continuation cb,
787 struct GNUNET_IDENTITY_Operation *op;
788 struct GNUNET_IDENTITY_RenameMessage *grm;
793 slen_old = strlen (old_name) + 1;
794 slen_new = strlen (new_name) + 1;
795 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
796 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
797 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
802 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
803 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
804 slen_old + slen_new);
808 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
809 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
810 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
811 slen_old + slen_new);
812 grm->old_name_len = htons (slen_old);
813 grm->new_name_len = htons (slen_new);
814 dst = (char *) &grm[1];
815 memcpy (dst, old_name, slen_old);
816 memcpy (&dst[slen_old], new_name, slen_new);
817 op->msg = &grm->header;
818 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
828 * Delete an existing identity.
830 * @param id identity service to use
831 * @param name name of the identity to delete
832 * @param cb function to call with the result (will only be called once)
833 * @param cb_cls closure for @a cb
834 * @return handle to abort the operation
836 struct GNUNET_IDENTITY_Operation *
837 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
839 GNUNET_IDENTITY_Continuation cb,
842 struct GNUNET_IDENTITY_Operation *op;
843 struct GNUNET_IDENTITY_DeleteMessage *gdm;
846 slen = strlen (name) + 1;
847 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
852 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
853 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
858 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
859 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
860 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
862 gdm->name_len = htons (slen);
863 gdm->reserved = htons (0);
864 memcpy (&gdm[1], name, slen);
865 op->msg = &gdm->header;
866 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
876 * Cancel an identity operation. Note that the operation MAY still
877 * be executed; this merely cancels the continuation; if the request
878 * was already transmitted, the service may still choose to complete
881 * @param op operation to cancel
884 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
886 struct GNUNET_IDENTITY_Handle *h = op->h;
888 if ( (h->op_head != op) ||
889 (NULL == h->client) )
891 /* request not active, can simply remove */
892 GNUNET_CONTAINER_DLL_remove (h->op_head,
900 /* request active but not yet with service, can still abort */
901 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
903 GNUNET_CONTAINER_DLL_remove (h->op_head,
910 /* request active with service, simply ensure continuations are not called */
917 * Free ego from hash map.
919 * @param cls identity service handle
921 * @param value ego to free
922 * @return #GNUNET_OK (continue to iterate)
926 const struct GNUNET_HashCode *key,
929 struct GNUNET_IDENTITY_Handle *h = cls;
930 struct GNUNET_IDENTITY_Ego *ego = value;
937 GNUNET_free (ego->pk);
938 GNUNET_free (ego->name);
945 * Disconnect from identity service
947 * @param h handle to destroy
950 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
952 struct GNUNET_IDENTITY_Operation *op;
954 GNUNET_assert (NULL != h);
955 while (NULL != (op = h->op_head))
958 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
959 GNUNET_CONTAINER_DLL_remove (h->op_head,
964 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
966 GNUNET_SCHEDULER_cancel (h->reconnect_task);
967 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
971 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
976 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
979 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
982 if (NULL != h->client)
984 GNUNET_CLIENT_disconnect (h->client);
990 /* end of identity_api.c */