55 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
60 #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
62 #define NODE_BASE_IP "192.168.15."
64 #define KNOWN_BASE_IP "92.68.151."
66 #define ROUTER_BASE_IP "92.68.150."
251 "message send to master loop\n");
255 "Cannot reply back successful initialization\n");
260 wc->
pos += bytes_wrote;
285 "write message to master loop\n");
301 "doing shutdown after delay\n");
315 reply->
header.
size = htons ((uint16_t) msg_length);
330 reply->
header.
size = htons ((uint16_t) msg_length);
334 "message prepared\n");
340 "delaying shutdown\n");
368 size_t plugin_name_size;
374 unsigned int namespace_n;
377 msize = ntohs (message->
size);
379 "Received message type %u and size %u\n",
393 "Received unexpected message -- exiting\n");
431 if (0 == namespace_n)
434 "known node n: %s\n",
443 "subnet node n: %s\n",
467 reply->
header.
size = htons ((uint16_t) msg_length);
474 const char *barrier_name;
478 barrier_name = (
const char *) &adm[1];
480 "cross barrier %s\n",
489 "all peers started\n");
496 "all local tests prepared\n");
508 "tokenizer shutting down!\n");
538 "tokenizer shutting down during reading, didn't expect any more data!\n");
542 LOG_DEBUG (
"Read %u bytes\n", (
unsigned int) sread);
550 "tokenizer shutting down during reading, writing to buffer failed!\n");
579 "Starting interpreter loop helper...\n");
592 "Interpreter loop helper started.\n");
632 unsigned int sscanf_ret;
634 size_t topology_data_length = 0;
648 sscanf_ret = sscanf (argv[5],
"%u", &
read_file);
658 for (i = 6; i<argc; i++)
659 topology_data_length += strlen (argv[i]) + 1;
661 "topo data length %lu\n",
662 topology_data_length);
665 for (i = 6; i<argc; i++)
674 "Wrong input for the fourth argument\n");
695 "gnunet-cmds-helper",
696 "Helper for starting a local interpreter loop",
702 "Finishing helper\n");
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
static struct GNUNET_SIGNAL_Context * shc_chld
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
struct GNUNET_MessageHeader * GNUNET_TESTING_send_local_test_finished_msg()
static void write_message(struct GNUNET_MessageHeader *message, size_t msg_length)
Callback to write a message to the master loop.
struct GNUNET_MessageStreamTokenizer * tokenizer
Our message stream tokenizer.
static void finished_cb(enum GNUNET_GenericReturnValue rv)
static void read_task(void *cls)
Task to read from stdin.
int main(int argc, char **argv)
Main function.
struct TestcasePlugin * plugin
The process handle to the testbed service.
static struct GNUNET_DISK_FileHandle * stdout_fd
Disk handle for stdout.
static int status
Result to return in case we fail.
#define LOG_DEBUG(...)
Debug logging shorthand.
static void do_shutdown(void *cls)
Task to shut down cleanly.
static struct GNUNET_DISK_PipeHandle * sigpipe
Pipe used to communicate shutdown via signal.
static void sighandler_child_death()
Signal handler called for SIGCHLD.
struct GNUNET_SCHEDULER_Task * finished_task
static struct GNUNET_SCHEDULER_Task * read_task_id
Task identifier for the read task.
static void write_task(void *cls)
Task to write to the standard out.
struct GNUNET_TESTING_Interpreter * is
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
#define LOG(kind,...)
Generic logging shortcut.
static struct GNUNET_SCHEDULER_Task * write_task_id
Task identifier for the write task.
static struct GNUNET_DISK_FileHandle * stdin_fd
Disk handle from stdin.
static int done_reading
Are we done reading messages from stdin?
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.
static void delay_shutdown_cb()
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * plugin_name
Name of our plugin.
Convenience API for writing testcases for GNUnet.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_native(FILE *fd)
Get a handle from a native FD.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
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.
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
@ GNUNET_DISK_PF_NONE
No special options, use non-blocking read/write operations.
@ GNUNET_DISK_PIPE_END_WRITE
The writing-end of a pipe.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#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
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
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 ...
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
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,...
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY
The reply message from gnunet-cmds-helper.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT
The initialization message towards gnunet-cmds-helper.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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...
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...
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
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.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
struct GNUNET_SIGNAL_Context * GNUNET_SIGNAL_handler_install(int signal, GNUNET_SIGNAL_Handler handler)
Install a signal handler that will be run if the given signal is received.
void GNUNET_SIGNAL_handler_uninstall(struct GNUNET_SIGNAL_Context *ctx)
Uninstall a previously installed signal handler.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_SECONDS
One second.
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Message send to a child loop to inform the child loop about a barrier being advanced.
Handle used to access files (and pipes).
Handle used to manage a pipe.
Definition of a command line option.
Handle to a message stream tokenizer.
Entry in list of pending tasks.
Initialization message for gnunet-cmds-testbed to start cmd binary.
uint16_t plugin_name_size
Reply message from cmds helper process.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
enum GNUNET_GenericReturnValue rv
The exit status local test return with.
Global state of the interpreter, used by a command to access information about other commands.
GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED all_local_tests_prepared
GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started
GNUNET_TESTING_PLUGIN_StartTestCase start_testcase
Struct with information about a specific node and the whole network namespace setup.
unsigned int * read_file
Shall we read the topology from file, or from a string.
char * topology_data
String with topology data or name of topology file.
char * m
The number of the node in the namespace.
char * n
The number of the namespace this node is in.
char * local_m
The number of local nodes per namespace.
char * global_n
The number of namespaces.
char * global_n
The number of namespaces.
char * local_m
The number of local nodes per namespace.
char * n
The number of the namespace this node is in.
char * m
The number of the node in the namespace.
char * library_name
Name of the shared library.
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Context for a single write on a chunk of memory.
size_t pos
The current position from where the write operation should begin.
size_t length
The length of the data.
void * data
The data to write.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void TST_interpreter_finish_attached_cmds(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Finish all "barrier reached" comands attached to this barrier.
Message formats for communication between testing cmds helper and testcase plugins.