GNUnet  0.11.x
gnunet-cmd.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2008--2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_testing_lib.h"
32 #include "gnunet_testing_plugin.h"
33 
37 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
38 
39 #define NODE_BASE_IP "192.168.15."
40 
41 #define ROUTER_BASE_IP "92.68.150."
42 
46 struct Plugin
47 {
51  char *library_name;
52 
57 
58  char *node_ip;
59 
60  char *plugin_name;
61 
62  char *global_n;
63 
64  char *local_m;
65 
66  char *n;
67 
68  char *m;
69 };
70 
71 
78 static void
79 run (void *cls)
80 {
81  struct Plugin *plugin = cls;
82  char *router_ip;
83  char *node_ip;
84 
85  router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) + 1);
86  strcpy (router_ip, ROUTER_BASE_IP);
87  strcat (router_ip, plugin->m);
88 
89  node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1);
90  strcat (node_ip, NODE_BASE_IP);
91  strcat (node_ip, plugin->n);
92 
93  plugin->api->start_testcase (NULL, router_ip, node_ip, NULL, NULL);
94 
95 }
96 
97 
98 int
99 main (int argc, char *const *argv)
100 {
101  int rv = 0;
102  struct Plugin *plugin;
103 
104  GNUNET_log_setup ("gnunet-cmd",
105  "DEBUG",
106  NULL);
107 
108  plugin = GNUNET_new (struct Plugin);
109  plugin->api = GNUNET_PLUGIN_load (argv[0],
110  NULL);
111  plugin->library_name = GNUNET_strdup (argv[0]);
112 
113  plugin->global_n = argv[1];
114  plugin->local_m = argv[2];
115  plugin->n = argv[3];
116  plugin->m = argv[4];
117 
119  plugin);
120 
122  return rv;
123 }
static void run(void *cls)
Main function to run the test cases.
Definition: gnunet-cmd.c:79
#define NODE_BASE_IP
Definition: gnunet-cmd.c:39
#define ROUTER_BASE_IP
Definition: gnunet-cmd.c:41
int main(int argc, char *const *argv)
Definition: gnunet-cmd.c:99
struct Plugin * plugin
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#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.
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:217
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720
void * cls
Closure for all of the callbacks.
Handle for a plugin.
Definition: block.c:38
char * node_ip
Definition: gnunet-cmd.c:58
char * m
Definition: gnunet-cmd.c:68
char * n
Definition: gnunet-cmd.c:66
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: gnunet-cmd.c:56
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
char * plugin_name
Definition: gnunet-cmd.c:60
char * global_n
Definition: gnunet-cmd.c:62
char * local_m
Definition: gnunet-cmd.c:64
char * library_name
Name of the shared library.
Definition: block.c:42