GNUnet  0.17.6
Data Structures | Functions
testing_api_cmd_netjail_stop_testsystem.c File Reference
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_cmd_netjail_stop_testsystem.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_testing_system (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 70 of file testing_api_cmd_netjail_stop_testsystem.c.

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

References GNUNET_free.

◆ 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 85 of file testing_api_cmd_netjail_stop_testsystem.c.

87 {
88  struct StopHelperState *shs = cls;
89  const struct GNUNET_HELPER_Handle **helper;
90  const struct GNUNET_TESTING_Command *start_helper_cmd;
91 
93  shs->
94  helper_start_label);
96  &helper);
97 
98  for (int i = 1; i <= shs->known; i++)
99  {
101  "i: %u\n",
102  i);
104  (struct GNUNET_HELPER_Handle *) helper[i - 1],
105  GNUNET_YES);
106  }
107 
108  for (int i = 1; i <= shs->global_n; i++)
109  {
110  for (int j = 1; j <= shs->local_m; j++)
111  {
113  "i: %u j: %u\n",
114  i,
115  j);
116  GNUNET_HELPER_stop ((struct GNUNET_HELPER_Handle *) helper[(i - 1)
117  * shs->local_m
118  + j
119  + shs->known
120  - 1],
121  GNUNET_NO);
122  }
123  }
124 }
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_helper_handles(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_HELPER_Handle ***ret)
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
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:571
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_ERROR_TYPE_DEBUG
The handle to a helper process.
Definition: helper.c:79
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_HELPER_stop(), GNUNET_log, GNUNET_NO, GNUNET_TESTING_get_trait_helper_handles(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_YES, is, StopHelperState::known, and StopHelperState::local_m.

Here is the call graph for this function:

◆ GNUNET_TESTING_cmd_stop_testing_system()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system ( 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 85 of file testing_api_cmd_netjail_stop_testsystem.c.

140 {
141  struct StopHelperState *shs;
142 
143  shs = GNUNET_new (struct StopHelperState);
145  shs->local_m = topology->nodes_m;
146  shs->global_n = topology->namespaces_n;
147  shs->known = topology->nodes_x;
148  shs->topology = topology;
149 
150  struct GNUNET_TESTING_Command cmd = {
151  .cls = shs,
152  .label = label,
153  .run = &stop_testing_system_run,
154  .cleanup = &stop_testing_system_cleanup,
155  };
156 
157  return cmd;
158 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
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.