struct Node *n = cls;
struct Experimentation_Request msg;
size_t msg_size = sizeof (msg);
- size_t ri_size = sizeof (struct Experimentation_Request_Issuer) * GSE_my_issuer_count;
+ size_t ri_size = sizeof (struct Experimentation_Issuer) * GSE_my_issuer_count;
size_t total_size = msg_size + ri_size;
memset (buf, '0', bufsize);
msg.capabilities = htonl (GSE_node_capabilities);
msg.issuer_count = htonl (GSE_my_issuer_count);
memcpy (buf, &msg, msg_size);
- memcpy (&buf[msg_size], GSE_my_issuer, ri_size);
+ memcpy (&((char *) buf)[msg_size], GSE_my_issuer, ri_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending request to peer %s\n"),
GNUNET_i2s (&n->id));
c_issuers = GSE_my_issuer_count;
size = sizeof (struct Experimentation_Request) +
- c_issuers * sizeof (struct Experimentation_Request_Issuer);
+ c_issuers * sizeof (struct Experimentation_Issuer);
n = GNUNET_malloc (sizeof (struct Node));
n->id = *peer;
n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n);
{
struct Node *n = cls;
struct Experimentation_Response msg;
- size_t size = sizeof (msg);
+ size_t ri_size = GSE_my_issuer_count * sizeof (struct Experimentation_Issuer);
+ size_t msg_size = sizeof (msg);
+ size_t total_size = msg_size + ri_size;
n->cth = NULL;
if (buf == NULL)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected\n");
return 0;
}
- GNUNET_assert (bufsize >= size);
+ GNUNET_assert (bufsize >= total_size);
- msg.msg.size = htons (size);
+ msg.msg.size = htons (total_size);
msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE);
msg.capabilities = htonl (GSE_node_capabilities);
- memcpy (buf, &msg, size);
+ msg.issuer_count = htonl (GSE_my_issuer_count);
+ memcpy (buf, &msg, msg_size);
+ memcpy (&((char *) buf)[msg_size], GSE_my_issuer, ri_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending response to peer %s\n"),
GNUNET_i2s (&n->id));
- return size;
+ return total_size;
}
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Scheduling experiment `%s' for peer %s\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting experiment `%s' with peer %s\n"),
+ e->name,
GNUNET_i2s (&n->id));
- GNUNET_EXPERIMENTATION_scheduler_add (e);
+
+ /* Request experiment */
+ GNUNET_EXPERIMENTATION_scheduler_add (n, e);
+
counter ++;
}
/* Request experiments for this node to start them */
for (c1 = 0; c1 < n->issuer_count; c1++)
+ {
+
GNUNET_EXPERIMENTATION_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb);
+ }
}
{
struct Node *n;
struct Experimentation_Request *rm = (struct Experimentation_Request *) message;
- struct Experimentation_Request_Issuer *rmi = (struct Experimentation_Request_Issuer *) &rm[1];
+ struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1];
int c1;
int c2;
uint32_t ic;
return;
}
ic = ntohl (rm->issuer_count);
- if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Request_Issuer))
+ if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer))
{
GNUNET_break (0);
return;
n->cth = NULL;
}
update_stats (nodes_requested);
- node_make_active (n);
+ make_active = GNUNET_YES;
}
else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey)))
{
n = GNUNET_malloc (sizeof (struct Node));
n->id = *peer;
n->capabilities = NONE;
- node_make_active (n);
+ make_active = GNUNET_YES;
}
/* Update node */
/* Send response */
n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0,
GNUNET_TIME_relative_get_forever_(),
- peer, sizeof (struct Experimentation_Response),
+ peer,
+ sizeof (struct Experimentation_Response) +
+ GSE_my_issuer_count * sizeof (struct Experimentation_Issuer),
send_response_cb, n);
}
const struct GNUNET_MessageHeader *message)
{
struct Node *n;
- struct Experimentation_Request *rm = (struct Experimentation_Request *) message;
+ struct Experimentation_Response *rm = (struct Experimentation_Response *) message;
+ struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1];
+ uint32_t ic;
+ uint32_t ic_accepted;
+ int make_active;
+ unsigned int c1;
+ unsigned int c2;
+
+ if (ntohs (message->size) < sizeof (struct Experimentation_Response))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ ic = ntohl (rm->issuer_count);
+ if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer))
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ make_active = GNUNET_NO;
if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_active, &peer->hashPubKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"),
"RESPONSE", "active", GNUNET_i2s (peer));
- n->capabilities = ntohl (rm->capabilities);
}
else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_requested, &peer->hashPubKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"),
"RESPONSE", "requested", GNUNET_i2s (peer));
- n->capabilities = ntohl (rm->capabilities);
GNUNET_CONTAINER_multihashmap_remove (nodes_requested, &peer->hashPubKey, n);
if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task)
{
n->cth = NULL;
}
update_stats (nodes_requested);
- node_make_active (n);
+ make_active = GNUNET_YES;
}
else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from peer `%s'\n"),
"RESPONSE", "inactive", GNUNET_i2s (peer));
- n->capabilities = ntohl (rm->capabilities);
GNUNET_CONTAINER_multihashmap_remove (nodes_inactive, &peer->hashPubKey, n);
update_stats (nodes_inactive);
- node_make_active (n);
+ make_active = GNUNET_YES;
}
else
{
"RESPONSE", "unknown", GNUNET_i2s (peer));
return;
}
+
+ /* Update */
+ n->capabilities = ntohl (rm->capabilities);
+
+ /* Filter accepted issuer */
+ ic_accepted = 0;
+ for (c1 = 0; c1 < ic; c1++)
+ {
+ if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ ic_accepted ++;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Response from peer `%s' with %u issuers, we accepted %u issuer \n"),
+ GNUNET_i2s (peer), ic, ic_accepted);
+ GNUNET_free_non_null (n->issuer_id);
+ n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity));
+ c2 = 0;
+ for (c1 = 0; c1 < ic; c1++)
+ {
+ if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ {
+ n->issuer_id[c2] = rmi[c1].issuer_id;
+ c2 ++;
+ }
+ }
+ n->issuer_count = ic_accepted;
+
+ if (GNUNET_YES == make_active)
+ node_make_active (n);
}
/**
}
+void
+GNUNET_EXPERIMENT_nodes_request_start (struct Node *n, struct Experiment *e)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending start request to peer `%s' for experiment `%s'\n"),
+ GNUNET_i2s(&n->id), e->name);
+}
+
/**
* Start the nodes management