- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received GET_DEFAULT message from client\n");
- // setup_estimate_message (&em);
- // GNUNET_SERVER_notification_context_unicast (nc, client, &em.header, GNUNET_YES);
- GNUNET_break (0); // not implemented!
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ const struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
+ struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
+ uint16_t size;
+ uint16_t name_len;
+ struct Ego *ego;
+ const char *name;
+ char *identifier;
+
+ size = ntohs (message->size);
+ if (size <= sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ gdm = (const struct GNUNET_IDENTITY_GetDefaultMessage *) message;
+ name = (const char *) &gdm[1];
+ name_len = ntohs (gdm->name_len);
+ if ( (name_len + sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) != size) ||
+ (0 != ntohs (gdm->reserved)) ||
+ ('\0' != name[name_len - 1]) )
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received GET_DEFAULT for service `%s' from client\n",
+ name);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
+ name,
+ "DEFAULT_IDENTIFIER",
+ &identifier))
+ {
+ send_result_code (client, 1, gettext_noop ("no default known"));
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+ for (ego = ego_head; NULL != ego; ego = ego->next)
+ {
+ if (0 == strcmp (ego->identifier,
+ identifier))
+ {
+ sdm = create_set_default_message (ego,
+ name);
+ GNUNET_SERVER_notification_context_unicast (nc, client,
+ &sdm->header, GNUNET_NO);
+ GNUNET_free (sdm);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_free (identifier);
+ return;
+ }
+ }
+ GNUNET_free (identifier);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to find ego `%s'\n",
+ name);
+ send_result_code (client, 1,
+ gettext_noop ("default configured, but ego unknown (internal error)"));
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
+ * Compare the given two private keys for equality.
+ *
+ * @param pk1 one private key
+ * @param pk2 another private key
+ * @return 0 if the keys are equal
+ */
+static int
+key_cmp (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2)
+{
+ return memcmp (pk1, pk2, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));