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 179 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.

44  {
49 
54 
59 
64 
69 
74 
79 
84 
89 
94 
99 
104 };
Stop and destroy all peers.
Definition: testbed_api.h:98
Reconfigure a peer.
Definition: testbed_api.h:73
Link controllers operation.
Definition: testbed_api.h:88
Peer destroy operation.
Definition: testbed_api.h:63
Peer start operation.
Definition: testbed_api.h:53
Overlay connection operation.
Definition: testbed_api.h:78
Forwarded operation.
Definition: testbed_api.h:83
Peer stop operation.
Definition: testbed_api.h:58
Get slave config operation.
Definition: testbed_api.h:93
Start/stop service at a peer.
Definition: testbed_api.h:103
Peer create operation.
Definition: testbed_api.h:48
Get peer information operation.
Definition: testbed_api.h:68

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

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

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

1330 {
1331  struct GNUNET_MQ_Envelope *env;
1332  struct GNUNET_MessageHeader *m2;
1333  uint16_t type;
1334  uint16_t size;
1335 
1336  type = ntohs(msg->type);
1337  size = ntohs(msg->size);
1340  env = GNUNET_MQ_msg_extra(m2, size - sizeof(*m2), type);
1341  GNUNET_memcpy(m2, msg, size);
1342  GNUNET_free(msg);
1343  GNUNET_MQ_send(controller->mq, env);
1344 }
#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:66
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:215
#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:351
#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 292 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().

294 {
295  if (NULL == c->opc_map)
298  c->opc_map,
299  (uint32_t)opc->id,
300  opc,
302 }
#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:159
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:226
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 313 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().

315 {
316  GNUNET_assert(NULL != c->opc_map);
319  (uint32_t)opc->id,
320  opc));
322  (NULL != c->opcq_empty_cb))
324 }
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:231
#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:159
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:226
void * opcq_empty_cls
Closure for the above task.
Definition: testbed_api.h:236
#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 1750 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().

1753 {
1754  size_t xsize;
1755 
1756  xsize = compressBound((uLong)size);
1757  *xconfig = GNUNET_malloc(xsize);
1758  GNUNET_assert(Z_OK == compress2((Bytef *)*xconfig,
1759  (uLongf *)&xsize,
1760  (const Bytef *)config,
1761  (uLongf)size,
1762  Z_BEST_SPEED));
1763  return xsize;
1764 }
#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:66
#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 1777 of file testbed_api.c.

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

Referenced by send_controller_link_response().

1780 {
1781  char *config;
1782  char *xconfig;
1783  size_t size_;
1784  size_t xsize_;
1785 
1786  config = GNUNET_CONFIGURATION_serialize(cfg, &size_);
1787  xsize_ = GNUNET_TESTBED_compress_config_(config, size_, &xconfig);
1788  GNUNET_free(config);
1789  *size = size_;
1790  *xsize = xsize_;
1791  return xconfig;
1792 }
static const struct GNUNET_CONFIGURATION_Handle * config
static unsigned int size
Size of the "table".
Definition: peer.c:66
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1750
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 1973 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().

1977 {
1979  char *config;
1980  char *xconfig;
1981  size_t config_size;
1982  size_t xconfig_size;
1983  uint16_t trusted_ip_len;
1984  uint16_t hostname_len;
1985  uint16_t msg_size;
1986 
1987  config = GNUNET_CONFIGURATION_serialize(cfg, &config_size);
1988  GNUNET_assert(NULL != config);
1989  xconfig_size =
1990  GNUNET_TESTBED_compress_config_(config, config_size, &xconfig);
1991  GNUNET_free(config);
1992  trusted_ip_len = strlen(trusted_ip);
1993  hostname_len = (NULL == hostname) ? 0 : strlen(hostname);
1994  msg_size = xconfig_size + trusted_ip_len + 1 +
1995  sizeof(struct GNUNET_TESTBED_HelperInit);
1996  msg_size += hostname_len;
1997  msg = GNUNET_realloc(xconfig, msg_size);
1998  (void)memmove(((void *)&msg[1]) + trusted_ip_len + 1 + hostname_len,
1999  msg,
2000  xconfig_size);
2001  msg->header.size = htons(msg_size);
2002  msg->header.type = htons(GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
2003  msg->trusted_ip_size = htons(trusted_ip_len);
2004  msg->hostname_size = htons(hostname_len);
2005  msg->config_size = htons(config_size);
2006  (void)strcpy((char *)&msg[1], trusted_ip);
2007  if (0 != hostname_len)
2008  GNUNET_memcpy((char *)&msg[1] + trusted_ip_len + 1,
2009  hostname,
2010  hostname_len);
2011  return msg;
2012 }
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:1750
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 1362 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().

1368 {
1369  struct OperationContext *opc;
1370  struct ForwardedOperationData *data;
1371  struct GNUNET_MQ_Envelope *env;
1372  struct GNUNET_MessageHeader *m2;
1373  uint16_t type = ntohs(msg->type);
1374  uint16_t size = ntohs(msg->size);
1375 
1376  env = GNUNET_MQ_msg_extra(m2, size - sizeof(*m2), type);
1377  GNUNET_memcpy(m2, msg, size);
1378  GNUNET_MQ_send(controller->mq, env);
1379  data = GNUNET_new(struct ForwardedOperationData);
1380  data->cc = cc;
1381  data->cc_cls = cc_cls;
1382  opc = GNUNET_new(struct OperationContext);
1383  opc->c = controller;
1384  opc->type = OP_FORWARDED;
1385  opc->data = data;
1386  opc->id = operation_id;
1387  GNUNET_TESTBED_insert_opc_(controller, opc);
1388  return opc;
1389 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
#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:159
GNUNET_MQ_MessageCallback cc
The callback to call when reply is available.
Definition: testbed_api.c:74
void * cc_cls
The closure for the above callback.
Definition: testbed_api.c:79
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
static unsigned int size
Size of the "table".
Definition: peer.c:66
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:83
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:215
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:292
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:351
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
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 1399 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().

1400 {
1401  GNUNET_TESTBED_remove_opc_(opc->c, opc);
1402  GNUNET_free(opc->data);
1403  GNUNET_free(opc);
1404 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
#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:313
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 2059 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().

2060 {
2062  Bytef *data;
2063  const Bytef *xdata;
2064  uLong data_len;
2065  uLong xdata_len;
2066  int ret;
2067 
2068  switch (ntohs(msg->type))
2069  {
2072 
2073  imsg =
2075  data_len = (uLong)ntohs(imsg->config_size);
2076  xdata_len =
2077  ntohs(imsg->header.size) -
2079  xdata = (const Bytef *)&imsg[1];
2080  }
2081  break;
2082 
2084  const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2085 
2086  imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *)msg;
2087  data_len = (uLong)ntohs(imsg->config_size);
2088  xdata_len = ntohs(imsg->header.size) -
2089  sizeof(struct GNUNET_TESTBED_SlaveConfiguration);
2090  xdata = (const Bytef *)&imsg[1];
2091  }
2092  break;
2093 
2095  const struct GNUNET_TESTBED_AddHostMessage *imsg;
2096  uint16_t osize;
2097 
2098  imsg = (const struct GNUNET_TESTBED_AddHostMessage *)msg;
2099  data_len = (uLong)ntohs(imsg->config_size);
2100  osize = sizeof(struct GNUNET_TESTBED_AddHostMessage) +
2101  ntohs(imsg->username_length) + ntohs(imsg->hostname_length);
2102  xdata_len = ntohs(imsg->header.size) - osize;
2103  xdata = (const Bytef *)((const void *)imsg + osize);
2104  }
2105  break;
2106 
2108  const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2109 
2110  imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *)msg;
2111  data_len = ntohs(imsg->config_size);
2112  xdata_len = ntohs(imsg->header.size) -
2113  sizeof(const struct GNUNET_TESTBED_ControllerLinkResponse);
2114  xdata = (const Bytef *)&imsg[1];
2115  }
2116  break;
2117 
2119  const struct GNUNET_TESTBED_PeerCreateMessage *imsg;
2120 
2121  imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *)msg;
2122  data_len = ntohs(imsg->config_size);
2123  xdata_len = ntohs(imsg->header.size) -
2124  sizeof(struct GNUNET_TESTBED_PeerCreateMessage);
2125  xdata = (const Bytef *)&imsg[1];
2126  }
2127  break;
2128 
2130  const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2131 
2132  imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *)msg;
2133  data_len = ntohs(imsg->config_size);
2134  xdata_len = ntohs(imsg->header.size) -
2136  xdata = (const Bytef *)&imsg[1];
2137  }
2138  break;
2139 
2140  default:
2141  GNUNET_assert(0);
2142  }
2143  data = GNUNET_malloc(data_len);
2144  if (Z_OK != (ret = uncompress(data, &data_len, xdata, xdata_len)))
2145  {
2146  GNUNET_free(data);
2147  GNUNET_break_op(0); /* Un-compression failure */
2148  return NULL;
2149  }
2152  (const char *)data,
2153  (size_t)data_len,
2154  NULL))
2155  {
2156  GNUNET_free(data);
2157  GNUNET_break_op(0); /* De-serialization failure */
2158  return NULL;
2159  }
2160  GNUNET_free(data);
2161  return cfg;
2162 }
#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:84
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:238
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:234
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT.
Definition: testbed.h:169
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:203
#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:63
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:95
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:584
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:90
uint16_t config_size
The size of the configuration when uncompressed.
Definition: testbed.h:657
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION.
Definition: testbed.h:588
#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...
static int ret
Final status code.
Definition: gnunet-arm.c:89
Response message for ControllerLinkRequest message.
Definition: testbed.h:165
uint16_t config_size
The length of the serialized configuration when uncompressed.
Definition: testbed.h:253
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:608
#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:199
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:638
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:67
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:175
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
Message to create a peer at a host.
configuration data
Definition: configuration.c:83
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:223
#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:642
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 2173 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().

2175 {
2176  uint16_t msize;
2177  const char *emsg;
2178 
2179  msize = ntohs(msg->header.size);
2180  if (sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
2181  return NULL;
2182  msize -= sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage);
2183  emsg = (const char *)&msg[1];
2184  if ('\0' != emsg[msize - 1])
2185  {
2186  GNUNET_break(0);
2187  return NULL;
2188  }
2189  return emsg;
2190 }
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT.
Definition: testbed.h:497
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:493
#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 2201 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().

2202 {
2203  uint64_t op_id;
2204 
2205  op_id = (uint64_t)GNUNET_TESTBED_host_get_id_(controller->host);
2206  op_id = op_id << 32;
2207  op_id |= (uint64_t)controller->operation_counter++;
2208  return op_id;
2209 }
uint32_t operation_counter
The operation id counter.
Definition: testbed_api.h:267
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:195
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 1886 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().

1889 {
1890  struct OperationContext *opc;
1891  struct GetSlaveConfigData *data;
1892 
1893  data = GNUNET_new(struct GetSlaveConfigData);
1894  data->slave_id = slave_host_id;
1895  opc = GNUNET_new(struct OperationContext);
1896  opc->state = OPC_STATE_INIT;
1897  opc->c = master;
1898  opc->id = GNUNET_TESTBED_get_next_op_id(master);
1899  opc->type = OP_GET_SLAVE_CONFIG;
1900  opc->data = data;
1901  opc->op_cls = op_cls;
1906  opc->op);
1908  return opc->op;
1909 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
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:86
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:2201
#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:1489
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:169
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
uint32_t slave_id
The id of the slave controller.
Definition: testbed_api.c:90
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:116
Get slave config operation.
Definition: testbed_api.h:93
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
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:1466
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
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 2363 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().

2369 {
2371  struct GNUNET_MQ_Envelope *env;
2372  struct GNUNET_TESTBED_Barrier *barrier;
2373  struct GNUNET_HashCode key;
2374  size_t name_len;
2375 
2376  GNUNET_assert(quorum <= 100);
2377  GNUNET_assert(NULL != cb);
2378  name_len = strlen(name);
2379  GNUNET_assert(0 < name_len);
2380  GNUNET_CRYPTO_hash(name, name_len, &key);
2381  if (NULL == controller->barrier_map)
2382  controller->barrier_map =
2384  if (GNUNET_YES ==
2386  {
2387  GNUNET_break(0);
2388  return NULL;
2389  }
2390  LOG_DEBUG("Initialising barrier `%s'\n", name);
2391  barrier = GNUNET_new(struct GNUNET_TESTBED_Barrier);
2392  barrier->c = controller;
2393  barrier->name = GNUNET_strdup(name);
2394  barrier->cb = cb;
2395  barrier->cls = cls;
2396  barrier->echo = echo;
2397  GNUNET_memcpy(&barrier->key, &key, sizeof(struct GNUNET_HashCode));
2400  controller->barrier_map,
2401  &barrier->key,
2402  barrier,
2404 
2405  env = GNUNET_MQ_msg_extra(msg,
2406  name_len,
2408  msg->quorum = (uint8_t)quorum;
2409  GNUNET_memcpy(msg->name, barrier->name, name_len);
2410  GNUNET_MQ_send(barrier->c->mq, env);
2411  return barrier;
2412 }
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:303
#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:298
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:44
char * name
The name of the barrier.
Definition: testbed_api.h:288
Handle for barrier.
Definition: testbed_api.h:274
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:283
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:278
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:215
uint8_t quorum
The quorum percentage needed for crossing the barrier.
Definition: testbed.h:766
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:257
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:351
char name[0]
name of the barrier.
Definition: testbed.h:771
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT
Message to initialise a barrier.
Message to initialise a barrier.
Definition: testbed.h:757
GNUNET_TESTBED_barrier_status_cb cb
The continuation callback to call when we have a status update on this.
Definition: testbed_api.h:293
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 2327 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().

2328 {
2329  struct GNUNET_TESTBED_Controller *c = barrier->c;
2330 
2331  GNUNET_assert(NULL != c->barrier_map); /* No barriers present */
2334  &barrier->key,
2335  barrier));
2336  GNUNET_free(barrier->name);
2337  GNUNET_free(barrier);
2339  {
2341  c->barrier_map = NULL;
2342  }
2343 }
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:191
#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:288
struct GNUNET_TESTBED_Controller * c
The controller handle given while initiliasing this barrier.
Definition: testbed_api.h:283
struct GNUNET_HashCode key
hashcode identifying this barrier in the hashmap
Definition: testbed_api.h:278
struct GNUNET_CONTAINER_MultiHashMap * barrier_map
handle for hashtable of barrier handles, values are of type struct GNUNET_TESTBED_Barrier.
Definition: testbed_api.h:257
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: