GNUnet 0.22.2
transport_api_cmd_stop_peer.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_core_service.h"
#include "gnunet_transport_application_service.h"
#include "transport-testing-cmds.h"
Include dependency graph for transport_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_TRANSPORT_cmd_stop_peer (const char *label, const char *start_label)
 Create command. More...
 

Macro Definition Documentation

◆ LOG

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

Generic logging shortcut.

Definition at line 38 of file transport_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 57 of file transport_api_cmd_stop_peer.c.

59{
60 struct StopPeerState *stop_ps = cls;
61 const struct GNUNET_TESTING_StartPeerState *sps;
62 const struct GNUNET_TESTING_Command *start_cmd;
63
65 stop_ps->start_label);
67 &sps);
68
69 if (NULL != sps->pic)
70 {
72 }
73 if (NULL != sps->th)
74 {
76 "Disconnecting from TRANSPORT service\n");
78 }
79 if (NULL != sps->ah)
80 {
82 }
83 if (NULL != sps->ph)
84 {
86 "Disconnecting from PEERSTORE service\n");
88 }
89 if (NULL != sps->peer)
90 {
91 if (GNUNET_OK !=
92 GNUNET_TESTING_peer_stop (sps->peer))
93 {
95 "Testing lib failed to stop peer %u (`%s')\n",
96 sps->no,
97 GNUNET_i2s (&sps->id));
98 }
99 GNUNET_TESTING_peer_destroy (sps->peer);
100 }
101 if (NULL != sps->rh_task)
103}
static 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)
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
#define GNUNET_log(kind,...)
@ 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
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iteration.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
A command to be run by the interpreter.
Handle for a peer controlled via ARM.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
unsigned int no
An unique number to identify the peer.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
Struct to hold information for callbacks.
const char * start_label
Label of the cmd to start the peer.
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_TESTING_StartPeerState::ah, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_iteration_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_TESTING_get_trait_state(), GNUNET_TESTING_StartPeerState::id, is, LOG, GNUNET_TESTING_StartPeerState::no, GNUNET_TESTING_StartPeerState::peer, GNUNET_TESTING_StartPeerState::ph, GNUNET_TESTING_StartPeerState::pic, GNUNET_TESTING_StartPeerState::rh_task, StopPeerState::start_label, and GNUNET_TESTING_StartPeerState::th.

Referenced by GNUNET_TRANSPORT_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 111 of file transport_api_cmd_stop_peer.c.

112{
113 struct StopPeerState *sps = cls;
114
115 GNUNET_free (sps);
116}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

Referenced by GNUNET_TRANSPORT_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 124 of file transport_api_cmd_stop_peer.c.

128{
129 return GNUNET_OK;
130}

References GNUNET_OK.

Referenced by GNUNET_TRANSPORT_cmd_stop_peer().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_cmd_stop_peer()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_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 141 of file transport_api_cmd_stop_peer.c.

143{
144 struct StopPeerState *sps;
145
146 sps = GNUNET_new (struct StopPeerState);
148 return GNUNET_TESTING_command_new (sps,
149 label,
153}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const char * label
Label of the cmd.
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::label, StopPeerState::start_label, stop_peer_cleanup(), stop_peer_run(), and stop_peer_traits().

Here is the call graph for this function: