GNUnet  0.11.x
Macros | Functions
testbed_api_cmd_controller.c File Reference

Command to create a controller. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet-service-testbed.h"
#include "testbed_api_hosts.h"
#include "gnunet_testbed_ng_service.h"
Include dependency graph for testbed_api_cmd_controller.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 

Functions

static void controller_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 
static void controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Signature of the event handler function called by the respective event controller. More...
 
static void controller_run (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
 
static int controller_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 
int GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTBED_Controller **controller)
 Offer data from trait. More...
 
void GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs)
 Shutdown nicely. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTBED_cmd_controller (const char *label, const char *host, uint64_t event_mask)
 

Detailed Description

Command to create a controller.

Author
t3sserakt

Definition in file testbed_api_cmd_controller.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 37 of file testbed_api_cmd_controller.c.

Referenced by controller_cb(), and GNUNET_TESTBED_shutdown_controller().

Function Documentation

◆ controller_cleanup()

static void controller_cleanup ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static
Parameters
clsclosure
cmdcurrent CMD being cleaned up.

Definition at line 48 of file testbed_api_cmd_controller.c.

Referenced by GNUNET_TESTBED_cmd_controller().

50 {
51  (void) cls;
52 }
Here is the caller graph for this function:

◆ controller_cb()

static void controller_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation event 
)
static

Signature of the event handler function called by the respective event controller.

Parameters
clsclosure
eventinformation about the event

Definition at line 63 of file testbed_api_cmd_controller.c.

References GNUNET_TESTBED_EventInformation::details, GNUNET_ERROR_TYPE_ERROR, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_shutdown_controller(), LOG, GNUNET_TESTBED_EventInformation::op, and GNUNET_TESTBED_EventInformation::operation_finished.

Referenced by controller_run().

65 {
66  struct ControllerState *cs = cls;
67 
68  if (NULL != event->details.operation_finished.emsg)
69  {
70  LOG (GNUNET_ERROR_TYPE_ERROR, "There was an operation error: %s\n",
71  event->details.operation_finished.emsg);
73  }
74  else if (NULL == event->details.operation_finished.generic)
75  {
77  }
78 }
union GNUNET_TESTBED_EventInformation::@43 details
Details about the event.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2045
struct GNUNET_TESTBED_EventInformation::@43::@48 operation_finished
Details about an operation finished event.
#define LOG(kind,...)
Generic logging shortcut.
void GNUNET_TESTBED_shutdown_controller(struct ControllerState *cs)
Shutdown nicely.
struct GNUNET_TESTBED_Operation * op
Handle for the corresponding operation that generated this event.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ controller_run()

static void controller_run ( void *  cls,
const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Interpreter is 
)
static

Definition at line 82 of file testbed_api_cmd_controller.c.

References ControllerState::controller, controller_cb(), ControllerState::event_mask, GNUNET_TESTBED_controller_connect(), ControllerState::host, is, and ControllerState::is.

Referenced by GNUNET_TESTBED_cmd_controller().

85 {
86  struct ControllerState *cs = cls;
87 
88  cs->is = is;
89 
90  cs->controller =
92  cs);
93 
94 
95 }
static void controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
struct GNUNET_TESTING_Interpreter * is
Interpreter state.
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_TESTBED_Host * host
The host to run peers and controllers on.
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
Definition: testbed_api.c:1555
uint64_t event_mask
A bit mask with set of events to call the controller for.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ controller_traits()

static int controller_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static
Parameters
clsclosure.
[out]retresult
traitname of the trait.
indexindex number of the object to offer.
Returns
GNUNET_OK on success.

Definition at line 107 of file testbed_api_cmd_controller.c.

References ControllerState::controller, GNUNET_OK, GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), and GNUNET_TESTING_Trait::index.

Referenced by GNUNET_TESTBED_cmd_controller().

111 {
112  (void) cls;
113 
114  struct ControllerState *cs = cls;
115 
116 
117  struct GNUNET_TESTING_Trait traits[] = {
118  {
119  .index = 0,
120  .trait_name = "controller",
121  .ptr = (const void *) cs->controller,
122  },
124  };
125 
126  return GNUNET_TESTING_get_trait (traits,
127  ret,
128  trait,
129  index);
130  return GNUNET_OK;
131 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
unsigned int index
Index number associated with the trait.
int GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Extract a trait.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" trait.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
Here is the call graph for this function:
Here is the caller graph for this function: