GNUnet  0.20.0
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.

36 {
40  INIT,
41 
46 
51 };
@ INIT
Initial state.
@ CFG_REQUEST_QUEUED
The configuration request has been sent.
@ SERVICE_CONNECTED
connected to service

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 134 of file testbed_api_services.c.

135 {
136  struct ServiceConnectData *data = cls;
137  struct GNUNET_TESTBED_Controller *c;
138  const char *emsg;
140  uint16_t mtype;
141 
142  c = data->peer->controller;
143  mtype = ntohs (msg->type);
144  emsg = NULL;
146  info.op = data->operation;
147  info.op_cls = data->op_cls;
149  {
150  emsg =
153  *) msg);
154  if (NULL == emsg)
155  emsg = "Unknown error";
156  info.details.operation_finished.emsg = emsg;
157  info.details.operation_finished.generic = NULL;
158  goto call_cb;
159  }
161  GNUNET_assert (NULL == data->op_result);
162  data->op_result = data->ca (data->cada_cls, data->cfg);
163  info.details.operation_finished.emsg = NULL;
164  info.details.operation_finished.generic = data->op_result;
165  data->state = SERVICE_CONNECTED;
166 
167 call_cb:
169  (NULL != c->cc))
170  c->cc (c->cc_cls, &info);
171  if (NULL != data->cb)
172  data->cb (data->cb_cls, data->operation, data->op_result, emsg);
173 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t data
The data value.
#define info
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
@ GNUNET_TESTBED_ET_OPERATION_FINISHED
A requested testbed operation has been completed.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:265
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:208
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:203
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
const char * emsg
Error message for the operation, NULL on success.
Event notification from a controller to a client.
Definition: testbed.h:509
Data accessed during service connections.
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 cont...
Definition: testbed_api.c:2150
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:2043

References GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, data, 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_(), info, msg, SERVICE_CONNECTED, and GNUNET_MessageHeader::type.

Referenced by opstart_service_connect().

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 182 of file testbed_api_services.c.

183 {
184  struct ServiceConnectData *data = cls;
186  struct GNUNET_TESTBED_Controller *c;
187  uint64_t op_id;
188 
189  GNUNET_assert (NULL != data);
190  GNUNET_assert (NULL != data->peer);
191  c = data->peer->controller;
192  op_id = GNUNET_TESTBED_get_next_op_id (c);
193  msg =
194  GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id);
195  data->opc =
196  GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header,
198  GNUNET_free (msg);
199  data->state = CFG_REQUEST_QUEUED;
200 }
#define GNUNET_free(ptr)
Wrapper around free.
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:582
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:2178
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:1370
struct GNUNET_TESTBED_PeerGetConfigurationMessage * GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, uint64_t operation_id)
Generate PeerGetConfigurationMessage.
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.

References CFG_REQUEST_QUEUED, configuration_receiver(), data, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTBED_generate_peergetconfig_msg_(), GNUNET_TESTBED_get_next_op_id(), and msg.

Referenced by GNUNET_TESTBED_service_connect().

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 210 of file testbed_api_services.c.

211 {
212  struct ServiceConnectData *data = cls;
213 
214  switch (data->state)
215  {
216  case INIT:
217  break;
218 
219  case CFG_REQUEST_QUEUED:
220  GNUNET_assert (NULL != data->opc);
222  break;
223 
224  case SERVICE_CONNECTED:
225  GNUNET_assert (NULL != data->cfg);
227  if (NULL != data->da)
228  data->da (data->cada_cls, data->op_result);
229  break;
230  }
231  GNUNET_free (data);
232 }
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
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:1407

References CFG_REQUEST_QUEUED, data, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TESTBED_forward_operation_msg_cancel_(), INIT, and SERVICE_CONNECTED.

Referenced by GNUNET_TESTBED_service_connect().

Here is the call graph for this function:
Here is the caller graph for this function: