#include <zlib.h>
+/***********/
+/* Globals */
+/***********/
+
+/**
+ * Our configuration
+ */
+struct GNUNET_CONFIGURATION_Handle *our_config;
+
+/**
+ * The master context; generated with the first INIT message
+ */
+struct Context *GST_context;
+
+/**
+ * A list of directly linked neighbours
+ */
+struct Slave **GST_slave_list;
+
+/**
+ * A list of peers we know about
+ */
+struct Peer **GST_peer_list;
+
+/**
+ * Array of hosts
+ */
+struct GNUNET_TESTBED_Host **GST_host_list;
+
+/**
+ * DLL head for forwarded operation contexts
+ */
+struct ForwardedOperationContext *fopcq_head;
+
+/**
+ * DLL tail for forwarded operation contexts
+ */
+struct ForwardedOperationContext *fopcq_tail;
+
+/**
+ * Operation queue for open file descriptors
+ */
+struct OperationQueue *GST_opq_openfds;
+
+/**
+ * Timeout for operations which may take some time
+ */
+const struct GNUNET_TIME_Relative GST_timeout;
+
+/**
+ * The size of the host list
+ */
+unsigned int GST_host_list_size;
+
+/**
+ * The size of directly linked neighbours list
+ */
+unsigned int GST_slave_list_size;
+
+/**
+ * The size of the peer list
+ */
+unsigned int GST_peer_list_size;
+
+
+/***********************************/
+/* Local definitions and variables */
+/***********************************/
+
/**
* The message queue for sending messages to clients
*/
struct MessageQueue *prev;
};
-
-/**
- * The master context; generated with the first INIT message
- */
-struct Context *TESTBED_context;
-
/**
* Our hostname; we give this to all the peers we start
*/
static char *hostname;
-
-/***********/
-/* Handles */
-/***********/
-
-/**
- * Our configuration
- */
-struct GNUNET_CONFIGURATION_Handle *our_config;
-
/**
* Current Transmit Handle; NULL if no notify transmit exists currently
*/
static struct GNUNET_SERVER_TransmitHandle *transmit_handle;
-/****************/
-/* Lists & Maps */
-/****************/
-
/**
* The head for the LCF queue
*/
static struct MessageQueue *mq_tail;
/**
- * DLL head for forwarded operation contexts
- */
-struct ForwardedOperationContext *fopcq_head;
-
-/**
- * DLL tail for forwarded operation contexts
- */
-struct ForwardedOperationContext *fopcq_tail;
-
-/**
- * Array of hosts
+ * The hashmap of shared services
*/
-struct GNUNET_TESTBED_Host **TESTBED_host_list;
+static struct GNUNET_CONTAINER_MultiHashMap *ss_map;
/**
* A list of routes
*/
static struct Route **route_list;
-/**
- * A list of directly linked neighbours
- */
-struct Slave **TESTBED_slave_list;
-
-/**
- * A list of peers we know about
- */
-struct Peer **TESTBED_peer_list;
-
-/**
- * The hashmap of shared services
- */
-static struct GNUNET_CONTAINER_MultiHashMap *ss_map;
-
/**
* The event mask for the events we listen from sub-controllers
*/
static uint64_t event_mask;
-/**
- * The size of the host list
- */
-unsigned int TESTBED_host_list_size;
-
/**
* The size of the route list
*/
static unsigned int route_list_size;
-/**
- * The size of directly linked neighbours list
- */
-unsigned int TESTBED_slave_list_size;
-
-/**
- * The size of the peer list
- */
-unsigned int TESTBED_peer_list_size;
-
-/*********/
-/* Tasks */
-/*********/
-
/**
* The lcf_task handle
*/
* @param msg the message to queue
*/
void
-TESTBED_queue_message (struct GNUNET_SERVER_Client *client,
- struct GNUNET_MessageHeader *msg)
+GST_queue_message (struct GNUNET_SERVER_Client *client,
+ struct GNUNET_MessageHeader *msg)
{
struct MessageQueue *mq_entry;
uint16_t type;
uint32_t host_id;
host_id = GNUNET_TESTBED_host_get_id_ (host);
- if (TESTBED_host_list_size <= host_id)
- array_grow_large_enough (TESTBED_host_list, TESTBED_host_list_size, host_id);
- if (NULL != TESTBED_host_list[host_id])
+ if (GST_host_list_size <= host_id)
+ array_grow_large_enough (GST_host_list, GST_host_list_size, host_id);
+ if (NULL != GST_host_list[host_id])
{
LOG_DEBUG ("A host with id: %u already exists\n", host_id);
return GNUNET_SYSERR;
}
- TESTBED_host_list[host_id] = host;
+ GST_host_list[host_id] = host;
return GNUNET_OK;
}
static void
slave_list_add (struct Slave *slave)
{
- if (slave->host_id >= TESTBED_slave_list_size)
- array_grow_large_enough (TESTBED_slave_list, TESTBED_slave_list_size, slave->host_id);
- GNUNET_assert (NULL == TESTBED_slave_list[slave->host_id]);
- TESTBED_slave_list[slave->host_id] = slave;
+ if (slave->host_id >= GST_slave_list_size)
+ array_grow_large_enough (GST_slave_list, GST_slave_list_size,
+ slave->host_id);
+ GNUNET_assert (NULL == GST_slave_list[slave->host_id]);
+ GST_slave_list[slave->host_id] = slave;
}
static void
peer_list_add (struct Peer *peer)
{
- if (peer->id >= TESTBED_peer_list_size)
- array_grow_large_enough (TESTBED_peer_list, TESTBED_peer_list_size, peer->id);
- GNUNET_assert (NULL == TESTBED_peer_list[peer->id]);
- TESTBED_peer_list[peer->id] = peer;
+ if (peer->id >= GST_peer_list_size)
+ array_grow_large_enough (GST_peer_list, GST_peer_list_size, peer->id);
+ GNUNET_assert (NULL == GST_peer_list[peer->id]);
+ GST_peer_list[peer->id] = peer;
}
unsigned int orig_size;
uint32_t id;
- TESTBED_peer_list[peer->id] = NULL;
- orig_size = TESTBED_peer_list_size;
- while (TESTBED_peer_list_size >= LIST_GROW_STEP)
+ GST_peer_list[peer->id] = NULL;
+ orig_size = GST_peer_list_size;
+ while (GST_peer_list_size >= LIST_GROW_STEP)
{
- for (id = TESTBED_peer_list_size - 1;
- (id >= TESTBED_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX); id--)
- if (NULL != TESTBED_peer_list[id])
+ for (id = GST_peer_list_size - 1;
+ (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX);
+ id--)
+ if (NULL != GST_peer_list[id])
break;
- if (id != ((TESTBED_peer_list_size - LIST_GROW_STEP) - 1))
+ if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1))
break;
- TESTBED_peer_list_size -= LIST_GROW_STEP;
+ GST_peer_list_size -= LIST_GROW_STEP;
}
- if (orig_size == TESTBED_peer_list_size)
+ if (orig_size == GST_peer_list_size)
return;
- TESTBED_peer_list =
- GNUNET_realloc (TESTBED_peer_list, sizeof (struct Peer *) * TESTBED_peer_list_size);
+ GST_peer_list =
+ GNUNET_realloc (GST_peer_list,
+ sizeof (struct Peer *) * GST_peer_list_size);
}
* is found
*/
struct Route *
-TESTBED_find_dest_route (uint32_t host_id)
+GST_find_dest_route (uint32_t host_id)
{
struct Route *route;
return NULL;
while (NULL != (route = route_list[host_id]))
{
- if (route->thru == TESTBED_context->host_id)
+ if (route->thru == GST_context->host_id)
break;
host_id = route->thru;
}
* @param emsg the error message; can be NULL
*/
void
-TESTBED_send_operation_fail_msg (struct GNUNET_SERVER_Client *client,
- uint64_t operation_id, const char *emsg)
+GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client,
+ uint64_t operation_id, const char *emsg)
{
struct GNUNET_TESTBED_OperationFailureEventMessage *msg;
uint16_t msize;
msize += emsg_len;
msg = GNUNET_malloc (msize);
msg->header.size = htons (msize);
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT);
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT);
msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
msg->operation_id = GNUNET_htonll (operation_id);
if (0 != emsg_len)
memcpy (&msg[1], emsg, emsg_len);
- TESTBED_queue_message (client, &msg->header);
+ GST_queue_message (client, &msg->header);
}
msize = sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage);
msg = GNUNET_malloc (msize);
msg->header.size = htons (msize);
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS);
+ msg->header.type =
+ htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS);
msg->operation_id = GNUNET_htonll (operation_id);
msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
- TESTBED_queue_message (client, &msg->header);
+ GST_queue_message (client, &msg->header);
}
* @param cls the handle to the slave at which the registration is completed
* @param emsg the error message; NULL if host registration is successful
*/
-static void
+static void
hr_completion (void *cls, const char *emsg);
register_next_host (struct Slave *slave)
{
struct HostRegistration *hr;
-
+
hr = slave->hr_dll_head;
GNUNET_assert (NULL != hr);
GNUNET_assert (NULL == slave->rhandle);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Registering host %u at %u\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u\n",
GNUNET_TESTBED_host_get_id_ (hr->host),
- GNUNET_TESTBED_host_get_id_ (TESTBED_host_list[slave->host_id]));
- slave->rhandle = GNUNET_TESTBED_register_host (slave->controller,
- hr->host,
- hr_completion,
- slave);
+ GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id]));
+ slave->rhandle =
+ GNUNET_TESTBED_register_host (slave->controller, hr->host, hr_completion,
+ slave);
}
* @param cls the handle to the slave at which the registration is completed
* @param emsg the error message; NULL if host registration is successful
*/
-static void
+static void
hr_completion (void *cls, const char *emsg)
{
struct Slave *slave = cls;
slave->rhandle = NULL;
hr = slave->hr_dll_head;
GNUNET_assert (NULL != hr);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Registering host %u at %u successful\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u successful\n",
GNUNET_TESTBED_host_get_id_ (hr->host),
- GNUNET_TESTBED_host_get_id_ (TESTBED_host_list[slave->host_id]));
- GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head,
- slave->hr_dll_tail,
- hr);
+ GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id]));
+ GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head, slave->hr_dll_tail, hr);
if (NULL != hr->cb)
hr->cb (hr->cb_cls, emsg);
GNUNET_free (hr);
* Adds a host registration's request to a slave's registration queue
*
* @param slave the slave controller at which the given host has to be
- * registered
+ * registered
* @param cb the host registration completion callback
* @param cb_cls the closure for the host registration completion callback
* @param host the host which has to be registered
*/
void
-TESTBED_queue_host_registration (struct Slave *slave,
- GNUNET_TESTBED_HostRegistrationCompletion cb,
- void *cb_cls,
- struct GNUNET_TESTBED_Host *host)
+GST_queue_host_registration (struct Slave *slave,
+ GNUNET_TESTBED_HostRegistrationCompletion cb,
+ void *cb_cls, struct GNUNET_TESTBED_Host *host)
{
struct HostRegistration *hr;
int call_register;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Queueing host registration for host %u at %u\n",
GNUNET_TESTBED_host_get_id_ (host),
- GNUNET_TESTBED_host_get_id_ (TESTBED_host_list[slave->host_id]));
+ GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id]));
hr = GNUNET_malloc (sizeof (struct HostRegistration));
hr->cb = cb;
hr->cb_cls = cb_cls;
hr->host = host;
call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
- GNUNET_CONTAINER_DLL_insert_tail (slave->hr_dll_head,
- slave->hr_dll_tail,
- hr);
+ GNUNET_CONTAINER_DLL_insert_tail (slave->hr_dll_head, slave->hr_dll_tail, hr);
if (GNUNET_YES == call_register)
register_next_host (slave);
}
}
return;
- registration_error:
+registration_error:
LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n",
emsg);
lcf->state = FINISHED;
* @param msg the message to relay
*/
void
-TESTBED_forwarded_operation_reply_relay (void *cls,
- const struct GNUNET_MessageHeader *msg)
+GST_forwarded_operation_reply_relay (void *cls,
+ const struct GNUNET_MessageHeader *msg)
{
struct ForwardedOperationContext *fopc = cls;
struct GNUNET_MessageHeader *dup_msg;
LOG_DEBUG ("Relaying message with type: %u, size: %u\n", ntohs (msg->type),
msize);
dup_msg = GNUNET_copy_message (msg);
- TESTBED_queue_message (fopc->client, dup_msg);
+ GST_queue_message (fopc->client, dup_msg);
GNUNET_SERVER_client_drop (fopc->client);
GNUNET_SCHEDULER_cancel (fopc->timeout_task);
GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fopc);
* @param tc the task context from scheduler
*/
void
-TESTBED_forwarded_operation_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+GST_forwarded_operation_timeout (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ForwardedOperationContext *fopc = cls;
GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc);
LOG (GNUNET_ERROR_TYPE_WARNING, "A forwarded operation has timed out\n");
- TESTBED_send_operation_fail_msg (fopc->client, fopc->operation_id, "Timeout");
+ GST_send_operation_fail_msg (fopc->client, fopc->operation_id, "Timeout");
GNUNET_SERVER_client_drop (fopc->client);
GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fopc);
GNUNET_free (fopc);
struct LCFContext *lcf = cls;
GNUNET_assert (NULL != lcf->fopc);
- TESTBED_forwarded_operation_reply_relay (lcf->fopc, msg);
+ GST_forwarded_operation_reply_relay (lcf->fopc, msg);
lcf->fopc = NULL;
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
GNUNET_assert (NULL != lcf->fopc);
lcf->fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- TESTBED_forwarded_operation_timeout (lcf->fopc, tc);
+ GST_forwarded_operation_timeout (lcf->fopc, tc);
lcf->fopc = NULL;
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
{
case INIT:
if (GNUNET_NO ==
- GNUNET_TESTBED_is_host_registered_ (TESTBED_host_list[lcf->delegated_host_id],
+ GNUNET_TESTBED_is_host_registered_ (GST_host_list
+ [lcf->delegated_host_id],
lcf->gateway->controller))
{
- TESTBED_queue_host_registration (lcf->gateway,
- lcf_proc_cc, lcf,
- TESTBED_host_list[lcf->delegated_host_id]);
+ GST_queue_host_registration (lcf->gateway, lcf_proc_cc, lcf,
+ GST_host_list[lcf->delegated_host_id]);
}
else
{
break;
case DELEGATED_HOST_REGISTERED:
if (GNUNET_NO ==
- GNUNET_TESTBED_is_host_registered_ (TESTBED_host_list[lcf->slave_host_id],
+ GNUNET_TESTBED_is_host_registered_ (GST_host_list[lcf->slave_host_id],
lcf->gateway->controller))
{
- TESTBED_queue_host_registration (lcf->gateway,
- lcf_proc_cc, lcf,
- TESTBED_host_list[lcf->slave_host_id]);
+ GST_queue_host_registration (lcf->gateway, lcf_proc_cc, lcf,
+ GST_host_list[lcf->slave_host_id]);
}
else
{
&lcf_forwarded_operation_reply_relay,
lcf);
lcf->fopc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &lcf_forwarded_operation_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &lcf_forwarded_operation_timeout,
lcf);
GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, lcf->fopc);
lcf->state = FINISHED;
struct RegisteredHostContext *rhc;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TESTBED_Operation *old_op;
-
+
/* We currently only get here when working on RegisteredHostContexts */
GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type);
rhc = event->details.operation_finished.op_cls;
old_op = rhc->sub_op;
rhc->state = RHC_LINK;
rhc->sub_op =
- GNUNET_TESTBED_controller_link (rhc,
- rhc->gateway->controller,
- rhc->reg_host,
- rhc->host,
- cfg,
+ GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
+ rhc->reg_host, rhc->host, cfg,
GNUNET_NO);
GNUNET_TESTBED_operation_done (old_op);
break;
GNUNET_TESTBED_operation_done (rhc->sub_op);
rhc->sub_op = NULL;
rhc->state = RHC_OL_CONNECT;
- TESTBED_process_next_focc (rhc);
+ GST_process_next_focc (rhc);
break;
default:
GNUNET_assert (0);
if (GNUNET_SYSERR == status)
{
slave->controller_proc = NULL;
- TESTBED_slave_list[slave->host_id] = NULL;
+ GST_slave_list[slave->host_id] = NULL;
if (NULL != slave->cfg)
GNUNET_CONFIGURATION_destroy (slave->cfg);
GNUNET_free (slave);
goto clean_lcc;
}
slave->controller =
- GNUNET_TESTBED_controller_connect (cfg, TESTBED_host_list[slave->host_id],
- event_mask,
- &slave_event_callback, slave);
+ GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id],
+ event_mask, &slave_event_callback,
+ slave);
if (NULL != slave->controller)
{
send_operation_success_msg (lcc->client, lcc->operation_id);
}
else
{
- TESTBED_send_operation_fail_msg (lcc->client, lcc->operation_id,
- "Could not connect to delegated controller");
+ GST_send_operation_fail_msg (lcc->client, lcc->operation_id,
+ "Could not connect to delegated controller");
GNUNET_TESTBED_controller_stop (slave->controller_proc);
- TESTBED_slave_list[slave->host_id] = NULL;
+ GST_slave_list[slave->host_id] = NULL;
GNUNET_free (slave);
slave = NULL;
}
- clean_lcc:
+clean_lcc:
if (NULL != lcc)
{
if (NULL != lcc->client)
const char *controller_hostname;
uint16_t msize;
- if (NULL != TESTBED_context)
+ if (NULL != GST_context)
{
LOG_DEBUG ("We are being connected to laterally\n");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- TESTBED_context = GNUNET_malloc (sizeof (struct Context));
+ GST_context = GNUNET_malloc (sizeof (struct Context));
GNUNET_SERVER_client_keep (client);
- TESTBED_context->client = client;
- TESTBED_context->host_id = ntohl (msg->host_id);
- TESTBED_context->master_ip = GNUNET_strdup (controller_hostname);
- LOG_DEBUG ("Our IP: %s\n", TESTBED_context->master_ip);
- TESTBED_context->system =
- GNUNET_TESTING_system_create ("testbed", TESTBED_context->master_ip, hostname);
+ GST_context->client = client;
+ GST_context->host_id = ntohl (msg->host_id);
+ GST_context->master_ip = GNUNET_strdup (controller_hostname);
+ LOG_DEBUG ("Our IP: %s\n", GST_context->master_ip);
+ GST_context->system =
+ GNUNET_TESTING_system_create ("testbed", GST_context->master_ip,
+ hostname);
host =
- GNUNET_TESTBED_host_create_with_id (TESTBED_context->host_id,
- TESTBED_context->master_ip,
- NULL,
- 0);
+ GNUNET_TESTBED_host_create_with_id (GST_context->host_id,
+ GST_context->master_ip, NULL, 0);
host_list_add (host);
- LOG_DEBUG ("Created master context with host ID: %u\n",
- TESTBED_context->host_id);
+ LOG_DEBUG ("Created master context with host ID: %u\n", GST_context->host_id);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
if (0 != username_length)
username_length++;
/* msg must contain hostname */
- GNUNET_assert (msize > (sizeof (struct GNUNET_TESTBED_AddHostMessage) +
- username_length + 1));
+ GNUNET_assert (msize >
+ (sizeof (struct GNUNET_TESTBED_AddHostMessage) +
+ username_length + 1));
if (0 != username_length)
GNUNET_assert ('\0' == username[username_length - 1]);
hostname = username + username_length;
}
else
{
- LOG_DEBUG ("Added host %u at %u\n",
- host_id, TESTBED_context->host_id);
+ LOG_DEBUG ("Added host %u at %u\n", host_id, GST_context->host_id);
reply = GNUNET_malloc (reply_size);
}
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS);
reply->header.size = htons (reply_size);
reply->host_id = htonl (host_id);
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
}
LOG_DEBUG ("Received service sharing request for %s, with %d peers\n",
service_name, ntohl (msg->num_peers));
- if (ntohl (msg->host_id) != TESTBED_context->host_id)
+ if (ntohl (msg->host_id) != GST_context->host_id)
{
route_message (ntohl (msg->host_id), message);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
uint32_t slave_host_id;
uint16_t msize;
- if (NULL == TESTBED_context)
+ if (NULL == GST_context)
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
}
msg = (const struct GNUNET_TESTBED_ControllerLinkMessage *) message;
delegated_host_id = ntohl (msg->delegated_host_id);
- if (delegated_host_id == TESTBED_context->host_id)
+ if (delegated_host_id == GST_context->host_id)
{
GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_WARNING, "Trying to link ourselves\n");
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- if ((delegated_host_id >= TESTBED_host_list_size) ||
- (NULL == TESTBED_host_list[delegated_host_id]))
+ if ((delegated_host_id >= GST_host_list_size) ||
+ (NULL == GST_host_list[delegated_host_id]))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- "Delegated host %u not registered with us\n", delegated_host_id);
+ "Delegated host %u not registered with us\n", delegated_host_id);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
slave_host_id = ntohl (msg->slave_host_id);
- if ((slave_host_id >= TESTBED_host_list_size) || (NULL == TESTBED_host_list[slave_host_id]))
+ if ((slave_host_id >= GST_host_list_size) ||
+ (NULL == GST_host_list[slave_host_id]))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Slave host %u not registered with us\n",
- slave_host_id);
+ slave_host_id);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
return;
}
- if (slave_host_id == TESTBED_context->host_id) /* Link from us */
+ if (slave_host_id == GST_context->host_id) /* Link from us */
{
struct Slave *slave;
struct LinkControllersContext *lcc;
msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkMessage);
config_size = ntohs (msg->config_size);
- if ((delegated_host_id < TESTBED_slave_list_size) && (NULL != TESTBED_slave_list[delegated_host_id])) /* We have already added */
+ if ((delegated_host_id < GST_slave_list_size) && (NULL != GST_slave_list[delegated_host_id])) /* We have already added */
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n",
delegated_host_id);
return;
}
GNUNET_free (config);
- if ((delegated_host_id < TESTBED_slave_list_size) &&
- (NULL != TESTBED_slave_list[delegated_host_id]))
+ if ((delegated_host_id < GST_slave_list_size) &&
+ (NULL != GST_slave_list[delegated_host_id]))
{
GNUNET_break (0); /* Configuration parsing error */
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
if (1 != msg->is_subordinate)
{
slave->controller =
- GNUNET_TESTBED_controller_connect (cfg, TESTBED_host_list[slave->host_id],
- event_mask,
- &slave_event_callback, slave);
+ GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id],
+ event_mask, &slave_event_callback,
+ slave);
slave->cfg = cfg;
if (NULL != slave->controller)
send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id));
else
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Could not connect to delegated controller");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Could not connect to delegated controller");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
lcc->client = client;
slave->lcc = lcc;
slave->controller_proc =
- GNUNET_TESTBED_controller_start (TESTBED_context->master_ip,
- TESTBED_host_list[slave->host_id], cfg,
- &slave_status_callback, slave);
+ GNUNET_TESTBED_controller_start (GST_context->master_ip,
+ GST_host_list[slave->host_id], cfg,
+ &slave_status_callback, slave);
GNUNET_CONFIGURATION_destroy (cfg);
new_route = GNUNET_malloc (sizeof (struct Route));
new_route->dest = delegated_host_id;
- new_route->thru = TESTBED_context->host_id;
+ new_route->thru = GST_context->host_id;
route_list_add (new_route);
return;
}
lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
lcfq->lcf->delegated_host_id = delegated_host_id;
lcfq->lcf->slave_host_id = slave_host_id;
- route = TESTBED_find_dest_route (slave_host_id);
+ route = GST_find_dest_route (slave_host_id);
GNUNET_assert (NULL != route); /* because we add routes carefully */
- GNUNET_assert (route->dest < TESTBED_slave_list_size);
- GNUNET_assert (NULL != TESTBED_slave_list[route->dest]);
+ GNUNET_assert (route->dest < GST_slave_list_size);
+ GNUNET_assert (NULL != GST_slave_list[route->dest]);
lcfq->lcf->state = INIT;
lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id);
- lcfq->lcf->gateway = TESTBED_slave_list[route->dest];
+ lcfq->lcf->gateway = GST_slave_list[route->dest];
lcfq->lcf->msg = GNUNET_malloc (msize);
(void) memcpy (lcfq->lcf->msg, msg, msize);
GNUNET_SERVER_client_keep (client);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if ((delegated_host_id < route_list_size)
- && (NULL != route_list[delegated_host_id]))
+ if ((delegated_host_id < route_list_size) &&
+ (NULL != route_list[delegated_host_id]))
{
- GNUNET_break_op (0); /* Are you trying to link delegated host twice
- with is subordinate flag set to GNUNET_YES? */
+ GNUNET_break_op (0); /* Are you trying to link delegated host twice
+ * with is subordinate flag set to GNUNET_YES? */
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
struct ForwardedOperationContext *fopc = cls;
GNUNET_free (fopc->cls);
- TESTBED_forwarded_operation_timeout (fopc, tc);
+ GST_forwarded_operation_timeout (fopc, tc);
}
struct ForwardedOperationContext *fopc = cls;
struct Peer *remote_peer;
- if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS)
+ if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS)
{
GNUNET_assert (NULL != fopc->cls);
remote_peer = fopc->cls;
peer_list_add (remote_peer);
}
- TESTBED_forwarded_operation_reply_relay (fopc, msg);
+ GST_forwarded_operation_reply_relay (fopc, msg);
}
* @param peer the peer structure to destroy
*/
void
-TESTBED_destroy_peer (struct Peer *peer)
+GST_destroy_peer (struct Peer *peer)
{
GNUNET_break (0 == peer->reference_cnt);
if (GNUNET_YES == peer->is_remote)
struct ForwardedOperationContext *fopc = cls;
struct Peer *remote_peer;
- if (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS == ntohs (msg->type))
+ if (GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS ==
+ ntohs (msg->type))
{
remote_peer = fopc->cls;
GNUNET_assert (NULL != remote_peer);
remote_peer->destroy_flag = GNUNET_YES;
if (0 == remote_peer->reference_cnt)
- TESTBED_destroy_peer (remote_peer);
+ GST_destroy_peer (remote_peer);
}
- TESTBED_forwarded_operation_reply_relay (fopc, msg);
+ GST_forwarded_operation_reply_relay (fopc, msg);
}
peer_id = ntohl (msg->peer_id);
if (UINT32_MAX == peer_id)
{
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Cannot create peer with given ID");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Cannot create peer with given ID");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if (host_id == TESTBED_context->host_id)
+ if (host_id == GST_context->host_id)
{
char *emsg;
return;
}
GNUNET_free (config);
- GNUNET_CONFIGURATION_set_value_number (cfg,
- "TESTBED",
- "PEERID",
- (unsigned long long) peer_id);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "TESTBED", "PEERID",
+ (unsigned long long) peer_id);
peer = GNUNET_malloc (sizeof (struct Peer));
peer->is_remote = GNUNET_NO;
peer->details.local.cfg = cfg;
peer->id = peer_id;
- LOG_DEBUG ("Creating peer with id: %u\n",
- (unsigned int) peer->id);
+ LOG_DEBUG ("Creating peer with id: %u\n", (unsigned int) peer->id);
peer->details.local.peer =
- GNUNET_TESTING_peer_configure (TESTBED_context->system,
+ GNUNET_TESTING_peer_configure (GST_context->system,
peer->details.local.cfg, peer->id,
NULL /* Peer id */ ,
&emsg);
(struct GNUNET_TESTBED_PeerCreateSuccessEventMessage));
reply->header.size =
htons (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage));
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS);
+ reply->header.type =
+ htons (GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS);
reply->peer_id = msg->peer_id;
reply->operation_id = msg->operation_id;
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
/* Forward peer create request */
- route = TESTBED_find_dest_route (host_id);
+ route = GST_find_dest_route (host_id);
if (NULL == route)
{
GNUNET_break (0);
peer = GNUNET_malloc (sizeof (struct Peer));
peer->is_remote = GNUNET_YES;
peer->id = peer_id;
- peer->details.remote.slave = TESTBED_slave_list[route->dest];
+ peer->details.remote.slave = GST_slave_list[route->dest];
peer->details.remote.remote_host_id = host_id;
fo_ctxt = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
GNUNET_SERVER_client_keep (client);
fo_ctxt->client = client;
fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
- fo_ctxt->cls = peer; //TESTBED_slave_list[route->dest]->controller;
+ fo_ctxt->cls = peer; //GST_slave_list[route->dest]->controller;
fo_ctxt->type = OP_PEER_CREATE;
fo_ctxt->opc =
- GNUNET_TESTBED_forward_operation_msg_ (TESTBED_slave_list [route->dest]->controller,
+ GNUNET_TESTBED_forward_operation_msg_ (GST_slave_list
+ [route->dest]->controller,
fo_ctxt->operation_id,
&msg->header,
peer_create_success_cb, fo_ctxt);
fo_ctxt->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &peer_create_forward_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &peer_create_forward_timeout,
fo_ctxt);
GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fo_ctxt);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
peer_id = ntohl (msg->peer_id);
LOG_DEBUG ("Received peer destory on peer: %u and operation id: %ul\n",
peer_id, GNUNET_ntohll (msg->operation_id));
- if ((TESTBED_peer_list_size <= peer_id) || (NULL == TESTBED_peer_list[peer_id]))
+ if ((GST_peer_list_size <= peer_id) || (NULL == GST_peer_list[peer_id]))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Asked to destroy a non existent peer with id: %u\n", peer_id);
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Peer doesn't exist");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Peer doesn't exist");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- peer = TESTBED_peer_list[peer_id];
+ peer = GST_peer_list[peer_id];
if (GNUNET_YES == peer->is_remote)
{
/* Forward the destory message to sub controller */
fopc->client = client;
fopc->cls = peer;
fopc->type = OP_PEER_DESTROY;
- fopc->operation_id = GNUNET_ntohll (msg->operation_id);
- fopc->opc =
- GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller,
+ fopc->operation_id = GNUNET_ntohll (msg->operation_id);
+ fopc->opc =
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
+ slave->controller,
fopc->operation_id, &msg->header,
- &peer_destroy_success_cb,
- fopc);
+ &peer_destroy_success_cb, fopc);
fopc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &TESTBED_forwarded_operation_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &GST_forwarded_operation_timeout,
fopc);
GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
peer->destroy_flag = GNUNET_YES;
if (0 == peer->reference_cnt)
- TESTBED_destroy_peer (peer);
+ GST_destroy_peer (peer);
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Delaying peer destroy as peer is currently in use\n");
msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message;
peer_id = ntohl (msg->peer_id);
- if ((peer_id >= TESTBED_peer_list_size) || (NULL == TESTBED_peer_list[peer_id]))
+ if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id]))
{
GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_ERROR,
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- peer = TESTBED_peer_list[peer_id];
+ peer = GST_peer_list[peer_id];
if (GNUNET_YES == peer->is_remote)
{
fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
fopc->operation_id = GNUNET_ntohll (msg->operation_id);
fopc->type = OP_PEER_START;
fopc->opc =
- GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller,
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
+ slave->controller,
fopc->operation_id, &msg->header,
- &TESTBED_forwarded_operation_reply_relay,
+ &GST_forwarded_operation_reply_relay,
fopc);
fopc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &TESTBED_forwarded_operation_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &GST_forwarded_operation_timeout,
fopc);
GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer))
{
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Failed to start");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Failed to start");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
peer->details.local.is_running = GNUNET_YES;
reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT);
reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_START);
- reply->host_id = htonl (TESTBED_context->host_id);
+ reply->host_id = htonl (GST_context->host_id);
reply->peer_id = msg->peer_id;
reply->operation_id = msg->operation_id;
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message;
peer_id = ntohl (msg->peer_id);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PEER_STOP for peer %u\n", peer_id);
- if ((peer_id >= TESTBED_peer_list_size) || (NULL == TESTBED_peer_list[peer_id]))
+ if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id]))
{
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Peer not found");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Peer not found");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- peer = TESTBED_peer_list[peer_id];
+ peer = GST_peer_list[peer_id];
if (GNUNET_YES == peer->is_remote)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarding PEER_STOP for peer %u\n", peer_id);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarding PEER_STOP for peer %u\n",
+ peer_id);
fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
GNUNET_SERVER_client_keep (client);
fopc->client = client;
fopc->operation_id = GNUNET_ntohll (msg->operation_id);
fopc->type = OP_PEER_STOP;
fopc->opc =
- GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller,
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
+ slave->controller,
fopc->operation_id, &msg->header,
- &TESTBED_forwarded_operation_reply_relay,
+ &GST_forwarded_operation_reply_relay,
fopc);
fopc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &TESTBED_forwarded_operation_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &GST_forwarded_operation_timeout,
fopc);
GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
if (GNUNET_OK != GNUNET_TESTING_peer_stop (peer->details.local.peer))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Stopping peer %u failed\n", peer_id);
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Peer not running");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Peer not running");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer %u successfully stopped\n", peer_id);
peer->details.local.is_running = GNUNET_NO;
reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT);
reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
- reply->host_id = htonl (TESTBED_context->host_id);
+ reply->host_id = htonl (GST_context->host_id);
reply->peer_id = msg->peer_id;
reply->operation_id = msg->operation_id;
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
msg = (const struct GNUNET_TESTBED_PeerGetConfigurationMessage *) message;
peer_id = ntohl (msg->peer_id);
- if ((peer_id >= TESTBED_peer_list_size) || (NULL == TESTBED_peer_list[peer_id]))
+ if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id]))
{
- TESTBED_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
- "Peer not found");
+ GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Peer not found");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- peer = TESTBED_peer_list[peer_id];
+ peer = GST_peer_list[peer_id];
if (GNUNET_YES == peer->is_remote)
{
struct ForwardedOperationContext *fopc;
-
+
LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n", peer_id);
fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
GNUNET_SERVER_client_keep (client);
fopc->operation_id = GNUNET_ntohll (msg->operation_id);
fopc->type = OP_PEER_INFO;
fopc->opc =
- GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller,
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
+ slave->controller,
fopc->operation_id, &msg->header,
- &TESTBED_forwarded_operation_reply_relay,
+ &GST_forwarded_operation_reply_relay,
fopc);
fopc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &TESTBED_forwarded_operation_timeout,
+ GNUNET_SCHEDULER_add_delayed (GST_timeout, &GST_forwarded_operation_timeout,
fopc);
- GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
+ GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n", peer_id);
config =
- GNUNET_CONFIGURATION_serialize (TESTBED_peer_list[peer_id]->details.local.cfg,
+ GNUNET_CONFIGURATION_serialize (GST_peer_list[peer_id]->details.local.cfg,
&c_size);
xc_size = GNUNET_TESTBED_compress_config_ (config, c_size, &xconfig);
GNUNET_free (config);
reply = GNUNET_realloc (xconfig, msize);
(void) memmove (&reply[1], reply, xc_size);
reply->header.size = htons (msize);
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION);
reply->peer_id = msg->peer_id;
reply->operation_id = msg->operation_id;
- GNUNET_TESTING_peer_get_identity (TESTBED_peer_list[peer_id]->details.local.peer,
+ GNUNET_TESTING_peer_get_identity (GST_peer_list[peer_id]->details.local.peer,
&reply->peer_identity);
reply->config_size = htons ((uint16_t) c_size);
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
*/
static void
handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
- struct Slave *slave;
+ struct Slave *slave;
struct GNUNET_TESTBED_SlaveConfiguration *reply;
char *config;
char *xconfig;
msg = (struct GNUNET_TESTBED_SlaveGetConfigurationMessage *) message;
slave_id = ntohl (msg->slave_id);
op_id = GNUNET_ntohll (msg->operation_id);
- if ((TESTBED_slave_list_size <= slave_id) || (NULL == TESTBED_slave_list[slave_id]))
+ if ((GST_slave_list_size <= slave_id) || (NULL == GST_slave_list[slave_id]))
{
/* FIXME: Add forwardings for this type of message here.. */
- TESTBED_send_operation_fail_msg (client, op_id, "Slave not found");
+ GST_send_operation_fail_msg (client, op_id, "Slave not found");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- slave = TESTBED_slave_list[slave_id];
+ slave = GST_slave_list[slave_id];
if (NULL == slave->cfg)
{
- TESTBED_send_operation_fail_msg (client, op_id,
- "Configuration not found (slave not started by me)");
+ GST_send_operation_fail_msg (client, op_id,
+ "Configuration not found (slave not started by me)");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size);
- xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size,
- &xconfig);
- GNUNET_free (config);
+ xconfig_size =
+ GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
+ GNUNET_free (config);
reply_size = xconfig_size + sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
GNUNET_break (reply_size <= UINT16_MAX);
GNUNET_break (config_size <= UINT16_MAX);
reply = GNUNET_realloc (xconfig, reply_size);
(void) memmove (&reply[1], reply, xconfig_size);
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION);
reply->header.size = htons ((uint16_t) reply_size);
reply->slave_id = msg->slave_id;
reply->operation_id = msg->operation_id;
reply->config_size = htons ((uint16_t) config_size);
- TESTBED_queue_message (client, &reply->header);
+ GST_queue_message (client, &reply->header);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
* iterate,
* GNUNET_NO if not.
*/
-static int
-reghost_free_iterator (void *cls,
- const struct GNUNET_HashCode * key,
+static int
+reghost_free_iterator (void *cls, const struct GNUNET_HashCode *key,
void *value)
{
struct Slave *slave = cls;
struct ForwardedOverlayConnectContext *focc;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (slave->reghost_map,
- key, value));
+ GNUNET_CONTAINER_multihashmap_remove (slave->reghost_map, key,
+ value));
while (NULL != (focc = rhc->focc_dll_head))
{
- GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head,
- rhc->focc_dll_tail,
- focc);
- TESTBED_cleanup_focc (focc);
+ GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc);
+ GST_cleanup_focc (focc);
}
if (NULL != rhc->sub_op)
GNUNET_TESTBED_operation_done (rhc->sub_op);
if (NULL != rhc->client)
- GNUNET_SERVER_client_drop (rhc->client);
+ GNUNET_SERVER_client_drop (rhc->client);
GNUNET_free (value);
return GNUNET_YES;
}
GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq);
GNUNET_free (lcfq);
}
- TESTBED_free_occq ();
- TESTBED_free_roccq ();
+ GST_free_occq ();
+ GST_free_roccq ();
/* Clear peer list */
- for (id = 0; id < TESTBED_peer_list_size; id++)
- if (NULL != TESTBED_peer_list[id])
+ for (id = 0; id < GST_peer_list_size; id++)
+ if (NULL != GST_peer_list[id])
{
/* If destroy flag is set it means that this peer should have been
- destroyed by a context which we destroy before */
- GNUNET_break (GNUNET_NO == TESTBED_peer_list[id]->destroy_flag);
+ * destroyed by a context which we destroy before */
+ GNUNET_break (GNUNET_NO == GST_peer_list[id]->destroy_flag);
/* counter should be zero as we free all contexts before */
- GNUNET_break (0 == TESTBED_peer_list[id]->reference_cnt);
- if ( (GNUNET_NO == TESTBED_peer_list[id]->is_remote)
- && (GNUNET_YES == TESTBED_peer_list[id]->details.local.is_running))
- GNUNET_TESTING_peer_kill (TESTBED_peer_list[id]->details.local.peer);
+ GNUNET_break (0 == GST_peer_list[id]->reference_cnt);
+ if ((GNUNET_NO == GST_peer_list[id]->is_remote) &&
+ (GNUNET_YES == GST_peer_list[id]->details.local.is_running))
+ GNUNET_TESTING_peer_kill (GST_peer_list[id]->details.local.peer);
}
- for (id = 0; id < TESTBED_peer_list_size; id++)
- if (NULL != TESTBED_peer_list[id])
+ for (id = 0; id < GST_peer_list_size; id++)
+ if (NULL != GST_peer_list[id])
{
- if (GNUNET_NO == TESTBED_peer_list[id]->is_remote)
+ if (GNUNET_NO == GST_peer_list[id]->is_remote)
{
- if (GNUNET_YES == TESTBED_peer_list[id]->details.local.is_running)
- GNUNET_TESTING_peer_wait (TESTBED_peer_list[id]->details.local.peer);
- GNUNET_TESTING_peer_destroy (TESTBED_peer_list[id]->details.local.peer);
- GNUNET_CONFIGURATION_destroy (TESTBED_peer_list[id]->details.local.cfg);
+ if (GNUNET_YES == GST_peer_list[id]->details.local.is_running)
+ GNUNET_TESTING_peer_wait (GST_peer_list[id]->details.local.peer);
+ GNUNET_TESTING_peer_destroy (GST_peer_list[id]->details.local.peer);
+ GNUNET_CONFIGURATION_destroy (GST_peer_list[id]->details.local.cfg);
}
- GNUNET_free (TESTBED_peer_list[id]);
+ GNUNET_free (GST_peer_list[id]);
}
- GNUNET_free_non_null (TESTBED_peer_list);
+ GNUNET_free_non_null (GST_peer_list);
/* Clear host list */
- for (id = 0; id < TESTBED_host_list_size; id++)
- if (NULL != TESTBED_host_list[id])
- GNUNET_TESTBED_host_destroy (TESTBED_host_list[id]);
- GNUNET_free_non_null (TESTBED_host_list);
+ for (id = 0; id < GST_host_list_size; id++)
+ if (NULL != GST_host_list[id])
+ GNUNET_TESTBED_host_destroy (GST_host_list[id]);
+ GNUNET_free_non_null (GST_host_list);
/* Clear route list */
for (id = 0; id < route_list_size; id++)
if (NULL != route_list[id])
GNUNET_free (route_list[id]);
GNUNET_free_non_null (route_list);
- /* Clear TESTBED_slave_list */
- for (id = 0; id < TESTBED_slave_list_size; id++)
- if (NULL != TESTBED_slave_list[id])
+ /* Clear GST_slave_list */
+ for (id = 0; id < GST_slave_list_size; id++)
+ if (NULL != GST_slave_list[id])
{
struct HostRegistration *hr_entry;
-
- while (NULL != (hr_entry = TESTBED_slave_list[id]->hr_dll_head))
+
+ while (NULL != (hr_entry = GST_slave_list[id]->hr_dll_head))
{
- GNUNET_CONTAINER_DLL_remove (TESTBED_slave_list[id]->hr_dll_head,
- TESTBED_slave_list[id]->hr_dll_tail,
- hr_entry);
+ GNUNET_CONTAINER_DLL_remove (GST_slave_list[id]->hr_dll_head,
+ GST_slave_list[id]->hr_dll_tail, hr_entry);
GNUNET_free (hr_entry);
}
- if (NULL != TESTBED_slave_list[id]->rhandle)
- GNUNET_TESTBED_cancel_registration (TESTBED_slave_list[id]->rhandle);
- (void) GNUNET_CONTAINER_multihashmap_iterate (TESTBED_slave_list[id]->reghost_map,
- reghost_free_iterator,
- TESTBED_slave_list[id]);
- GNUNET_CONTAINER_multihashmap_destroy (TESTBED_slave_list[id]->reghost_map);
- if (NULL != TESTBED_slave_list[id]->cfg)
- GNUNET_CONFIGURATION_destroy (TESTBED_slave_list[id]->cfg);
- if (NULL != TESTBED_slave_list[id]->controller)
- GNUNET_TESTBED_controller_disconnect (TESTBED_slave_list[id]->controller);
- if (NULL != TESTBED_slave_list[id]->controller_proc)
- GNUNET_TESTBED_controller_stop (TESTBED_slave_list[id]->controller_proc);
- GNUNET_free (TESTBED_slave_list[id]);
+ if (NULL != GST_slave_list[id]->rhandle)
+ GNUNET_TESTBED_cancel_registration (GST_slave_list[id]->rhandle);
+ (void)
+ GNUNET_CONTAINER_multihashmap_iterate (GST_slave_list
+ [id]->reghost_map,
+ reghost_free_iterator,
+ GST_slave_list[id]);
+ GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map);
+ if (NULL != GST_slave_list[id]->cfg)
+ GNUNET_CONFIGURATION_destroy (GST_slave_list[id]->cfg);
+ if (NULL != GST_slave_list[id]->controller)
+ GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller);
+ if (NULL != GST_slave_list[id]->controller_proc)
+ GNUNET_TESTBED_controller_stop (GST_slave_list[id]->controller_proc);
+ GNUNET_free (GST_slave_list[id]);
}
- GNUNET_free_non_null (TESTBED_slave_list);
- if (NULL != TESTBED_context)
+ GNUNET_free_non_null (GST_slave_list);
+ if (NULL != GST_context)
{
- GNUNET_free_non_null (TESTBED_context->master_ip);
- if (NULL != TESTBED_context->system)
- GNUNET_TESTING_system_destroy (TESTBED_context->system, GNUNET_YES);
- GNUNET_SERVER_client_drop (TESTBED_context->client);
- GNUNET_free (TESTBED_context);
- TESTBED_context = NULL;
+ GNUNET_free_non_null (GST_context->master_ip);
+ if (NULL != GST_context->system)
+ GNUNET_TESTING_system_destroy (GST_context->system, GNUNET_YES);
+ GNUNET_SERVER_client_drop (GST_context->client);
+ GNUNET_free (GST_context);
+ GST_context = NULL;
}
if (NULL != transmit_handle)
- GNUNET_SERVER_notify_transmit_ready_cancel (transmit_handle);
+ GNUNET_SERVER_notify_transmit_ready_cancel (transmit_handle);
while (NULL != (mq_entry = mq_head))
{
GNUNET_free (mq_entry->msg);
GNUNET_SERVER_client_drop (mq_entry->client);
- GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry);
+ GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry);
GNUNET_free (mq_entry);
- }
+ }
GNUNET_free_non_null (hostname);
GNUNET_CONFIGURATION_destroy (our_config);
/* Free hello cache */
- TESTBED_cache_clear ();
+ GST_cache_clear ();
+ GNUNET_TESTBED_operation_queue_destroy_ (GST_opq_openfds);
+ GST_opq_openfds = NULL;
}
static void
client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client)
{
- if (NULL == TESTBED_context)
+ if (NULL == GST_context)
return;
- if (client == TESTBED_context->client)
+ if (client == GST_context->client)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Master client disconnected\n");
/* should not be needed as we're terminated by failure to read
{
static const struct GNUNET_SERVER_MessageHandler message_handlers[] = {
{&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, 0},
- {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0},
+ {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, 0},
{&handle_configure_shared_service, NULL,
- GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0},
+ GNUNET_MESSAGE_TYPE_TESTBED_SHARE_SERVICE, 0},
{&handle_link_controllers, NULL,
- GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS, 0},
- {&handle_peer_create, NULL, GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER, 0},
- {&handle_peer_destroy, NULL, GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER,
+ GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, 0},
+ {&handle_peer_create, NULL, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, 0},
+ {&handle_peer_destroy, NULL, GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER,
sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)},
- {&handle_peer_start, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER,
+ {&handle_peer_start, NULL, GNUNET_MESSAGE_TYPE_TESTBED_START_PEER,
sizeof (struct GNUNET_TESTBED_PeerStartMessage)},
- {&handle_peer_stop, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER,
+ {&handle_peer_stop, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER,
sizeof (struct GNUNET_TESTBED_PeerStopMessage)},
- {&handle_peer_get_config, NULL, GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG,
+ {&handle_peer_get_config, NULL,
+ GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_CONFIGURATION,
sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)},
- {&TESTBED_handle_overlay_connect, NULL, GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT,
+ {&GST_handle_overlay_connect, NULL,
+ GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT,
sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)},
- {&TESTBED_handle_overlay_request_connect, NULL,
- GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT, 0},
- {handle_slave_get_config, NULL, GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG,
+ {&GST_handle_remote_overlay_connect, NULL,
+ GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT, 0},
+ {handle_slave_get_config, NULL,
+ GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION,
sizeof (struct GNUNET_TESTBED_SlaveGetConfigurationMessage)},
{NULL}
};
char *logfile;
unsigned long long num;
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
- "TESTBED",
- "LOG_FILE",
- &logfile))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "TESTBED", "LOG_FILE",
+ &logfile))
{
GNUNET_break (GNUNET_OK == GNUNET_log_setup ("testbed", "DEBUG", logfile));
GNUNET_free (logfile);
}
- GNUNET_assert (GNUNET_OK ==
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
+ "CACHE_SIZE", &num));
+ GST_cache_init ((unsigned int) num);
+ GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
- "HELLO_CACHE_SIZE",
- &num));
- TESTBED_cache_init ((unsigned int) num);
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string
- (cfg, "testbed", "HOSTNAME", &hostname));
+ "MAX_OPEN_FDS", &num));
+ GST_opq_openfds = GNUNET_TESTBED_operation_queue_create_ ((unsigned int) num);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_time (cfg, "TESTBED",
+ "OPERATION_TIMEOUT",
+ (struct
+ GNUNET_TIME_Relative *)
+ &GST_timeout));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
+ "HOSTNAME", &hostname));
our_config = GNUNET_CONFIGURATION_dup (cfg);
GNUNET_SERVER_add_handlers (server, message_handlers);
GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);