GNUnet 0.21.1
testing_api_cmd_netjail_start_cmds_helper.c File Reference

Command to start the netjail peers. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "testing_api_barrier.h"
#include "testing_api_loop.h"
#include "testing_cmds.h"
#include "testing_api_topology.h"
Include dependency graph for testing_api_cmd_netjail_start_cmds_helper.c:

Go to the source code of this file.

Data Structures

struct  NetJailState
 Struct to hold information for callbacks. More...
 
struct  TestingSystemCount
 Struct containing the number of the netjail node and the NetJailState which will be handed to callbacks specific to a test environment. More...
 

Macros

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

Functions

static void clear_msg (void *cls, enum GNUNET_GenericReturnValue result)
 Continuation function from GNUNET_HELPER_send() More...
 
static void handle_helper_barrier_reached (void *cls, const struct GNUNET_TESTING_CommandBarrierReached *rm)
 
static void handle_helper_local_finished (void *cls, const struct GNUNET_TESTING_CommandLocalFinished *lf)
 
static enum GNUNET_GenericReturnValue helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
 Functions with this signature are called whenever a complete message is received by the tokenizer. More...
 
static void exp_cb (void *cls)
 Callback called if there was an exception during execution of the helper. More...
 
static enum GNUNET_GenericReturnValue add_barrier (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static bool send_start_messages (struct NetJailState *ns, struct GNUNET_HELPER_Handle *helper)
 
static bool start_helper (struct NetJailState *ns, unsigned int script_num)
 Function which start a single helper process. More...
 
static void do_timeout (void *cls)
 Function run when the cmd terminates (good or bad) with timeout. More...
 
static void netjail_exec_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 This function starts a helper process for each node. More...
 
static void netjail_exec_cleanup (void *cls)
 Code to clean up resource this cmd used. More...
 
static enum GNUNET_GenericReturnValue netjail_exec_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 This function prepares an array with traits. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_helpers (const char *label, const char *topology_cmd_label, struct GNUNET_TIME_Relative timeout)
 Create command. More...
 

Detailed Description

Command to start the netjail peers.

Author
t3sserakt

Definition in file testing_api_cmd_netjail_start_cmds_helper.c.

Macro Definition Documentation

◆ LOG

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

Generic logging shortcut.

Definition at line 37 of file testing_api_cmd_netjail_start_cmds_helper.c.

Function Documentation

◆ clear_msg()

static void clear_msg ( void *  cls,
enum GNUNET_GenericReturnValue  result 
)
static

Continuation function from GNUNET_HELPER_send()

Parameters
clsclosure
resultGNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_stop

Definition at line 154 of file testing_api_cmd_netjail_start_cmds_helper.c.

156{
157 struct TestingSystemCount *tbc = cls;
158 struct NetJailState *ns = tbc->ns;
159
160 GNUNET_assert (NULL != tbc->shandle);
161 tbc->shandle = NULL;
163 ns->tbc_tail,
164 tbc);
165 GNUNET_free (tbc);
166 if ( (! ns->failed) &&
167 (GNUNET_OK != result) )
168 {
169 ns->failed = true;
171 }
172}
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static int result
Global testing status.
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.
Struct containing the number of the netjail node and the NetJailState which will be handed to callbac...
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
struct NetJailState * ns
Struct to store information handed over to callbacks.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, GNUNET_TESTING_FAIL, ns, TestingSystemCount::ns, result, and TestingSystemCount::shandle.

Referenced by send_start_messages().

Here is the caller graph for this function:

◆ handle_helper_barrier_reached()

static void handle_helper_barrier_reached ( void *  cls,
const struct GNUNET_TESTING_CommandBarrierReached rm 
)
static

Definition at line 176 of file testing_api_cmd_netjail_start_cmds_helper.c.

179{
180 struct NetJailState *ns = cls;
181 struct GNUNET_TESTING_Barrier *barrier;
182
183 barrier = GNUNET_TESTING_get_barrier2_ (ns->is,
184 &rm->barrier_key);
185 if (NULL == barrier)
186 {
187 if (! ns->failed)
188 {
189 ns->failed = true;
191 }
192 return;
193 }
194 if (barrier->inherited)
195 {
196 /* pass on to parent */
198 &rm->header);
199 }
200 else
201 {
202 barrier->reached++;
203 if (barrier->reached == barrier->expected_reaches)
204 {
206 .header.size
207 = htons (sizeof (cbs)),
208 .header.type
210 .barrier_key
211 = rm->barrier_key
212 };
213
214 GNUNET_assert (! barrier->satisfied);
215 barrier->satisfied = true;
216 /* unblock children */
218 &cbs.header);
219 /* unblock self */
220 for (unsigned int i = 0; i<barrier->cnt_waiting; i++)
222 GNUNET_array_grow (barrier->waiting,
223 barrier->cnt_waiting,
224 0);
225 }
226 }
227}
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
An entry for a barrier list.
bool inherited
Did we inherit the barrier from our parent loop?
unsigned int reached
Number of times the barrier has been reached.
unsigned int expected_reaches
Number of total commands expected to be reached by the barrier.
struct GNUNET_TESTING_AsyncContext ** waiting
Context of barrier reached commands of our local interpreter that are currently blocked on this barri...
unsigned int cnt_waiting
Length of the waiting array.
bool satisfied
Did we reach expected_reaches? Used in particular if inherited is true and we cannot compute locally.
struct GNUNET_ShortHashCode barrier_key
Definition: testing_cmds.h:77
struct GNUNET_MessageHeader header
Definition: testing_cmds.h:76
Parent to child: this barrier was satisfied.
Definition: testing_cmds.h:97
struct GNUNET_MessageHeader header
Definition: testing_cmds.h:98
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier2_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)
void GNUNET_TESTING_loop_notify_parent_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_MessageHeader *hdr)
Send message to our parent.
void GNUNET_TESTING_loop_notify_children_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_MessageHeader *hdr)
Send message to all netjail children (if there are any).

References GNUNET_TESTING_CommandBarrierReached::barrier_key, GNUNET_TESTING_Barrier::cnt_waiting, GNUNET_TESTING_Barrier::expected_reaches, GNUNET_array_grow, GNUNET_assert, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE, GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), GNUNET_TESTING_get_barrier2_(), GNUNET_TESTING_loop_notify_children_(), GNUNET_TESTING_loop_notify_parent_(), GNUNET_TESTING_CommandBarrierReached::header, GNUNET_TESTING_CommandBarrierSatisfied::header, GNUNET_TESTING_Barrier::inherited, ns, GNUNET_TESTING_Barrier::reached, GNUNET_TESTING_Barrier::satisfied, GNUNET_MessageHeader::size, and GNUNET_TESTING_Barrier::waiting.

Here is the call graph for this function:

◆ handle_helper_local_finished()

static void handle_helper_local_finished ( void *  cls,
const struct GNUNET_TESTING_CommandLocalFinished lf 
)
static

Definition at line 231 of file testing_api_cmd_netjail_start_cmds_helper.c.

234{
235 struct NetJailState *ns = cls;
236
237 ns->n_finished++;
238 if ( (! ns->failed) &&
239 (GNUNET_OK != ntohl (lf->rv)) )
240 {
241 ns->failed = true;
243 return;
244 }
245 if (ns->n_finished == ns->n_helpers)
246 {
247 GNUNET_SCHEDULER_cancel (ns->timeout_task);
248 ns->timeout_task = NULL;
250 }
251}
void lf(char *msg)
Definition: gnunet_gst.c:587
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981

References GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), lf(), and ns.

Here is the call graph for this function:

◆ helper_mst()

static enum GNUNET_GenericReturnValue helper_mst ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Functions with this signature are called whenever a complete message is received by the tokenizer.

Do not call GNUNET_SERVER_mst_destroy in callback

Parameters
clsclosure
messagethe actual message
Returns
GNUNET_OK on success, GNUNET_SYSERR to stop further processing

Definition at line 265 of file testing_api_cmd_netjail_start_cmds_helper.c.

267{
268 struct NetJailState *ns = cls;
271 helper_barrier_reached,
274 ns),
276 helper_local_finished,
279 ns),
281 };
283
285 message);
286 if (GNUNET_OK != ret)
287 {
288 GNUNET_break (0);
289 if (! ns->failed)
290 {
291 ns->failed = true;
293 }
294 }
295 return ret;
296}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static int ret
Final status code.
Definition: gnunet-arm.c:94
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
enum GNUNET_GenericReturnValue GNUNET_MQ_handle_message(const struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given h...
Definition: mq.c:205
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
Message handler for a specific message type.
Child to parent: I reached the given barrier, increment the counter (or pass to grandparent).
Definition: testing_cmds.h:75

References GNUNET_break, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED, GNUNET_MQ_handle_message(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_OK, GNUNET_TESTING_async_fail(), handlers, ns, and ret.

Referenced by start_helper().

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

◆ exp_cb()

static void exp_cb ( void *  cls)
static

Callback called if there was an exception during execution of the helper.

Definition at line 303 of file testing_api_cmd_netjail_start_cmds_helper.c.

304{
305 struct NetJailState *ns = cls;
306
308 "Called exp_cb.\n");
309 if (NULL != ns->timeout_task)
310 {
311 GNUNET_SCHEDULER_cancel (ns->timeout_task);
312 ns->timeout_task = NULL;
313 }
314 if (! ns->failed)
316}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_async_fail(), and ns.

Referenced by GNUNET_HELPER_start(), and start_helper().

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

◆ add_barrier()

static enum GNUNET_GenericReturnValue add_barrier ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 320 of file testing_api_cmd_netjail_start_cmds_helper.c.

323{
324 struct GNUNET_ShortHashCode **bar_posp = cls;
325 struct GNUNET_ShortHashCode *bar_pos = *bar_posp;
326
327 *bar_pos = *key;
328 *bar_posp = bar_pos + 1;
329 return GNUNET_OK;
330}
struct GNUNET_HashCode key
The key used in the DHT.
A 256-bit hashcode.

References GNUNET_OK, and key.

Referenced by send_start_messages().

Here is the caller graph for this function:

◆ send_start_messages()

static bool send_start_messages ( struct NetJailState ns,
struct GNUNET_HELPER_Handle helper 
)
static
Returns
true on success

Definition at line 337 of file testing_api_cmd_netjail_start_cmds_helper.c.

339{
341 struct TestingSystemCount *tbc;
342 struct GNUNET_ShortHashCode *bar;
343 struct GNUNET_ShortHashCode *bar_pos;
344 unsigned int num_barriers = GNUNET_TESTING_barrier_count_ (ns->is);
345 size_t topo_length;
346 size_t msg_len;
347
348 topo_length = strlen (ns->topology_data) + 1;
349 GNUNET_assert (topo_length < SIZE_MAX - sizeof (*msg));
350 GNUNET_assert (SIZE_MAX / sizeof (struct GNUNET_ShortHashCode) >
351 num_barriers);
352 GNUNET_assert (sizeof (*msg) + topo_length <
354 - num_barriers * sizeof (struct GNUNET_ShortHashCode));
355 msg_len = sizeof (*msg) + topo_length
356 + num_barriers * sizeof (struct GNUNET_ShortHashCode);
357 if (msg_len > UINT16_MAX)
358 {
359 /* ask a wizzard to enhance the protocol;
360 start with gzip topology_data? multiple
361 init messages for barriers + topo data,
362 etc.*/
363 GNUNET_break (0);
364 return false;
365 }
366 msg = GNUNET_malloc (msg_len);
367 msg->header.size = htons ((uint16_t) msg_len);
369 bar = (struct GNUNET_ShortHashCode *) &msg[1];
370 bar_pos = bar;
373 &bar_pos);
374 GNUNET_assert (bar_pos == &bar[num_barriers]);
375 memcpy (&bar[num_barriers],
376 ns->topology_data,
377 topo_length);
378 tbc = GNUNET_new (struct TestingSystemCount);
379 tbc->ns = ns;
381 helper,
382 &msg->header,
383 GNUNET_NO,
384 &clear_msg,
385 tbc);
387 if (NULL == tbc->shandle)
388 {
390 "Send handle is NULL!\n");
391 GNUNET_free (tbc);
392 return false;
393 }
395 ns->tbc_tail,
396 tbc);
397 return true;
398}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, bool can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:613
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
@ GNUNET_NO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT
The initialization message towards gnunet-cmds-helper.
#define SIZE_MAX
Definition: platform.h:208
Initialization message for gnunet-cmds-testbed to start cmd binary.
Definition: testing_cmds.h:39
static enum GNUNET_GenericReturnValue add_barrier(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static void clear_msg(void *cls, enum GNUNET_GenericReturnValue result)
Continuation function from GNUNET_HELPER_send()
unsigned int GNUNET_TESTING_barrier_count_(struct GNUNET_TESTING_Interpreter *is)
void GNUNET_TESTING_barrier_iterate_(struct GNUNET_TESTING_Interpreter *is, GNUNET_CONTAINER_ShortmapIterator cb, void *cb_cls)

References add_barrier(), clear_msg(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_HELPER_send(), GNUNET_log, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT, GNUNET_new, GNUNET_NO, GNUNET_TESTING_barrier_count_(), GNUNET_TESTING_barrier_iterate_(), msg, ns, TestingSystemCount::ns, TestingSystemCount::shandle, GNUNET_MessageHeader::size, SIZE_MAX, and GNUNET_MessageHeader::type.

Referenced by start_helper().

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

◆ start_helper()

static bool start_helper ( struct NetJailState ns,
unsigned int  script_num 
)
static

Function which start a single helper process.

Returns
true on success

Definition at line 406 of file testing_api_cmd_netjail_start_cmds_helper.c.

408{
409 char *gnunet_cmds_helper
411 char node_id[32];
412 char *const script_argv[] = {
413 "ip",
414 "netns",
415 "exec",
416 node_id,
417 gnunet_cmds_helper,
418 node_id,
419 NULL
420 };
421 struct GNUNET_HELPER_Handle *helper;
422
423 GNUNET_snprintf (node_id,
424 sizeof (node_id),
425 "if%06x-%06x\n",
426 (unsigned int) getpid (),
427 script_num);
428 helper = GNUNET_HELPER_start (
429 GNUNET_YES, /* with control pipe */
430 script_argv[0],
431 script_argv,
432 &helper_mst,
433 &exp_cb,
434 ns);
435 GNUNET_free (gnunet_cmds_helper);
436 if (NULL == helper)
437 {
438 GNUNET_break (0);
439 return false;
440 }
441 GNUNET_array_append (ns->helpers,
442 ns->n_helpers,
443 helper);
445 helper);
446 return send_start_messages (ns,
447 helper);
448}
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:460
@ GNUNET_YES
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
The handle to a helper process.
Definition: helper.c:77
static enum GNUNET_GenericReturnValue helper_mst(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
static void exp_cb(void *cls)
Callback called if there was an exception during execution of the helper.
static bool send_start_messages(struct NetJailState *ns, struct GNUNET_HELPER_Handle *helper)
void GNUNET_TESTING_add_netjail_helper_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to the interpreter.
#define HELPER_CMDS_BINARY
Definition: testing_cmds.h:30

References exp_cb(), GNUNET_array_append, GNUNET_break, GNUNET_free, GNUNET_HELPER_start(), GNUNET_OS_get_libexec_binary_path(), GNUNET_snprintf(), GNUNET_TESTING_add_netjail_helper_(), GNUNET_YES, HELPER_CMDS_BINARY, helper_mst(), ns, and send_start_messages().

Referenced by netjail_exec_run().

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

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Function run when the cmd terminates (good or bad) with timeout.

Parameters
clsthe interpreter state

Definition at line 457 of file testing_api_cmd_netjail_start_cmds_helper.c.

458{
459 struct NetJailState *ns = cls;
460
461 ns->timeout_task = NULL;
463 "Terminating cmd due to global timeout\n");
465}

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_TESTING_async_finish(), and ns.

Referenced by netjail_exec_run().

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

◆ netjail_exec_run()

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

This function starts a helper process for each node.

Parameters
clsclosure.
cmdCMD being run.
isinterpreter state.

Definition at line 476 of file testing_api_cmd_netjail_start_cmds_helper.c.

478{
479 struct NetJailState *ns = cls;
480 struct GNUNET_TESTING_NetjailTopology *topology;
481 bool failed = false;
482 const struct GNUNET_TESTING_Command *topo_cmd;
483
484 ns->is = is;
486 ns->topology_cmd_label);
487 if (NULL == topo_cmd)
489 if (GNUNET_OK !=
490 GNUNET_TESTING_get_trait_topology_string (topo_cmd,
491 &ns->topology_data))
493 topology
494 = GNUNET_TESTING_get_topo_from_string_ (ns->topology_data);
495 for (unsigned int i = 1; i <= topology->total; i++)
496 {
497 if (! start_helper (ns,
498 i))
499 {
500 failed = true;
501 break;
502 }
503 }
505 if (failed)
506 {
507 ns->failed = true;
509 }
510 ns->timeout_task
512 &do_timeout,
513 ns);
514}
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.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
A command to be run by the interpreter.
Toplogy of our netjail setup.
unsigned int total
Total number of namespaces in the topology; numbered starting from 1 (!).
static bool start_helper(struct NetJailState *ns, unsigned int script_num)
Function which start a single helper process.
static void do_timeout(void *cls)
Function run when the cmd terminates (good or bad) with timeout.
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string_(const char *input)
Parse the topology data.

References do_timeout(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTING_FAIL, GNUNET_TESTING_free_topology(), GNUNET_TESTING_get_topo_from_string_(), GNUNET_TESTING_interpreter_lookup_command(), is, ns, start_helper(), and GNUNET_TESTING_NetjailTopology::total.

Referenced by GNUNET_TESTING_cmd_netjail_start_helpers().

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

◆ netjail_exec_cleanup()

static void netjail_exec_cleanup ( void *  cls)
static

Code to clean up resource this cmd used.

Parameters
clsclosure

Definition at line 523 of file testing_api_cmd_netjail_start_cmds_helper.c.

524{
525 struct NetJailState *ns = cls;
526
527 if (NULL != ns->timeout_task)
528 {
529 GNUNET_SCHEDULER_cancel (ns->timeout_task);
530 ns->timeout_task = NULL;
531 }
532 for (unsigned int i = 0; i<ns->n_helpers; i++)
533 GNUNET_HELPER_stop (ns->helpers[i],
534 GNUNET_YES);
535 GNUNET_free (ns);
536}
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

References GNUNET_free, GNUNET_HELPER_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, and ns.

Referenced by GNUNET_TESTING_cmd_netjail_start_helpers().

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

◆ netjail_exec_traits()

static enum GNUNET_GenericReturnValue netjail_exec_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

This function prepares an array with traits.

Definition at line 543 of file testing_api_cmd_netjail_start_cmds_helper.c.

547{
548 struct NetJailState *ns = cls;
549 struct GNUNET_TESTING_Trait traits[] = {
551 };
552
553 (void) ns;
555 ret,
556 trait,
557 index);
558}
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, ns, ret, and traits().

Referenced by GNUNET_TESTING_cmd_netjail_start_helpers().

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

◆ GNUNET_TESTING_cmd_netjail_start_helpers()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_helpers ( const char *  label,
const char *  topology_cmd_label,
struct GNUNET_TIME_Relative  timeout 
)

Create command.

Parameters
labelName for the command.
topology_datatopology data
timeoutBefore this timeout is reached this cmd MUST finish.
Returns
command.

Definition at line 570 of file testing_api_cmd_netjail_start_cmds_helper.c.

574{
575 struct NetJailState *ns;
576
577 ns = GNUNET_new (struct NetJailState);
578 ns->topology_cmd_label = topology_cmd_label;
579 ns->timeout = timeout;
581 label,
585 &ns->ac);
586}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
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.
const char * topology_cmd_label
Configuration file for the test topology.
static void netjail_exec_cleanup(void *cls)
Code to clean up resource this cmd used.
static void netjail_exec_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function starts a helper process for each node.
static enum GNUNET_GenericReturnValue netjail_exec_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_new, GNUNET_TESTING_command_new_ac(), netjail_exec_cleanup(), netjail_exec_run(), netjail_exec_traits(), ns, timeout, and NetJailState::topology_cmd_label.

Referenced by main().

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