GNUnet  0.11.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 181 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 111 of file testbed_api.h.

112 {
117  OPC_STATE_INIT = 0,
118 
124 
130 };
The operation has been started.
Definition: testbed_api.h:123
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:117
The operation has finished.
Definition: testbed_api.h:129

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 1335 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().

1337 {
1338  struct GNUNET_MQ_Envelope *env;
1339  struct GNUNET_MessageHeader *m2;
1340  uint16_t type;
1341  uint16_t size;
1342 
1343  type = ntohs (msg->type);
1344  size = ntohs (msg->size);
1347  env = GNUNET_MQ_msg_extra (m2, size - sizeof(*m2), type);
1348  GNUNET_memcpy (m2, msg, size);
1349  GNUNET_free (msg);
1350  GNUNET_MQ_send (controller->mq, env);
1351 }
#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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
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:218
#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 298 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().

300 {
301  if (NULL == c->opc_map)
304  c->opc_map,
305  (uint32_t) opc->id,
306  opc,
308 }
#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:75
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:161
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:229
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 319 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().

321 {
322  GNUNET_assert (NULL != c->opc_map);
325  (uint32_t) opc->id,
326  opc));
328  (NULL != c->opcq_empty_cb))
330 }
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:234
#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:161
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:229
void * opcq_empty_cls
Closure for the above task.
Definition: testbed_api.h:239
#define GNUNET_YES
Definition: gnunet_common.h:77
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 1757 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().

1760 {
1761  size_t xsize;
1762 
1763  xsize = compressBound ((uLong) size);
1764  *xconfig = GNUNET_malloc (xsize);
1765  GNUNET_assert (Z_OK == compress2 ((Bytef *) *xconfig,
1766  (uLongf *) &xsize,
1767  (const Bytef *) config,
1768  (uLongf) size,
1769  Z_BEST_SPEED));
1770  return xsize;
1771 }
#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 1784 of file testbed_api.c.

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

Referenced by send_controller_link_response().

1787 {
1788  char *config;
1789  char *xconfig;
1790  size_t size_;
1791  size_t xsize_;
1792 
1793  config = GNUNET_CONFIGURATION_serialize (cfg, &size_);
1794  xsize_ = GNUNET_TESTBED_compress_config_ (config, size_, &xconfig);
1795  GNUNET_free (config);
1796  *size = size_;
1797  *xsize = xsize_;
1798  return xconfig;
1799 }
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:1757
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 1980 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().

1984 {
1986  char *config;
1987  char *xconfig;
1988  size_t config_size;
1989  size_t xconfig_size;
1990  uint16_t trusted_ip_len;
1991  uint16_t hostname_len;
1992  uint16_t msg_size;
1993 
1994  config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
1995  GNUNET_assert (NULL != config);
1996  xconfig_size =
1997  GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
1998  GNUNET_free (config);
1999  trusted_ip_len = strlen (trusted_ip);
2000  hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
2001  msg_size = xconfig_size + trusted_ip_len + 1
2002  + sizeof(struct GNUNET_TESTBED_HelperInit);
2003  msg_size += hostname_len;
2004  msg = GNUNET_realloc (xconfig, msg_size);
2005  (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len,
2006  msg,
2007  xconfig_size);
2008  msg->header.size = htons (msg_size);
2009  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
2010  msg->trusted_ip_size = htons (trusted_ip_len);
2011  msg->hostname_size = htons (hostname_len);
2012  msg->config_size = htons (config_size);
2013  (void) strcpy ((char *) &msg[1], trusted_ip);
2014  if (0 != hostname_len)
2015  GNUNET_memcpy ((char *) &msg[1] + trusted_ip_len + 1,
2016  hostname,
2017  hostname_len);
2018  return msg;
2019 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Initialization message for gnunet-helper-testbed to start testbed service.
#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:1757
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 1369 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().

1375 {
1376  struct OperationContext *opc;
1377  struct ForwardedOperationData *data;
1378  struct GNUNET_MQ_Envelope *env;
1379  struct GNUNET_MessageHeader *m2;
1380  uint16_t type = ntohs (msg->type);
1381  uint16_t size = ntohs (msg->size);
1382 
1383  env = GNUNET_MQ_msg_extra (m2, size - sizeof(*m2), type);
1384  GNUNET_memcpy (m2, msg, size);
1385  GNUNET_MQ_send (controller->mq, env);
1386  data = GNUNET_new (struct ForwardedOperationData);
1387  data->cc = cc;
1388  data->cc_cls = cc_cls;
1389  opc = GNUNET_new (struct OperationContext);
1390  opc->c = controller;
1391  opc->type = OP_FORWARDED;
1392  opc->data = data;
1393  opc->id = operation_id;
1394  GNUNET_TESTBED_insert_opc_ (controller, opc);
1395  return opc;
1396 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
GNUNET_MQ_MessageCallback cc
The callback to call when reply is available.
Definition: testbed_api.c:75
void * cc_cls
The closure for the above callback.
Definition: testbed_api.c:80
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
static unsigned int size
Size of the "table".
Definition: peer.c:67
Context data for forwarded Operation.
Definition: testbed_api.c:70
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:218
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:298
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:156
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
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 1406 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().

1407 {
1408  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1409  GNUNET_free (opc->data);
1410  GNUNET_free (opc);
1411 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
#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:319
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 2066 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().

2067 {
2069  Bytef *data;
2070  const Bytef *xdata;
2071  uLong data_len;
2072  uLong xdata_len;
2073  int ret;
2074 
2075  switch (ntohs (msg->type))
2076  {
2079 
2080  imsg =
2082  data_len = (uLong) ntohs (imsg->config_size);
2083  xdata_len =
2084  ntohs (imsg->header.size)
2086  xdata = (const Bytef *) &imsg[1];
2087  }
2088  break;
2089 
2091  const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2092 
2093  imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg;
2094  data_len = (uLong) ntohs (imsg->config_size);
2095  xdata_len = ntohs (imsg->header.size)
2096  - sizeof(struct GNUNET_TESTBED_SlaveConfiguration);
2097  xdata = (const Bytef *) &imsg[1];
2098  }
2099  break;
2100 
2102  const struct GNUNET_TESTBED_AddHostMessage *imsg;
2103  uint16_t osize;
2104 
2105  imsg = (const struct GNUNET_TESTBED_AddHostMessage *) msg;
2106  data_len = (uLong) ntohs (imsg->config_size);
2107  osize = sizeof(struct GNUNET_TESTBED_AddHostMessage)
2108  + ntohs (imsg->username_length) + ntohs (imsg->hostname_length);
2109  xdata_len = ntohs (imsg->header.size) - osize;
2110  xdata = (const Bytef *) ((const void *) imsg + osize);
2111  }
2112  break;
2113 
2115  const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2116 
2117  imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg;
2118  data_len = ntohs (imsg->config_size);
2119  xdata_len = ntohs (imsg->header.size)
2120  - sizeof(const struct GNUNET_TESTBED_ControllerLinkResponse);
2121  xdata = (const Bytef *) &imsg[1];
2122  }
2123  break;
2124 
2126  const struct GNUNET_TESTBED_PeerCreateMessage *imsg;
2127 
2128  imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *) msg;
2129  data_len = ntohs (imsg->config_size);
2130  xdata_len = ntohs (imsg->header.size)
2131  - sizeof(struct GNUNET_TESTBED_PeerCreateMessage);
2132  xdata = (const Bytef *) &imsg[1];
2133  }
2134  break;
2135 
2137  const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2138 
2139  imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *) msg;
2140  data_len = ntohs (imsg->config_size);
2141  xdata_len = ntohs (imsg->header.size)
2142  - sizeof(struct GNUNET_TESTBED_PeerReconfigureMessage);
2143  xdata = (const Bytef *) &imsg[1];
2144  }
2145  break;
2146 
2147  default:
2148  GNUNET_assert (0);
2149  }
2150  data = GNUNET_malloc (data_len);
2151  if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
2152  {
2153  GNUNET_free (data);
2154  GNUNET_break_op (0); /* Un-compression failure */
2155  return NULL;
2156  }
2157  cfg = GNUNET_CONFIGURATION_create ();
2159  (const char *) data,
2160  (size_t) data_len,
2161  NULL))
2162  {
2163  GNUNET_free (data);
2164  GNUNET_break_op (0); /* De-serialization failure */
2165  return NULL;
2166  }
2167  GNUNET_free (data);
2168  return cfg;
2169 }
#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:86
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:245
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:240
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT.
Definition: testbed.h:174
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:209
#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:64
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:97
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:603
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:92
uint16_t config_size
The size of the configuration when uncompressed.
Definition: testbed.h:679
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION.
Definition: testbed.h:608
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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...
Response message for ControllerLinkRequest message.
Definition: testbed.h:169
uint16_t config_size
The length of the serialized configuration when uncompressed.
Definition: testbed.h:260
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:628
#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:204
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:659
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:69
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:180
#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:229
#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:664
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 2180 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().

2182 {
2183  uint16_t msize;
2184  const char *emsg;
2185 
2186  msize = ntohs (msg->header.size);
2187  if (sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
2188  return NULL;
2189  msize -= sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage);
2190  emsg = (const char *) &msg[1];
2191  if ('\0' != emsg[msize - 1])
2192  {
2193  GNUNET_break (0);
2194  return NULL;
2195  }
2196  return emsg;
2197 }
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT.
Definition: testbed.h:513
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:508
#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 2208 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().

2209 {
2210  uint64_t op_id;
2211 
2212  op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host);
2213  op_id = op_id << 32;
2214  op_id |= (uint64_t) controller->operation_counter++;
2215  return op_id;
2216 }
uint32_t operation_counter
The operation id counter.
Definition: testbed_api.h:270
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:198
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 1893 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().

1896 {
1897  struct OperationContext *opc;
1898  struct GetSlaveConfigData *data;
1899 
1900  data = GNUNET_new (struct GetSlaveConfigData);
1901  data->slave_id = slave_host_id;
1902  opc = GNUNET_new (struct OperationContext);
1903  opc->state = OPC_STATE_INIT;
1904  opc->c = master;
1905  opc->id = GNUNET_TESTBED_get_next_op_id (master);
1906  opc->type = OP_GET_SLAVE_CONFIG;
1907  opc->data = data;
1908  opc->op_cls = op_cls;
1913  opc->op);
1915  return opc->op;
1916 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:146
void * op_cls
The operation closure.
Definition: testbed_api.h:151
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:87
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:2208
#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:1496
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
uint32_t slave_id
The id of the slave controller.
Definition: testbed_api.c:92
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:117
Get slave config operation.
Definition: testbed_api.h:94
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:244
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:1473
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
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 2370 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().

2376 {
2378  struct GNUNET_MQ_Envelope *env;
2379  struct GNUNET_TESTBED_Barrier *barrier;
2380  struct GNUNET_HashCode key;
2381  size_t name_len;
2382 
2383  GNUNET_assert (quorum <= 100);
2384  GNUNET_assert (NULL != cb);
2385  name_len = strlen (name);
2386  GNUNET_assert (0 < name_len);
2387  GNUNET_CRYPTO_hash (name, name_len, &key);
2388  if (NULL == controller->barrier_map)
2389  controller->barrier_map =
2391  if (GNUNET_YES ==
2393  {
2394  GNUNET_break (0);
2395  return NULL;
2396  }
2397  LOG_DEBUG ("Initialising barrier `%s'\n", name);
2398  barrier = GNUNET_new (struct GNUNET_TESTBED_Barrier);
2399  barrier->c = controller;
2400  barrier->name = GNUNET_strdup (name);
2401  barrier->cb = cb;
2402  barrier->cls = cls;
2403  barrier->echo = echo;
2404  GNUNET_memcpy (&barrier->key, &key, sizeof(struct GNUNET_HashCode));
2407  controller->barrier_map,
2408  &barrier->key,
2409  barrier,
2411 
2412  env = GNUNET_MQ_msg_extra (msg,
2413  name_len,
2415  msg->quorum = (uint8_t) quorum;
2416  GNUNET_memcpy (msg->name, barrier->name, name_len);
2417  GNUNET_MQ_send (barrier->c->mq, env);
2418  return barrier;
2419 }
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int echo
Should the barrier crossed status message be echoed back to the controller?
Definition: testbed_api.h:307
#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:302
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:52
#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
, &#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:48
char * name
The name of the barrier.
Definition: testbed_api.h:292
Handle for barrier.
Definition: testbed_api.h:277
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
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:287
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:282
const char * name
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
uint8_t quorum
The quorum percentage needed for crossing the barrier.
Definition: testbed.h:792
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:260
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:77
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:797
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT
Message to initialise a barrier.
Message to initialise a barrier.
Definition: testbed.h:782
GNUNET_TESTBED_barrier_status_cb cb
The continuation callback to call when we have a status update on this.
Definition: testbed_api.h:297
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 2334 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().

2335 {
2336  struct GNUNET_TESTBED_Controller *c = barrier->c;
2337 
2338  GNUNET_assert (NULL != c->barrier_map); /* No barriers present */
2341  &barrier->key,
2342  barrier));
2343  GNUNET_free (barrier->name);
2344  GNUNET_free (barrier);
2346  {
2348  c->barrier_map = NULL;
2349  }
2350 }
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:193
#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:75
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:292
struct GNUNET_TESTBED_Controller * c
The controller handle given while initiliasing this barrier.
Definition: testbed_api.h:287
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:282
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:260
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: