- op = h->op_head;
- GNUNET_CONTAINER_DLL_remove (h->op_head,
- h->op_tail,
- op);
- if (NULL != op->cont)
- op->cont (op->cls,
- str);
- else if (NULL != op->cb)
- op->cb (op->cls, NULL, NULL, NULL);
- GNUNET_free (op);
- break;
- case GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE:
- if (size < sizeof (struct GNUNET_IDENTITY_UpdateMessage))
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
- pk_len = ntohs (um->pk_len);
- name_len = ntohs (um->name_len);
- str = (const char *) &um[1];
- if ( (size != pk_len + name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
- ( (0 != name_len) &&
- ('\0' != str[pk_len + name_len - 1])) )
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- if ( (0 == pk_len) &&
- (0 == name_len) )
- {
- /* end of initial list of data */
- if (NULL != h->cb)
- h->cb (h->cb_cls, NULL, NULL, NULL);
- return;
- }
- priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES);
- if (NULL == priv)
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- GNUNET_CRYPTO_ecc_key_get_public (priv,
- &pub);
- GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
- if (0 == name_len)
- str = NULL;
- else
- str = &str[pk_len];
- 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 */
+
+/**
+ * Handle identity update message.
+ *
+ * @param cls closure
+ * @param um message received
+ */
+static void
+handle_identity_update (void *cls,
+ const struct UpdateMessage *um)
+{
+ struct GNUNET_IDENTITY_Handle *h = cls;
+ uint16_t name_len = ntohs (um->name_len);
+ const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ struct GNUNET_HashCode id;
+ struct GNUNET_IDENTITY_Ego *ego;
+
+ if (GNUNET_YES == ntohs (um->end_of_list))
+ {
+ /* end of initial list of data */