GNUnet  0.10.x
Data Structures | Enumerations | Functions
testbed_api_services.c File Reference

convenience functions for accessing services More...

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

Go to the source code of this file.

Data Structures

struct  ServiceConnectData
 Data accessed during service connections. More...
 

Enumerations

enum  State {
  STATE_INIT = 0, STATE_SLAVES_STARTING, STATE_PEERS_CREATING, STATE_PEERS_STARTING,
  STATE_PEERS_LINKING, STATE_SEARCH_REGEX, STATE_PEERS_DESTROYING, INIT,
  CFG_REQUEST_QUEUED, SERVICE_CONNECTED, RC_INIT = 0, RC_LINKED,
  RC_PEERS_CREATED, RC_READY, RC_PEERS_SHUTDOWN
}
 States for Service connect operations. More...
 

Functions

static void configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
 Type of a function to call when we receive a message from the service. More...
 
static void opstart_service_connect (void *cls)
 Function called when a service connect operation is ready. More...
 
static void oprelease_service_connect (void *cls)
 Callback which will be called when service connect type operation is released. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
 Connect to a service offered by the given peer. More...
 

Detailed Description

convenience functions for accessing services

Author
Christian Grothoff

Definition in file testbed_api_services.c.

Enumeration Type Documentation

◆ State

enum State

States for Service connect operations.

Enumerator
STATE_INIT 

Initial state.

STATE_SLAVES_STARTING 

Starting slaves.

STATE_PEERS_CREATING 

Creating peers.

STATE_PEERS_STARTING 

Starting peers.

STATE_PEERS_LINKING 

Linking peers.

STATE_SEARCH_REGEX 

Matching strings against announced regexes.

STATE_PEERS_DESTROYING 

Destroying peers; we can do this as the controller takes care of stopping a peer if it is running.

INIT 

Initial state.

CFG_REQUEST_QUEUED 

The configuration request has been sent.

SERVICE_CONNECTED 

connected to service

RC_INIT 

Initial state.

RC_LINKED 

Controllers on given hosts started and linked.

RC_PEERS_CREATED 

Peers are created.

RC_READY 

The testbed run is ready and the master callback can be called now.

At this time the peers are all started and if a topology is provided in the configuration the topology would have been attempted

RC_PEERS_SHUTDOWN 

All peers shutdown (stopped and destroyed)

Definition at line 35 of file testbed_api_services.c.

35  {
39  INIT,
40 
45 
50 };
connected to service
Initial state.
The configuration request has been sent.

Function Documentation

◆ configuration_receiver()

static void configuration_receiver ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Type of a function to call when we receive a message from the service.

Parameters
clsServiceConnectData
msgmessage received, NULL on timeout or fatal error

Definition at line 132 of file testbed_api_services.c.

References ServiceConnectData::ca, ServiceConnectData::cada_cls, ServiceConnectData::cb, ServiceConnectData::cb_cls, GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, ServiceConnectData::cfg, GNUNET_TESTBED_Peer::controller, data, GNUNET_TESTBED_EventInformation::details, GNUNET_TESTBED_EventInformation::emsg, GNUNET_TESTBED_Controller::event_mask, GNUNET_assert, GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_parse_error_string_(), GNUNET_TESTBED_EventInformation::op, ServiceConnectData::op_cls, GNUNET_TESTBED_EventInformation::op_cls, ServiceConnectData::op_result, ServiceConnectData::operation, GNUNET_TESTBED_EventInformation::operation_finished, ServiceConnectData::peer, SERVICE_CONNECTED, ServiceConnectData::state, GNUNET_MessageHeader::type, and GNUNET_TESTBED_EventInformation::type.

Referenced by opstart_service_connect().

133 {
134  struct ServiceConnectData *data = cls;
135  struct GNUNET_TESTBED_Controller *c;
136  const char *emsg;
138  uint16_t mtype;
139 
140  c = data->peer->controller;
141  mtype = ntohs(msg->type);
142  emsg = NULL;
144  info.op = data->operation;
145  info.op_cls = data->op_cls;
147  {
148  emsg =
151  *)msg);
152  if (NULL == emsg)
153  emsg = "Unknown error";
154  info.details.operation_finished.emsg = emsg;
155  info.details.operation_finished.generic = NULL;
156  goto call_cb;
157  }
158  data->cfg = GNUNET_TESTBED_extract_config_(msg);
159  GNUNET_assert(NULL == data->op_result);
160  data->op_result = data->ca(data->cada_cls, data->cfg);
161  info.details.operation_finished.emsg = NULL;
162  info.details.operation_finished.generic = data->op_result;
163  data->state = SERVICE_CONNECTED;
164 
165 call_cb:
167  (NULL != c->cc))
168  c->cc(c->cc_cls, &info);
169  if (NULL != data->cb)
170  data->cb(data->cb_cls, data->operation, data->op_result, emsg);
171 }
struct GNUNET_TESTBED_Operation * operation
The operation which created this structure.
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.
struct GNUNET_CONFIGURATION_Handle * cfg
The acquired configuration of the peer.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
GNUNET_TESTBED_ConnectAdapter ca
helper function callback to establish the connection
const char * emsg
Error message for the operation, NULL on success.
Event notification from a controller to a client.
Definition: testbed.h:493
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2059
void * op_cls
Closure for operation event.
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:262
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
void * cb_cls
The closure for operation completion callback.
connected to service
enum State state
State information.
A requested testbed operation has been completed.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
struct GNUNET_TESTBED_Peer * peer
The peer handle.
GNUNET_TESTBED_ServiceConnectCompletionCallback cb
The operation completion callback.
void * cada_cls
Closure to the above callbacks.
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:205
void * op_result
The op_result pointer from ConnectAdapter.
Data accessed during service connections.
uint32_t data
The data value.
const char * GNUNET_TESTBED_parse_error_string_(const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
Checks the integrity of the OperationFailureEventMessage and if good returns the error message it con...
Definition: testbed_api.c:2173
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:200
Here is the call graph for this function:
Here is the caller graph for this function:

◆ opstart_service_connect()

static void opstart_service_connect ( void *  cls)
static

Function called when a service connect operation is ready.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 180 of file testbed_api_services.c.

References CFG_REQUEST_QUEUED, configuration_receiver(), GNUNET_TESTBED_Peer::controller, data, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTBED_generate_peergetconfig_msg_(), GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_PeerGetConfigurationMessage::header, msg, ServiceConnectData::opc, ServiceConnectData::peer, ServiceConnectData::state, and GNUNET_TESTBED_Peer::unique_id.

Referenced by GNUNET_TESTBED_service_connect().

181 {
182  struct ServiceConnectData *data = cls;
184  struct GNUNET_TESTBED_Controller *c;
185  uint64_t op_id;
186 
187  GNUNET_assert(NULL != data);
188  GNUNET_assert(NULL != data->peer);
189  c = data->peer->controller;
191  msg =
193  data->opc =
195  &configuration_receiver, data);
196  GNUNET_free(msg);
197  data->state = CFG_REQUEST_QUEUED;
198 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:563
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
struct GNUNET_TESTBED_PeerGetConfigurationMessage * GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, uint64_t operation_id)
Generate PeerGetConfigurationMessage.
enum State state
State information.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:567
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
struct OperationContext * opc
The operation context from GNUNET_TESTBED_forward_operation_msg_()
struct GNUNET_TESTBED_Peer * peer
The peer handle.
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.
Definition: testbed_api.c:1362
uint32_t unique_id
Globally unique ID of the peer.
Data accessed during service connections.
uint32_t data
The data value.
static void configuration_receiver(void *cls, const struct GNUNET_MessageHeader *msg)
Type of a function to call when we receive a message from the service.
#define GNUNET_free(ptr)
Wrapper around free.
The configuration request has been sent.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oprelease_service_connect()

static void oprelease_service_connect ( void *  cls)
static

Callback which will be called when service connect type operation is released.

Parameters
clsthe closure from GNUNET_TESTBED_operation_create_()

Definition at line 208 of file testbed_api_services.c.

References ServiceConnectData::cada_cls, ServiceConnectData::cfg, CFG_REQUEST_QUEUED, ServiceConnectData::da, data, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TESTBED_forward_operation_msg_cancel_(), INIT, ServiceConnectData::op_result, ServiceConnectData::opc, SERVICE_CONNECTED, and ServiceConnectData::state.

Referenced by GNUNET_TESTBED_service_connect().

209 {
210  struct ServiceConnectData *data = cls;
211 
212  switch (data->state)
213  {
214  case INIT:
215  break;
216 
217  case CFG_REQUEST_QUEUED:
218  GNUNET_assert(NULL != data->opc);
220  break;
221 
222  case SERVICE_CONNECTED:
223  GNUNET_assert(NULL != data->cfg);
225  if (NULL != data->da)
226  data->da(data->cada_cls, data->op_result);
227  break;
228  }
229  GNUNET_free(data);
230 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONFIGURATION_Handle * cfg
The acquired configuration of the peer.
connected to service
enum State state
State information.
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1399
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
GNUNET_TESTBED_DisconnectAdapter da
helper function callback to close the connection
struct OperationContext * opc
The operation context from GNUNET_TESTBED_forward_operation_msg_()
void * cada_cls
Closure to the above callbacks.
void * op_result
The op_result pointer from ConnectAdapter.
Data accessed during service connections.
Initial state.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
The configuration request has been sent.
Here is the call graph for this function:
Here is the caller graph for this function: