- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received SET_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_SetDefaultMessage *sdm;
+ uint16_t size;
+ uint16_t name_len;
+ struct Ego *ego;
+ const char *str;
+
+ size = ntohs (message->size);
+ if (size <= sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message;
+ name_len = ntohs (sdm->name_len);
+ GNUNET_break (0 == ntohs (sdm->reserved));
+ if (name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ str = (const char *) &sdm[1];
+ if ('\0' != str[name_len - 1])
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received SET_DEFAULT for service `%s' from client\n",
+ str);
+ for (ego = ego_head; NULL != ego; ego = ego->next)
+ {
+ if (0 == key_cmp (ego->pk,
+ &sdm->private_key))
+ {
+ GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
+ str,
+ "DEFAULT_IDENTIFIER",
+ ego->identifier);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_write (subsystem_cfg,
+ subsystem_cfg_file))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to write subsystem default identifier map to `%s'.\n"),
+ subsystem_cfg_file);
+ send_result_code (client, 0, NULL);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+ }
+ send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);