GNUnet 0.22.2
testing_arm_cmd_stop_peer.c File Reference
Include dependency graph for testing_arm_cmd_stop_peer.c:

Go to the source code of this file.

Data Structures

struct  StopPeerState
 Struct to hold information for callbacks. More...
 

Functions

static void stop_cb (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
 Function called in response to a start/stop request. More...
 
static void stop_peer_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 The run method of this cmd will stop all services of a peer which were used to test the transport service. More...
 
static void stop_peer_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static int stop_peer_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 Trait function of this cmd does nothing. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_peer (const char *label, const char *start_label)
 Create command. More...
 

Function Documentation

◆ stop_cb()

static void stop_cb ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

Function called in response to a start/stop request.

Will be called when request was not sent successfully, or when a reply comes. If the request was not sent successfully, rs will indicate that, and result will be undefined.

Parameters
clsclosure
rsstatus of the request
resultresult of the operation

Definition at line 68 of file testing_arm_cmd_stop_peer.c.

72{
73 struct StopPeerState *stop_ps = cls;
74
75 stop_ps->op = NULL;
77 {
78 GNUNET_TESTING_async_fail (&stop_ps->ac);
79 return;
80 }
82}
static int result
Global testing status.
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
@ GNUNET_ARM_RESULT_STOPPED
Service was stopped (never sent for ARM itself).
Struct to hold information for callbacks.
struct GNUNET_ARM_Operation * op
struct GNUNET_TESTING_AsyncContext ac

References StopPeerState::ac, GNUNET_ARM_RESULT_STOPPED, GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), StopPeerState::op, and result.

Referenced by stop_peer_run().

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

◆ stop_peer_run()

static void stop_peer_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

The run method of this cmd will stop all services of a peer which were used to test the transport service.

Definition at line 90 of file testing_arm_cmd_stop_peer.c.

92{
93 struct StopPeerState *stop_ps = cls;
94 const struct GNUNET_TESTING_Command *start_cmd;
95 struct GNUNET_ARM_Handle *ah;
96
97 stop_ps->is = is;
98 start_cmd
100 stop_ps->start_label);
101 if (NULL == start_cmd)
103 if (GNUNET_OK !=
104 GNUNET_TESTING_ARM_get_trait_arm_handle (start_cmd,
105 &ah))
108 "arm",
109 &stop_cb,
110 stop_ps);
111 if (NULL == stop_ps->op)
113}
static struct GNUNET_TESTING_Interpreter * is
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
Definition: arm_api.c:1050
@ GNUNET_OK
Handle for interacting with ARM.
Definition: arm_api.c:103
A command to be run by the interpreter.
const char * start_label
Label of the cmd to start the peer.
struct GNUNET_TESTING_Interpreter * is
static void stop_cb(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
Function called in response to a start/stop request.

References ah, GNUNET_ARM_request_service_stop(), GNUNET_OK, GNUNET_TESTING_FAIL, GNUNET_TESTING_interpreter_lookup_command(), is, StopPeerState::is, StopPeerState::op, StopPeerState::start_label, and stop_cb().

Referenced by GNUNET_TESTING_cmd_stop_peer().

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

◆ stop_peer_cleanup()

static void stop_peer_cleanup ( void *  cls)
static

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 121 of file testing_arm_cmd_stop_peer.c.

122{
123 struct StopPeerState *sps = cls;
124
125 if (NULL != sps->op)
126 {
128 sps->label);
130 sps->op = NULL;
131 }
132 GNUNET_free (sps);
133}
#define GNUNET_TESTING_command_incomplete(is, label)
Log an error message about a command not having run to completion.
void GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
Abort an operation.
Definition: arm_api.c:795
#define GNUNET_free(ptr)
Wrapper around free.
const char * label
Label of the cmd.

References GNUNET_ARM_operation_cancel(), GNUNET_free, GNUNET_TESTING_command_incomplete, StopPeerState::is, StopPeerState::label, and StopPeerState::op.

Referenced by GNUNET_TESTING_cmd_stop_peer().

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

◆ stop_peer_traits()

static int stop_peer_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

Trait function of this cmd does nothing.

Definition at line 141 of file testing_arm_cmd_stop_peer.c.

145{
146 struct GNUNET_TESTING_Trait traits[] = {
148 };
149
150 (void) cls;
152 ret,
153 trait,
154 index);
155}
static int ret
Final status code.
Definition: gnunet-arm.c:93
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), GNUNET_TESTING_Trait::index, ret, and traits().

Referenced by GNUNET_TESTING_cmd_stop_peer().

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

◆ GNUNET_TESTING_cmd_stop_peer()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_peer ( const char *  label,
const char *  start_label 
)

Create command.

Parameters
labelname for command.
start_labelLabel of the cmd to start the peer.
Returns
command.

Definition at line 159 of file testing_arm_cmd_stop_peer.c.

161{
162 struct StopPeerState *sps;
163
164 sps = GNUNET_new (struct StopPeerState);
166 sps->label = label;
168 sps,
169 label,
173 &sps->ac);
174}
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command that may be asynchronous.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int stop_peer_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static void stop_peer_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void stop_peer_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will stop all services of a peer which were used to test the transport ser...

References StopPeerState::ac, GNUNET_new, GNUNET_TESTING_command_new_ac(), StopPeerState::label, StopPeerState::start_label, stop_peer_cleanup(), stop_peer_run(), and stop_peer_traits().

Here is the call graph for this function: