- 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);
- GNUNET_CRYPTO_ecc_key_free (priv);
- reschedule_connect (h);
- return;
- }
- ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
- ego->pk = priv;
- ego->identifier = GNUNET_strdup (str);
- ego->id = id;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_put (h->egos,
- &ego->id,
- ego,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- }
- else
- {
- GNUNET_CRYPTO_ecc_key_free (priv);
- }
- /* inform application about change */
- h->cb (h->cb_cls,
- ego,
- &ego->ctx,
- str);
- if (NULL == str)
- {
- /* ego was deleted */
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (h->egos,
- &ego->id,
- ego));
- GNUNET_CRYPTO_ecc_key_free (ego->pk);
- GNUNET_free (ego->identifier);
- GNUNET_free (ego);
- }
- else
- {
- /* ego changed name */
- GNUNET_free (ego->identifier);
- ego->identifier = GNUNET_strdup (str);
- }
- break;
- case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT:
- if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
- str = (const char *) &sdm[1];
- if ( (size > sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) &&
- ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) - 1]) )
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- if (size == sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
- str = NULL;
- // FIXME: sdr->pk does NOT work!
- priv = GNUNET_CRYPTO_ecc_decode_key (NULL, 0, GNUNET_YES); // FIXME...
- if (NULL == priv)
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- GNUNET_CRYPTO_ecc_key_get_public (priv,
- &pub);
- GNUNET_CRYPTO_ecc_key_free (priv);
- 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;
- GNUNET_CONTAINER_DLL_remove (h->op_head,
- h->op_tail,
- op);
- if (NULL != op->cb)
- op->cb (op->cls,
- ego,
- &ego->ctx,
- ego->identifier);
- GNUNET_break (NULL == op->cont);
- GNUNET_free (op);
- break;
- default: