-/**
- * Iterator over hash map entries.
- *
- * @param cls closure
- * @param key current key code
- * @param value value in the hash map
- * @return GNUNET_YES if we should continue to
- * iterate,
- * GNUNET_NO if not.
- */
-int
-ss_exists_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
-{
- struct SharedService *queried_ss = cls;
- struct SharedService *ss = value;
-
- if (0 == strcmp (ss->name, queried_ss->name))
- return GNUNET_NO;
- else
- return GNUNET_YES;
-}
-
-
-/**
- * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages
- *
- * @param cls NULL
- * @param client identification of the client
- * @param message the actual message
- */
-static void
-handle_configure_shared_service (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg;
- struct SharedService *ss;
- char *service_name;
- struct GNUNET_HashCode hash;
- uint16_t msg_size;
- uint16_t service_name_size;
-
- msg = (const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *) message;
- msg_size = ntohs (message->size);
- if (msg_size <= sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- service_name_size =
- msg_size - sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage);
- service_name = (char *) &msg[1];
- if ('\0' != service_name[service_name_size - 1])
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- LOG_DEBUG ("Received service sharing request for %s, with %d peers\n",
- service_name, ntohl (msg->num_peers));
- if (ntohl (msg->host_id) != GST_context->host_id)
- {
- route_message (ntohl (msg->host_id), message);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return;
- }
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- ss = GNUNET_malloc (sizeof (struct SharedService));
- ss->name = strdup (service_name);
- ss->num_shared = ntohl (msg->num_peers);
- GNUNET_CRYPTO_hash (ss->name, service_name_size, &hash);
- if (GNUNET_SYSERR ==
- GNUNET_CONTAINER_multihashmap_get_multiple (ss_map, &hash,
- &ss_exists_iterator, ss))
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Service %s already configured as a shared service. "
- "Ignoring service sharing request \n", ss->name);
- GNUNET_free (ss->name);
- GNUNET_free (ss);
- return;
- }
- GNUNET_CONTAINER_multihashmap_put (ss_map, &hash, ss,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-}
-
-