GNUnet 0.21.2
gnunet-cmds-helper.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "testing_api_loop.h"
#include "testing_cmds.h"
#include "testing_api_topology.h"
Include dependency graph for gnunet-cmds-helper.c:

Go to the source code of this file.

Data Structures

struct  WriteContext
 Context for a single write on a chunk of memory. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 
#define LOG_DEBUG(...)   LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 Debug logging shorthand. More...
 

Functions

static void do_shutdown (void *cls)
 Task to shut down cleanly. More...
 
static void write_task (void *cls)
 Task to write to the standard out. More...
 
static void write_message (const struct GNUNET_MessageHeader *message)
 Callback to write a message to the parent process. More...
 
static void finished_cb (void *cls, enum GNUNET_GenericReturnValue rv)
 
static enum GNUNET_GenericReturnValue check_helper_init (void *cls, const struct GNUNET_TESTING_CommandHelperInit *msg)
 
static void handle_helper_init (void *cls, const struct GNUNET_TESTING_CommandHelperInit *msg)
 
static void handle_helper_barrier_crossable (void *cls, const struct GNUNET_TESTING_CommandBarrierSatisfied *cbs)
 
static enum GNUNET_GenericReturnValue tokenizer_cb (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 read_task (void *cls)
 Task to read from stdin. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run. More...
 
int main (int argc, char **argv)
 Main function. More...
 

Variables

static struct WriteContextwc_head
 
static struct WriteContextwc_tail
 
static struct GNUNET_TESTING_Interpreteris
 
static const char * my_node_id
 
static struct GNUNET_TESTING_PluginFunctionsplugin
 Plugin to dynamically load a test case. More...
 
static char * plugin_name
 Name of our plugin. More...
 
struct GNUNET_TESTING_NetjailTopologynjt
 The loaded topology. More...
 
static struct GNUNET_MessageStreamTokenizertokenizer
 Our message stream tokenizer. More...
 
static struct GNUNET_DISK_FileHandlestdin_fd
 Disk handle from stdin. More...
 
static struct GNUNET_DISK_FileHandlestdout_fd
 Disk handle for stdout. More...
 
static struct GNUNET_SCHEDULER_Taskread_task_id
 Task identifier for the read task. More...
 
static struct GNUNET_SCHEDULER_Taskwrite_task_id
 Task identifier for the write task. More...
 
static int global_ret
 Result to return in case we fail. More...
 
static bool finished
 Set to true once we are finished and should exit after sending our final message to the parent. More...
 

Macro Definition Documentation

◆ LOG

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

Generic logging shortcut.

Definition at line 47 of file gnunet-cmds-helper.c.

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

Debug logging shorthand.

Definition at line 52 of file gnunet-cmds-helper.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task to shut down cleanly.

Parameters
clsNULL

Definition at line 147 of file gnunet-cmds-helper.c.

148{
149 struct WriteContext *wc;
150
151 if (NULL != read_task_id)
152 {
154 read_task_id = NULL;
155 }
156 if (NULL != write_task_id)
157 {
159 write_task_id = NULL;
160 }
161 while (NULL != (wc = wc_head))
162 {
164 wc_tail,
165 wc);
166 GNUNET_free (wc->data);
167 GNUNET_free (wc);
168 }
169 if (NULL != tokenizer)
170 {
172 tokenizer = NULL;
173 }
174 if (NULL != plugin)
175 {
177 plugin);
178 }
179 if (NULL != njt)
180 {
182 njt = NULL;
183 }
184}
static struct GNUNET_MessageStreamTokenizer * tokenizer
Our message stream tokenizer.
static char * plugin_name
Name of our plugin.
struct GNUNET_TESTING_NetjailTopology * njt
The loaded topology.
static struct WriteContext * wc_tail
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
static struct GNUNET_SCHEDULER_Task * read_task_id
Task identifier for the read task.
static struct GNUNET_SCHEDULER_Task * write_task_id
Task identifier for the write task.
static struct WriteContext * wc_head
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:242
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
Definition: mst.c:404
Context for a single write on a chunk of memory.
void * data
The data to write.
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.

References WriteContext::data, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MST_destroy(), GNUNET_PLUGIN_unload(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_free_topology(), njt, plugin, plugin_name, read_task_id, tokenizer, wc_head, wc_tail, and write_task_id.

Referenced by run().

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

◆ write_task()

static void write_task ( void *  cls)
static

Task to write to the standard out.

Parameters
clsthe WriteContext

Definition at line 193 of file gnunet-cmds-helper.c.

194{
195 struct WriteContext *wc = wc_head;
196 ssize_t bytes_wrote;
197
198 write_task_id = NULL;
199 if (NULL == wc)
200 {
201 if (finished)
203 return;
204 }
205 bytes_wrote
207 wc->data + wc->pos,
208 wc->length - wc->pos);
209 if (GNUNET_SYSERR == bytes_wrote)
210 {
212 "write");
213 GNUNET_free (wc->data);
214 GNUNET_free (wc);
215 global_ret = EXIT_FAILURE;
217 return;
218 }
219 wc->pos += bytes_wrote;
220 if (wc->pos == wc->length)
221 {
223 wc_tail,
224 wc);
225 GNUNET_free (wc->data);
226 GNUNET_free (wc);
227 }
230 stdout_fd,
231 &write_task,
232 NULL);
233}
static int global_ret
Result to return in case we fail.
static struct GNUNET_DISK_FileHandle * stdout_fd
Disk handle for stdout.
static bool finished
Set to true once we are finished and should exit after sending our final message to the parent.
static void write_task(void *cls)
Task to write to the standard out.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
@ GNUNET_SYSERR
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_write_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1695
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
size_t pos
The current position from where the write operation should begin.
size_t length
The length of the data.

References WriteContext::data, finished, global_ret, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror, GNUNET_SCHEDULER_add_write_file(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, WriteContext::length, WriteContext::pos, stdout_fd, wc_head, wc_tail, write_task(), and write_task_id.

Referenced by write_message(), and write_task().

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

◆ write_message()

static void write_message ( const struct GNUNET_MessageHeader message)
static

Callback to write a message to the parent process.

Definition at line 241 of file gnunet-cmds-helper.c.

242{
243 struct WriteContext *wc;
244 size_t msg_length = ntohs (message->size);
245
246 wc = GNUNET_new (struct WriteContext);
247 wc->length = msg_length;
248 wc->data = GNUNET_memdup (message,
249 msg_length);
251 wc_tail,
252 wc);
253 if (NULL == write_task_id)
254 {
255 GNUNET_assert (wc_head == wc);
259 stdout_fd,
260 &write_task,
261 NULL);
262 }
263}
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.

References WriteContext::data, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_memdup, GNUNET_new, GNUNET_SCHEDULER_add_write_file(), GNUNET_TIME_UNIT_FOREVER_REL, WriteContext::length, GNUNET_MessageHeader::size, stdout_fd, wc_head, wc_tail, write_task(), and write_task_id.

Referenced by finished_cb(), and handle_helper_init().

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

◆ finished_cb()

static void finished_cb ( void *  cls,
enum GNUNET_GenericReturnValue  rv 
)
static

Definition at line 267 of file gnunet-cmds-helper.c.

269{
272 .header.size = htons (sizeof (reply)),
273 .rv = htonl ((uint32_t) rv)
274 };
275
276 (void) cls;
277 finished = true;
278 write_message (&reply.header);
279}
static void write_message(const struct GNUNET_MessageHeader *message)
Callback to write a message to the parent process.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
Definition: testing_cmds.h:64
uint32_t rv
The exit status local test return with in NBO.
Definition: testing_cmds.h:69

References finished, GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED, GNUNET_TESTING_CommandLocalFinished::header, GNUNET_TESTING_CommandLocalFinished::rv, GNUNET_MessageHeader::type, and write_message().

Referenced by GDS_u_send(), GNUNET_NAMESTORE_record_set_edit_cancel(), gnunet_send(), handle_helper_init(), and ip_send().

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

◆ check_helper_init()

static enum GNUNET_GenericReturnValue check_helper_init ( void *  cls,
const struct GNUNET_TESTING_CommandHelperInit msg 
)
static

Definition at line 283 of file gnunet-cmds-helper.c.

286{
287 uint16_t msize = ntohs (msg->header.size);
288 uint32_t barrier_count = ntohl (msg->barrier_count);
289 size_t bs = barrier_count * sizeof (struct GNUNET_ShortHashCode);
290 size_t left = msize - bs - sizeof (*msg);
291 const struct GNUNET_ShortHashCode *bd
292 = (const struct GNUNET_ShortHashCode *) &msg[1];
293 const char *topo = (const char *) &bd[barrier_count];
294
295 if (msize < bs + sizeof (*msg))
296 {
297 GNUNET_break_op (0);
298 return GNUNET_SYSERR;
299 }
300 if ('\0' != topo[left - 1])
301 {
302 GNUNET_break_op (0);
303 return GNUNET_SYSERR;
304 }
305 return GNUNET_OK;
306}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
@ GNUNET_OK
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
A 256-bit hashcode.

References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_helper_init()

static void handle_helper_init ( void *  cls,
const struct GNUNET_TESTING_CommandHelperInit msg 
)
static

Definition at line 310 of file gnunet-cmds-helper.c.

313{
314 uint16_t msize = ntohs (msg->header.size);
315 //uint32_t barrier_count = GNUNET_ntohll (msg->barrier_count);
316 uint32_t barrier_count = ntohl (msg->barrier_count);
317 size_t bs = barrier_count * sizeof (struct GNUNET_ShortHashCode);
318 size_t left = msize - bs - sizeof (*msg);
319 const struct GNUNET_ShortHashCode *bd
320 = (const struct GNUNET_ShortHashCode *) &msg[1];
321 const char *topo = (const char *) &bd[barrier_count];
322
323
324 GNUNET_assert ('\0' == topo[left - 1]);
326 if (NULL == njt)
327 {
328 GNUNET_break_op (0);
329 global_ret = EXIT_FAILURE;
331 return;
332 }
334 my_node_id);
336 (void *) my_node_id);
338 "Starting plugin `%s' for node %s\n",
340 my_node_id);
341 if (NULL == plugin)
342 {
344 "Plugin `%s' not found!\n",
346 global_ret = EXIT_FAILURE;
348 return;
349 }
351 unsigned int i;
352
353 for (i = 0; NULL != commands[i].run; i++)
355 "helper %s\n",
356 commands[i].label.value);
358 topo,
359 barrier_count,
360 bd,
363 NULL);
364}
static struct GNUNET_TESTING_Interpreter * is
static const char * my_node_id
static void finished_cb(void *cls, enum GNUNET_GenericReturnValue rv)
static struct VoipCommand commands[]
List of supported commands.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:198
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
void * cls
Closure to pass to start_testcase.
struct GNUNET_TESTING_Interpreter *(* start_testcase)(void *cls, const char *topology_data, uint32_t barrier_count, const struct GNUNET_ShortHashCode *barriers, GNUNET_TESTING_cmd_helper_write_cb write_message, GNUNET_TESTING_ResultCallback finish_cb, void *finish_cb_cls)
Function to be implemented for each test case plugin which starts the test case on a netjail node.
char * GNUNET_TESTING_get_plugin_from_topo(struct GNUNET_TESTING_NetjailTopology *njt, const char *my_node_id)
Get the global plugin name form the topology file.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string_(const char *input)
Parse the topology data.

References GNUNET_TESTING_PluginFunctions::cls, commands, finished_cb(), global_ret, GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_PLUGIN_load(), GNUNET_SCHEDULER_shutdown(), GNUNET_TESTING_get_plugin_from_topo(), GNUNET_TESTING_get_topo_from_string_(), is, GNUNET_TESTING_Command::label, msg, my_node_id, njt, plugin, plugin_name, GNUNET_MessageHeader::size, GNUNET_TESTING_PluginFunctions::start_testcase, GNUNET_TESTING_CommandLabel::value, and write_message().

Here is the call graph for this function:

◆ handle_helper_barrier_crossable()

static void handle_helper_barrier_crossable ( void *  cls,
const struct GNUNET_TESTING_CommandBarrierSatisfied cbs 
)
static

Definition at line 368 of file gnunet-cmds-helper.c.

371{
372 struct GNUNET_TESTING_Barrier *barrier;
373
374 if (NULL == is)
375 {
376 /* Barrier satisfied *before* helper_init?! */
377 GNUNET_break_op (0);
378 global_ret = EXIT_FAILURE;
380 return;
381 }
383 &cbs->barrier_key);
384 if (barrier->satisfied)
385 {
386 /* Barrier satisfied *twice* is strange... */
387 GNUNET_break_op (0);
388 global_ret = EXIT_FAILURE;
390 return;
391 }
392 barrier->satisfied = true;
394 &cbs->header);
395 for (unsigned int i = 0; i<barrier->cnt_waiting; i++)
397 GNUNET_array_grow (barrier->waiting,
398 barrier->cnt_waiting,
399 0);
400}
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
An entry for a barrier list.
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_MessageHeader header
Definition: testing_cmds.h:101
struct GNUNET_ShortHashCode barrier_key
Definition: testing_cmds.h:102
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier2_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)
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_CommandBarrierSatisfied::barrier_key, GNUNET_TESTING_Barrier::cnt_waiting, global_ret, GNUNET_array_grow, GNUNET_break_op, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTING_async_finish(), GNUNET_TESTING_get_barrier2_(), GNUNET_TESTING_loop_notify_children_(), GNUNET_TESTING_CommandBarrierSatisfied::header, is, GNUNET_TESTING_Barrier::satisfied, and GNUNET_TESTING_Barrier::waiting.

Here is the call graph for this function:

◆ tokenizer_cb()

static enum GNUNET_GenericReturnValue tokenizer_cb ( 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_mst_destroy() in this callback

Parameters
clsidentification of the client
messagethe actual message
Returns
GNUNET_OK on success, GNUNET_NO to stop further processing (no error) GNUNET_SYSERR to stop further processing with error

Definition at line 416 of file gnunet-cmds-helper.c.

418{
421 helper_init,
424 NULL),
426 helper_barrier_crossable,
429 NULL),
431 };
432
434 message);
435}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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_BARRIER_CROSSABLE
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT
The initialization message towards gnunet-cmds-helper.
Message handler for a specific message type.
Parent to child: this barrier was satisfied.
Definition: testing_cmds.h:100
Initialization message for gnunet-cmds-testbed to start cmd binary.
Definition: testing_cmds.h:42

References GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE, GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT, GNUNET_MQ_handle_message(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, and handlers.

Referenced by run().

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

◆ read_task()

static void read_task ( void *  cls)
static

Task to read from stdin.

Parameters
clsNULL

Definition at line 444 of file gnunet-cmds-helper.c.

445{
446 char buf[GNUNET_MAX_MESSAGE_SIZE];
447 ssize_t sread;
448
449 read_task_id = NULL;
451 buf,
452 sizeof(buf));
453 if (GNUNET_SYSERR == sread)
454 {
455 GNUNET_break (0);
456 global_ret = EXIT_FAILURE;
458 return;
459 }
460 if (0 == sread)
461 {
462 LOG_DEBUG ("STDIN eof\n");
464 return;
465 }
466 if (GNUNET_OK !=
468 buf,
469 sread,
470 GNUNET_NO,
471 GNUNET_NO))
472 {
473 GNUNET_break (0);
474 global_ret = EXIT_FAILURE;
476 return;
477 }
480 stdin_fd,
481 &read_task,
482 NULL);
483}
static void read_task(void *cls)
Task to read from stdin.
#define LOG_DEBUG(...)
Debug logging shorthand.
static struct GNUNET_DISK_FileHandle * stdin_fd
Disk handle from stdin.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:622
@ GNUNET_NO
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1662
enum GNUNET_GenericReturnValue GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
Definition: mst.c:101

References global_ret, GNUNET_break, GNUNET_DISK_file_read(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_MST_from_buffer(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, LOG_DEBUG, read_task(), read_task_id, stdin_fd, and tokenizer.

Referenced by read_task(), and run().

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

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 495 of file gnunet-cmds-helper.c.

499{
500 if (NULL == args[0])
501 {
502 /* must be called with our node ID as 1st argument */
503 GNUNET_break_op (0);
505 return;
506 }
507 my_node_id = args[0];
509 NULL);
513 stdin_fd,
514 &read_task,
515 NULL);
517 NULL);
518}
static void do_shutdown(void *cls)
Task to shut down cleanly.
static enum GNUNET_GenericReturnValue tokenizer_cb(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_native(FILE *fd)
Get a handle from a native FD.
Definition: disk.c:1346
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
Definition: mst.c:86
#define EXIT_INVALIDARGUMENT
Definition: platform.h:253

References consensus-simulation::args, do_shutdown(), EXIT_INVALIDARGUMENT, global_ret, GNUNET_break_op, GNUNET_DISK_get_handle_from_native(), GNUNET_MST_create(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_UNIT_FOREVER_REL, my_node_id, read_task(), read_task_id, stdin_fd, stdout_fd, tokenizer, and tokenizer_cb().

Referenced by main().

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

◆ main()

int main ( int  argc,
char **  argv 
)

Main function.

Parameters
argcthe number of command line arguments
argvcommand line arg array
Returns
return code

Definition at line 529 of file gnunet-cmds-helper.c.

531{
534 };
536
537 ret = GNUNET_PROGRAM_run (argc,
538 argv,
539 "gnunet-cmds-helper",
540 "Helper for starting a local interpreter loop",
541 options,
542 &run,
543 NULL);
544 if (GNUNET_OK != ret)
545 return 1;
546 return global_ret;
547}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int ret
Final status code.
Definition: gnunet-arm.c:94
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
Definition of a command line option.

References global_ret, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), options, ret, and run().

Here is the call graph for this function:

Variable Documentation

◆ wc_head

struct WriteContext* wc_head
static

Definition at line 81 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), write_message(), and write_task().

◆ wc_tail

struct WriteContext* wc_tail
static

Definition at line 83 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), write_message(), and write_task().

◆ is

struct GNUNET_TESTING_Interpreter* is
static

Definition at line 85 of file gnunet-cmds-helper.c.

Referenced by backchannel_check_run(), barrier_reached_run(), barrier_run(), batch_run(), check_backchannel_encapsulation(), check_communicator_backchannel(), connect_peers_run(), delete_networks(), do_timeout(), finish_test(), get_addresses(), GNUNET_NT_scanner_done(), GNUNET_NT_scanner_get_type(), GNUNET_NT_scanner_init(), GNUNET_TESTING_add_barrier_(), GNUNET_TESTING_add_netjail_helper_(), GNUNET_TESTING_barrier_count_(), GNUNET_TESTING_barrier_iterate_(), GNUNET_TESTING_get_barrier2_(), GNUNET_TESTING_get_barrier_(), GNUNET_TESTING_interpreter_commands_iterate(), GNUNET_TESTING_interpreter_current_cmd_get_label(), GNUNET_TESTING_interpreter_current_cmd_inc_tries(), GNUNET_TESTING_interpreter_current_cmd_touch(), GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_get_command(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_interpreter_next_(), GNUNET_TESTING_interpreter_run_cmd_(), GNUNET_TESTING_interpreter_skip(), GNUNET_TESTING_loop_notify_children_(), GNUNET_TESTING_loop_notify_parent_(), GNUNET_TESTING_run(), handle_communicator_backchannel(), handle_helper_barrier_crossable(), handle_helper_init(), interface_proc(), interpreter_run(), join_room_run(), netjail_exec_run(), netjail_start_run(), notify_connect(), rewind_ip_run(), run(), run_finish(), seek_batch(), send_finished(), send_simple_run(), setup_is(), signal_run(), start_peer_run(), start_service_run(), start_testcase(), stat_run(), stop_peer_run(), and stop_service_run().

◆ my_node_id

const char* my_node_id
static

Definition at line 87 of file gnunet-cmds-helper.c.

Referenced by handle_helper_init(), and run().

◆ plugin

struct GNUNET_TESTING_PluginFunctions* plugin
static

Plugin to dynamically load a test case.

Definition at line 92 of file gnunet-cmds-helper.c.

Referenced by __attribute__(), add_addr(), add_plugin(), core_connect_cb(), core_disconnect_cb(), core_init_cb(), create_source(), create_target(), database_connect(), database_prepare(), database_setup(), database_shutdown(), delete_by_rowid(), delete_old_block(), delete_value(), DHTU_gnunet_done(), DHTU_gnunet_init(), DHTU_ip_done(), DHTU_ip_init(), do_shutdown(), execute_get(), expire_blocks(), find_plugin(), find_source(), find_target(), free_value(), get_any(), get_records_and_call_iterator(), get_typed(), GNUNET_BLOCK_check_block(), GNUNET_BLOCK_check_query(), GNUNET_BLOCK_check_reply(), GNUNET_BLOCK_context_destroy(), GNUNET_BLOCK_get_key(), GNUNET_BLOCK_group_create(), gnunet_drop(), GNUNET_GNSRECORD_is_critical(), GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), gnunet_hold(), GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_typename_to_number(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_credential_get_attributes(), GNUNET_RECLAIM_credential_get_expiration(), GNUNET_RECLAIM_credential_get_issuer(), GNUNET_RECLAIM_credential_get_presentation(), GNUNET_RECLAIM_credential_number_to_typename(), GNUNET_RECLAIM_credential_string_to_value(), GNUNET_RECLAIM_credential_typename_to_number(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_RECLAIM_presentation_get_attributes(), GNUNET_RECLAIM_presentation_get_expiration(), GNUNET_RECLAIM_presentation_get_issuer(), GNUNET_RECLAIM_presentation_number_to_typename(), GNUNET_RECLAIM_presentation_string_to_value(), GNUNET_RECLAIM_presentation_typename_to_number(), GNUNET_RECLAIM_presentation_value_to_string(), gnunet_try_connect(), handle_core_message(), handle_helper_init(), heap_get_keys(), heap_plugin_del(), heap_plugin_estimate_size(), heap_plugin_get(), heap_plugin_get_closest(), heap_plugin_get_expiration(), heap_plugin_get_key(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), heap_plugin_remove_key(), init_connection(), ip_send(), ip_try_connect(), libgnunet_plugin_datacache_heap_done(), libgnunet_plugin_datacache_heap_init(), libgnunet_plugin_datacache_postgres_done(), libgnunet_plugin_datacache_postgres_init(), libgnunet_plugin_datacache_sqlite_done(), libgnunet_plugin_datacache_sqlite_init(), libgnunet_plugin_datacache_template_done(), libgnunet_plugin_datacache_template_init(), libgnunet_plugin_datastore_heap_done(), libgnunet_plugin_datastore_heap_init(), libgnunet_plugin_datastore_postgres_done(), libgnunet_plugin_datastore_postgres_init(), libgnunet_plugin_datastore_sqlite_done(), libgnunet_plugin_datastore_sqlite_init(), libgnunet_plugin_datastore_template_done(), libgnunet_plugin_datastore_template_init(), libgnunet_plugin_namecache_flat_done(), libgnunet_plugin_namecache_flat_init(), libgnunet_plugin_namecache_postgres_done(), libgnunet_plugin_namecache_postgres_init(), libgnunet_plugin_namecache_sqlite_done(), libgnunet_plugin_namecache_sqlite_init(), libgnunet_plugin_namestore_flat_done(), libgnunet_plugin_namestore_flat_init(), libgnunet_plugin_namestore_postgres_done(), libgnunet_plugin_namestore_postgres_init(), libgnunet_plugin_namestore_sqlite_done(), libgnunet_plugin_namestore_sqlite_init(), libgnunet_plugin_peerstore_sqlite_done(), libgnunet_plugin_peerstore_sqlite_init(), libgnunet_plugin_rest_pabc_init(), libgnunet_plugin_rest_reclaim_done(), lookup_records(), namecache_cache_block(), namecache_expire_blocks(), namecache_lookup_block(), namecache_postgres_cache_block(), namecache_postgres_expire_blocks(), namecache_postgres_lookup_block(), namecache_sqlite_cache_block(), namecache_sqlite_expire_blocks(), namecache_sqlite_lookup_block(), namestore_flat_iterate_records(), namestore_flat_lookup_records(), namestore_flat_store_records(), namestore_flat_zone_to_name(), namestore_postgres_begin_tx(), namestore_postgres_clear_editor_hint(), namestore_postgres_commit_tx(), namestore_postgres_create_tables(), namestore_postgres_drop_tables(), namestore_postgres_edit_records(), namestore_postgres_iterate_records(), namestore_postgres_lookup_records(), namestore_postgres_rollback_tx(), namestore_postgres_store_records(), namestore_postgres_zone_to_name(), namestore_sqlite_begin_tx(), namestore_sqlite_commit_tx(), namestore_sqlite_create_tables(), namestore_sqlite_drop_tables(), namestore_sqlite_editor_hint_clear(), namestore_sqlite_iterate_records(), namestore_sqlite_rollback_tx(), namestore_sqlite_store_records(), namestore_sqlite_zone_to_name(), nse_cb(), peerinfo_cb(), peerstore_sqlite_delete_records(), peerstore_sqlite_expire_records(), peerstore_sqlite_iterate_records(), peerstore_sqlite_store_record(), postgres_plugin_del(), postgres_plugin_drop(), postgres_plugin_estimate_size(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), postgres_plugin_get_key(), postgres_plugin_get_keys(), postgres_plugin_get_replication(), postgres_plugin_get_zero_anonymity(), postgres_plugin_put(), postgres_plugin_remove_key(), process_ifcs(), process_result(), read_cb(), repl_proc(), REST_config_done(), REST_config_init(), REST_config_process_request(), REST_copying_done(), REST_copying_init(), REST_gns_done(), REST_gns_init(), REST_identity_done(), REST_identity_init(), REST_namestore_done(), REST_namestore_init(), REST_openid_done(), REST_openid_init(), REST_reclaim_done(), REST_reclaim_init(), run(), scan(), sqlite_plugin_del(), sqlite_plugin_drop(), sqlite_plugin_estimate_size(), sqlite_plugin_get_closest(), sqlite_plugin_get_expiration(), sqlite_plugin_get_key(), sqlite_plugin_get_keys(), sqlite_plugin_get_replication(), sqlite_plugin_get_zero_anonymity(), sqlite_plugin_put(), and sqlite_plugin_remove_key().

◆ plugin_name

◆ njt

The loaded topology.

Definition at line 102 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), GNUNET_TESTING_get_plugin_from_topo(), and handle_helper_init().

◆ tokenizer

struct GNUNET_MessageStreamTokenizer* tokenizer
static

Our message stream tokenizer.

Definition at line 107 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), read_task(), and run().

◆ stdin_fd

struct GNUNET_DISK_FileHandle* stdin_fd
static

Disk handle from stdin.

Definition at line 112 of file gnunet-cmds-helper.c.

Referenced by read_task(), and run().

◆ stdout_fd

struct GNUNET_DISK_FileHandle* stdout_fd
static

Disk handle for stdout.

Definition at line 117 of file gnunet-cmds-helper.c.

Referenced by run(), write_message(), and write_task().

◆ read_task_id

struct GNUNET_SCHEDULER_Task* read_task_id
static

Task identifier for the read task.

Definition at line 122 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), read_task(), and run().

◆ write_task_id

struct GNUNET_SCHEDULER_Task* write_task_id
static

Task identifier for the write task.

Definition at line 127 of file gnunet-cmds-helper.c.

Referenced by do_shutdown(), write_message(), and write_task().

◆ global_ret

int global_ret
static

Result to return in case we fail.

Definition at line 132 of file gnunet-cmds-helper.c.

Referenced by handle_helper_barrier_crossable(), handle_helper_init(), main(), read_task(), run(), and write_task().

◆ finished

bool finished
static

Set to true once we are finished and should exit after sending our final message to the parent.

Definition at line 138 of file gnunet-cmds-helper.c.

Referenced by finished_cb(), GNUNET_TIME_calculate_eta(), process_command_stdin(), and write_task().