+ if (GNUNET_YES == ntohs (um->end_of_list))
+ {
+ /* end of initial list of data */
+ if (NULL != h->cb)
+ h->cb (h->cb_cls,
+ NULL,
+ NULL,
+ NULL);
+ return;
+ }
+ GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key,
+ &pub);
+ GNUNET_CRYPTO_hash (&pub,
+ sizeof (pub),
+ &id);
+ ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
+ &id);
+ if (NULL == ego)
+ {
+ /* ego was created */
+ if (NULL == str)
+ {
+ /* deletion of unknown ego? not allowed */
+ GNUNET_break (0);
+ reschedule_connect (h);
+ return;
+ }
+ ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
+ ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
+ *ego->pk = um->private_key;
+ ego->name = GNUNET_strdup (str);
+ ego->id = id;
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_put (h->egos,
+ &ego->id,
+ ego,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ }
+ if (NULL == str)
+ {
+ /* ego was deleted */
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (h->egos,
+ &ego->id,
+ ego));
+ }
+ else
+ {
+ /* ego changed name */
+ GNUNET_free (ego->name);
+ ego->name = GNUNET_strdup (str);
+ }
+ /* inform application about change */
+ if (NULL != h->cb)
+ h->cb (h->cb_cls,
+ ego,
+ &ego->ctx,
+ str);
+ /* complete deletion */
+ if (NULL == str)
+ {
+ GNUNET_free (ego->pk);
+ GNUNET_free (ego->name);
+ GNUNET_free (ego);
+ }
+}
+
+
+/**
+ * Function called when we receive a set default message from the
+ * service.
+ *
+ * @param cls closure
+ * @param sdm message received
+ * @return #GNUNET_OK if the message is well-formed
+ */
+static int
+check_identity_set_default (void *cls,
+ const struct SetDefaultMessage *sdm)
+{
+ uint16_t size = ntohs (sdm->header.size) - sizeof (*sdm);
+ uint16_t name_len = ntohs (sdm->name_len);
+ const char *str = (const char *) &sdm[1];
+
+ if ( (size != name_len) ||
+ ( (0 != name_len) &&
+ ('\0' != str[name_len - 1]) ) )
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_break (0 == ntohs (sdm->reserved));
+ return GNUNET_OK;
+}
+
+
+/**
+ * Type of a function to call when we receive a message
+ * from the service.
+ *
+ * @param cls closure
+ * @param sdm message received
+ */
+static void
+handle_identity_set_default (void *cls,
+ const struct SetDefaultMessage *sdm)
+{
+ struct GNUNET_IDENTITY_Handle *h = cls;
+ struct GNUNET_IDENTITY_Operation *op;
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ struct GNUNET_HashCode id;
+ struct GNUNET_IDENTITY_Ego *ego;
+
+ GNUNET_CRYPTO_ecdsa_key_get_public (&sdm->private_key,
+ &pub);
+ GNUNET_CRYPTO_hash (&pub,
+ sizeof (pub),
+ &id);
+ ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
+ &id);
+ if (NULL == ego)
+ {
+ GNUNET_break (0);
+ reschedule_connect (h);
+ return;
+ }
+ op = h->op_head;
+ if (NULL == op)