GNUnet 0.21.1
testing_api_cmd_stop_peer.c File Reference

cmd to stop a peer. More...

Include dependency graph for testing_api_cmd_stop_peer.c:

Go to the source code of this file.

Data Structures

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

Macros

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

Functions

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

Detailed Description

cmd to stop a peer.

Author
t3sserakt

Definition in file testing_api_cmd_stop_peer.c.

Macro Definition Documentation

◆ LOG

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

Generic logging shortcut.

Definition at line 34 of file testing_api_cmd_stop_peer.c.

Function Documentation

◆ 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 53 of file testing_api_cmd_stop_peer.c.

55{
56 struct StopPeerState *stop_ps = cls;
57 const struct GNUNET_TESTING_StartPeerState *sps;
58 const struct GNUNET_TESTING_Command *start_cmd;
59
61 stop_ps->start_label);
63 &sps);
64
65 if (NULL != sps->peer)
66 {
67 if (GNUNET_OK !=
69 {
71 "Testing lib failed to stop peer %u (`%s')\n",
72 sps->no,
73 GNUNET_i2s (&sps->id));
74 }
76 }
77 if (NULL != sps->rh_task)
79}
struct GNUNET_TESTING_Interpreter * is
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_TESTING_get_trait_state(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_StartPeerState **ret)
@ GNUNET_OK
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1485
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1566
A command to be run by the interpreter.
struct GNUNET_PeerIdentity id
Peer identity.
unsigned int no
An unique number to identify the peer.
struct GNUNET_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
Struct to hold information for callbacks.
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_stop(), GNUNET_TRANSPORT_TESTING_get_trait_state(), GNUNET_TESTING_StartPeerState::id, is, LOG, GNUNET_TESTING_StartPeerState::no, GNUNET_TESTING_StartPeerState::peer, GNUNET_TESTING_StartPeerState::rh_task, and StopPeerState::start_label.

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 87 of file testing_api_cmd_stop_peer.c.

88{
89 struct StopPeerState *sps = cls;
90
91 GNUNET_free (sps);
92}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

Referenced by GNUNET_TESTING_cmd_stop_peer().

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 100 of file testing_api_cmd_stop_peer.c.

104{
105 return GNUNET_OK;
106}

References GNUNET_OK.

Referenced by GNUNET_TESTING_cmd_stop_peer().

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 117 of file testing_api_cmd_stop_peer.c.

119{
120 struct StopPeerState *sps;
121
122 sps = GNUNET_new (struct StopPeerState);
124 return GNUNET_TESTING_command_new (sps,
125 label,
129 NULL);
130}
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(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.
#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 GNUNET_new, GNUNET_TESTING_command_new(), StopPeerState::start_label, stop_peer_cleanup(), stop_peer_run(), and stop_peer_traits().

Here is the call graph for this function: