GNUnet  0.19.5
gnunet-service-testbed.c File Reference

implementation of the TESTBED service More...

Include dependency graph for gnunet-service-testbed.c:

Go to the source code of this file.

Macros

#define GROW_SS
 

Functions

static int host_list_add (struct GNUNET_TESTBED_Host *host)
 Function to add a host to the current list of known hosts. More...
 
void GST_send_operation_fail_msg (struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
 Send operation failure message to client. More...
 
void GST_send_operation_success_msg (struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
 Function to send generic operation success message to given client. More...
 
static void hr_completion (void *cls, const char *emsg)
 Callback which will be called after a host registration succeeded or failed. More...
 
static void register_next_host (struct Slave *slave)
 Attempts to register the next host in the host registration queue. More...
 
void GST_queue_host_registration (struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
 Adds a host registration's request to a slave's registration queue. More...
 
void GST_forwarded_operation_reply_relay (void *cls, const struct GNUNET_MessageHeader *msg)
 Callback to relay the reply msg of a forwarded operation back to the client. More...
 
void GST_forwarded_operation_timeout (void *cls)
 Task to free resources when forwarded operation has been timed out. More...
 
static struct GNUNET_TESTING_SharedServiceparse_shared_services (char *ss_str, struct GNUNET_CONFIGURATION_Handle *cfg)
 Parse service sharing specification line. More...
 
static int check_init (void *cls, const struct GNUNET_TESTBED_InitMessage *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_INIT messages. More...
 
static void handle_init (void *cls, const struct GNUNET_TESTBED_InitMessage *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_INIT messages. More...
 
static int check_add_host (void *cls, const struct GNUNET_TESTBED_AddHostMessage *msg)
 Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages. More...
 
static void handle_add_host (void *cls, const struct GNUNET_TESTBED_AddHostMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages. More...
 
static void handle_slave_get_config (void *cls, const struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG messages. More...
 
void GST_clear_fopcq ()
 Clears the forwarded operations queue. More...
 
static void shutdown_task (void *cls)
 Task to clean up and shutdown nicely. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Callback for client connect. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Callback for client disconnect. More...
 
static void testbed_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Testbed setup. More...
 
 GNUNET_SERVICE_MAIN ("testbed", GNUNET_SERVICE_OPTION_NONE, &testbed_run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(init, GNUNET_MESSAGE_TYPE_TESTBED_INIT, struct GNUNET_TESTBED_InitMessage, NULL), GNUNET_MQ_hd_var_size(add_host, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, struct GNUNET_TESTBED_AddHostMessage, NULL), GNUNET_MQ_hd_fixed_size(slave_get_config, GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION, struct GNUNET_TESTBED_SlaveGetConfigurationMessage, NULL), GNUNET_MQ_hd_fixed_size(link_controllers, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, struct GNUNET_TESTBED_ControllerLinkRequest, NULL), GNUNET_MQ_hd_var_size(remote_overlay_connect, GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT, struct GNUNET_TESTBED_RemoteOverlayConnectMessage, NULL), GNUNET_MQ_hd_fixed_size(overlay_connect, GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT, struct GNUNET_TESTBED_OverlayConnectMessage, NULL), GNUNET_MQ_hd_var_size(peer_create, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, struct GNUNET_TESTBED_PeerCreateMessage, NULL), GNUNET_MQ_hd_fixed_size(peer_destroy, GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER, struct GNUNET_TESTBED_PeerDestroyMessage, NULL), GNUNET_MQ_hd_fixed_size(peer_start, GNUNET_MESSAGE_TYPE_TESTBED_START_PEER, struct GNUNET_TESTBED_PeerStartMessage, NULL), GNUNET_MQ_hd_fixed_size(peer_stop, GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER, struct GNUNET_TESTBED_PeerStopMessage, NULL), GNUNET_MQ_hd_fixed_size(peer_get_config, GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION, struct GNUNET_TESTBED_PeerGetConfigurationMessage, NULL), GNUNET_MQ_hd_var_size(manage_peer_service, GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE, struct GNUNET_TESTBED_ManagePeerServiceMessage, NULL), GNUNET_MQ_hd_fixed_size(shutdown_peers, GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS, struct GNUNET_TESTBED_ShutdownPeersMessage, NULL), GNUNET_MQ_hd_var_size(peer_reconfigure, GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, struct GNUNET_TESTBED_PeerReconfigureMessage, NULL), GNUNET_MQ_hd_var_size(barrier_init, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT, struct GNUNET_TESTBED_BarrierInit, NULL), GNUNET_MQ_hd_var_size(barrier_cancel, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL, struct GNUNET_TESTBED_BarrierCancel, NULL), GNUNET_MQ_hd_var_size(barrier_status, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, struct GNUNET_TESTBED_BarrierStatusMsg, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

struct GNUNET_CONFIGURATION_HandleGST_config
 Our configuration. More...
 
struct ContextGST_context
 The master context; generated with the first INIT message. More...
 
struct GNUNET_TESTBED_Host ** GST_host_list
 Array of hosts. More...
 
struct ForwardedOperationContextfopcq_head
 DLL head for forwarded operation contexts. More...
 
struct ForwardedOperationContextfopcq_tail
 DLL tail for forwarded operation contexts. More...
 
struct OperationQueueGST_opq_openfds
 Operation queue for open file descriptors. More...
 
struct GNUNET_TIME_Relative GST_timeout
 Timeout for operations which may take some time. More...
 
unsigned int GST_host_list_size
 The size of the host list. More...
 
unsigned int GST_peer_list_size
 The size of the peer list. More...
 
static char * hostname
 Our hostname; we give this to all the peers we start. More...
 

Detailed Description

implementation of the TESTBED service

Author
Sree Harsha Totakura

Definition in file gnunet-service-testbed.c.

Macro Definition Documentation

◆ GROW_SS

#define GROW_SS
Value:
do { \
GNUNET_array_grow (slist, n, n + 1); \
GNUNET_memcpy (&slist[n - 1], &ss, \
sizeof(struct GNUNET_TESTING_SharedService)); \
} while (0)
Specification of a service that is to be shared among peers.

Function Documentation

◆ host_list_add()

static int host_list_add ( struct GNUNET_TESTBED_Host host)
static

Function to add a host to the current list of known hosts.

Parameters
hostthe host to add
Returns
GNUNET_OK on success; GNUNET_SYSERR on failure due to host-id already in use

Definition at line 100 of file gnunet-service-testbed.c.

101 {
102  uint32_t host_id;
103 
104  host_id = GNUNET_TESTBED_host_get_id_ (host);
105  if (GST_host_list_size <= host_id)
107  if (NULL != GST_host_list[host_id])
108  {
109  LOG_DEBUG ("A host with id: %u already exists\n", host_id);
110  return GNUNET_SYSERR;
111  }
112  GST_host_list[host_id] = host;
113  return GNUNET_OK;
114 }
#define LOG_DEBUG(...)
Debug logging shorthand.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
unsigned int GST_host_list_size
The size of the host list.
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
@ GNUNET_OK
@ GNUNET_SYSERR
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain a host's unique global ID.

References GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_host_get_id_(), GST_array_grow_large_enough, GST_host_list, GST_host_list_size, and LOG_DEBUG.

Referenced by handle_add_host(), and handle_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_send_operation_fail_msg()

void GST_send_operation_fail_msg ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id,
const char *  emsg 
)

Send operation failure message to client.

Parameters
clientthe client to which the failure message has to be sent to
operation_idthe id of the failed operation
emsgthe error message; can be NULL

Definition at line 125 of file gnunet-service-testbed.c.

128 {
129  struct GNUNET_MQ_Envelope *env;
131  uint16_t emsg_len;
132 
133  emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1;
135  emsg_len,
137  msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
138  msg->operation_id = GNUNET_htonll (operation_id);
139  GNUNET_memcpy (&msg[1],
140  emsg,
141  emsg_len);
143  env);
144 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:62
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2443
@ GNUNET_TESTBED_ET_OPERATION_FINISHED
A requested testbed operation has been completed.
Event notification from a controller to a client.
Definition: testbed.h:509
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:524

References env, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, msg, and GNUNET_TESTBED_OperationFailureEventMessage::operation_id.

Referenced by GST_forwarded_operation_timeout(), handle_manage_peer_service(), handle_peer_create(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_slave_get_config(), prc_stop_cb(), service_manage_result_cb(), shutdown_peers_reply_cb(), and timeout_overlay_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_send_operation_success_msg()

void GST_send_operation_success_msg ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id 
)

Function to send generic operation success message to given client.

Parameters
clientthe client to send the message to
operation_idthe id of the operation which was successful

Definition at line 154 of file gnunet-service-testbed.c.

156 {
157  struct GNUNET_MQ_Envelope *env;
159 
160  env = GNUNET_MQ_msg (msg,
162  msg->operation_id = GNUNET_htonll (operation_id);
163  msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED);
165  env);
166 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:558
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:573

References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, msg, and GNUNET_TESTBED_GenericOperationSuccessEventMessage::operation_id.

Referenced by handle_peer_destroy(), handle_peer_reconfigure(), handle_shutdown_peers(), prc_stop_cb(), service_manage_result_cb(), and shutdown_peers_reply_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hr_completion()

static void hr_completion ( void *  cls,
const char *  emsg 
)
static

Callback which will be called after a host registration succeeded or failed.

Callback which will be called to after a host registration succeeded or failed.

Parameters
clsthe handle to the slave at which the registration is completed
emsgthe error message; NULL if host registration is successful

Definition at line 212 of file gnunet-service-testbed.c.

214 {
215  struct Slave *slave = cls;
216  struct HostRegistration *hr;
217 
218  slave->rhandle = NULL;
219  hr = slave->hr_dll_head;
220  GNUNET_assert (NULL != hr);
222  "Registering host %u at %u successful\n",
226  slave->hr_dll_tail,
227  hr);
228  if (NULL != hr->cb)
229  hr->cb (hr->cb_cls,
230  emsg);
231  GNUNET_free (hr);
232  if (NULL != slave->hr_dll_head)
233  register_next_host (slave);
234 }
#define LOG(kind,...)
Definition: abd_api.c:38
static void register_next_host(struct Slave *slave)
Attempts to register the next host in the host registration queue.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
A DLL of host registrations to be made.
struct GNUNET_TESTBED_Host * host
The host that has to be registered.
GNUNET_TESTBED_HostRegistrationCompletion cb
The callback to call after this registration's status is available.
void * cb_cls
The closure for the above callback.
Structure representing a connected(directly-linked) controller.
uint32_t host_id
The id of the host this controller is running on.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
struct GNUNET_TESTBED_HostRegistrationHandle * rhandle
The current host registration handle.

References HostRegistration::cb, HostRegistration::cb_cls, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_TESTBED_host_get_id_(), GST_host_list, HostRegistration::host, Slave::host_id, Slave::hr_dll_head, Slave::hr_dll_tail, LOG, register_next_host(), and Slave::rhandle.

Referenced by register_next_host().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_next_host()

static void register_next_host ( struct Slave slave)
static

Attempts to register the next host in the host registration queue.

Parameters
slavethe slave controller whose host registration queue is checked for host registrations

Definition at line 187 of file gnunet-service-testbed.c.

188 {
189  struct HostRegistration *hr;
190 
191  hr = slave->hr_dll_head;
192  GNUNET_assert (NULL != hr);
193  GNUNET_assert (NULL == slave->rhandle);
194  LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u\n",
197  slave->rhandle
199  hr->host,
201  slave);
202 }
static void hr_completion(void *cls, const char *emsg)
Callback which will be called after a host registration succeeded or failed.
struct GNUNET_TESTBED_HostRegistrationHandle * GNUNET_TESTBED_register_host(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_HostRegistrationCompletion cc, void *cc_cls)
Register a host with the controller.
struct GNUNET_TESTBED_Controller * controller
The controller handle.

References Slave::controller, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_register_host(), GST_host_list, HostRegistration::host, Slave::host_id, hr_completion(), Slave::hr_dll_head, LOG, and Slave::rhandle.

Referenced by GST_queue_host_registration(), and hr_completion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_queue_host_registration()

void GST_queue_host_registration ( struct Slave slave,
GNUNET_TESTBED_HostRegistrationCompletion  cb,
void *  cb_cls,
struct GNUNET_TESTBED_Host host 
)

Adds a host registration's request to a slave's registration queue.

Parameters
slavethe slave controller at which the given host has to be registered
cbthe host registration completion callback
cb_clsthe closure for the host registration completion callback
hostthe host which has to be registered

Definition at line 247 of file gnunet-service-testbed.c.

251 {
252  struct HostRegistration *hr;
253  int call_register;
254 
256  "Queueing host registration for host %u at %u\n",
259  hr = GNUNET_new (struct HostRegistration);
260  hr->cb = cb;
261  hr->cb_cls = cb_cls;
262  hr->host = host;
263  call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
265  slave->hr_dll_tail,
266  hr);
267  if (GNUNET_YES == call_register)
268  register_next_host (slave);
269 }
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References HostRegistration::cb, HostRegistration::cb_cls, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_TESTBED_host_get_id_(), GNUNET_YES, GST_host_list, HostRegistration::host, Slave::host_id, Slave::hr_dll_head, Slave::hr_dll_tail, LOG, and register_next_host().

Referenced by lcf_proc_task(), and register_host().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_forwarded_operation_reply_relay()

void GST_forwarded_operation_reply_relay ( void *  cls,
const struct GNUNET_MessageHeader msg 
)

Callback to relay the reply msg of a forwarded operation back to the client.

Parameters
clsForwardedOperationContext
msgthe message to relay

Definition at line 279 of file gnunet-service-testbed.c.

281 {
282  struct ForwardedOperationContext *fopc = cls;
283  struct GNUNET_MQ_Envelope *env;
284 
285  LOG_DEBUG ("Relaying message with type: %u, size: %u\n",
286  ntohs (msg->type),
287  ntohs (msg->size));
290  env);
293  fopcq_tail,
294  fopc);
295  GNUNET_free (fopc);
296 }
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:533
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
Context information for operations forwarded to subcontrollers.
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, env, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_get_mq(), LOG_DEBUG, msg, GNUNET_MessageHeader::size, ForwardedOperationContext::timeout_task, and GNUNET_MessageHeader::type.

Referenced by forward_overlay_connect(), forwarded_overlay_connect_listener(), handle_manage_peer_service(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), peer_create_success_cb(), and peer_destroy_success_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_forwarded_operation_timeout()

void GST_forwarded_operation_timeout ( void *  cls)

Task to free resources when forwarded operation has been timed out.

Parameters
clsthe ForwardedOperationContext

Definition at line 300 of file gnunet-service-testbed.c.

301 {
302  struct ForwardedOperationContext *fopc = cls;
303 
304  fopc->timeout_task = NULL;
307  "A forwarded operation has timed out\n");
309  fopc->operation_id,
310  "A forwarded operation has timed out");
312  fopcq_tail,
313  fopc);
314  GNUNET_free (fopc);
315 }
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct OperationContext * opc
The generated operation context.
uint64_t operation_id
The id of the operation that has been forwarded.
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1407

References ForwardedOperationContext::client, ForwardedOperationContext::cls, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_TESTBED_forward_operation_msg_cancel_(), GST_send_operation_fail_msg(), LOG, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, and ForwardedOperationContext::timeout_task.

Referenced by client_disconnect_cb(), forward_overlay_connect(), forwarded_overlay_connect_timeout(), GST_notify_client_disconnect_oc(), GST_notify_client_disconnect_peers(), handle_manage_peer_service(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), and peer_create_forward_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_shared_services()

static struct GNUNET_TESTING_SharedService* parse_shared_services ( char *  ss_str,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Parse service sharing specification line.

Format is "[<service:share>] [<service:share>] ..."

Parameters
ss_strthe spec string to be parsed
cfgthe configuration to use for shared services
Returns
an array suitable to pass to GNUNET_TESTING_system_create(). NULL upon empty service sharing specification.

Definition at line 328 of file gnunet-service-testbed.c.

330 {
332  struct GNUNET_TESTING_SharedService *slist;
333  char service[256];
334  char *arg;
335  unsigned int n;
336 
337 #define GROW_SS \
338  do { \
339  GNUNET_array_grow (slist, n, n + 1); \
340  GNUNET_memcpy (&slist[n - 1], &ss, \
341  sizeof(struct GNUNET_TESTING_SharedService)); \
342  } while (0)
343 
344  slist = NULL;
345  n = 0;
346  ss.cfg = cfg;
347  for (; NULL != (arg = strtok (ss_str, " ")); ss_str = NULL)
348  {
349  ss.service = NULL;
350  ss.share = 0;
351  if (2 != sscanf (arg, "%255[^:]:%u",
352  service,
353  &ss.share))
354  {
356  "Ignoring shared service spec: %s",
357  arg);
358  continue;
359  }
360  LOG_DEBUG ("Will be sharing %s service among %u peers\n",
361  service,
362  ss.share);
363  ss.service = GNUNET_strdup (service);
364  GROW_SS;
365  }
366  if (NULL != slist)
367  {
368  /* Add trailing NULL block */
369  (void) memset (&ss,
370  0,
371  sizeof(struct GNUNET_TESTING_SharedService));
372  GROW_SS;
373  }
374  return slist;
375 #undef GROW_SS
376 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
#define GROW_SS
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration template for the service.

References find_typedefs::arg, cfg, GNUNET_TESTING_SharedService::cfg, GNUNET_ERROR_TYPE_WARNING, GNUNET_strdup, GROW_SS, LOG, LOG_DEBUG, service, GNUNET_TESTING_SharedService::service, and GNUNET_TESTING_SharedService::share.

Referenced by handle_init().

Here is the caller graph for this function:

◆ check_init()

static int check_init ( void *  cls,
const struct GNUNET_TESTBED_InitMessage msg 
)
static

Check GNUNET_MESSAGE_TYPE_TESTBED_INIT messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if message is well-formed

Definition at line 387 of file gnunet-service-testbed.c.

389 {
390  const char *controller_hostname;
391  uint16_t msize;
392 
393  msize = ntohs (msg->header.size) - sizeof(struct GNUNET_TESTBED_InitMessage);
394  controller_hostname = (const char *) &msg[1];
395  if ('\0' != controller_hostname[msize - 1])
396  {
397  GNUNET_break (0);
398  return GNUNET_SYSERR;
399  }
400  return GNUNET_OK;
401 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
Initial message from a client to a testing control service.
Definition: testbed.h:37

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_init()

static void handle_init ( void *  cls,
const struct GNUNET_TESTBED_InitMessage msg 
)
static

Message handler for GNUNET_MESSAGE_TYPE_TESTBED_INIT messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 411 of file gnunet-service-testbed.c.

413 {
414  struct GNUNET_SERVICE_Client *client = cls;
415  struct GNUNET_TESTBED_Host *host;
416  const char *controller_hostname;
417  char *ss_str;
418  struct GNUNET_TESTING_SharedService *ss;
419  unsigned int cnt;
420 
421  if (NULL != GST_context)
422  {
423  LOG_DEBUG ("We are being connected to laterally\n");
425  return;
426  }
427  controller_hostname = (const char *) &msg[1];
428  ss_str = NULL;
429  ss = NULL;
430  if (GNUNET_OK ==
432  "TESTBED",
433  "SHARED_SERVICES",
434  &ss_str))
435  {
436  ss = parse_shared_services (ss_str,
437  GST_config);
438  GNUNET_free (ss_str);
439  ss_str = NULL;
440  }
441  GST_context = GNUNET_new (struct Context);
442  GST_context->client = client;
443  GST_context->host_id = ntohl (msg->host_id);
444  GST_context->master_ip = GNUNET_strdup (controller_hostname);
445  LOG_DEBUG ("Our IP: %s\n",
448  = GNUNET_TESTING_system_create ("testbed",
450  hostname,
451  ss);
452  if (NULL != ss)
453  {
454  for (cnt = 0; NULL != ss[cnt].service; cnt++)
455  {
456  ss_str = (char *) ss[cnt].service;
457  GNUNET_free (ss_str);
458  }
459  GNUNET_free (ss);
460  ss = NULL;
461  }
462  host =
465  NULL,
466  GST_config,
467  0);
468  host_list_add (host);
469  LOG_DEBUG ("Created master context with host ID: %u\n",
472 }
static struct GNUNET_TESTING_SharedService * parse_shared_services(char *ss_str, struct GNUNET_CONFIGURATION_Handle *cfg)
Parse service sharing specification line.
static int host_list_add(struct GNUNET_TESTBED_Host *host)
Function to add a host to the current list of known hosts.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_CONFIGURATION_Handle * GST_config
Our configuration.
static char * hostname
Our hostname; we give this to all the peers we start.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create_with_id(uint32_t id, const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:477
Context to hold data of peer.
char * master_ip
The network address of the master controller.
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
uint32_t host_id
Our host id according to this context.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
Handle to a client that is connected to a service.
Definition: service.c:252
Opaque handle to a host running experiments managed by the testing framework.
const char * service
The name of the service.

References Context::client, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_TESTBED_host_create_with_id(), GNUNET_TESTING_system_create(), GST_config, GST_context, Context::host_id, host_list_add(), hostname, LOG_DEBUG, Context::master_ip, msg, parse_shared_services(), service, GNUNET_TESTING_SharedService::service, and Context::system.

Here is the call graph for this function:

◆ check_add_host()

static int check_add_host ( void *  cls,
const struct GNUNET_TESTBED_AddHostMessage msg 
)
static

Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if message is well-formed

Definition at line 483 of file gnunet-service-testbed.c.

485 {
486  uint16_t username_length;
487  uint16_t hostname_length;
488  uint16_t msize;
489 
490  msize = ntohs (msg->header.size) - sizeof(struct
492  username_length = ntohs (msg->username_length);
493  hostname_length = ntohs (msg->hostname_length);
494  /* msg must contain hostname */
495  if ((msize <= username_length) ||
496  (0 == hostname_length))
497  {
498  GNUNET_break (0);
499  return GNUNET_SYSERR;
500  }
501  /* msg must contain configuration */
502  if (msize <= username_length + hostname_length)
503  {
504  GNUNET_break (0);
505  return GNUNET_SYSERR;
506  }
507  return GNUNET_OK;
508 }
Notify the service about a host that we intend to use.
Definition: testbed.h:65

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_add_host()

static void handle_add_host ( void *  cls,
const struct GNUNET_TESTBED_AddHostMessage msg 
)
static

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 518 of file gnunet-service-testbed.c.

520 {
521  struct GNUNET_SERVICE_Client *client = cls;
522  struct GNUNET_TESTBED_Host *host;
524  struct GNUNET_CONFIGURATION_Handle *host_cfg;
525  char *username;
526  char *hostname;
527  char *emsg;
528  const void *ptr;
529  uint32_t host_id;
530  uint16_t username_length;
531  uint16_t hostname_length;
532  struct GNUNET_MQ_Envelope *env;
533 
534  username_length = ntohs (msg->username_length);
535  hostname_length = ntohs (msg->hostname_length);
536  username = NULL;
537  hostname = NULL;
538  ptr = &msg[1];
539  if (0 != username_length)
540  {
541  username = GNUNET_malloc (username_length + 1);
542  GNUNET_strlcpy (username, ptr, username_length + 1);
543  ptr += username_length;
544  }
545  hostname = GNUNET_malloc (hostname_length + 1);
546  GNUNET_strlcpy (hostname, ptr, hostname_length + 1);
547  if (NULL == (host_cfg = GNUNET_TESTBED_extract_config_ (&msg->header)))
548  {
549  GNUNET_free (username);
551  GNUNET_break_op (0);
553  return;
554  }
555  host_id = ntohl (msg->host_id);
556  LOG_DEBUG ("Received ADDHOST %u message\n", host_id);
557  LOG_DEBUG ("-------host id: %u\n", host_id);
558  LOG_DEBUG ("-------hostname: %s\n", hostname);
559  if (NULL != username)
560  LOG_DEBUG ("-------username: %s\n", username);
561  else
562  LOG_DEBUG ("-------username: <not given>\n");
563  LOG_DEBUG ("-------ssh port: %u\n", ntohs (msg->ssh_port));
564  host = GNUNET_TESTBED_host_create_with_id (host_id,
565  hostname,
566  username,
567  host_cfg,
568  ntohs (msg->ssh_port));
569  GNUNET_free (username);
571  GNUNET_CONFIGURATION_destroy (host_cfg);
572  if (NULL == host)
573  {
574  GNUNET_break_op (0);
576  return;
577  }
578  if (GNUNET_OK != host_list_add (host))
579  {
580  /* We are unable to add a host */
581  emsg = "A host exists with given host-id";
582  LOG_DEBUG ("%s: %u",
583  emsg,
584  host_id);
586  env = GNUNET_MQ_msg_extra (reply,
587  strlen (emsg) + 1,
589  GNUNET_memcpy (&reply[1],
590  emsg,
591  strlen (emsg) + 1);
592  }
593  else
594  {
595  LOG_DEBUG ("Added host %u at %u\n",
596  host_id,
598  env = GNUNET_MQ_msg (reply,
600  }
601  reply->host_id = htonl (host_id);
603  env);
605 }
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
Message to signal that a add host succeeded.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:138
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
Confirmation from the service that adding a host worked (or failed).
Definition: testbed.h:115
uint32_t host_id
Unique ID for the host (in NBO).
Definition: testbed.h:124
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2043

References env, GNUNET_break_op, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_strlcpy(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_host_create_with_id(), GNUNET_TESTBED_host_destroy(), GST_context, Context::host_id, GNUNET_TESTBED_HostConfirmedMessage::host_id, host_list_add(), hostname, LOG_DEBUG, and msg.

Here is the call graph for this function:

◆ handle_slave_get_config()

static void handle_slave_get_config ( void *  cls,
const struct GNUNET_TESTBED_SlaveGetConfigurationMessage msg 
)
static

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 615 of file gnunet-service-testbed.c.

618 {
619  struct GNUNET_SERVICE_Client *client = cls;
620  struct Slave *slave;
621  struct GNUNET_TESTBED_SlaveConfiguration *reply;
622  const struct GNUNET_CONFIGURATION_Handle *cfg;
623  struct GNUNET_MQ_Envelope *env;
624  char *config;
625  char *xconfig;
626  size_t config_size;
627  size_t xconfig_size;
628  uint64_t op_id;
629  uint32_t slave_id;
630 
631  slave_id = ntohl (msg->slave_id);
632  op_id = GNUNET_ntohll (msg->operation_id);
633  if ((GST_slave_list_size <= slave_id) ||
634  (NULL == GST_slave_list[slave_id]))
635  {
636  /* FIXME: Add forwardings for this type of message here.. */
638  op_id,
639  "Slave not found");
641  return;
642  }
643  slave = GST_slave_list[slave_id];
645  GST_host_list[slave->host_id])));
647  &config_size);
648  /* FIXME: maybe we want to transmit the delta to the default here? */
649  xconfig_size = GNUNET_TESTBED_compress_config_ (config,
650  config_size,
651  &xconfig);
653  GNUNET_assert (xconfig_size + sizeof(struct
655  UINT16_MAX);
656  GNUNET_assert (xconfig_size <= UINT16_MAX);
657  env = GNUNET_MQ_msg_extra (reply,
658  xconfig_size,
660  reply->slave_id = msg->slave_id;
661  reply->operation_id = msg->operation_id;
662  reply->config_size = htons ((uint16_t) config_size);
663  GNUNET_memcpy (&reply[1],
664  xconfig,
665  xconfig_size);
666  GNUNET_free (xconfig);
668  env);
670 }
static const struct GNUNET_CONFIGURATION_Handle * config
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
Message which contains the configuration of slave controller.
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:660
uint64_t operation_id
Operation ID.
Definition: testbed.h:674
uint16_t config_size
The size of the configuration when uncompressed.
Definition: testbed.h:679
uint32_t slave_id
The id of the host where the slave is running.
Definition: testbed.h:669
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1758
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's configuration template.

References cfg, config, GNUNET_TESTBED_SlaveConfiguration::config_size, env, GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_host_get_cfg_(), GST_host_list, GST_send_operation_fail_msg(), GST_slave_list, GST_slave_list_size, Slave::host_id, msg, GNUNET_TESTBED_SlaveConfiguration::operation_id, and GNUNET_TESTBED_SlaveConfiguration::slave_id.

Here is the call graph for this function:

◆ GST_clear_fopcq()

void GST_clear_fopcq ( void  )

Clears the forwarded operations queue.

Definition at line 677 of file gnunet-service-testbed.c.

678 {
679  struct ForwardedOperationContext *fopc;
680 
681  while (NULL != (fopc = fopcq_head))
682  {
684  fopcq_tail,
685  fopc);
687  if (NULL != fopc->timeout_task)
689  switch (fopc->type)
690  {
691  case OP_PEER_CREATE:
692  GNUNET_free (fopc->cls);
693  break;
694 
695  case OP_SHUTDOWN_PEERS:
696  {
697  struct HandlerContext_ShutdownPeers *hc = fopc->cls;
698 
699  GNUNET_assert (0 < hc->nslaves);
700  hc->nslaves--;
701  if (0 == hc->nslaves)
702  GNUNET_free (hc);
703  }
704  break;
705 
706  case OP_PEER_START:
707  case OP_PEER_STOP:
708  case OP_PEER_DESTROY:
709  case OP_PEER_INFO:
710  case OP_OVERLAY_CONNECT:
711  case OP_LINK_CONTROLLERS:
712  case OP_GET_SLAVE_CONFIG:
713  case OP_MANAGE_SERVICE:
714  case OP_PEER_RECONFIGURE:
715  break;
716 
717  case OP_FORWARDED:
718  GNUNET_assert (0);
719  }
720  ;
721  GNUNET_free (fopc);
722  }
723 }
enum OperationType type
The type of the operation which is forwarded.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
@ OP_GET_SLAVE_CONFIG
Get slave config operation.
Definition: testbed_api.h:94
@ OP_PEER_RECONFIGURE
Reconfigure a peer.
Definition: testbed_api.h:74
@ OP_FORWARDED
Forwarded operation.
Definition: testbed_api.h:84
@ OP_PEER_START
Peer start operation.
Definition: testbed_api.h:54
@ OP_PEER_INFO
Get peer information operation.
Definition: testbed_api.h:69
@ OP_SHUTDOWN_PEERS
Stop and destroy all peers.
Definition: testbed_api.h:99
@ OP_MANAGE_SERVICE
Start/stop service at a peer.
Definition: testbed_api.h:104
@ OP_PEER_DESTROY
Peer destroy operation.
Definition: testbed_api.h:64
@ OP_OVERLAY_CONNECT
Overlay connection operation.
Definition: testbed_api.h:79
@ OP_LINK_CONTROLLERS
Link controllers operation.
Definition: testbed_api.h:89
@ OP_PEER_STOP
Peer stop operation.
Definition: testbed_api.h:59
@ OP_PEER_CREATE
Peer create operation.
Definition: testbed_api.h:49

References ForwardedOperationContext::cls, fopcq_head, fopcq_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_forward_operation_msg_cancel_(), HandlerContext_ShutdownPeers::nslaves, OP_FORWARDED, OP_GET_SLAVE_CONFIG, OP_LINK_CONTROLLERS, OP_MANAGE_SERVICE, OP_OVERLAY_CONNECT, OP_PEER_CREATE, OP_PEER_DESTROY, OP_PEER_INFO, OP_PEER_RECONFIGURE, OP_PEER_START, OP_PEER_STOP, OP_SHUTDOWN_PEERS, ForwardedOperationContext::opc, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

Referenced by handle_shutdown_peers(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task to clean up and shutdown nicely.

Parameters
clsNULL

Definition at line 732 of file gnunet-service-testbed.c.

733 {
734  uint32_t id;
735 
736  LOG_DEBUG ("Shutting down testbed service\n");
737  /* cleanup any remaining forwarded operations */
738  GST_clear_fopcq ();
739  GST_free_lcf ();
740  GST_free_mctxq ();
741  GST_free_occq ();
742  GST_free_roccq ();
743  GST_free_nccq ();
745  GST_free_prcq ();
746  /* Clear peer list */
748  /* Clear route list */
750  /* Clear GST_slave_list */
752  /* Clear host list */
753  for (id = 0; id < GST_host_list_size; id++)
754  if (NULL != GST_host_list[id])
757  if (NULL != GST_context)
758  {
760  if (NULL != GST_context->system)
762  GNUNET_YES);
764  GST_context = NULL;
765  }
767  /* Free hello cache */
768  GST_cache_clear ();
771  GST_opq_openfds = NULL;
775 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
void GST_clear_fopcq()
Clears the forwarded operations queue.
void GST_route_list_clear(void)
Cleans up the route list.
void GST_free_mctxq(void)
Frees the ManageServiceContext queue.
void GST_destroy_peers(void)
Stops and destroys all peers.
void GST_cache_clear(void)
Clear cache.
void GST_stats_destroy(void)
Shutdown the status calls module.
void GST_free_lcf(void)
Cleans up the queue used for forwarding link controllers requests.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void GST_free_prcq(void)
Cleans up the Peer reconfigure context list.
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
void GST_barriers_destroy()
Function to stop the barrier service.
void GST_connection_pool_destroy()
Cleanup the connection pool.
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:557
void GNUNET_TESTBED_operation_queue_destroy_(struct OperationQueue *queue)
Destroys an operation queue.

References GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TESTBED_host_destroy(), GNUNET_TESTBED_operation_queue_destroy_(), GNUNET_TESTING_system_destroy(), GNUNET_YES, GST_barriers_destroy(), GST_cache_clear(), GST_clear_fopcq(), GST_config, GST_connection_pool_destroy(), GST_context, GST_destroy_peers(), GST_free_lcf(), GST_free_mctxq(), GST_free_nccq(), GST_free_occq(), GST_free_prcq(), GST_free_roccq(), GST_host_list, GST_host_list_size, GST_neighbour_list_clean(), GST_opq_openfds, GST_route_list_clear(), GST_slave_list_clear(), GST_stats_destroy(), hostname, id, LOG_DEBUG, Context::master_ip, and Context::system.

Referenced by testbed_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Callback for client connect.

Parameters
clsNULL
clientthe client which has disconnected
mqqueue for sending messages to client
Returns
client

Definition at line 787 of file gnunet-service-testbed.c.

790 {
791  return client;
792 }

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Callback for client disconnect.

Parameters
clsNULL
clientthe client which has disconnected
app_ctxshould match client

Definition at line 803 of file gnunet-service-testbed.c.

806 {
807  struct ForwardedOperationContext *fopc;
808  struct ForwardedOperationContext *fopcn;
809 
810  GNUNET_assert (client == app_ctx);
814  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
815  {
816  fopcn = fopc->next;
817  if (fopc->client == client)
818  {
819  /* handle as if it were a timeout */
822  }
823  }
824  if (NULL == GST_context)
825  return;
826  if (client == GST_context->client)
827  {
829  "Master client disconnected\n");
830  GST_context->client = NULL;
831  /* should not be needed as we're terminated by failure to read
832  * from stdin, but if stdin fails for some reason, this shouldn't
833  * hurt for now --- might need to revise this later if we ever
834  * decide that master connections might be temporarily down
835  * for some reason */// GNUNET_SCHEDULER_shutdown ();
836  }
837 }
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
void GST_notify_client_disconnect_peers(struct GNUNET_SERVICE_Client *client)
Notify peers subsystem that client disconnected.
void GST_notify_client_disconnect_oc(struct GNUNET_SERVICE_Client *client)
Notify OC subsystem that client disconnected.
struct ForwardedOperationContext * next
The next pointer for DLL.

References ForwardedOperationContext::client, Context::client, fopcq_head, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_cancel(), GST_context, GST_forwarded_operation_timeout(), GST_link_notify_disconnect(), GST_notify_client_disconnect_oc(), GST_notify_client_disconnect_peers(), LOG, ForwardedOperationContext::next, and ForwardedOperationContext::timeout_task.

Here is the call graph for this function:

◆ testbed_run()

static void testbed_run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Testbed setup.

Parameters
clsclosure
cfgconfiguration to use
servicethe initialized server

Definition at line 848 of file gnunet-service-testbed.c.

851 {
852  char *logfile;
853  unsigned long long num;
854 
855  LOG_DEBUG ("Starting testbed\n");
856  if (GNUNET_OK ==
857  GNUNET_CONFIGURATION_get_value_filename (cfg, "TESTBED", "LOG_FILE",
858  &logfile))
859  {
861  GNUNET_log_setup ("testbed",
862  "DEBUG",
863  logfile));
864  GNUNET_free (logfile);
865  }
868  "testbed",
869  "CACHE_SIZE",
870  &num));
871  GST_cache_init ((unsigned int) num);
872  GST_connection_pool_init ((unsigned int) num);
875  "testbed",
876  "MAX_OPEN_FDS",
877  &num));
880  (unsigned int) num);
883  "testbed",
884  "OPERATION_TIMEOUT",
885  &GST_timeout));
888  "testbed",
889  "HOSTNAME",
890  &hostname));
893  NULL);
894  LOG_DEBUG ("Testbed startup complete\n");
897 }
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
static void shutdown_task(void *cls)
Task to clean up and shutdown nicely.
void GST_stats_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize logging CPU and IO statisticfs.
void GST_cache_init(unsigned int size)
Initializes the cache.
void GST_barriers_init(struct GNUNET_CONFIGURATION_Handle *cfg)
Function to initialise barriers component.
void GST_connection_pool_init(unsigned int size)
Initialise the connection pool.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
@ OPERATION_QUEUE_TYPE_FIXED
Operation queue which permits a fixed maximum number of operations to be active at any time.

References cfg, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_free, GNUNET_log_setup(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_operation_queue_create_(), GST_barriers_init(), GST_cache_init(), GST_config, GST_connection_pool_init(), GST_opq_openfds, GST_stats_init(), GST_timeout, hostname, LOG_DEBUG, OPERATION_QUEUE_TYPE_FIXED, and shutdown_task().

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "testbed"  ,
GNUNET_SERVICE_OPTION_NONE  ,
testbed_run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(init, GNUNET_MESSAGE_TYPE_TESTBED_INIT, struct GNUNET_TESTBED_InitMessage, NULL)  ,
GNUNET_MQ_hd_var_size(add_host, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, struct GNUNET_TESTBED_AddHostMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(slave_get_config, GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION, struct GNUNET_TESTBED_SlaveGetConfigurationMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(link_controllers, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, struct GNUNET_TESTBED_ControllerLinkRequest, NULL)  ,
GNUNET_MQ_hd_var_size(remote_overlay_connect, GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT, struct GNUNET_TESTBED_RemoteOverlayConnectMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(overlay_connect, GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT, struct GNUNET_TESTBED_OverlayConnectMessage, NULL)  ,
GNUNET_MQ_hd_var_size(peer_create, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, struct GNUNET_TESTBED_PeerCreateMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(peer_destroy, GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER, struct GNUNET_TESTBED_PeerDestroyMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(peer_start, GNUNET_MESSAGE_TYPE_TESTBED_START_PEER, struct GNUNET_TESTBED_PeerStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(peer_stop, GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER, struct GNUNET_TESTBED_PeerStopMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(peer_get_config, GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION, struct GNUNET_TESTBED_PeerGetConfigurationMessage, NULL)  ,
GNUNET_MQ_hd_var_size(manage_peer_service, GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE, struct GNUNET_TESTBED_ManagePeerServiceMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(shutdown_peers, GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS, struct GNUNET_TESTBED_ShutdownPeersMessage, NULL)  ,
GNUNET_MQ_hd_var_size(peer_reconfigure, GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, struct GNUNET_TESTBED_PeerReconfigureMessage, NULL)  ,
GNUNET_MQ_hd_var_size(barrier_init, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT, struct GNUNET_TESTBED_BarrierInit, NULL)  ,
GNUNET_MQ_hd_var_size(barrier_cancel, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL, struct GNUNET_TESTBED_BarrierCancel, NULL)  ,
GNUNET_MQ_hd_var_size(barrier_status, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, struct GNUNET_TESTBED_BarrierStatusMsg, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ GST_config

struct GNUNET_CONFIGURATION_Handle* GST_config

Our configuration.

Definition at line 39 of file gnunet-service-testbed.c.

Referenced by handle_init(), shutdown_task(), and testbed_run().

◆ GST_context

◆ GST_host_list

◆ fopcq_head

◆ fopcq_tail

◆ GST_opq_openfds

struct OperationQueue* GST_opq_openfds

Operation queue for open file descriptors.

Definition at line 64 of file gnunet-service-testbed.c.

Referenced by GST_connection_pool_get_handle(), GST_neighbour_get_connection(), shutdown_task(), and testbed_run().

◆ GST_timeout

◆ GST_host_list_size

unsigned int GST_host_list_size

The size of the host list.

Definition at line 74 of file gnunet-service-testbed.c.

Referenced by handle_link_controllers(), host_list_add(), and shutdown_task().

◆ GST_peer_list_size

unsigned int GST_peer_list_size

◆ hostname