GNUnet  0.11.x
Functions | Variables
testbed_api_peers.c File Reference

management of the knowledge about peers in this library (we know the peer ID, its host, pending operations, etc.) More...

#include "platform.h"
#include "testbed_api_peers.h"
#include "testbed_api.h"
#include "testbed.h"
#include "testbed_api_hosts.h"
#include "testbed_api_operations.h"
Include dependency graph for testbed_api_peers.c:

Go to the source code of this file.

Functions

void GNUNET_TESTBED_peer_register_ (struct GNUNET_TESTBED_Peer *peer)
 Adds a peer to the peer list. More...
 
void GNUNET_TESTBED_peer_deregister_ (struct GNUNET_TESTBED_Peer *peer)
 Removes a peer from the peer list. More...
 
void GNUNET_TESTBED_cleanup_peers_ (void)
 Frees all peers. More...
 
static void opstart_peer_create (void *cls)
 Function to call to start a peer_create type operation once all queues the operation is part of declare that the operation can be activated. More...
 
static void oprelease_peer_create (void *cls)
 Callback which will be called when peer_create type operation is released. More...
 
static void opstart_peer_destroy (void *cls)
 Function called when a peer destroy operation is ready. More...
 
static void oprelease_peer_destroy (void *cls)
 Callback which will be called when peer_create type operation is released. More...
 
static void opstart_peer_start (void *cls)
 Function called when a peer start operation is ready. More...
 
static void oprelease_peer_start (void *cls)
 Callback which will be called when peer start type operation is released. More...
 
static void opstart_peer_stop (void *cls)
 Function called when a peer stop operation is ready. More...
 
static void oprelease_peer_stop (void *cls)
 Callback which will be called when peer stop type operation is released. More...
 
struct GNUNET_TESTBED_PeerGetConfigurationMessageGNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id, uint64_t operation_id)
 Generate PeerGetConfigurationMessage. More...
 
static void opstart_peer_getinfo (void *cls)
 Function called when a peer get information operation is ready. More...
 
static void oprelease_peer_getinfo (void *cls)
 Callback which will be called when peer stop type operation is released. More...
 
static void opstart_overlay_connect (void *cls)
 Function called when a overlay connect operation is ready. More...
 
static void oprelease_overlay_connect (void *cls)
 Callback which will be called when overlay connect operation is released. More...
 
static void opstart_peer_reconfigure (void *cls)
 Function called when a peer reconfigure operation is ready. More...
 
static void oprelease_peer_reconfigure (void *cls)
 Callback which will be called when a peer reconfigure operation is released. More...
 
struct GNUNET_TESTBED_PeerGNUNET_TESTBED_peer_lookup_by_id_ (uint32_t id)
 Lookup a peer by ID. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
 Create the given peer at the specified host using the given controller. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_start (void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
 Start the given peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_stop (void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
 Stop the given peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
 Request information about a peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Change peer configuration. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer)
 Destroy the given peer; the peer should have been stopped first (if it was started). More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_underlay_configure_link (void *op_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2, enum GNUNET_TESTBED_ConnectOption co,...)
 Manipulate the P2P underlay topology by configuring a link between two peers. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_overlay_connect (void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2)
 Both peers must have been started before calling this function. More...
 
static void opstart_manage_service (void *cls)
 Function called when a peer manage service operation is ready. More...
 
static void oprelease_manage_service (void *cls)
 Callback which will be called when peer manage server operation is released. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_manage_service (void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
 Start or stop given service at a peer. More...
 

Variables

static struct GNUNET_TESTBED_Peerpeer_list_head
 Peer list DLL head. More...
 
static struct GNUNET_TESTBED_Peerpeer_list_tail
 Peer list DLL tail. More...
 

Detailed Description

management of the knowledge about peers in this library (we know the peer ID, its host, pending operations, etc.)

Author
Christian Grothoff
Sree Harsha Totakura

Definition in file testbed_api_peers.c.

Function Documentation

◆ GNUNET_TESTBED_peer_register_()

void GNUNET_TESTBED_peer_register_ ( struct GNUNET_TESTBED_Peer peer)

Adds a peer to the peer list.

Parameters
peerthe peer to add to the peer list

Definition at line 54 of file testbed_api_peers.c.

References GNUNET_CONTAINER_DLL_insert_tail.

Referenced by handle_peer_create_success().

55 {
57 }
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static struct GNUNET_TESTBED_Peer * peer_list_head
Peer list DLL head.
static struct GNUNET_TESTBED_Peer * peer_list_tail
Peer list DLL tail.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_peer_deregister_()

void GNUNET_TESTBED_peer_deregister_ ( struct GNUNET_TESTBED_Peer peer)

Removes a peer from the peer list.

Parameters
peerthe peer to remove

Definition at line 66 of file testbed_api_peers.c.

References GNUNET_CONTAINER_DLL_remove.

Referenced by GNUNET_TESTBED_cleanup_peers_(), and handle_opsuccess().

67 {
69 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_TESTBED_Peer * peer_list_head
Peer list DLL head.
static struct GNUNET_TESTBED_Peer * peer_list_tail
Peer list DLL tail.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_cleanup_peers_()

void GNUNET_TESTBED_cleanup_peers_ ( void  )

Frees all peers.

Definition at line 76 of file testbed_api_peers.c.

References GNUNET_free, GNUNET_TESTBED_peer_deregister_(), and peer.

Referenced by handle_opsuccess().

77 {
78  struct GNUNET_TESTBED_Peer *peer;
79 
80  while (NULL != (peer = peer_list_head))
81  {
83  GNUNET_free (peer);
84  }
85 }
void GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer)
Removes a peer from the peer list.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static struct GNUNET_TESTBED_Peer * peer_list_head
Peer list DLL head.
A peer controlled by the testing framework.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_peer_create()

static void opstart_peer_create ( void *  cls)
static

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

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 96 of file testbed_api_peers.c.

References OperationContext::c, PeerCreateData::cfg, config, GNUNET_TESTBED_PeerCreateMessage::config_size, data, OperationContext::data, env, GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_insert_opc_(), GNUNET_TESTBED_Peer::host, GNUNET_TESTBED_PeerCreateMessage::host_id, OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OP_PEER_CREATE, OPC_STATE_STARTED, GNUNET_TESTBED_PeerCreateMessage::operation_id, PeerCreateData::peer, GNUNET_TESTBED_PeerCreateMessage::peer_id, OperationContext::state, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_create().

97 {
98  struct OperationContext *opc = cls;
99  struct PeerCreateData *data = opc->data;
101  struct GNUNET_MQ_Envelope *env;
102  char *config;
103  char *xconfig;
104  size_t c_size;
105  size_t xc_size;
106 
108  GNUNET_assert (NULL != data);
109  GNUNET_assert (NULL != data->peer);
110  opc->state = OPC_STATE_STARTED;
111  config = GNUNET_CONFIGURATION_serialize (data->cfg,
112  &c_size);
113  xc_size = GNUNET_TESTBED_compress_config_ (config,
114  c_size,
115  &xconfig);
116  GNUNET_free (config);
117  env = GNUNET_MQ_msg_extra (msg,
118  xc_size,
120  msg->operation_id = GNUNET_htonll (opc->id);
121  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host));
122  msg->peer_id = htonl (data->peer->unique_id);
123  msg->config_size = htons ((uint16_t) c_size);
124  GNUNET_memcpy (&msg[1],
125  xconfig,
126  xc_size);
127  GNUNET_MQ_send (opc->c->mq,
128  env);
129  GNUNET_free (xconfig);
130  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
131 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
#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.
const struct GNUNET_CONFIGURATION_Handle * cfg
The template configuration of the peer.
#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
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
static const struct GNUNET_CONFIGURATION_Handle * config
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's unique global ID.
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
uint64_t operation_id
Unique operation id.
Definition: testbed.h:219
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:204
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
Message to create a peer at a host.
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.
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
uint32_t host_id
On which host should the peer be started?
Definition: testbed.h:214
Peer create operation.
Definition: testbed_api.h:49
struct GNUNET_TESTBED_Peer * peer
The peer structure to return when we get success message.
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
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:224
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint32_t data
The data value.
Data for the OperationType OP_PEER_CREATE.
uint16_t config_size
Size of the uncompressed configuration.
Definition: testbed.h:229
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_peer_create()

static void oprelease_peer_create ( void *  cls)
static

Callback which will be called when peer_create type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 140 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_create().

141 {
142  struct OperationContext *opc = cls;
143 
144  switch (opc->state)
145  {
146  case OPC_STATE_STARTED:
147  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
148 
149  /* No break we continue flow */
150  case OPC_STATE_INIT:
151  GNUNET_free (((struct PeerCreateData *) opc->data)->peer);
152  GNUNET_free (opc->data);
153  break;
154 
155  case OPC_STATE_FINISHED:
156  break;
157  }
158  GNUNET_free (opc);
159 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
Data for the OperationType OP_PEER_CREATE.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#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:

◆ opstart_peer_destroy()

static void opstart_peer_destroy ( void *  cls)
static

Function called when a peer destroy operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 168 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, OperationContext::data, env, GNUNET_assert, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OP_PEER_DESTROY, OPC_STATE_STARTED, GNUNET_TESTBED_PeerDestroyMessage::operation_id, peer, GNUNET_TESTBED_PeerDestroyMessage::peer_id, OperationContext::state, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_destroy().

169 {
170  struct OperationContext *opc = cls;
171  struct GNUNET_TESTBED_Peer *peer = opc->data;
173  struct GNUNET_MQ_Envelope *env;
174 
176  GNUNET_assert (NULL != peer);
177  opc->state = OPC_STATE_STARTED;
178  env = GNUNET_MQ_msg (msg,
180  msg->peer_id = htonl (peer->unique_id);
181  msg->operation_id = GNUNET_htonll (opc->id);
182  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
183  GNUNET_MQ_send (peer->controller->mq,
184  env);
185 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:317
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:327
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
Peer destroy operation.
Definition: testbed_api.h:64
#define GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER
Message to destroy a peer.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
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
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:332
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:

◆ oprelease_peer_destroy()

static void oprelease_peer_destroy ( void *  cls)
static

Callback which will be called when peer_create type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 194 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_destroy().

195 {
196  struct OperationContext *opc = cls;
197 
198  switch (opc->state)
199  {
200  case OPC_STATE_STARTED:
201  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
202 
203  /* no break; continue */
204  case OPC_STATE_INIT:
205  break;
206 
207  case OPC_STATE_FINISHED:
208  break;
209  }
210  GNUNET_free (opc);
211 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#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:

◆ opstart_peer_start()

static void opstart_peer_start ( void *  cls)
static

Function called when a peer start operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 220 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, env, GNUNET_assert, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_START_PEER, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OP_PEER_START, OPC_STATE_STARTED, GNUNET_TESTBED_PeerStartMessage::operation_id, peer, PeerEventData::peer, GNUNET_TESTBED_PeerStartMessage::peer_id, GNUNET_TESTBED_Peer::state, OperationContext::state, TESTBED_PS_CREATED, TESTBED_PS_STOPPED, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_start().

221 {
222  struct OperationContext *opc = cls;
224  struct GNUNET_MQ_Envelope *env;
225  struct PeerEventData *data;
226  struct GNUNET_TESTBED_Peer *peer;
227 
228  GNUNET_assert (OP_PEER_START == opc->type);
229  GNUNET_assert (NULL != (data = opc->data));
230  GNUNET_assert (NULL != (peer = data->peer));
232  peer->state));
233  opc->state = OPC_STATE_STARTED;
234  env = GNUNET_MQ_msg (msg,
236  msg->peer_id = htonl (peer->unique_id);
237  msg->operation_id = GNUNET_htonll (opc->id);
238  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
239  GNUNET_MQ_send (peer->controller->mq,
240  env);
241 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:286
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
Data for OperationType OP_PEER_START and OP_PEER_STOP.
Message sent from client to testing service to start a peer.
Definition: testbed.h:271
enum PeerState state
Peer's state.
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
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Peer start operation.
Definition: testbed_api.h:54
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
The peer is stopped.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
The peer has been created.
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
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint32_t data
The data value.
#define GNUNET_MESSAGE_TYPE_TESTBED_START_PEER
Message to start a peer at a host.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:281
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:

◆ oprelease_peer_start()

static void oprelease_peer_start ( void *  cls)
static

Callback which will be called when peer start type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 250 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_start().

251 {
252  struct OperationContext *opc = cls;
253 
254  switch (opc->state)
255  {
256  case OPC_STATE_STARTED:
257  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
258 
259  /* no break; continue */
260  case OPC_STATE_INIT:
261  GNUNET_free (opc->data);
262  break;
263 
264  case OPC_STATE_FINISHED:
265  break;
266  }
267  GNUNET_free (opc);
268 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#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:

◆ opstart_peer_stop()

static void opstart_peer_stop ( void *  cls)
static

Function called when a peer stop operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 277 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, env, GNUNET_assert, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OPC_STATE_STARTED, GNUNET_TESTBED_PeerStopMessage::operation_id, peer, PeerEventData::peer, GNUNET_TESTBED_PeerStopMessage::peer_id, GNUNET_TESTBED_Peer::state, OperationContext::state, TESTBED_PS_STARTED, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_stop().

278 {
279  struct OperationContext *opc = cls;
281  struct PeerEventData *data;
282  struct GNUNET_TESTBED_Peer *peer;
283  struct GNUNET_MQ_Envelope *env;
284 
285  GNUNET_assert (NULL != (data = opc->data));
286  GNUNET_assert (NULL != (peer = data->peer));
288  opc->state = OPC_STATE_STARTED;
289  env = GNUNET_MQ_msg (msg,
291  msg->peer_id = htonl (peer->unique_id);
292  msg->operation_id = GNUNET_htonll (opc->id);
293  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
294  GNUNET_MQ_send (peer->controller->mq,
295  env);
296 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
Message sent from client to testing service to stop a peer.
Definition: testbed.h:294
The operation has been started.
Definition: testbed_api.h:123
#define GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER
Message to stop a peer at a host.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
Data for OperationType OP_PEER_START and OP_PEER_STOP.
enum PeerState state
Peer's state.
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
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:304
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
The peer is running.
A peer controlled by the testing framework.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:309
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:

◆ oprelease_peer_stop()

static void oprelease_peer_stop ( void *  cls)
static

Callback which will be called when peer stop type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 305 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_stop().

306 {
307  struct OperationContext *opc = cls;
308 
309  switch (opc->state)
310  {
311  case OPC_STATE_STARTED:
312  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
313 
314  /* no break; continue */
315  case OPC_STATE_INIT:
316  GNUNET_free (opc->data);
317  break;
318 
319  case OPC_STATE_FINISHED:
320  break;
321  }
322  GNUNET_free (opc);
323 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#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_generate_peergetconfig_msg_()

struct GNUNET_TESTBED_PeerGetConfigurationMessage* GNUNET_TESTBED_generate_peergetconfig_msg_ ( uint32_t  peer_id,
uint64_t  operation_id 
)

Generate PeerGetConfigurationMessage.

Parameters
peer_idthe id of the peer whose information we have to get
operation_idthe ip of the operation that should be represented in the message
Returns
the PeerGetConfigurationMessage

Definition at line 335 of file testbed_api_peers.c.

References GNUNET_htonll(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION, GNUNET_TESTBED_PeerGetConfigurationMessage::header, msg, GNUNET_TESTBED_PeerGetConfigurationMessage::operation_id, GNUNET_TESTBED_PeerGetConfigurationMessage::peer_id, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by opstart_peer_getinfo(), and opstart_service_connect().

337 {
339 
340  msg =
341  GNUNET_malloc (sizeof
343  msg->header.size =
344  htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
346  msg->peer_id = htonl (peer_id);
348  return msg;
349 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:581
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:591
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:596
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:586
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
Message to get a peer's information.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_peer_getinfo()

static void opstart_peer_getinfo ( void *  cls)
static

Function called when a peer get information operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 358 of file testbed_api_peers.c.

References OperationContext::c, data, OperationContext::data, GNUNET_assert, GNUNET_TESTBED_generate_peergetconfig_msg_(), GNUNET_TESTBED_insert_opc_(), GNUNET_TESTBED_queue_message_(), GNUNET_TESTBED_PeerGetConfigurationMessage::header, OperationContext::id, msg, OPC_STATE_STARTED, PeerInfoData::peer, OperationContext::state, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_get_information().

359 {
360  struct OperationContext *opc = cls;
361  struct PeerInfoData *data = opc->data;
363 
364  GNUNET_assert (NULL != data);
365  opc->state = OPC_STATE_STARTED;
366  msg =
368  opc->id);
369  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
370  GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
371 }
Data for the OperationType OP_PEER_INFO.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:581
The operation has been started.
Definition: testbed_api.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_PeerGetConfigurationMessage * GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, uint64_t operation_id)
Generate PeerGetConfigurationMessage.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:586
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1335
uint32_t unique_id
Globally unique ID of the peer.
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 * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint32_t data
The data value.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
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:

◆ oprelease_peer_getinfo()

static void oprelease_peer_getinfo ( void *  cls)
static

Callback which will be called when peer stop type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 380 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_PeerInformation::cfg, data, OperationContext::data, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TESTBED_PIT_CONFIGURATION, GNUNET_TESTBED_PIT_IDENTITY, GNUNET_TESTBED_remove_opc_(), GNUNET_TESTBED_PeerInformation::id, OPC_STATE_FINISHED, OPC_STATE_INIT, OPC_STATE_STARTED, GNUNET_TESTBED_PeerInformation::pit, GNUNET_TESTBED_PeerInformation::result, and OperationContext::state.

Referenced by GNUNET_TESTBED_peer_get_information().

381 {
382  struct OperationContext *opc = cls;
384 
385  switch (opc->state)
386  {
387  case OPC_STATE_STARTED:
388  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
389 
390  /* no break; continue */
391  case OPC_STATE_INIT:
392  GNUNET_free (opc->data);
393  break;
394 
395  case OPC_STATE_FINISHED:
396  data = opc->data;
397  GNUNET_assert (NULL != data);
398  switch (data->pit)
399  {
401  if (NULL != data->result.cfg)
403  break;
404 
406  GNUNET_free (data->result.id);
407  break;
408 
409  default:
410  GNUNET_assert (0); /* We should never reach here */
411  }
412  GNUNET_free (data);
413  break;
414  }
415  GNUNET_free (opc);
416 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the 'op_result' is actually in use...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PeerIdentity * id
The identity of the peer.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
What configuration is the peer using? Returns a 'const struct GNUNET_CONFIGURATION_Handle *'...
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer.
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
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'. ...
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
uint32_t data
The data value.
union GNUNET_TESTBED_PeerInformation::@61 result
The result of the get information operation; Choose according to the pit.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:136
#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
Data returned from GNUNET_TESTBED_peer_get_information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_overlay_connect()

static void opstart_overlay_connect ( void *  cls)
static

Function called when a overlay connect operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 425 of file testbed_api_peers.c.

References OperationContext::c, data, OperationContext::data, env, GNUNET_assert, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_insert_opc_(), GNUNET_TESTBED_Peer::host, OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OPC_STATE_STARTED, GNUNET_TESTBED_OverlayConnectMessage::operation_id, OverlayConnectData::p1, OverlayConnectData::p2, GNUNET_TESTBED_OverlayConnectMessage::peer1, GNUNET_TESTBED_OverlayConnectMessage::peer2, GNUNET_TESTBED_OverlayConnectMessage::peer2_host_id, OperationContext::state, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_overlay_connect().

426 {
427  struct OperationContext *opc = cls;
428  struct GNUNET_MQ_Envelope *env;
430  struct OverlayConnectData *data;
431 
432  opc->state = OPC_STATE_STARTED;
433  data = opc->data;
434  GNUNET_assert (NULL != data);
435  env = GNUNET_MQ_msg (msg,
437  msg->peer1 = htonl (data->p1->unique_id);
438  msg->peer2 = htonl (data->p2->unique_id);
439  msg->operation_id = GNUNET_htonll (opc->id);
440  msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host));
442  opc);
443  GNUNET_MQ_send (opc->c->mq,
444  env);
445 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:390
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:395
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:385
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:400
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's unique global ID.
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
#define GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT
Message to connect peers in a overlay.
Data structure for OperationType OP_OVERLAY_CONNECT.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_TESTBED_Peer * p1
Peer A to connect to peer B.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Message sent from client to testing service to connect two peers.
Definition: testbed.h:375
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_TESTBED_Peer * p2
Peer B.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
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:

◆ oprelease_overlay_connect()

static void oprelease_overlay_connect ( void *  cls)
static

Callback which will be called when overlay connect operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 454 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_overlay_connect().

455 {
456  struct OperationContext *opc = cls;
457  struct OverlayConnectData *data;
458 
459  data = opc->data;
460  switch (opc->state)
461  {
462  case OPC_STATE_INIT:
463  break;
464 
465  case OPC_STATE_STARTED:
466  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
467  break;
468 
469  case OPC_STATE_FINISHED:
470  break;
471  }
472  GNUNET_free (data);
473  GNUNET_free (opc);
474 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
Data structure for OperationType OP_OVERLAY_CONNECT.
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
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
#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:

◆ opstart_peer_reconfigure()

static void opstart_peer_reconfigure ( void *  cls)
static

Function called when a peer reconfigure operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 483 of file testbed_api_peers.c.

References OperationContext::c, PeerReconfigureData::cfg_size, PeerReconfigureData::config, GNUNET_TESTBED_PeerReconfigureMessage::config_size, data, OperationContext::data, env, GNUNET_assert, GNUNET_free, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OPC_STATE_STARTED, GNUNET_TESTBED_PeerReconfigureMessage::operation_id, PeerReconfigureData::peer, GNUNET_TESTBED_PeerReconfigureMessage::peer_id, OperationContext::state, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_update_configuration().

484 {
485  struct OperationContext *opc = cls;
486  struct PeerReconfigureData *data = opc->data;
487  struct GNUNET_MQ_Envelope *env;
489  char *xconfig;
490  size_t xc_size;
491 
492  opc->state = OPC_STATE_STARTED;
493  GNUNET_assert (NULL != data);
494  xc_size = GNUNET_TESTBED_compress_config_ (data->config,
495  data->cfg_size,
496  &xconfig);
497  GNUNET_free (data->config);
498  data->config = NULL;
499  GNUNET_assert (xc_size < UINT16_MAX - sizeof(*msg));
500  env = GNUNET_MQ_msg_extra (msg,
501  xc_size,
503  msg->peer_id = htonl (data->peer->unique_id);
504  msg->operation_id = GNUNET_htonll (opc->id);
505  msg->config_size = htons (data->cfg_size);
506  GNUNET_memcpy (&msg[1],
507  xconfig,
508  xc_size);
509  GNUNET_free (xconfig);
510  GNUNET_free (data);
511  opc->data = NULL;
512  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
513  GNUNET_MQ_send (opc->c->mq,
514  env);
515 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:240
uint16_t cfg_size
the size of the serialized configuration
The operation has been started.
Definition: testbed_api.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:250
uint16_t config_size
The length of the serialized configuration when uncompressed.
Definition: testbed.h:260
#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
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:255
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
#define GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER
Message to reconfigure a peer.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Data for the operations of type OP_PEER_RECONFIGURE.
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
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
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
char * config
The serialized new configuration template.
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
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_peer_reconfigure()

static void oprelease_peer_reconfigure ( void *  cls)
static

Callback which will be called when a peer reconfigure operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 524 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_update_configuration().

525 {
526  struct OperationContext *opc = cls;
527  struct PeerReconfigureData *data = opc->data;
528 
529  switch (opc->state)
530  {
531  case OPC_STATE_INIT:
532  GNUNET_free (data->config);
533  GNUNET_free (data);
534  break;
535 
536  case OPC_STATE_STARTED:
537  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
538  break;
539 
540  case OPC_STATE_FINISHED:
541  break;
542  }
543  GNUNET_free (opc);
544 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
Data for the operations of type OP_PEER_RECONFIGURE.
char * config
The serialized new configuration template.
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
#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_peer_lookup_by_id_()

struct GNUNET_TESTBED_Peer* GNUNET_TESTBED_peer_lookup_by_id_ ( uint32_t  id)

Lookup a peer by ID.

Parameters
idglobal peer ID assigned to the peer
Returns
handle to the host, NULL on error

Definition at line 554 of file testbed_api_peers.c.

References GNUNET_break.

555 {
556  GNUNET_break (0);
557  return NULL;
558 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...

◆ opstart_manage_service()

static void opstart_manage_service ( void *  cls)
static

Function called when a peer manage service operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 901 of file testbed_api_peers.c.

References OperationContext::c, data, OperationContext::data, env, GNUNET_assert, GNUNET_free, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, ManageServiceData::msize, OPC_STATE_STARTED, GNUNET_TESTBED_ManagePeerServiceMessage::operation_id, ManageServiceData::peer, GNUNET_TESTBED_ManagePeerServiceMessage::peer_id, ManageServiceData::service_name, ManageServiceData::start, GNUNET_TESTBED_ManagePeerServiceMessage::start, OperationContext::state, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_peer_manage_service().

902 {
903  struct OperationContext *opc = cls;
904  struct ManageServiceData *data = opc->data;
905  struct GNUNET_MQ_Envelope *env;
907  size_t xlen;
908 
909  GNUNET_assert (NULL != data);
910  xlen = data->msize - sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage);
911  env = GNUNET_MQ_msg_extra (msg,
912  xlen,
914  msg->peer_id = htonl (data->peer->unique_id);
915  msg->operation_id = GNUNET_htonll (opc->id);
916  msg->start = (uint8_t) data->start;
917  GNUNET_memcpy (&msg[1],
918  data->service_name,
919  xlen);
920  GNUNET_free (data->service_name);
921  data->service_name = NULL;
922  opc->state = OPC_STATE_STARTED;
923  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
924  GNUNET_MQ_send (opc->c->mq,
925  env);
926 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
#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.
#define GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE
Message to start/stop a service of a peer.
#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
uint64_t operation_id
Operation ID.
Definition: testbed.h:720
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
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:725
uint32_t unique_id
Globally unique ID of the peer.
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:715
struct GNUNET_TESTBED_Peer * peer
Message to start/stop services of a peer.
Definition: testbed.h:705
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
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
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_manage_service()

static void oprelease_manage_service ( void *  cls)
static

Callback which will be called when peer manage server operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 935 of file testbed_api_peers.c.

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

Referenced by GNUNET_TESTBED_peer_manage_service().

936 {
937  struct OperationContext *opc = cls;
938  struct ManageServiceData *data;
939 
940  data = opc->data;
941  switch (opc->state)
942  {
943  case OPC_STATE_STARTED:
944  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
945  break;
946 
947  case OPC_STATE_INIT:
948  GNUNET_assert (NULL != data);
949  GNUNET_free (data->service_name);
950  break;
951 
952  case OPC_STATE_FINISHED:
953  break;
954  }
955  GNUNET_free_non_null (data);
956  GNUNET_free (opc);
957 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
The operation has been started.
Definition: testbed_api.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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
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
#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:

Variable Documentation

◆ peer_list_head

struct GNUNET_TESTBED_Peer* peer_list_head
static

Peer list DLL head.

Definition at line 40 of file testbed_api_peers.c.

◆ peer_list_tail

struct GNUNET_TESTBED_Peer* peer_list_tail
static

Peer list DLL tail.

Definition at line 45 of file testbed_api_peers.c.