GNUnet  0.10.x
Data Structures | Macros | Typedefs | Enumerations | Functions
testbed_api.h File Reference

Interface for functions internally exported from testbed_api.c. More...

#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "testbed.h"
#include "testbed_helper.h"
Include dependency graph for testbed_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OperationContext
 Context information for GNUNET_TESTBED_Operation. More...
 
struct  GNUNET_TESTBED_Controller
 Handle to interact with a GNUnet testbed controller. More...
 
struct  GNUNET_TESTBED_Barrier
 Handle for barrier. More...
 

Macros

#define HELPER_TESTBED_BINARY   "gnunet-helper-testbed"
 Testbed Helper binary name. More...
 

Typedefs

typedef void(* TESTBED_opcq_empty_cb) (void *cls)
 Operation empty callback. More...
 

Enumerations

enum  OperationType {
  SOLVER_OP_ADD_ADDRESS, SOLVER_OP_DEL_ADDRESS, SOLVER_OP_START_SET_PROPERTY, SOLVER_OP_STOP_SET_PROPERTY,
  SOLVER_OP_START_SET_PREFERENCE, SOLVER_OP_STOP_SET_PREFERENCE, SOLVER_OP_START_REQUEST, SOLVER_OP_STOP_REQUEST,
  START_SEND, STOP_SEND, START_PREFERENCE, STOP_PREFERENCE,
  OP_PEER_CREATE, OP_PEER_START, OP_PEER_STOP, OP_PEER_DESTROY,
  OP_PEER_INFO, OP_PEER_RECONFIGURE, OP_OVERLAY_CONNECT, OP_FORWARDED,
  OP_LINK_CONTROLLERS, OP_GET_SLAVE_CONFIG, OP_SHUTDOWN_PEERS, OP_MANAGE_SERVICE
}
 Enumeration of operations. More...
 
enum  OperationContextState { OPC_STATE_INIT = 0, OPC_STATE_STARTED, OPC_STATE_FINISHED }
 Enumeration of states of OperationContext. More...
 

Functions

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...
 
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...
 
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_HelperInitGNUNET_TESTBED_create_helper_init_msg_ (const char *cname, const char *hostname, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Creates a helper initialization message. 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...
 
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 OpeationFailureEventMessage 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...
 
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_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...
 
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...
 

Detailed Description

Interface for functions internally exported from testbed_api.c.

Author
Sree Harsha Totakura

Definition in file testbed_api.h.

Macro Definition Documentation

◆ HELPER_TESTBED_BINARY

#define HELPER_TESTBED_BINARY   "gnunet-helper-testbed"

Testbed Helper binary name.

Definition at line 38 of file testbed_api.h.

Referenced by GNUNET_TESTBED_controller_start(), and GNUNET_TESTBED_is_host_habitable().

Typedef Documentation

◆ TESTBED_opcq_empty_cb

typedef void(* TESTBED_opcq_empty_cb) (void *cls)

Operation empty callback.

Parameters
clsclosure

Definition at line 182 of file testbed_api.h.

Enumeration Type Documentation

◆ OperationType

Enumeration of operations.

Enumerator
SOLVER_OP_ADD_ADDRESS 
SOLVER_OP_DEL_ADDRESS 
SOLVER_OP_START_SET_PROPERTY 
SOLVER_OP_STOP_SET_PROPERTY 
SOLVER_OP_START_SET_PREFERENCE 
SOLVER_OP_STOP_SET_PREFERENCE 
SOLVER_OP_START_REQUEST 
SOLVER_OP_STOP_REQUEST 
START_SEND 
STOP_SEND 
START_PREFERENCE 
STOP_PREFERENCE 
OP_PEER_CREATE 

Peer create operation.

OP_PEER_START 

Peer start operation.

OP_PEER_STOP 

Peer stop operation.

OP_PEER_DESTROY 

Peer destroy operation.

OP_PEER_INFO 

Get peer information operation.

OP_PEER_RECONFIGURE 

Reconfigure a peer.

OP_OVERLAY_CONNECT 

Overlay connection operation.

OP_FORWARDED 

Forwarded operation.

OP_LINK_CONTROLLERS 

Link controllers operation.

OP_GET_SLAVE_CONFIG 

Get slave config operation.

OP_SHUTDOWN_PEERS 

Stop and destroy all peers.

OP_MANAGE_SERVICE 

Start/stop service at a peer.

Definition at line 44 of file testbed_api.h.

45 {
50 
55 
60 
65 
70 
75 
80 
85 
90 
95 
100 
105 };
Stop and destroy all peers.
Definition: testbed_api.h:99
Reconfigure a peer.
Definition: testbed_api.h:74
Link controllers operation.
Definition: testbed_api.h:89
Peer destroy operation.
Definition: testbed_api.h:64
Peer start operation.
Definition: testbed_api.h:54
Overlay connection operation.
Definition: testbed_api.h:79
Forwarded operation.
Definition: testbed_api.h:84
Peer stop operation.
Definition: testbed_api.h:59
Get slave config operation.
Definition: testbed_api.h:94
Start/stop service at a peer.
Definition: testbed_api.h:104
Peer create operation.
Definition: testbed_api.h:49
Get peer information operation.
Definition: testbed_api.h:69

◆ OperationContextState

Enumeration of states of OperationContext.

Enumerator
OPC_STATE_INIT 

The initial state where the associated operation has just been created and is waiting in the operation queues to be started.

OPC_STATE_STARTED 

The operation has been started.

It may occupy some resources which are to be freed if cancelled.

OPC_STATE_FINISHED 

The operation has finished.

The end results of this operation may occupy some resources which are to be freed by operation_done

Definition at line 112 of file testbed_api.h.

113 {
118  OPC_STATE_INIT = 0,
119 
125 
131 };
The operation has been started.
Definition: testbed_api.h:124
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

Function Documentation

◆ 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
Deprecated:
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_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:

◆ 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_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_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:

◆ 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_PEERCONFIG, #GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG

Parameters
msgthe message containing compressed configuration
Returns
handle to the parsed configuration

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 'strlen (username)'...
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'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 OpeationFailureEventMessage and if good returns the error message it contains.

Parameters
msgthe OperationFailureEventMessage
Returns
the error message

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:

◆ 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_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
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:

◆ 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: