GNUnet 0.21.1
testing_api_cmd_netjail_stop_cmds_helper.c File Reference
Include dependency graph for testing_api_cmd_netjail_stop_cmds_helper.c:

Go to the source code of this file.

Data Structures

struct  StopHelperState
 Struct to store information handed over to callbacks. More...
 

Functions

static void stop_testing_system_cleanup (void *cls)
 Code to clean up resource this cmd used. More...
 
static void stop_testing_system_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 This function stops the helper process for each node. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_cmds_helper (const char *label, const char *helper_start_label, struct GNUNET_TESTING_NetjailTopology *topology)
 Create command. More...
 

Function Documentation

◆ stop_testing_system_cleanup()

static void stop_testing_system_cleanup ( void *  cls)
static

Code to clean up resource this cmd used.

Parameters
clsclosure
cmdcurrent CMD being cleaned up.

Definition at line 72 of file testing_api_cmd_netjail_stop_cmds_helper.c.

73{
74 struct StopHelperState *shs = cls;
75
76 GNUNET_free (shs);
77}
#define GNUNET_free(ptr)
Wrapper around free.
Struct to store information handed over to callbacks.

References GNUNET_free.

Referenced by GNUNET_TESTING_cmd_stop_cmds_helper().

Here is the caller graph for this function:

◆ stop_testing_system_run()

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

This function stops the helper process for each node.

Parameters
clsclosure.
isinterpreter state.

Definition at line 87 of file testing_api_cmd_netjail_stop_cmds_helper.c.

89{
90 struct StopHelperState *shs = cls;
91 const struct GNUNET_HELPER_Handle **helper;
92 const struct GNUNET_TESTING_Command *start_helper_cmd;
93
95 shs->
96 helper_start_label);
98 &helper);
99
100 for (int i = 1; i <= shs->known; i++)
101 {
103 "i: %u\n",
104 i);
106 (struct GNUNET_HELPER_Handle *) helper[i - 1],
107 GNUNET_YES);
108 }
109
110 for (int i = 1; i <= shs->global_n; i++)
111 {
112 for (int j = 1; j <= shs->local_m; j++)
113 {
115 "i: %u j: %u\n",
116 i,
117 j);
118 GNUNET_HELPER_stop ((struct GNUNET_HELPER_Handle *) helper[(i - 1)
119 * shs->local_m
120 + j
121 + shs->known
122 - 1],
123 GNUNET_YES);
124 }
125 }
126 GNUNET_free (helper);
127}
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_TESTING_get_trait_helper_handles(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_HELPER_Handle ***ret)
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
Definition: helper.c:536
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_DEBUG
The handle to a helper process.
Definition: helper.c:77
A command to be run by the interpreter.
unsigned int known
Number of global known nodes.

References StopHelperState::global_n, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELPER_stop(), GNUNET_log, GNUNET_TESTING_get_trait_helper_handles(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_YES, is, StopHelperState::known, and StopHelperState::local_m.

Referenced by GNUNET_TESTING_cmd_stop_cmds_helper().

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

◆ GNUNET_TESTING_cmd_stop_cmds_helper()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_cmds_helper ( const char *  label,
const char *  helper_start_label,
struct GNUNET_TESTING_NetjailTopology topology 
)

Create command.

Parameters
labelname for command.
helper_start_labellabel of the cmd to start the test system.
topologyThe complete topology information.
Returns
command.

Definition at line 139 of file testing_api_cmd_netjail_stop_cmds_helper.c.

143{
144 struct StopHelperState *shs;
145
146 shs = GNUNET_new (struct StopHelperState);
148 shs->local_m = topology->nodes_m;
150 shs->known = topology->nodes_x;
151 shs->topology = topology;
152
153 return GNUNET_TESTING_command_new (shs, label,
156 NULL, NULL);
157}
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.
unsigned int nodes_m
Number of nodes per subnet.
unsigned int nodes_x
Number of global known nodes.
unsigned int namespaces_n
Number of subnets.
struct GNUNET_TESTING_NetjailTopology * topology
The complete topology information.
static void stop_testing_system_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function stops the helper process for each node.
static void stop_testing_system_cleanup(void *cls)
Code to clean up resource this cmd used.

References StopHelperState::global_n, GNUNET_new, GNUNET_TESTING_command_new(), StopHelperState::helper_start_label, StopHelperState::known, StopHelperState::local_m, GNUNET_TESTING_NetjailTopology::namespaces_n, GNUNET_TESTING_NetjailTopology::nodes_m, GNUNET_TESTING_NetjailTopology::nodes_x, stop_testing_system_cleanup(), stop_testing_system_run(), and StopHelperState::topology.

Here is the call graph for this function: