GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
testbed_api.c File Reference

API for accessing the GNUnet testing service. More...

#include "platform.h"
#include "gnunet_testbed_service.h"
#include "gnunet_core_service.h"
#include "gnunet_constants.h"
#include "gnunet_transport_service.h"
#include "gnunet_hello_lib.h"
#include <zlib.h>
#include "testbed.h"
#include "testbed_api.h"
#include "testbed_api_hosts.h"
#include "testbed_api_peers.h"
#include "testbed_api_operations.h"
#include "testbed_api_sd.h"
Include dependency graph for testbed_api.c:

Go to the source code of this file.

Data Structures

struct  ForwardedOperationData
 Context data for forwarded Operation. More...
 
struct  GetSlaveConfigData
 Context data for get slave config operations. More...
 
struct  ControllerLinkData
 Context data for controller link operations. More...
 
struct  ShutdownPeersData
 Date context for OP_SHUTDOWN_PEERS operations. More...
 
struct  ExpireOperationEntry
 An entry in the stack for keeping operations which are about to expire. More...
 
struct  SearchContext
 Context information to be used while searching for operation contexts. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "testbed-api", __VA_ARGS__)
 Generic logging shorthand. More...
 
#define LOG_DEBUG(...)   LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 Debug logging. More...
 
#define TIME_REL_SECS(sec)   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
 Relative time seconds shorthand. More...
 
#define TIMEOUT_REL   TIME_REL_SECS(1)
 Default server message sending retry timeout. More...
 

Functions

static void exop_insert (struct GNUNET_TESTBED_Operation *op)
 Inserts an operation into the list of operations marked for expiry. More...
 
static int exop_check (const struct GNUNET_TESTBED_Operation *const op)
 Checks if an operation is present in the list of operations marked for expiry. More...
 
static int opc_search_iterator (void *cls, uint32_t key, void *value)
 Search iterator for searching an operation context. More...
 
static struct OperationContextfind_opc (const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
 Returns the operation context with the given id if found in the Operation context queues of the controller. More...
 
void GNUNET_TESTBED_insert_opc_ (struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
 Inserts the given operation context into the operation context map of the given controller. More...
 
void GNUNET_TESTBED_remove_opc_ (const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
 Removes the given operation context from the operation context map of the given controller. More...
 
static int check_add_host_confirm (void *cls, const struct GNUNET_TESTBED_HostConfirmedMessage *msg)
 Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message is well-formed. More...
 
static void handle_add_host_confirm (void *cls, const struct GNUNET_TESTBED_HostConfirmedMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from controller (testbed service) More...
 
static void handle_forwarded_operation_msg (void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
 Handler for forwarded operations. More...
 
static void handle_opsuccess (void *cls, const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS message from controller (testbed service) More...
 
static void handle_peer_create_success (void *cls, const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS message from controller (testbed service) More...
 
static void handle_peer_event (void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT message from controller (testbed service) More...
 
static void handle_peer_conevent (void *cls, const struct GNUNET_TESTBED_ConnectionEventMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT message from controller (testbed service) More...
 
static int check_peer_config (void *cls, const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
 Validate GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION message from controller (testbed service) More...
 
static void handle_peer_config (void *cls, const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION message from controller (testbed service) More...
 
static int check_op_fail_event (void *cls, const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
 Validate GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT message from controller (testbed service) More...
 
static void handle_op_fail_event (void *cls, const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT message from controller (testbed service) More...
 
static struct GNUNET_TESTBED_SlaveGetConfigurationMessageGNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
 Function to build GET_SLAVE_CONFIG message. More...
 
static int check_slave_config (void *cls, const struct GNUNET_TESTBED_SlaveConfiguration *msg)
 Validate #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_INFORMATION message from controller (testbed service) More...
 
static void handle_slave_config (void *cls, const struct GNUNET_TESTBED_SlaveConfiguration *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION message from controller (testbed service) More...
 
static int check_link_controllers_result (void *cls, const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT message from controller (testbed service) More...
 
static void handle_link_controllers_result (void *cls, const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT message from controller (testbed service) More...
 
static int check_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Validate GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS message. More...
 
static void handle_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages. More...
 
void GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
 Queues a message in send queue for sending to the service. More...
 
struct OperationContextGNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
 Sends the given message as an operation. More...
 
void GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
 Function to cancel an operation created by simply forwarding an operation message. More...
 
static void opstart_link_controllers (void *cls)
 Function to call to start a link-controllers type operation once all queues the operation is part of declare that the operation can be activated. More...
 
static void oprelease_link_controllers (void *cls)
 Callback which will be called when link-controllers type operation is released. More...
 
static void opstart_get_slave_config (void *cls)
 Function to be called when get slave config operation is ready. More...
 
static void oprelease_get_slave_config (void *cls)
 Function to be called when get slave config operation is cancelled or finished. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
struct GNUNET_TESTBED_ControllerGNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
 Start a controller process using the given configuration at the given host. More...
 
static int opc_free_iterator (void *cls, uint32_t key, void *value)
 Iterator to free opc map entries. More...
 
void GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c)
 Stop the given controller (also will terminate all peers and controllers dependent on this controller). More...
 
size_t GNUNET_TESTBED_compress_config_ (const char *config, size_t size, char **xconfig)
 Compresses given configuration using zlib compress. More...
 
char * GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size, size_t *xsize)
 Function to serialize and compress using zlib a configuration through a configuration handle. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_controller_link (void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *slave_host, int is_subordinate)
 Create a link from slave controller to delegated controller. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_get_slave_config_ (void *op_cls, struct GNUNET_TESTBED_Controller *master, uint32_t slave_host_id)
 Like GNUNET_TESTBED_get_slave_config(), however without the host registration check. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_get_slave_config (void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *slave_host)
 Function to acquire the configuration of a running slave controller. More...
 
void GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller, const char *filename)
 Ask the testbed controller to write the current overlay topology to a file. More...
 
struct GNUNET_TESTBED_HelperInitGNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip, const char *hostname, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Creates a helper initialization message. More...
 
void GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
 This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) from an operation has been fully processed i.e. More...
 
struct GNUNET_CONFIGURATION_HandleGNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
 Generates configuration by uncompressing configuration in given message. More...
 
const char * GNUNET_TESTBED_parse_error_string_ (const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
 Checks the integrity of the OperationFailureEventMessage and if good returns the error message it contains. More...
 
uint64_t GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller)
 Function to return the operation id for a controller. More...
 
static void opstart_shutdown_peers (void *cls)
 Function called when a shutdown peers operation is ready. More...
 
static void oprelease_shutdown_peers (void *cls)
 Callback which will be called when shutdown peers operation is released. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c, void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls)
 Stops and destroys all peers. More...
 
uint32_t GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer)
 Return the index of the peer inside of the total peer array, aka. More...
 
void GNUNET_TESTBED_barrier_remove_ (struct GNUNET_TESTBED_Barrier *barrier)
 Remove a barrier and it was the last one in the barrier hash map, destroy the hash map. More...
 
struct GNUNET_TESTBED_BarrierGNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cls, int echo)
 Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier OR upon error. More...
 
struct GNUNET_TESTBED_BarrierGNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cls)
 Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier OR upon error. More...
 
void GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier)
 Cancel a barrier. More...
 

Variables

static struct ExpireOperationEntryexop_head
 DLL head for list of operations marked for expiry. More...
 
static struct ExpireOperationEntryexop_tail
 DLL tail for list of operation marked for expiry. More...
 

Detailed Description

API for accessing the GNUnet testing service.

This library is supposed to make it easier to write testcases and script large-scale benchmarks.

Author
Christian Grothoff
Sree Harsha Totakura

Definition in file testbed_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "testbed-api", __VA_ARGS__)

Generic logging shorthand.

Definition at line 47 of file testbed_api.c.

Referenced by handle_add_host_confirm().

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

◆ TIME_REL_SECS

#define TIME_REL_SECS (   sec)    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)

Relative time seconds shorthand.

Definition at line 59 of file testbed_api.c.

◆ TIMEOUT_REL

#define TIMEOUT_REL   TIME_REL_SECS(1)

Default server message sending retry timeout.

Definition at line 66 of file testbed_api.c.

Function Documentation

◆ exop_insert()

static void exop_insert ( struct GNUNET_TESTBED_Operation op)
static

Inserts an operation into the list of operations marked for expiry.

Parameters
opthe operation to insert

Definition at line 175 of file testbed_api.c.

References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, op, and ExpireOperationEntry::op.

Referenced by handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_create_success(), and handle_peer_event().

176 {
177  struct ExpireOperationEntry *entry;
178 
179  entry = GNUNET_new (struct ExpireOperationEntry);
180  entry->op = op;
182 }
static struct ExpireOperationEntry * exop_tail
DLL tail for list of operation marked for expiry.
Definition: testbed_api.c:166
static struct ExpireOperationEntry * exop_head
DLL head for list of operations marked for expiry.
Definition: testbed_api.c:161
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.c:154
An entry in the stack for keeping operations which are about to expire.
Definition: testbed_api.c:139
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
Here is the caller graph for this function:

◆ exop_check()

static int exop_check ( const struct GNUNET_TESTBED_Operation *const  op)
static

Checks if an operation is present in the list of operations marked for expiry.

If the operation is found, it and the tail of operations after it are removed from the list.

Parameters
opthe operation to check
Returns
GNUNET_NO if the operation is not present in the list; GNUNET_YES if the operation is found in the list (the operation is then removed from the list – calling this function again with the same paramenter will return GNUNET_NO)

Definition at line 197 of file testbed_api.c.

References exop_head, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_YES, ExpireOperationEntry::next, and ExpireOperationEntry::op.

Referenced by GNUNET_TESTBED_operation_done(), handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_create_success(), and handle_peer_event().

198 {
199  struct ExpireOperationEntry *entry;
200  struct ExpireOperationEntry *entry2;
201  int found;
202 
203  found = GNUNET_NO;
204  entry = exop_head;
205  while (NULL != entry)
206  {
207  if (op == entry->op)
208  {
209  found = GNUNET_YES;
210  break;
211  }
212  entry = entry->next;
213  }
214  if (GNUNET_NO == found)
215  return GNUNET_NO;
216  /* Truncate the tail */
217  while (NULL != entry)
218  {
219  entry2 = entry->next;
221  exop_tail,
222  entry);
223  GNUNET_free (entry);
224  entry = entry2;
225  }
226  return GNUNET_YES;
227 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct ExpireOperationEntry * exop_tail
DLL tail for list of operation marked for expiry.
Definition: testbed_api.c:166
static struct ExpireOperationEntry * exop_head
DLL head for list of operations marked for expiry.
Definition: testbed_api.c:161
#define GNUNET_NO
Definition: gnunet_common.h:81
const struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.c:154
An entry in the stack for keeping operations which are about to expire.
Definition: testbed_api.c:139
struct ExpireOperationEntry * next
DLL head; new entries are to be inserted here.
Definition: testbed_api.c:144
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ opc_search_iterator()

static int opc_search_iterator ( void *  cls,
uint32_t  key,
void *  value 
)
static

Search iterator for searching an operation context.

Parameters
clsthe serach context
keycurrent key code
valuevalue in the hash map
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 257 of file testbed_api.c.

References GNUNET_assert, GNUNET_NO, GNUNET_YES, OperationContext::id, SearchContext::id, SearchContext::opc, sc, and value.

Referenced by find_opc().

260 {
261  struct SearchContext *sc = cls;
262  struct OperationContext *opc = value;
263 
264  GNUNET_assert (NULL != opc);
265  GNUNET_assert (NULL == sc->opc);
266  if (opc->id != sc->id)
267  return GNUNET_YES;
268  sc->opc = opc;
269  return GNUNET_NO;
270 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
static char * value
Value of the record to add/remove.
struct OperationContext * opc
The result of the search.
Definition: testbed_api.c:238
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Context information to be used while searching for operation contexts.
Definition: testbed_api.c:233
uint64_t id
The id of the operation context we are searching for.
Definition: testbed_api.c:243
#define GNUNET_YES
Definition: gnunet_common.h:80
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Here is the caller graph for this function:

◆ find_opc()

static struct OperationContext* find_opc ( const struct GNUNET_TESTBED_Controller c,
const uint64_t  id 
)
static

Returns the operation context with the given id if found in the Operation context queues of the controller.

Parameters
cthe controller whose operation context map is searched
idthe id which has to be checked
Returns
the matching operation context; NULL if no match found

Definition at line 282 of file testbed_api.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get_multiple(), GNUNET_SYSERR, id, SearchContext::id, SearchContext::opc, GNUNET_TESTBED_Controller::opc_map, and opc_search_iterator().

Referenced by handle_link_controllers_result(), handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_config(), handle_peer_create_success(), handle_peer_event(), and handle_slave_config().

283 {
284  struct SearchContext sc;
285 
286  sc.id = id;
287  sc.opc = NULL;
288  GNUNET_assert (NULL != c->opc_map);
289  if (GNUNET_SYSERR !=
292  return NULL;
293  return sc.opc;
294 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:230
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
static int opc_search_iterator(void *cls, uint32_t key, void *value)
Search iterator for searching an operation context.
Definition: testbed_api.c:257
Context information to be used while searching for operation contexts.
Definition: testbed_api.c:233
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_HashMapIterator32 it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_insert_opc_()

void GNUNET_TESTBED_insert_opc_ ( struct GNUNET_TESTBED_Controller c,
struct OperationContext opc 
)

Inserts the given operation context into the operation context map of the given controller.

Creates the operation context map if one does not exist for the controller

Parameters
cthe controller
opcthe operation context to be inserted

Definition at line 306 of file testbed_api.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_OK, OperationContext::id, and GNUNET_TESTBED_Controller::opc_map.

Referenced by GNUNET_TESTBED_forward_operation_msg_(), opstart_get_slave_config(), opstart_link_controllers(), opstart_manage_service(), opstart_overlay_connect(), opstart_peer_create(), opstart_peer_destroy(), opstart_peer_getinfo(), opstart_peer_reconfigure(), opstart_peer_start(), opstart_peer_stop(), and opstart_shutdown_peers().

308 {
309  if (NULL == c->opc_map)
313  (uint32_t) opc->id, opc,
315 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:230
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
Allow multiple values with the same key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_remove_opc_()

void GNUNET_TESTBED_remove_opc_ ( const struct GNUNET_TESTBED_Controller c,
struct OperationContext opc 
)

Removes the given operation context from the operation context map of the given controller.

Parameters
cthe controller
opcthe operation context to remove

Definition at line 326 of file testbed_api.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_YES, OperationContext::id, GNUNET_TESTBED_Controller::opc_map, GNUNET_TESTBED_Controller::opcq_empty_cb, and GNUNET_TESTBED_Controller::opcq_empty_cls.

Referenced by GNUNET_TESTBED_forward_operation_msg_cancel_(), handle_forwarded_operation_msg(), handle_link_controllers_result(), handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_config(), handle_peer_create_success(), handle_peer_event(), handle_slave_config(), oprelease_get_slave_config(), oprelease_link_controllers(), oprelease_manage_service(), oprelease_overlay_connect(), oprelease_peer_create(), oprelease_peer_destroy(), oprelease_peer_getinfo(), oprelease_peer_reconfigure(), oprelease_peer_start(), oprelease_peer_stop(), and oprelease_shutdown_peers().

328 {
329  GNUNET_assert (NULL != c->opc_map);
332  (uint32_t) opc->id,
333  opc));
335  && (NULL != c->opcq_empty_cb) )
337 }
TESTBED_opcq_empty_cb opcq_empty_cb
If this callback is not NULL, schedule it as a task when opc_map gets empty.
Definition: testbed_api.h:235
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:230
void * opcq_empty_cls
Closure for the above task.
Definition: testbed_api.h:240
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_add_host_confirm()

static int check_add_host_confirm ( void *  cls,
const struct GNUNET_TESTBED_HostConfirmedMessage msg 
)
static

Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message is well-formed.

Parameters
clsthe controller handler
msgmessage received
Returns
GNUNET_OK if message is well-formed

Definition at line 349 of file testbed_api.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_HostConfirmedMessage::header, and GNUNET_MessageHeader::size.

351 {
352  const char *emsg;
353  uint16_t msg_size;
354 
355  msg_size = ntohs (msg->header.size) - sizeof (*msg);
356  if (0 == msg_size)
357  return GNUNET_OK;
358  /* We have an error message */
359  emsg = (const char *) &msg[1];
360  if ('\0' != emsg[msg_size - 1])
361  {
362  GNUNET_break (0);
363  return GNUNET_SYSERR;
364  }
365  return GNUNET_OK;
366 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS.
Definition: testbed.h:123

◆ handle_add_host_confirm()

static void handle_add_host_confirm ( void *  cls,
const struct GNUNET_TESTBED_HostConfirmedMessage msg 
)
static

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from controller (testbed service)

Parameters
clsthe controller handler
msgmessage received

Definition at line 377 of file testbed_api.c.

References _, GNUNET_TESTBED_HostRegistrationHandle::cc, GNUNET_TESTBED_HostRegistrationHandle::cc_cls, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_mark_host_registered_at_(), GNUNET_TESTBED_HostConfirmedMessage::header, GNUNET_TESTBED_HostRegistrationHandle::host, GNUNET_TESTBED_HostConfirmedMessage::host_id, LOG, LOG_DEBUG, GNUNET_TESTBED_Controller::rh, and GNUNET_MessageHeader::size.

379 {
380  struct GNUNET_TESTBED_Controller *c = cls;
382  const char *emsg;
383  uint16_t msg_size;
384 
385  if (NULL == rh)
386  return;
387  if (GNUNET_TESTBED_host_get_id_ (rh->host) != ntohl (msg->host_id))
388  {
389  LOG_DEBUG ("Mismatch in host id's %u, %u of host confirm msg\n",
391  ntohl (msg->host_id));
392  return;
393  }
394  c->rh = NULL;
395  msg_size = ntohs (msg->header.size) - sizeof (*msg);
396  if (0 == msg_size)
397  {
398  LOG_DEBUG ("Host %u successfully registered\n",
399  ntohl (msg->host_id));
401  c);
402  rh->cc (rh->cc_cls,
403  NULL);
404  GNUNET_free (rh);
405  return;
406  }
407  /* We have an error message */
408  emsg = (const char *) &msg[1];
410  _("Adding host %u failed with error: %s\n"),
411  ntohl (msg->host_id),
412  emsg);
413  rh->cc (rh->cc_cls,
414  emsg);
415  GNUNET_free (rh);
416 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
void GNUNET_TESTBED_mark_host_registered_at_(struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
Marks a host as registered with a controller.
struct GNUNET_TESTBED_Host * host
The host being registered.
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:225
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void * cc_cls
The closure for above callback.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
uint32_t host_id
Unique ID for the host (in NBO).
Definition: testbed.h:128
#define LOG(kind,...)
Generic logging shorthand.
Definition: testbed_api.c:47
GNUNET_TESTBED_HostRegistrationCompletion cc
The Registartion completion callback.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS.
Definition: testbed.h:123
handle for host registration
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_forwarded_operation_msg()

static void handle_forwarded_operation_msg ( void *  cls,
struct OperationContext opc,
const struct GNUNET_MessageHeader msg 
)
static

Handler for forwarded operations.

Parameters
cthe controller handle
opcthe opearation context
msgthe message

Definition at line 427 of file testbed_api.c.

References ForwardedOperationData::cc, ForwardedOperationData::cc_cls, OperationContext::data, GNUNET_free, and GNUNET_TESTBED_remove_opc_().

Referenced by handle_link_controllers_result(), handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_config(), handle_peer_create_success(), and handle_peer_event().

430 {
431  struct GNUNET_TESTBED_Controller *c = cls;
432  struct ForwardedOperationData *fo_data;
433 
434  fo_data = opc->data;
435  if (NULL != fo_data->cc)
436  fo_data->cc (fo_data->cc_cls, msg);
438  GNUNET_free (fo_data);
439  GNUNET_free (opc);
440 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
GNUNET_MQ_MessageCallback cc
The callback to call when reply is available.
Definition: testbed_api.c:78
void * cc_cls
The closure for the above callback.
Definition: testbed_api.c:83
Context data for forwarded Operation.
Definition: testbed_api.c:72
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_opsuccess()

static void handle_opsuccess ( void *  cls,
const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 451 of file testbed_api.c.

References OperationContext::c, ShutdownPeersData::cb, ManageServiceData::cb, ShutdownPeersData::cb_cls, ManageServiceData::cb_cls, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, data, OperationContext::data, GNUNET_TESTBED_Controller::event_mask, exop_check(), exop_insert(), find_opc(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_cleanup_peers_(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_peer_deregister_(), GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), LOG_DEBUG, OperationContext::op, GNUNET_TESTBED_EventInformation::op, OperationContext::op_cls, OP_FORWARDED, OP_MANAGE_SERVICE, OP_PEER_DESTROY, OP_PEER_RECONFIGURE, OP_SHUTDOWN_PEERS, OPC_STATE_FINISHED, GNUNET_TESTBED_GenericOperationSuccessEventMessage::operation_id, peer, OperationContext::state, and OperationContext::type.

453 {
454  struct GNUNET_TESTBED_Controller *c = cls;
455  struct OperationContext *opc;
457  void *op_comp_cb_cls;
458  struct GNUNET_TESTBED_EventInformation event;
459  uint64_t op_id;
460 
461  op_id = GNUNET_ntohll (msg->operation_id);
462  LOG_DEBUG ("Operation %lu successful\n", op_id);
463  if (NULL == (opc = find_opc (c, op_id)))
464  {
465  LOG_DEBUG ("Operation not found\n");
466  return;
467  }
469  event.op = opc->op;
470  event.op_cls = opc->op_cls;
471  event.details.operation_finished.emsg = NULL;
472  event.details.operation_finished.generic = NULL;
473  op_comp_cb = NULL;
474  op_comp_cb_cls = NULL;
475  switch (opc->type)
476  {
477  case OP_FORWARDED:
478  {
480  (const struct GNUNET_MessageHeader *) msg);
481  return;
482  }
483  break;
484  case OP_PEER_DESTROY:
485  {
486  struct GNUNET_TESTBED_Peer *peer;
487 
488  peer = opc->data;
490  GNUNET_free (peer);
491  opc->data = NULL;
492  //PEERDESTROYDATA
493  }
494  break;
495  case OP_SHUTDOWN_PEERS:
496  {
497  struct ShutdownPeersData *data;
498 
499  data = opc->data;
500  op_comp_cb = data->cb;
501  op_comp_cb_cls = data->cb_cls;
502  GNUNET_free (data);
503  opc->data = NULL;
505  }
506  break;
507  case OP_MANAGE_SERVICE:
508  {
509  struct ManageServiceData *data;
510 
511  GNUNET_assert (NULL != (data = opc->data));
512  op_comp_cb = data->cb;
513  op_comp_cb_cls = data->cb_cls;
514  GNUNET_free (data);
515  opc->data = NULL;
516  }
517  break;
518  case OP_PEER_RECONFIGURE:
519  break;
520  default:
521  GNUNET_assert (0);
522  }
523  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
524  opc->state = OPC_STATE_FINISHED;
525  exop_insert (event.op);
526  if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
527  {
528  if (NULL != c->cc)
529  c->cc (c->cc_cls, &event);
530  if (GNUNET_NO == exop_check (event.op))
531  return;
532  }
533  else
534  LOG_DEBUG ("Not calling callback\n");
535  if (NULL != op_comp_cb)
536  op_comp_cb (op_comp_cb_cls, event.op, NULL);
537  /* You could have marked the operation as done by now */
538  GNUNET_break (GNUNET_NO == exop_check (event.op));
539 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:197
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
Stop and destroy all peers.
Definition: testbed_api.h:99
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Reconfigure a peer.
Definition: testbed_api.h:74
void GNUNET_TESTBED_cleanup_peers_(void)
Frees all peers.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:606
static void exop_insert(struct GNUNET_TESTBED_Operation *op)
Inserts an operation into the list of operations marked for expiry.
Definition: testbed_api.c:175
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
Peer destroy operation.
Definition: testbed_api.h:64
A requested testbed operation has been completed.
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
void GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer)
Removes a peer from the peer list.
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call.
Definition: testbed_api.c:127
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
GNUNET_TESTBED_OperationCompletionCallback cb
Forwarded operation.
Definition: testbed_api.h:84
The operation has finished.
Definition: testbed_api.h:130
Date context for OP_SHUTDOWN_PEERS operations.
Definition: testbed_api.c:122
void(* GNUNET_TESTBED_OperationCompletionCallback)(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when an operation is completed.
Start/stop service at a peer.
Definition: testbed_api.h:104
void * cb_cls
The closure for the above callback.
Definition: testbed_api.c:132
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
Header for all communications.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:

◆ handle_peer_create_success()

static void handle_peer_create_success ( void *  cls,
const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS message from controller (testbed service)

Parameters
cthe controller handle
msgmessage received

Definition at line 550 of file testbed_api.c.

References OperationContext::c, PeerCreateData::cb, GNUNET_TESTBED_Operation::cb_cls, PeerCreateData::cls, data, OperationContext::data, exop_check(), exop_insert(), find_opc(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_peer_register_(), GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), GNUNET_TESTBED_PeerCreateSuccessEventMessage::header, LOG_DEBUG, op, OperationContext::op, OP_FORWARDED, OP_PEER_CREATE, OPC_STATE_FINISHED, GNUNET_TESTBED_PeerCreateSuccessEventMessage::operation_id, peer, PeerCreateData::peer, GNUNET_TESTBED_PeerCreateSuccessEventMessage::peer_id, GNUNET_MessageHeader::size, GNUNET_TESTBED_Peer::state, OperationContext::state, TESTBED_PS_CREATED, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

552 {
553  struct GNUNET_TESTBED_Controller *c = cls;
554  struct OperationContext *opc;
555  struct PeerCreateData *data;
556  struct GNUNET_TESTBED_Peer *peer;
559  void *cb_cls;
560  uint64_t op_id;
561 
563  ntohs (msg->header.size));
564  op_id = GNUNET_ntohll (msg->operation_id);
565  if (NULL == (opc = find_opc (c, op_id)))
566  {
567  LOG_DEBUG ("Operation context for PeerCreateSuccessEvent not found\n");
568  return;
569  }
570  if (OP_FORWARDED == opc->type)
571  {
573  (const struct GNUNET_MessageHeader *) msg);
574  return;
575  }
577  GNUNET_assert (NULL != opc->data);
578  data = opc->data;
579  GNUNET_assert (NULL != data->peer);
580  peer = data->peer;
581  GNUNET_assert (peer->unique_id == ntohl (msg->peer_id));
582  peer->state = TESTBED_PS_CREATED;
584  cb = data->cb;
585  cb_cls = data->cls;
586  op = opc->op;
587  GNUNET_free (opc->data);
588  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
589  opc->state = OPC_STATE_FINISHED;
590  exop_insert (op);
591  if (NULL != cb)
592  cb (cb_cls, peer, NULL);
593  /* You could have marked the operation as done by now */
595 }
void * cb_cls
Closure for callbacks.
Event notification from a controller to a client.
Definition: testbed.h:563
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:197
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * cls
The closure for the above callback.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS.
Definition: testbed.h:569
#define GNUNET_NO
Definition: gnunet_common.h:81
GNUNET_TESTBED_PeerCreateCallback cb
The call back to call when we receive peer create success message.
void GNUNET_TESTBED_peer_register_(struct GNUNET_TESTBED_Peer *peer)
Adds a peer to the peer list.
uint32_t peer_id
Peer identity of the peer that was created.
Definition: testbed.h:574
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Opaque handle to an abstract operation to be executed by the testing framework.
void(* GNUNET_TESTBED_PeerCreateCallback)(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
Functions of this signature are called when a peer has been successfully created. ...
static void exop_insert(struct GNUNET_TESTBED_Operation *op)
Inserts an operation into the list of operations marked for expiry.
Definition: testbed_api.c:175
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
enum PeerState state
Peer&#39;s state.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Forwarded operation.
Definition: testbed_api.h:84
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:579
The operation has finished.
Definition: testbed_api.h:130
uint32_t unique_id
Globally unique ID of the peer.
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
Peer create operation.
Definition: testbed_api.h:49
struct GNUNET_TESTBED_Peer * peer
The peer structure to return when we get success message.
The peer has been created.
Header for all communications.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Data for the OperationType OP_PEER_CREATE.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:

◆ handle_peer_event()

static void handle_peer_event ( void *  cls,
const struct GNUNET_TESTBED_PeerEventMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 606 of file testbed_api.c.

References OperationContext::c, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, data, OperationContext::data, GNUNET_TESTBED_Controller::event_mask, GNUNET_TESTBED_PeerEventMessage::event_type, exop_check(), exop_insert(), find_opc(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_ET_PEER_STOP, GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), GNUNET_TESTBED_PeerEventMessage::header, GNUNET_TESTBED_Peer::host, LOG_DEBUG, OperationContext::op, GNUNET_TESTBED_EventInformation::op, OperationContext::op_cls, OP_FORWARDED, OP_PEER_START, OP_PEER_STOP, OPC_STATE_FINISHED, GNUNET_TESTBED_PeerEventMessage::operation_id, PeerEventData::pcc, PeerEventData::pcc_cls, peer, PeerEventData::peer, GNUNET_MessageHeader::size, GNUNET_TESTBED_Peer::state, OperationContext::state, TESTBED_PS_STARTED, TESTBED_PS_STOPPED, OperationContext::type, and GNUNET_TESTBED_EventInformation::type.

608 {
609  struct GNUNET_TESTBED_Controller *c = cls;
610  struct OperationContext *opc;
611  struct GNUNET_TESTBED_Peer *peer;
612  struct PeerEventData *data;
614  void *pcc_cls;
615  struct GNUNET_TESTBED_EventInformation event;
616  uint64_t op_id;
617  uint64_t mask;
618 
620  ntohs (msg->header.size));
621  op_id = GNUNET_ntohll (msg->operation_id);
622  if (NULL == (opc = find_opc (c, op_id)))
623  {
624  LOG_DEBUG ("Operation not found\n");
625  return;
626  }
627  if (OP_FORWARDED == opc->type)
628  {
630  (const struct GNUNET_MessageHeader *) msg);
631  return;
632  }
633  GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type));
634  data = opc->data;
635  GNUNET_assert (NULL != data);
636  peer = data->peer;
637  GNUNET_assert (NULL != peer);
638  event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type);
639  event.op = opc->op;
640  event.op_cls = opc->op_cls;
641  switch (event.type)
642  {
644  peer->state = TESTBED_PS_STARTED;
645  event.details.peer_start.host = peer->host;
646  event.details.peer_start.peer = peer;
647  break;
649  peer->state = TESTBED_PS_STOPPED;
650  event.details.peer_stop.peer = peer;
651  break;
652  default:
653  GNUNET_assert (0); /* We should never reach this state */
654  }
655  pcc = data->pcc;
656  pcc_cls = data->pcc_cls;
657  GNUNET_free (data);
658  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
659  opc->state = OPC_STATE_FINISHED;
660  exop_insert (event.op);
661  mask = 1LL << GNUNET_TESTBED_ET_PEER_START;
662  mask |= 1LL << GNUNET_TESTBED_ET_PEER_STOP;
663  if (0 != (mask & c->event_mask))
664  {
665  if (NULL != c->cc)
666  c->cc (c->cc_cls, &event);
667  if (GNUNET_NO == exop_check (event.op))
668  return;
669  }
670  if (NULL != pcc)
671  pcc (pcc_cls, NULL);
672  /* You could have marked the operation as done by now */
673  GNUNET_break (GNUNET_NO == exop_check (event.op));
674 }
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:493
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:197
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Event notification from a controller to a client.
Definition: testbed.h:466
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Data for OperationType OP_PEER_START and OP_PEER_STOP.
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:478
static void exop_insert(struct GNUNET_TESTBED_Operation *op)
Inserts an operation into the list of operations marked for expiry.
Definition: testbed_api.c:175
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
enum PeerState state
Peer&#39;s state.
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
GNUNET_TESTBED_PeerChurnCallback pcc
The Peer churn callback to call when this operation is completed.
void * pcc_cls
Closure for the above callback.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
Peer start operation.
Definition: testbed_api.h:54
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
void(* GNUNET_TESTBED_PeerChurnCallback)(void *cls, const char *emsg)
Functions of this signature are called when a peer has been successfully started or stopped...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
The peer is stopped.
Forwarded operation.
Definition: testbed_api.h:84
The operation has finished.
Definition: testbed_api.h:130
GNUNET_TESTBED_EventType
Enumeration with (at most 64) possible event types that can be monitored using the testbed framework...
Peer stop operation.
Definition: testbed_api.h:59
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT.
Definition: testbed.h:472
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
Header for all communications.
The peer is running.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
A peer controlled by the testing framework.
A peer has been stopped.
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:

◆ handle_peer_conevent()

static void handle_peer_conevent ( void *  cls,
const struct GNUNET_TESTBED_ConnectionEventMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 685 of file testbed_api.c.

References OperationContext::c, OverlayConnectData::cb, OverlayConnectData::cb_cls, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, data, OperationContext::data, GNUNET_TESTBED_Controller::event_mask, GNUNET_TESTBED_ConnectionEventMessage::event_type, exop_check(), exop_insert(), find_opc(), GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_DISCONNECT, GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), LOG_DEBUG, OperationContext::op, GNUNET_TESTBED_EventInformation::op, OperationContext::op_cls, OP_FORWARDED, OP_OVERLAY_CONNECT, OPC_STATE_FINISHED, GNUNET_TESTBED_ConnectionEventMessage::operation_id, OverlayConnectData::p1, OverlayConnectData::p2, GNUNET_TESTBED_ConnectionEventMessage::peer1, GNUNET_TESTBED_ConnectionEventMessage::peer2, OperationContext::state, OperationContext::type, GNUNET_TESTBED_EventInformation::type, and GNUNET_TESTBED_Peer::unique_id.

687 {
688  struct GNUNET_TESTBED_Controller *c = cls;
689  struct OperationContext *opc;
690  struct OverlayConnectData *data;
692  void *cb_cls;
693  struct GNUNET_TESTBED_EventInformation event;
694  uint64_t op_id;
695  uint64_t mask;
696 
697  op_id = GNUNET_ntohll (msg->operation_id);
698  if (NULL == (opc = find_opc (c, op_id)))
699  {
700  LOG_DEBUG ("Operation not found\n");
701  return;
702  }
703  if (OP_FORWARDED == opc->type)
704  {
706  (const struct GNUNET_MessageHeader *) msg);
707  return;
708  }
710  GNUNET_assert (NULL != (data = opc->data));
711  GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) &&
712  (ntohl (msg->peer2) == data->p2->unique_id));
713  event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type);
714  event.op = opc->op;
715  event.op_cls = opc->op_cls;
716  switch (event.type)
717  {
719  event.details.peer_connect.peer1 = data->p1;
720  event.details.peer_connect.peer2 = data->p2;
721  break;
723  GNUNET_assert (0); /* FIXME: implement */
724  break;
725  default:
726  GNUNET_assert (0); /* Should never reach here */
727  break;
728  }
729  cb = data->cb;
730  cb_cls = data->cb_cls;
731  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
732  opc->state = OPC_STATE_FINISHED;
733  exop_insert (event.op);
734  mask = 1LL << GNUNET_TESTBED_ET_CONNECT;
735  mask |= 1LL << GNUNET_TESTBED_ET_DISCONNECT;
736  if (0 != (mask & c->event_mask))
737  {
738  if (NULL != c->cc)
739  c->cc (c->cc_cls, &event);
740  if (GNUNET_NO == exop_check (event.op))
741  return;
742  }
743  if (NULL != cb)
744  cb (cb_cls, opc->op, NULL);
745  /* You could have marked the operation as done by now */
746  GNUNET_break (GNUNET_NO == exop_check (event.op));
747 }
void * cb_cls
The closure for the above callback.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:197
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void exop_insert(struct GNUNET_TESTBED_Operation *op)
Inserts an operation into the list of operations marked for expiry.
Definition: testbed_api.c:175
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
uint32_t peer2
Second peer.
Definition: testbed.h:523
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:528
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call once this operation is done.
A connection between two peers was torn down.
Data structure for OperationType OP_OVERLAY_CONNECT.
uint32_t peer1
First peer.
Definition: testbed.h:518
struct GNUNET_TESTBED_Peer * p1
Peer A to connect to peer B.
Overlay connection operation.
Definition: testbed_api.h:79
Forwarded operation.
Definition: testbed_api.h:84
int32_t event_type
&#39;enum GNUNET_TESTBED_EventType&#39; (in NBO); either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCO...
Definition: testbed.h:513
A connection between two peers was established.
The operation has finished.
Definition: testbed_api.h:130
GNUNET_TESTBED_EventType
Enumeration with (at most 64) possible event types that can be monitored using the testbed framework...
void(* GNUNET_TESTBED_OperationCompletionCallback)(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when an operation is completed.
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_TESTBED_Peer * p2
Peer B.
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
Header for all communications.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:

◆ check_peer_config()

static int check_peer_config ( void *  cls,
const struct GNUNET_TESTBED_PeerConfigurationInformationMessage msg 
)
static

Validate GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 758 of file testbed_api.c.

References GNUNET_OK.

760 {
761  /* anything goes? */
762  return GNUNET_OK;
763 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_peer_config()

static void handle_peer_config ( void *  cls,
const struct GNUNET_TESTBED_PeerConfigurationInformationMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 774 of file testbed_api.c.

References OperationContext::c, PeerInfoData::cb, PeerInfoData::cb_cls, GNUNET_TESTBED_PeerInformation::cfg, data, OperationContext::data, find_opc(), GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_ntohll(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_PIT_CONFIGURATION, GNUNET_TESTBED_PIT_GENERIC, GNUNET_TESTBED_PIT_IDENTITY, GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), GNUNET_TESTBED_PeerConfigurationInformationMessage::header, GNUNET_TESTBED_PeerInformation::id, LOG_DEBUG, OperationContext::op, OP_FORWARDED, OPC_STATE_FINISHED, GNUNET_TESTBED_PeerConfigurationInformationMessage::operation_id, peer, PeerInfoData::peer, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_identity, PeerInfoData::pit, GNUNET_TESTBED_PeerInformation::pit, GNUNET_TESTBED_PeerInformation::result, OperationContext::state, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

776 {
777  struct GNUNET_TESTBED_Controller *c = cls;
778  struct OperationContext *opc;
779  struct GNUNET_TESTBED_Peer *peer;
780  struct PeerInfoData *data;
781  struct GNUNET_TESTBED_PeerInformation *pinfo;
783  void *cb_cls;
784  uint64_t op_id;
785 
786  op_id = GNUNET_ntohll (msg->operation_id);
787  if (NULL == (opc = find_opc (c, op_id)))
788  {
789  LOG_DEBUG ("Operation not found\n");
790  return;
791  }
792  if (OP_FORWARDED == opc->type)
793  {
795  opc,
796  &msg->header);
797  return;
798  }
799  data = opc->data;
800  GNUNET_assert (NULL != data);
801  peer = data->peer;
802  GNUNET_assert (NULL != peer);
803  GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id);
805  pinfo->pit = data->pit;
806  cb = data->cb;
807  cb_cls = data->cb_cls;
808  GNUNET_assert (NULL != cb);
809  GNUNET_free (data);
810  opc->data = NULL;
811  switch (pinfo->pit)
812  {
814  pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity);
815  GNUNET_memcpy (pinfo->result.id,
816  &msg->peer_identity,
817  sizeof (struct GNUNET_PeerIdentity));
818  break;
820  pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */
822  break;
824  GNUNET_assert (0); /* never reach here */
825  break;
826  }
827  opc->data = pinfo;
828  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
829  opc->state = OPC_STATE_FINISHED;
830  cb (cb_cls, opc->op, pinfo, NULL);
831  /* We dont check whether the operation is marked as done here as the
832  operation contains data (cfg/identify) which will be freed at a later point
833  */
834 }
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:650
Data for the OperationType OP_PEER_INFO.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
union GNUNET_TESTBED_PeerInformation::@64 result
The result of the get information operation; Choose according to the pit.
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * cb_cls
The closure for peer info callback.
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the &#39;op_result&#39; is actually in use...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION.
Definition: testbed.h:645
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:655
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:2068
GNUNET_TESTBED_PeerInfoCallback cb
The Peer info callback to call when this operation has completed.
struct GNUNET_PeerIdentity * id
The identity of the peer.
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
#define GNUNET_memcpy(dst, src, n)
Special value (not valid for requesting information) that is used in the event struct if a &#39;generic&#39; ...
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
void(* GNUNET_TESTBED_PeerInfoCallback)(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Callback to be called when the requested peer information is available The peer information in the ca...
What configuration is the peer using? Returns a &#39;const struct GNUNET_CONFIGURATION_Handle *&#39;...
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:660
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Forwarded operation.
Definition: testbed_api.h:84
The operation has finished.
Definition: testbed_api.h:130
uint32_t unique_id
Globally unique ID of the peer.
The identity of the host (wraps the signing key of the peer).
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
enum GNUNET_TESTBED_PeerInformationType pit
The type of peer information requested.
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Data returned from GNUNET_TESTBED_peer_get_information.
Here is the call graph for this function:

◆ check_op_fail_event()

static int check_op_fail_event ( void *  cls,
const struct GNUNET_TESTBED_OperationFailureEventMessage msg 
)
static

Validate GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received
Returns
GNUNET_OK if message is well-formed

Definition at line 846 of file testbed_api.c.

References GNUNET_OK.

848 {
849  /* we accept anything as a valid error message */
850  return GNUNET_OK;
851 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_op_fail_event()

static void handle_op_fail_event ( void *  cls,
const struct GNUNET_TESTBED_OperationFailureEventMessage msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 862 of file testbed_api.c.

References OperationContext::c, PeerCreateData::cb, PeerInfoData::cb, OverlayConnectData::cb, ManageServiceData::cb, PeerInfoData::cb_cls, OverlayConnectData::cb_cls, ManageServiceData::cb_cls, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, PeerCreateData::cls, data, OperationContext::data, GNUNET_TESTBED_Controller::event_mask, exop_check(), exop_insert(), find_opc(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_operation_mark_failed(), GNUNET_TESTBED_parse_error_string_(), GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), LOG_DEBUG, OperationContext::op, GNUNET_TESTBED_EventInformation::op, OperationContext::op_cls, OP_FORWARDED, OP_LINK_CONTROLLERS, OP_MANAGE_SERVICE, OP_OVERLAY_CONNECT, OP_PEER_CREATE, OP_PEER_DESTROY, OP_PEER_INFO, OP_PEER_START, OP_PEER_STOP, OP_SHUTDOWN_PEERS, OPC_STATE_FINISHED, GNUNET_TESTBED_OperationFailureEventMessage::operation_id, PeerEventData::pcc, PeerEventData::pcc_cls, PeerCreateData::peer, OperationContext::state, and OperationContext::type.

864 {
865  struct GNUNET_TESTBED_Controller *c = cls;
866  struct OperationContext *opc;
867  const char *emsg;
868  uint64_t op_id;
869  uint64_t mask;
870  struct GNUNET_TESTBED_EventInformation event;
871 
872  op_id = GNUNET_ntohll (msg->operation_id);
873  if (NULL == (opc = find_opc (c, op_id)))
874  {
875  LOG_DEBUG ("Operation not found\n");
876  return;
877  }
878  if (OP_FORWARDED == opc->type)
879  {
881  (const struct GNUNET_MessageHeader *) msg);
882  return;
883  }
884  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
885  opc->state = OPC_STATE_FINISHED;
887  if (NULL == emsg)
888  emsg = "Unknown error";
889  if (OP_PEER_INFO == opc->type)
890  {
891  struct PeerInfoData *data;
892 
893  data = opc->data;
894  if (NULL != data->cb)
895  data->cb (data->cb_cls, opc->op, NULL, emsg);
896  GNUNET_free (data);
897  return; /* We do not call controller callback for peer info */
898  }
900  event.op = opc->op;
901  event.op_cls = opc->op_cls;
902  event.details.operation_finished.emsg = emsg;
903  event.details.operation_finished.generic = NULL;
904  mask = (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
905  if ((0 != (mask & c->event_mask)) && (NULL != c->cc))
906  {
907  exop_insert (event.op);
908  c->cc (c->cc_cls, &event);
909  if (GNUNET_NO == exop_check (event.op))
910  return;
911  }
912  switch (opc->type)
913  {
914  case OP_PEER_CREATE:
915  {
916  struct PeerCreateData *data;
917 
918  data = opc->data;
919  GNUNET_free (data->peer);
920  if (NULL != data->cb)
921  data->cb (data->cls, NULL, emsg);
922  GNUNET_free (data);
923  }
924  break;
925  case OP_PEER_START:
926  case OP_PEER_STOP:
927  {
928  struct PeerEventData *data;
929 
930  data = opc->data;
931  if (NULL != data->pcc)
932  data->pcc (data->pcc_cls, emsg);
933  GNUNET_free (data);
934  }
935  break;
936  case OP_PEER_DESTROY:
937  break;
938  case OP_PEER_INFO:
939  GNUNET_assert (0);
940  case OP_OVERLAY_CONNECT:
941  {
942  struct OverlayConnectData *data;
943 
944  data = opc->data;
946  if (NULL != data->cb)
947  data->cb (data->cb_cls, opc->op, emsg);
948  }
949  break;
950  case OP_FORWARDED:
951  GNUNET_assert (0);
952  case OP_LINK_CONTROLLERS: /* No secondary callback */
953  break;
954  case OP_SHUTDOWN_PEERS:
955  {
956  struct ShutdownPeersData *data;
957 
958  data = opc->data;
959  GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */
960  opc->data = NULL;
961  }
962  break;
963  case OP_MANAGE_SERVICE:
964  {
965  struct ManageServiceData *data = opc->data;
967  void *cb_cls;
968 
969  GNUNET_assert (NULL != data);
970  cb = data->cb;
971  cb_cls = data->cb_cls;
972  GNUNET_free (data);
973  opc->data = NULL;
974  exop_insert (event.op);
975  if (NULL != cb)
976  cb (cb_cls, opc->op, emsg);
977  /* You could have marked the operation as done by now */
978  GNUNET_break (GNUNET_NO == exop_check (event.op));
979  }
980  break;
981  default:
982  GNUNET_break (0);
983  }
984 }
void GNUNET_TESTBED_operation_mark_failed(struct GNUNET_TESTBED_Operation *op)
Marks an operation as failed.
Data for the OperationType OP_PEER_INFO.
void * cb_cls
The closure for the above callback.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:197
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * cb_cls
The closure for peer info callback.
void * op_cls
The operation closure.
Definition: testbed_api.h:152
void * cls
The closure for the above callback.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
Stop and destroy all peers.
Definition: testbed_api.h:99
#define GNUNET_NO
Definition: gnunet_common.h:81
GNUNET_TESTBED_PeerCreateCallback cb
The call back to call when we receive peer create success message.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Data for OperationType OP_PEER_START and OP_PEER_STOP.
GNUNET_TESTBED_PeerInfoCallback cb
The Peer info callback to call when this operation has completed.
static void exop_insert(struct GNUNET_TESTBED_Operation *op)
Inserts an operation into the list of operations marked for expiry.
Definition: testbed_api.c:175
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
GNUNET_TESTBED_PeerChurnCallback pcc
The Peer churn callback to call when this operation is completed.
Link controllers operation.
Definition: testbed_api.h:89
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:553
void * pcc_cls
Closure for the above callback.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
Peer destroy operation.
Definition: testbed_api.h:64
A requested testbed operation has been completed.
Peer start operation.
Definition: testbed_api.h:54
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call once this operation is done.
Data structure for OperationType OP_OVERLAY_CONNECT.
GNUNET_TESTBED_OperationCompletionCallback cb
Overlay connection operation.
Definition: testbed_api.h:79
Forwarded operation.
Definition: testbed_api.h:84
The operation has finished.
Definition: testbed_api.h:130
Date context for OP_SHUTDOWN_PEERS operations.
Definition: testbed_api.c:122
Peer stop operation.
Definition: testbed_api.h:59
void(* GNUNET_TESTBED_OperationCompletionCallback)(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when an operation is completed.
Start/stop service at a peer.
Definition: testbed_api.h:104
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
Peer create operation.
Definition: testbed_api.h:49
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
struct GNUNET_TESTBED_Peer * peer
The peer structure to return when we get success message.
Header for all communications.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Data for the OperationType OP_PEER_CREATE.
const char * GNUNET_TESTBED_parse_error_string_(const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
Checks the integrity of the OperationFailureEventMessage and if good returns the error message it con...
Definition: testbed_api.c:2184
Get peer information operation.
Definition: testbed_api.h:69
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:

◆ GNUNET_TESTBED_generate_slavegetconfig_msg_()

static struct GNUNET_TESTBED_SlaveGetConfigurationMessage* GNUNET_TESTBED_generate_slavegetconfig_msg_ ( uint64_t  op_id,
uint32_t  slave_id 
)
static

Function to build GET_SLAVE_CONFIG message.

Parameters
op_idthe id this message should contain in its operation id field
slave_idthe id this message should contain in its slave id field
Returns
newly allocated SlaveGetConfigurationMessage

Definition at line 995 of file testbed_api.c.

References GNUNET_htonll(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION, GNUNET_TESTBED_SlaveGetConfigurationMessage::header, msg, GNUNET_TESTBED_SlaveGetConfigurationMessage::operation_id, GNUNET_MessageHeader::size, GNUNET_TESTBED_SlaveGetConfigurationMessage::slave_id, and GNUNET_MessageHeader::type.

Referenced by opstart_get_slave_config().

996 {
998  uint16_t msize;
999 
1000  msize = sizeof (struct GNUNET_TESTBED_SlaveGetConfigurationMessage);
1001  msg = GNUNET_malloc (msize);
1002  msg->header.size = htons (msize);
1003  msg->header.type =
1005  msg->operation_id = GNUNET_htonll (op_id);
1006  msg->slave_id = htonl (slave_id);
1007  return msg;
1008 }
Message to request configuration of a slave controller.
Definition: testbed.h:675
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
Message to request configuration of a slave controller.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint64_t operation_id
Operation ID.
Definition: testbed.h:690
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION.
Definition: testbed.h:680
uint32_t slave_id
The id of the slave host.
Definition: testbed.h:685
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_slave_config()

static int check_slave_config ( void *  cls,
const struct GNUNET_TESTBED_SlaveConfiguration msg 
)
static

Validate #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_INFORMATION message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 1020 of file testbed_api.c.

References GNUNET_OK.

1022 {
1023  /* anything goes? */
1024  return GNUNET_OK;
1025 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_slave_config()

static void handle_slave_config ( void *  cls,
const struct GNUNET_TESTBED_SlaveConfiguration msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 1036 of file testbed_api.c.

References OperationContext::c, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, OperationContext::data, GNUNET_TESTBED_Controller::event_mask, find_opc(), GNUNET_break, GNUNET_ntohll(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_remove_opc_(), GNUNET_TESTBED_SlaveConfiguration::header, LOG_DEBUG, OperationContext::op, OperationContext::op_cls, OP_GET_SLAVE_CONFIG, OPC_STATE_FINISHED, GNUNET_TESTBED_SlaveConfiguration::operation_id, OperationContext::state, and OperationContext::type.

1038 {
1039  struct GNUNET_TESTBED_Controller *c = cls;
1040  struct OperationContext *opc;
1041  uint64_t op_id;
1042  uint64_t mask;
1043  struct GNUNET_TESTBED_EventInformation event;
1044 
1045  op_id = GNUNET_ntohll (msg->operation_id);
1046  if (NULL == (opc = find_opc (c, op_id)))
1047  {
1048  LOG_DEBUG ("Operation not found\n");
1049  return;
1050  }
1051  if (OP_GET_SLAVE_CONFIG != opc->type)
1052  {
1053  GNUNET_break (0);
1054  return;
1055  }
1056  opc->state = OPC_STATE_FINISHED;
1057  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1059  if ((0 != (mask & c->event_mask)) &&
1060  (NULL != c->cc))
1061  {
1064  event.op = opc->op;
1065  event.op_cls = opc->op_cls;
1066  event.details.operation_finished.generic = opc->data;
1067  event.details.operation_finished.emsg = NULL;
1068  c->cc (c->cc_cls, &event);
1069  }
1070 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
uint64_t operation_id
Operation ID.
Definition: testbed.h:713
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
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:2068
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
A requested testbed operation has been completed.
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
The operation has finished.
Definition: testbed_api.h:130
Get slave config operation.
Definition: testbed_api.h:94
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION.
Definition: testbed.h:703
Here is the call graph for this function:

◆ check_link_controllers_result()

static int check_link_controllers_result ( void *  cls,
const struct GNUNET_TESTBED_ControllerLinkResponse msg 
)
static

Check GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received
Returns
GNUNET_OK if msg is well-formed

Definition at line 1082 of file testbed_api.c.

References GNUNET_OK.

1084 {
1085  /* actual check to be implemented */
1086  return GNUNET_OK;
1087 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_link_controllers_result()

static void handle_link_controllers_result ( void *  cls,
const struct GNUNET_TESTBED_ControllerLinkResponse msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT message from controller (testbed service)

Parameters
cthe controller handler
msgmessage received

Definition at line 1098 of file testbed_api.c.

References OperationContext::c, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, cfg, GNUNET_TESTBED_ControllerLinkResponse::config_size, data, OperationContext::data, GNUNET_TESTBED_EventInformation::emsg, GNUNET_TESTBED_Controller::event_mask, find_opc(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_free_non_null, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_ntohll(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_host_lookup_by_id_(), GNUNET_TESTBED_host_replace_cfg_(), GNUNET_TESTBED_remove_opc_(), handle_forwarded_operation_msg(), GNUNET_TESTBED_ControllerLinkResponse::header, host, ControllerLinkData::host_id, LOG_DEBUG, OperationContext::op, OperationContext::op_cls, OP_FORWARDED, OP_LINK_CONTROLLERS, OPC_STATE_FINISHED, GNUNET_TESTBED_ControllerLinkResponse::operation_id, GNUNET_MessageHeader::size, OperationContext::state, GNUNET_TESTBED_ControllerLinkResponse::success, and OperationContext::type.

1100 {
1101  struct GNUNET_TESTBED_Controller *c = cls;
1102  struct OperationContext *opc;
1103  struct ControllerLinkData *data;
1105  struct GNUNET_TESTBED_Host *host;
1106  char *emsg;
1107  uint64_t op_id;
1108  struct GNUNET_TESTBED_EventInformation event;
1109 
1110  op_id = GNUNET_ntohll (msg->operation_id);
1111  if (NULL == (opc = find_opc (c, op_id)))
1112  {
1113  LOG_DEBUG ("Operation not found\n");
1114  return;
1115  }
1116  if (OP_FORWARDED == opc->type)
1117  {
1119  (const struct GNUNET_MessageHeader *) msg);
1120  return;
1121  }
1122  if (OP_LINK_CONTROLLERS != opc->type)
1123  {
1124  GNUNET_break (0);
1125  return;
1126  }
1127  GNUNET_assert (NULL != (data = opc->data));
1129  GNUNET_assert (NULL != host);
1130  GNUNET_free (data);
1131  opc->data = NULL;
1132  opc->state = OPC_STATE_FINISHED;
1133  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1135  event.op = opc->op;
1136  event.op_cls = opc->op_cls;
1137  event.details.operation_finished.emsg = NULL;
1138  event.details.operation_finished.generic = NULL;
1139  emsg = NULL;
1140  cfg = NULL;
1141  if (GNUNET_NO == ntohs (msg->success))
1142  {
1143  emsg = GNUNET_malloc (ntohs (msg->header.size)
1144  - sizeof (struct
1146  GNUNET_memcpy (emsg,
1147  &msg[1],
1148  ntohs (msg->header.size)- sizeof (struct GNUNET_TESTBED_ControllerLinkResponse));
1149  event.details.operation_finished.emsg = emsg;
1150  }
1151  else
1152  {
1153  if (0 != ntohs (msg->config_size))
1154  {
1155  cfg = GNUNET_TESTBED_extract_config_ ((const struct GNUNET_MessageHeader *) msg);
1156  GNUNET_assert (NULL != cfg);
1158  }
1159  }
1160  if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
1161  {
1162  if (NULL != c->cc)
1163  c->cc (c->cc_cls, &event);
1164  }
1165  else
1166  LOG_DEBUG ("Not calling callback\n");
1167  if (NULL != cfg)
1169  GNUNET_free_non_null (emsg);
1170 }
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:198
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT.
Definition: testbed.h:182
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_TESTBED_host_replace_cfg_(struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *new_cfg)
Function to replace host&#39;s configuration.
const char * emsg
Error message for the operation, NULL on success.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Opaque handle to a host running experiments managed by the testing framework.
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:2068
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Response message for ControllerLinkRequest message.
Definition: testbed.h:176
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:266
uint32_t host_id
The id of the host which is hosting the controller to be linked.
Definition: testbed_api.c:114
Link controllers operation.
Definition: testbed_api.h:89
#define GNUNET_memcpy(dst, src, n)
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
A requested testbed operation has been completed.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint16_t success
Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure.
Definition: testbed.h:193
GUID host
Forwarded operation.
Definition: testbed_api.h:84
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:188
The operation has finished.
Definition: testbed_api.h:130
configuration data
Definition: configuration.c:85
static struct OperationContext * find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
Returns the operation context with the given id if found in the Operation context queues of the contr...
Definition: testbed_api.c:282
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:209
Context data for controller link operations.
Definition: testbed_api.c:104
Header for all communications.
static void handle_forwarded_operation_msg(void *cls, struct OperationContext *opc, const struct GNUNET_MessageHeader *msg)
Handler for forwarded operations.
Definition: testbed_api.c:427
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:204
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_lookup_by_id_(uint32_t id)
Lookup a host by ID.
Here is the call graph for this function:

◆ check_barrier_status()

static int check_barrier_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)
static

Validate GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS message.

Parameters
clsthe controller handle to determine the connection this message belongs to
msgthe barrier status message
Returns
GNUNET_OK if the message is valid; GNUNET_SYSERR to tear it down signalling an error (message malformed)

Definition at line 1183 of file testbed_api.c.

References GNUNET_TESTBED_BarrierStatusMsg::data, GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BarrierStatusMsg::header, name, GNUNET_TESTBED_BarrierStatusMsg::name_len, GNUNET_MessageHeader::size, status, and GNUNET_TESTBED_BarrierStatusMsg::status.

1185 {
1186  uint16_t msize;
1187  uint16_t name_len;
1188  int status;
1189  const char *name;
1190  size_t emsg_len;
1191 
1192  msize = ntohs (msg->header.size);
1193  name = msg->data;
1194  name_len = ntohs (msg->name_len);
1195 
1196  if (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) + name_len + 1 > msize)
1197  {
1198  GNUNET_break_op (0);
1199  return GNUNET_SYSERR;
1200  }
1201  if ('\0' != name[name_len])
1202  {
1203  GNUNET_break_op (0);
1204  return GNUNET_SYSERR;
1205  }
1206  status = ntohs (msg->status);
1207  if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)
1208  {
1209  emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) + name_len
1210  + 1); /* +1!? */
1211  if (0 == emsg_len)
1212  {
1213  GNUNET_break_op (0);
1214  return GNUNET_SYSERR;
1215  }
1216  }
1217  return GNUNET_OK;
1218 }
uint16_t name_len
strlen of the barrier name
Definition: testbed.h:877
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS.
Definition: testbed.h:867
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t status
status.
Definition: testbed.h:872
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char data[0]
the barrier name (0-terminated) concatenated with an error message (0-terminated) if the status were ...
Definition: testbed.h:883
const char * name
Message for signalling status changes of a barrier.
Definition: testbed.h:862

◆ handle_barrier_status()

static void handle_barrier_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)
static

Handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.

Parameters
clsthe controller handle to determine the connection this message belongs to
msgthe barrier status message

Do not remove the barrier if we did not echo the status back; this is required at the chained testbed controller setup to ensure the only the test-driver echos the status and the controller hierarchy properly propagates the status.

Definition at line 1229 of file testbed_api.c.

References GNUNET_TESTBED_Controller::barrier_map, GNUNET_TESTBED_Barrier::cb, cleanup(), GNUNET_TESTBED_Barrier::cls, GNUNET_TESTBED_BarrierStatusMsg::data, GNUNET_TESTBED_Barrier::echo, GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get(), GNUNET_copy_message(), GNUNET_CRYPTO_hash(), GNUNET_free_non_null, GNUNET_malloc, GNUNET_memcpy, GNUNET_TESTBED_barrier_remove_(), GNUNET_TESTBED_BARRIERSTATUS_CROSSED, GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BARRIERSTATUS_INITIALISED, GNUNET_TESTBED_queue_message_(), GNUNET_YES, GNUNET_TESTBED_BarrierStatusMsg::header, LOG_DEBUG, name, GNUNET_TESTBED_BarrierStatusMsg::name_len, GNUNET_MessageHeader::size, status, and GNUNET_TESTBED_BarrierStatusMsg::status.

1231 {
1232  struct GNUNET_TESTBED_Controller *c = cls;
1233  struct GNUNET_TESTBED_Barrier *barrier;
1234  char *emsg;
1235  const char *name;
1236  struct GNUNET_HashCode key;
1237  size_t emsg_len;
1238  int status;
1239  uint16_t msize;
1240  uint16_t name_len;
1241 
1242  emsg = NULL;
1243  barrier = NULL;
1244  msize = ntohs (msg->header.size);
1245  if (msize <= sizeof (struct GNUNET_TESTBED_BarrierStatusMsg))
1246  {
1247  GNUNET_break_op (0);
1248  goto cleanup;
1249  }
1250  name = msg->data;
1251  name_len = ntohs (msg->name_len);
1252  if (name_len >= //name_len is strlen(barrier_name)
1253  (msize - ((sizeof msg->header) + sizeof (msg->status)) ) )
1254  {
1255  GNUNET_break_op (0);
1256  goto cleanup;
1257  }
1258  if ('\0' != name[name_len])
1259  {
1260  GNUNET_break_op (0);
1261  goto cleanup;
1262  }
1263  LOG_DEBUG ("Received BARRIER_STATUS msg\n");
1264  status = ntohs (msg->status);
1265  if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)
1266  {
1267  status = -1;
1268  //unlike name_len, emsg_len includes the trailing zero
1269  emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg)
1270  + (name_len + 1));
1271  if (0 == emsg_len)
1272  {
1273  GNUNET_break_op (0);
1274  goto cleanup;
1275  }
1276  if ('\0' != (msg->data[(name_len + 1) + (emsg_len - 1)]))
1277  {
1278  GNUNET_break_op (0);
1279  goto cleanup;
1280  }
1281  emsg = GNUNET_malloc (emsg_len);
1282  GNUNET_memcpy (emsg,
1283  msg->data + name_len + 1,
1284  emsg_len);
1285  }
1286  if (NULL == c->barrier_map)
1287  {
1288  GNUNET_break_op (0);
1289  goto cleanup;
1290  }
1291  GNUNET_CRYPTO_hash (name, name_len, &key);
1293  if (NULL == barrier)
1294  {
1295  GNUNET_break_op (0);
1296  goto cleanup;
1297  }
1298  GNUNET_assert (NULL != barrier->cb);
1299  if ((GNUNET_YES == barrier->echo) &&
1302  GNUNET_copy_message (&msg->header));
1303  barrier->cb (barrier->cls,
1304  name,
1305  barrier,
1306  status,
1307  emsg);
1309  return; /* just initialised; skip cleanup */
1310 
1311  cleanup:
1312  GNUNET_free_non_null (emsg);
1319  if ((NULL != barrier) && (GNUNET_YES == barrier->echo))
1321 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
uint16_t name_len
strlen of the barrier name
Definition: testbed.h:877
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int echo
Should the barrier crossed status message be echoed back to the controller?
Definition: testbed_api.h:309
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS.
Definition: testbed.h:867
void * cls
the closure for the above callback
Definition: testbed_api.h:304
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
uint16_t status
status.
Definition: testbed.h:872
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_TESTBED_barrier_remove_(struct GNUNET_TESTBED_Barrier *barrier)
Remove a barrier and it was the last one in the barrier hash map, destroy the hash map...
Definition: testbed_api.c:2339
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
uint16_t status
See PRISM_STATUS_*-constants.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for barrier.
Definition: testbed_api.h:279
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
char data[0]
the barrier name (0-terminated) concatenated with an error message (0-terminated) if the status were ...
Definition: testbed.h:883
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
const char * name
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:261
Barrier initialised successfully.
#define GNUNET_YES
Definition: gnunet_common.h:80
Message for signalling status changes of a barrier.
Definition: testbed.h:862
#define GNUNET_malloc(size)
Wrapper around malloc.
GNUNET_TESTBED_barrier_status_cb cb
The continuation callback to call when we have a status update on this.
Definition: testbed_api.h:299
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:

◆ GNUNET_TESTBED_queue_message_()

void GNUNET_TESTBED_queue_message_ ( struct GNUNET_TESTBED_Controller controller,
struct GNUNET_MessageHeader msg 
)

Queues a message in send queue for sending to the service.

Parameters
controllerthe handle to the controller
msgthe message to queue

Definition at line 1331 of file testbed_api.c.

References env, GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_INIT, GNUNET_MESSAGE_TYPE_TESTBED_MAX, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_Controller::mq, size, GNUNET_MessageHeader::size, type, and GNUNET_MessageHeader::type.

Referenced by GNUNET_TESTBED_register_host(), handle_barrier_status(), handle_remote_overlay_connect(), opstart_get_slave_config(), opstart_link_controllers(), opstart_peer_getinfo(), and send_hello_thru_rocc().

1333 {
1334  struct GNUNET_MQ_Envelope *env;
1335  struct GNUNET_MessageHeader *m2;
1336  uint16_t type;
1337  uint16_t size;
1338 
1339  type = ntohs (msg->type);
1340  size = ntohs (msg->size);
1343  env = GNUNET_MQ_msg_extra (m2,
1344  size - sizeof (*m2),
1345  type);
1346  GNUNET_memcpy (m2, msg, size);
1347  GNUNET_free (msg);
1348  GNUNET_MQ_send (controller->mq,
1349  env);
1350 }
#define GNUNET_MESSAGE_TYPE_TESTBED_MAX
Not really a message, but for careful checks on the testbed messages; Should always be the maximum an...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#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:52
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_memcpy(dst, src, n)
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
#define GNUNET_MESSAGE_TYPE_TESTBED_INIT
Initial message from a client to a testing control service.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
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:353
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_forward_operation_msg_()

struct OperationContext* GNUNET_TESTBED_forward_operation_msg_ ( struct GNUNET_TESTBED_Controller controller,
uint64_t  operation_id,
const struct GNUNET_MessageHeader msg,
GNUNET_MQ_MessageCallback  cc,
void *  cc_cls 
)

Sends the given message as an operation.

The given callback is called when a reply for the operation is available. Call GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned operation context if the cc hasn't been called

Parameters
controllerthe controller to which the message has to be sent
operation_idthe operation id of the message
msgthe message to send
ccthe callback to call when reply is available
cc_clsthe closure for the above callback
Returns
the operation context which can be used to cancel the forwarded operation

Definition at line 1368 of file testbed_api.c.

References OperationContext::c, ForwardedOperationData::cc, ForwardedOperationData::cc_cls, data, OperationContext::data, env, GNUNET_memcpy, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, OP_FORWARDED, size, GNUNET_MessageHeader::size, type, OperationContext::type, and GNUNET_MessageHeader::type.

Referenced by forward_overlay_connect(), GST_process_next_focc(), handle_manage_peer_service(), handle_peer_create(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_shutdown_peers(), opstart_service_connect(), and p2_controller_connect_cb().

1373 {
1374  struct OperationContext *opc;
1375  struct ForwardedOperationData *data;
1376  struct GNUNET_MQ_Envelope *env;
1377  struct GNUNET_MessageHeader *m2;
1378  uint16_t type = ntohs (msg->type);
1379  uint16_t size = ntohs (msg->size);
1380 
1381  env = GNUNET_MQ_msg_extra (m2,
1382  size - sizeof (*m2),
1383  type);
1384  GNUNET_memcpy (m2,
1385  msg,
1386  size);
1387  GNUNET_MQ_send (controller->mq,
1388  env);
1389  data = GNUNET_new (struct ForwardedOperationData);
1390  data->cc = cc;
1391  data->cc_cls = cc_cls;
1392  opc = GNUNET_new (struct OperationContext);
1393  opc->c = controller;
1394  opc->type = OP_FORWARDED;
1395  opc->data = data;
1396  opc->id = operation_id;
1397  GNUNET_TESTBED_insert_opc_ (controller,
1398  opc);
1399  return opc;
1400 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#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:52
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_memcpy(dst, src, n)
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
GNUNET_MQ_MessageCallback cc
The callback to call when reply is available.
Definition: testbed_api.c:78
void * cc_cls
The closure for the above callback.
Definition: testbed_api.c:83
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
static unsigned int size
Size of the "table".
Definition: peer.c:67
Context data for forwarded Operation.
Definition: testbed_api.c:72
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Forwarded operation.
Definition: testbed_api.h:84
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
void GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Inserts the given operation context into the operation context map of the given controller.
Definition: testbed_api.c:306
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:353
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_forward_operation_msg_cancel_()

void GNUNET_TESTBED_forward_operation_msg_cancel_ ( struct OperationContext opc)

Function to cancel an operation created by simply forwarding an operation message.

Parameters
opcthe operation context from GNUNET_TESTBED_forward_operation_msg_()

Definition at line 1410 of file testbed_api.c.

References OperationContext::c, OperationContext::data, GNUNET_free, and GNUNET_TESTBED_remove_opc_().

Referenced by cleanup_occ_rp2c(), GST_clear_fopcq(), GST_forwarded_operation_timeout(), and oprelease_service_connect().

1411 {
1413  opc);
1414  GNUNET_free (opc->data);
1415  GNUNET_free (opc);
1416 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_link_controllers()

static void opstart_link_controllers ( void *  cls)
static

Function to call to start a link-controllers type operation once all queues the operation is part of declare that the operation can be activated.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 1426 of file testbed_api.c.

References OperationContext::c, data, OperationContext::data, GNUNET_assert, GNUNET_TESTBED_insert_opc_(), GNUNET_TESTBED_queue_message_(), GNUNET_TESTBED_ControllerLinkRequest::header, msg, ControllerLinkData::msg, OPC_STATE_STARTED, and OperationContext::state.

Referenced by GNUNET_TESTBED_controller_link().

1427 {
1428  struct OperationContext *opc = cls;
1429  struct ControllerLinkData *data;
1431 
1432  GNUNET_assert (NULL != opc->data);
1433  data = opc->data;
1434  msg = data->msg;
1435  data->msg = NULL;
1436  opc->state = OPC_STATE_STARTED;
1437  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
1438  GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
1439 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
Context data for controller link operations.
Definition: testbed_api.c:104
void GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Inserts the given operation context into the operation context map of the given controller.
Definition: testbed_api.c:306
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS.
Definition: testbed.h:147
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:141
struct GNUNET_TESTBED_ControllerLinkRequest * msg
The controller link message.
Definition: testbed_api.c:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_link_controllers()

static void oprelease_link_controllers ( void *  cls)
static

Callback which will be called when link-controllers type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 1448 of file testbed_api.c.

References OperationContext::c, data, OperationContext::data, GNUNET_free, GNUNET_free_non_null, GNUNET_TESTBED_remove_opc_(), ControllerLinkData::msg, OPC_STATE_FINISHED, OPC_STATE_INIT, OPC_STATE_STARTED, and OperationContext::state.

Referenced by GNUNET_TESTBED_controller_link().

1449 {
1450  struct OperationContext *opc = cls;
1451  struct ControllerLinkData *data;
1452 
1453  data = opc->data;
1454  switch (opc->state)
1455  {
1456  case OPC_STATE_INIT:
1457  GNUNET_free (data->msg);
1458  break;
1459  case OPC_STATE_STARTED:
1460  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1461  break;
1462  case OPC_STATE_FINISHED:
1463  break;
1464  }
1465  GNUNET_free_non_null (data);
1466  GNUNET_free (opc);
1467 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
The operation has finished.
Definition: testbed_api.h:130
Context data for controller link operations.
Definition: testbed_api.c:104
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
struct GNUNET_TESTBED_ControllerLinkRequest * msg
The controller link message.
Definition: testbed_api.c:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_get_slave_config()

static void opstart_get_slave_config ( void *  cls)
static

Function to be called when get slave config operation is ready.

Parameters
clsthe OperationContext of type OP_GET_SLAVE_CONFIG

Definition at line 1476 of file testbed_api.c.

References OperationContext::c, data, OperationContext::data, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_generate_slavegetconfig_msg_(), GNUNET_TESTBED_insert_opc_(), GNUNET_TESTBED_queue_message_(), GNUNET_TESTBED_SlaveGetConfigurationMessage::header, OperationContext::id, msg, OPC_STATE_STARTED, GetSlaveConfigData::slave_id, and OperationContext::state.

Referenced by GNUNET_TESTBED_get_slave_config_().

1477 {
1478  struct OperationContext *opc = cls;
1479  struct GetSlaveConfigData *data = opc->data;
1481 
1482  GNUNET_assert (NULL != data);
1484  GNUNET_free (opc->data);
1485  data = NULL;
1486  opc->data = NULL;
1487  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
1488  GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
1489  opc->state = OPC_STATE_STARTED;
1490 }
Message to request configuration of a slave controller.
Definition: testbed.h:675
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context data for get slave config operations.
Definition: testbed_api.c:91
static struct GNUNET_TESTBED_SlaveGetConfigurationMessage * GNUNET_TESTBED_generate_slavegetconfig_msg_(uint64_t op_id, uint32_t slave_id)
Function to build GET_SLAVE_CONFIG message.
Definition: testbed_api.c:995
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
uint32_t slave_id
The id of the slave controller.
Definition: testbed_api.c:96
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION.
Definition: testbed.h:680
void GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Inserts the given operation context into the operation context map of the given controller.
Definition: testbed_api.c:306
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_get_slave_config()

static void oprelease_get_slave_config ( void *  cls)
static

Function to be called when get slave config operation is cancelled or finished.

Parameters
clsthe OperationContext of type OP_GET_SLAVE_CONFIG

Definition at line 1499 of file testbed_api.c.

References OperationContext::c, OperationContext::data, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TESTBED_remove_opc_(), OPC_STATE_FINISHED, OPC_STATE_INIT, OPC_STATE_STARTED, and OperationContext::state.

Referenced by GNUNET_TESTBED_get_slave_config_().

1500 {
1501  struct OperationContext *opc = cls;
1502 
1503  switch (opc->state)
1504  {
1505  case OPC_STATE_INIT:
1506  GNUNET_free (opc->data);
1507  break;
1508  case OPC_STATE_STARTED:
1509  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1510  break;
1511  case OPC_STATE_FINISHED:
1512  if (NULL != opc->data)
1514  break;
1515  }
1516  GNUNET_free (opc);
1517 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
The operation has finished.
Definition: testbed_api.h:130
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure, a struct GNUNET_TESTBED_Controller *
errorerror code

Definition at line 1529 of file testbed_api.c.

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, and GNUNET_SCHEDULER_shutdown().

Referenced by GNUNET_TESTBED_controller_connect().

1531 {
1532  /* struct GNUNET_TESTBED_Controller *c = cls; */
1533 
1535  "Encountered MQ error: %d\n",
1536  error);
1537  /* now what? */
1538  GNUNET_SCHEDULER_shutdown (); /* seems most reasonable */
1539 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opc_free_iterator()

static int opc_free_iterator ( void *  cls,
uint32_t  key,
void *  value 
)
static

Iterator to free opc map entries.

Parameters
clsclosure
keycurrent key code
valuevalue in the hash map
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 1701 of file testbed_api.c.

References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_free, GNUNET_YES, map, and value.

Referenced by GNUNET_TESTBED_controller_disconnect().

1702 {
1703  struct GNUNET_CONTAINER_MultiHashMap32 *map = cls;
1704  struct OperationContext *opc = value;
1705 
1706  GNUNET_assert (NULL != opc);
1707  GNUNET_break (0);
1710  GNUNET_free (opc);
1711  return GNUNET_YES;
1712 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
static char * value
Value of the record to add/remove.
Internal representation of the hash map.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_YES
Definition: gnunet_common.h:80
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_compress_config_()

size_t GNUNET_TESTBED_compress_config_ ( const char *  config,
size_t  size,
char **  xconfig 
)

Compresses given configuration using zlib compress.

Parameters
configthe serialized configuration
sizethe size of config
xconfigwill be set to the compressed configuration (memory is fresly allocated)
Returns
the size of the xconfig

Definition at line 1761 of file testbed_api.c.

References GNUNET_assert, and GNUNET_malloc.

Referenced by GNUNET_TESTBED_compress_cfg_(), GNUNET_TESTBED_create_helper_init_msg_(), GNUNET_TESTBED_register_host(), handle_peer_get_config(), handle_slave_get_config(), opstart_peer_create(), opstart_peer_reconfigure(), and tokenizer_cb().

1764 {
1765  size_t xsize;
1766 
1767  xsize = compressBound ((uLong) size);
1768  *xconfig = GNUNET_malloc (xsize);
1769  GNUNET_assert (Z_OK ==
1770  compress2 ((Bytef *) * xconfig, (uLongf *) & xsize,
1771  (const Bytef *) config, (uLongf) size,
1772  Z_BEST_SPEED));
1773  return xsize;
1774 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static const struct GNUNET_CONFIGURATION_Handle * config
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_compress_cfg_()

char* GNUNET_TESTBED_compress_cfg_ ( const struct GNUNET_CONFIGURATION_Handle cfg,
size_t *  size,
size_t *  xsize 
)

Function to serialize and compress using zlib a configuration through a configuration handle.

Parameters
cfgthe configuration
sizethe size of configuration when serialize. Will be set on success.
xsizethe sizeo of the compressed configuration. Will be set on success.
Returns
the serialized and compressed configuration

Definition at line 1787 of file testbed_api.c.

References config, GNUNET_CONFIGURATION_serialize(), GNUNET_free, and GNUNET_TESTBED_compress_config_().

Referenced by send_controller_link_response().

1789 {
1790  char *config;
1791  char *xconfig;
1792  size_t size_;
1793  size_t xsize_;
1794 
1795  config = GNUNET_CONFIGURATION_serialize (cfg, &size_);
1796  xsize_ = GNUNET_TESTBED_compress_config_ (config, size_, &xconfig);
1797  GNUNET_free (config);
1798  *size = size_;
1799  *xsize = xsize_;
1800  return xconfig;
1801 }
static const struct GNUNET_CONFIGURATION_Handle * config
static unsigned int size
Size of the "table".
Definition: peer.c:67
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1761
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_get_slave_config_()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_get_slave_config_ ( void *  op_cls,
struct GNUNET_TESTBED_Controller master,
uint32_t  slave_host_id 
)

Like GNUNET_TESTBED_get_slave_config(), however without the host registration check.

Another difference is that this function takes the id of the slave host.

Parameters
op_clsthe closure for the operation
masterthe handle to master controller
slave_host_idid of the host where the slave controller is running to the slave_host should remain valid until this operation is cancelled or marked as finished
Returns
the operation handle;

Definition at line 1896 of file testbed_api.c.

References OperationContext::c, data, OperationContext::data, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OperationContext::op_cls, OP_GET_SLAVE_CONFIG, OPC_STATE_INIT, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_get_slave_config(), opstart_get_slave_config(), GetSlaveConfigData::slave_id, OperationContext::state, and OperationContext::type.

Referenced by GNUNET_TESTBED_get_slave_config().

1899 {
1900  struct OperationContext *opc;
1901  struct GetSlaveConfigData *data;
1902 
1903  data = GNUNET_new (struct GetSlaveConfigData);
1904  data->slave_id = slave_host_id;
1905  opc = GNUNET_new (struct OperationContext);
1906  opc->state = OPC_STATE_INIT;
1907  opc->c = master;
1908  opc->id = GNUNET_TESTBED_get_next_op_id (master);
1909  opc->type = OP_GET_SLAVE_CONFIG;
1910  opc->data = data;
1911  opc->op_cls = op_cls;
1912  opc->op =
1916  opc->op);
1918  return opc->op;
1919 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
Context data for get slave config operations.
Definition: testbed_api.c:91
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2213
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
static void oprelease_get_slave_config(void *cls)
Function to be called when get slave config operation is cancelled or finished.
Definition: testbed_api.c:1499
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
uint32_t slave_id
The id of the slave controller.
Definition: testbed_api.c:96
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
Get slave config operation.
Definition: testbed_api.h:94
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void opstart_get_slave_config(void *cls)
Function to be called when get slave config operation is ready.
Definition: testbed_api.c:1476
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_create_helper_init_msg_()

struct GNUNET_TESTBED_HelperInit* GNUNET_TESTBED_create_helper_init_msg_ ( const char *  trusted_ip,
const char *  hostname,
const struct GNUNET_CONFIGURATION_Handle cfg 
)

Creates a helper initialization message.

This function is here because we want to use this in testing

Parameters
trusted_ipthe ip address of the controller which will be set as TRUSTED HOST(all connections form this ip are permitted by the testbed) when starting testbed controller at host. This can either be a single ip address or a network address in CIDR notation.
hostnamethe hostname of the destination this message is intended for
cfgthe configuration that has to used to start the testbed service thru helper
Returns
the initialization message

Definition at line 1982 of file testbed_api.c.

References config, GNUNET_TESTBED_HelperInit::config_size, GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT, GNUNET_realloc, GNUNET_TESTBED_compress_config_(), hostname, and msg.

Referenced by GNUNET_TESTBED_controller_start().

1986 {
1988  char *config;
1989  char *xconfig;
1990  size_t config_size;
1991  size_t xconfig_size;
1992  uint16_t trusted_ip_len;
1993  uint16_t hostname_len;
1994  uint16_t msg_size;
1995 
1996  config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
1997  GNUNET_assert (NULL != config);
1998  xconfig_size =
1999  GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
2000  GNUNET_free (config);
2001  trusted_ip_len = strlen (trusted_ip);
2002  hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
2003  msg_size =
2004  xconfig_size + trusted_ip_len + 1 +
2005  sizeof (struct GNUNET_TESTBED_HelperInit);
2006  msg_size += hostname_len;
2007  msg = GNUNET_realloc (xconfig, msg_size);
2008  (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len, msg,
2009  xconfig_size);
2010  msg->header.size = htons (msg_size);
2011  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
2012  msg->trusted_ip_size = htons (trusted_ip_len);
2013  msg->hostname_size = htons (hostname_len);
2014  msg->config_size = htons (config_size);
2015  (void) strcpy ((char *) &msg[1], trusted_ip);
2016  if (0 != hostname_len)
2017  GNUNET_memcpy (&msg[1] + trusted_ip_len + 1,
2018  hostname,
2019  hostname_len);
2020  return msg;
2021 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Initialization message for gnunet-helper-testbed to start testbed service.
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
static const struct GNUNET_CONFIGURATION_Handle * config
#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT
The initialization message towards gnunet-testbed-helper.
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1761
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
static char * hostname
Our hostname; we give this to all the peers we start.
uint16_t config_size
The size of the uncompressed configuration.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_extract_config_()

struct GNUNET_CONFIGURATION_Handle* GNUNET_TESTBED_extract_config_ ( const struct GNUNET_MessageHeader msg)

Generates configuration by uncompressing configuration in given message.

The given message should be of the following types: GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,

FIXME: This API is incredibly ugly.

Parameters
msgthe message containing compressed configuration
Returns
handle to the parsed configuration; NULL upon error while parsing the message

Definition at line 2068 of file testbed_api.c.

References cfg, GNUNET_TESTBED_AddHostMessage::config_size, GNUNET_TESTBED_ControllerLinkResponse::config_size, GNUNET_TESTBED_PeerCreateMessage::config_size, GNUNET_TESTBED_PeerReconfigureMessage::config_size, GNUNET_TESTBED_PeerConfigurationInformationMessage::config_size, GNUNET_TESTBED_SlaveConfiguration::config_size, data, GNUNET_assert, GNUNET_break_op, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_free, GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_OK, GNUNET_TESTBED_AddHostMessage::header, GNUNET_TESTBED_ControllerLinkResponse::header, GNUNET_TESTBED_PeerCreateMessage::header, GNUNET_TESTBED_PeerReconfigureMessage::header, GNUNET_TESTBED_PeerConfigurationInformationMessage::header, GNUNET_TESTBED_SlaveConfiguration::header, ret, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by configuration_receiver(), handle_add_host(), handle_link_controllers_result(), handle_peer_config(), handle_peer_create(), handle_peer_reconfigure(), and handle_slave_config().

2069 {
2071  Bytef *data;
2072  const Bytef *xdata;
2073  uLong data_len;
2074  uLong xdata_len;
2075  int ret;
2076 
2077  switch (ntohs (msg->type))
2078  {
2080  {
2082 
2083  imsg =
2085  data_len = (uLong) ntohs (imsg->config_size);
2086  xdata_len =
2087  ntohs (imsg->header.size) -
2089  xdata = (const Bytef *) &imsg[1];
2090  }
2091  break;
2093  {
2094  const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2095 
2096  imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg;
2097  data_len = (uLong) ntohs (imsg->config_size);
2098  xdata_len =
2099  ntohs (imsg->header.size) -
2100  sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
2101  xdata = (const Bytef *) &imsg[1];
2102  }
2103  break;
2105  {
2106  const struct GNUNET_TESTBED_AddHostMessage *imsg;
2107  uint16_t osize;
2108 
2109  imsg = (const struct GNUNET_TESTBED_AddHostMessage *) msg;
2110  data_len = (uLong) ntohs (imsg->config_size);
2111  osize = sizeof (struct GNUNET_TESTBED_AddHostMessage) +
2112  ntohs (imsg->username_length) + ntohs (imsg->hostname_length);
2113  xdata_len = ntohs (imsg->header.size) - osize;
2114  xdata = (const Bytef *) ((const void *) imsg + osize);
2115  }
2116  break;
2118  {
2119  const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2120 
2121  imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg;
2122  data_len = ntohs (imsg->config_size);
2123  xdata_len = ntohs (imsg->header.size) -
2124  sizeof (const struct GNUNET_TESTBED_ControllerLinkResponse);
2125  xdata = (const Bytef *) &imsg[1];
2126  }
2127  break;
2129  {
2130  const struct GNUNET_TESTBED_PeerCreateMessage *imsg;
2131 
2132  imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *) msg;
2133  data_len = ntohs (imsg->config_size);
2134  xdata_len = ntohs (imsg->header.size) -
2135  sizeof (struct GNUNET_TESTBED_PeerCreateMessage);
2136  xdata = (const Bytef *) &imsg[1];
2137  }
2138  break;
2140  {
2141  const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2142 
2143  imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *) msg;
2144  data_len = ntohs (imsg->config_size);
2145  xdata_len = ntohs (imsg->header.size) -
2146  sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage);
2147  xdata = (const Bytef *) &imsg[1];
2148  }
2149  break;
2150  default:
2151  GNUNET_assert (0);
2152  }
2153  data = GNUNET_malloc (data_len);
2154  if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
2155  {
2156  GNUNET_free (data);
2157  GNUNET_break_op (0); /* Un-compression failure */
2158  return NULL;
2159  }
2160  cfg = GNUNET_CONFIGURATION_create ();
2161  if (GNUNET_OK !=
2163  (const char *) data,
2164  (size_t) data_len,
2165  NULL))
2166  {
2167  GNUNET_free (data);
2168  GNUNET_break_op (0); /* De-serialization failure */
2169  return NULL;
2170  }
2171  GNUNET_free (data);
2172  return cfg;
2173 }
#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
Message which contains the configuration of slave controller.
uint16_t username_length
Number of bytes in the user name that follows; 0 to use no user name; otherwise &#39;strlen (username)&#39;...
Definition: testbed.h:88
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:257
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:251
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT.
Definition: testbed.h:182
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:219
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notify the service about a host that we intend to use.
Definition: testbed.h:65
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:99
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:639
uint16_t hostname_length
Number of bytes in the host name (excluding 0-termination) that follows the user name; cannot be 0...
Definition: testbed.h:94
uint16_t config_size
The size of the configuration when uncompressed.
Definition: testbed.h:718
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION.
Definition: testbed.h:645
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static int ret
Final status code.
Definition: gnunet-arm.c:89
Response message for ControllerLinkRequest message.
Definition: testbed.h:176
uint16_t config_size
The length of the serialized configuration when uncompressed.
Definition: testbed.h:272
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:665
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER
Message to reconfigure a peer.
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
Message to add host.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:213
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:698
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:71
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:188
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
Message to create a peer at a host.
configuration data
Definition: configuration.c:85
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
uint32_t data
The data value.
uint16_t config_size
Size of the uncompressed configuration.
Definition: testbed.h:239
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION.
Definition: testbed.h:703
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_parse_error_string_()

const char* GNUNET_TESTBED_parse_error_string_ ( const struct GNUNET_TESTBED_OperationFailureEventMessage msg)

Checks the integrity of the OperationFailureEventMessage and if good returns the error message it contains.

Checks the integrity of the OpeationFailureEventMessage and if good returns the error message it contains.

Parameters
msgthe OperationFailureEventMessage
Returns
the error message

Definition at line 2184 of file testbed_api.c.

References GNUNET_break, GNUNET_TESTBED_OperationFailureEventMessage::header, and GNUNET_MessageHeader::size.

Referenced by configuration_receiver(), and handle_op_fail_event().

2187 {
2188  uint16_t msize;
2189  const char *emsg;
2190 
2191  msize = ntohs (msg->header.size);
2192  if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
2193  return NULL;
2194  msize -= sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage);
2195  emsg = (const char *) &msg[1];
2196  if ('\0' != emsg[msize - 1])
2197  {
2198  GNUNET_break (0);
2199  return NULL;
2200  }
2201  return emsg;
2202 }
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT.
Definition: testbed.h:542
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Event notification from a controller to a client.
Definition: testbed.h:536
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Here is the caller graph for this function:

◆ GNUNET_TESTBED_get_next_op_id()

uint64_t GNUNET_TESTBED_get_next_op_id ( struct GNUNET_TESTBED_Controller controller)

Function to return the operation id for a controller.

The operation id is created from the controllers host id and its internal operation counter.

Parameters
controllerthe handle to the controller whose operation id has to be incremented
Returns
the incremented operation id.

Definition at line 2213 of file testbed_api.c.

References GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_Controller::host, and GNUNET_TESTBED_Controller::operation_counter.

Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_overlay_connect(), GNUNET_TESTBED_peer_create(), GNUNET_TESTBED_peer_destroy(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_peer_manage_service(), GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_shutdown_peers(), and opstart_service_connect().

2214 {
2215  uint64_t op_id;
2216 
2217  op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host);
2218  op_id = op_id << 32;
2219  op_id |= (uint64_t) controller->operation_counter++;
2220  return op_id;
2221 }
uint32_t operation_counter
The operation id counter.
Definition: testbed_api.h:271
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_shutdown_peers()

static void opstart_shutdown_peers ( void *  cls)
static

Function called when a shutdown peers operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 2230 of file testbed_api.c.

References OperationContext::c, env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OPC_STATE_STARTED, GNUNET_TESTBED_ShutdownPeersMessage::operation_id, and OperationContext::state.

Referenced by GNUNET_TESTBED_shutdown_peers().

2231 {
2232  struct OperationContext *opc = cls;
2233  struct GNUNET_MQ_Envelope *env;
2235 
2236  opc->state = OPC_STATE_STARTED;
2237  env = GNUNET_MQ_msg (msg,
2239  msg->operation_id = GNUNET_htonll (opc->id);
2241  opc);
2242  GNUNET_MQ_send (opc->c->mq,
2243  env);
2244 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
Shutdown peers message.
Definition: testbed.h:728
#define GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
A controller receiving this message floods it to its directly-connected sub-controllers and then stop...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint64_t operation_id
Operation ID.
Definition: testbed.h:738
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
void GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Inserts the given operation context into the operation context map of the given controller.
Definition: testbed_api.c:306
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:353
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_shutdown_peers()

static void oprelease_shutdown_peers ( void *  cls)
static

Callback which will be called when shutdown peers operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 2253 of file testbed_api.c.

References OperationContext::c, OperationContext::data, GNUNET_free, GNUNET_TESTBED_remove_opc_(), OPC_STATE_FINISHED, OPC_STATE_INIT, OPC_STATE_STARTED, and OperationContext::state.

Referenced by GNUNET_TESTBED_shutdown_peers().

2254 {
2255  struct OperationContext *opc = cls;
2256 
2257  switch (opc->state)
2258  {
2259  case OPC_STATE_STARTED:
2260  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
2261  /* no break; continue */
2262  case OPC_STATE_INIT:
2263  GNUNET_free (opc->data);
2264  break;
2265  case OPC_STATE_FINISHED:
2266  break;
2267  }
2268  GNUNET_free (opc);
2269 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
The operation has been started.
Definition: testbed_api.h:124
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
The operation has finished.
Definition: testbed_api.h:130
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_barrier_remove_()

void GNUNET_TESTBED_barrier_remove_ ( struct GNUNET_TESTBED_Barrier barrier)

Remove a barrier and it was the last one in the barrier hash map, destroy the hash map.

Parameters
barrierthe barrier to remove

Definition at line 2339 of file testbed_api.c.

References GNUNET_TESTBED_Controller::barrier_map, GNUNET_TESTBED_Barrier::c, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_free, GNUNET_OK, GNUNET_TESTBED_Barrier::key, and GNUNET_TESTBED_Barrier::name.

Referenced by GNUNET_TESTBED_barrier_cancel(), and handle_barrier_status().

2340 {
2341  struct GNUNET_TESTBED_Controller *c = barrier->c;
2342 
2343  GNUNET_assert (NULL != c->barrier_map); /* No barriers present */
2346  &barrier->key,
2347  barrier));
2348  GNUNET_free (barrier->name);
2349  GNUNET_free (barrier);
2351  {
2353  c->barrier_map = NULL;
2354  }
2355 }
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
char * name
The name of the barrier.
Definition: testbed_api.h:294
struct GNUNET_TESTBED_Controller * c
The controller handle given while initiliasing this barrier.
Definition: testbed_api.h:289
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:284
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:261
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_barrier_init_()

struct GNUNET_TESTBED_Barrier* GNUNET_TESTBED_barrier_init_ ( struct GNUNET_TESTBED_Controller controller,
const char *  name,
unsigned int  quorum,
GNUNET_TESTBED_barrier_status_cb  cb,
void *  cls,
int  echo 
)

Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier OR upon error.

Parameters
controllerthe handle to the controller
nameidentification name of the barrier
quorumthe percentage of peers that is required to reach the barrier. Peers signal reaching a barrier by calling GNUNET_TESTBED_barrier_reached().
cbthe callback to call when the barrier is reached or upon error. Cannot be NULL.
clsclosure for the above callback
echoGNUNET_YES to echo the barrier crossed status message back to the controller
Returns
barrier handle; NULL upon error

Definition at line 2375 of file testbed_api.c.

References GNUNET_TESTBED_Controller::barrier_map, GNUNET_TESTBED_Barrier::c, GNUNET_TESTBED_Barrier::cb, GNUNET_TESTBED_Barrier::cls, echo, GNUNET_TESTBED_Barrier::echo, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_YES, GNUNET_TESTBED_Barrier::key, LOG_DEBUG, GNUNET_TESTBED_Controller::mq, msg, GNUNET_TESTBED_Barrier::name, GNUNET_TESTBED_BarrierInit::name, and GNUNET_TESTBED_BarrierInit::quorum.

Referenced by GNUNET_TESTBED_barrier_init(), and handle_barrier_init().

2380 {
2382  struct GNUNET_MQ_Envelope *env;
2383  struct GNUNET_TESTBED_Barrier *barrier;
2384  struct GNUNET_HashCode key;
2385  size_t name_len;
2386 
2387  GNUNET_assert (quorum <= 100);
2388  GNUNET_assert (NULL != cb);
2389  name_len = strlen (name);
2390  GNUNET_assert (0 < name_len);
2391  GNUNET_CRYPTO_hash (name, name_len, &key);
2392  if (NULL == controller->barrier_map)
2394  if (GNUNET_YES ==
2396  &key))
2397  {
2398  GNUNET_break (0);
2399  return NULL;
2400  }
2401  LOG_DEBUG ("Initialising barrier `%s'\n", name);
2402  barrier = GNUNET_new (struct GNUNET_TESTBED_Barrier);
2403  barrier->c = controller;
2404  barrier->name = GNUNET_strdup (name);
2405  barrier->cb = cb;
2406  barrier->cls = cls;
2407  barrier->echo = echo;
2408  GNUNET_memcpy (&barrier->key, &key, sizeof (struct GNUNET_HashCode));
2411  &barrier->key,
2412  barrier,
2414 
2415  env = GNUNET_MQ_msg_extra (msg,
2416  name_len,
2418  msg->quorum = (uint8_t) quorum;
2419  GNUNET_memcpy (msg->name,
2420  barrier->name,
2421  name_len);
2422  GNUNET_MQ_send (barrier->c->mq,
2423  env);
2424  return barrier;
2425 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int echo
Request echo service.
Definition: gnunet-cadet.c:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int echo
Should the barrier crossed status message be echoed back to the controller?
Definition: testbed_api.h:309
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * cls
the closure for the above callback
Definition: testbed_api.h:304
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG_DEBUG(...)
Debug logging.
Definition: testbed_api.c:53
#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:52
#define GNUNET_memcpy(dst, src, n)
, &#39; bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
char * name
The name of the barrier.
Definition: testbed_api.h:294
Handle for barrier.
Definition: testbed_api.h:279
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
const char * name
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_TESTBED_Controller * c
The controller handle given while initiliasing this barrier.
Definition: testbed_api.h:289
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:284
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
uint8_t quorum
The quorum percentage needed for crossing the barrier.
Definition: testbed.h:833
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:261
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
char name[0]
name of the barrier.
Definition: testbed.h:838
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT
Message to initialise a barrier.
Message to initialise a barrier.
Definition: testbed.h:823
GNUNET_TESTBED_barrier_status_cb cb
The continuation callback to call when we have a status update on this.
Definition: testbed_api.h:299
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ exop_head

struct ExpireOperationEntry* exop_head
static

DLL head for list of operations marked for expiry.

Definition at line 161 of file testbed_api.c.

Referenced by exop_check().

◆ exop_tail

struct ExpireOperationEntry* exop_tail
static

DLL tail for list of operation marked for expiry.

Definition at line 166 of file testbed_api.c.