diff options
author | t3sserakt <t3ss@posteo.de> | 2021-09-20 09:00:09 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-09-20 09:00:09 +0200 |
commit | d5df403e64bbde52c5436165eee5231a1b2f876b (patch) | |
tree | 3a4efc07dc5d2576a9f6656de58764aa9840d856 /src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c | |
parent | 9bdaa1f9b21b324963fe0f41311ae6d9c0948946 (diff) | |
download | gnunet-d5df403e64bbde52c5436165eee5231a1b2f876b.tar.gz gnunet-d5df403e64bbde52c5436165eee5231a1b2f876b.zip |
- added new udp backchannel testcase, changed netjail script to have port forwarding into subnets, master loop is no configured completely by topology config file, connect cmd reads topology file to connect to configured nodes
Diffstat (limited to 'src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c')
-rw-r--r-- | src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c | 262 |
1 files changed, 0 insertions, 262 deletions
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c b/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c deleted file mode 100644 index ce1245296..000000000 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c +++ /dev/null | |||
@@ -1,262 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 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 | |||
21 | /** | ||
22 | * @file testbed/plugin_cmd_simple_send.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_transport_application_service.h" | ||
30 | #include "transport-testing2.h" | ||
31 | #include "transport-testing-cmds.h" | ||
32 | |||
33 | /** | ||
34 | * Generic logging shortcut | ||
35 | */ | ||
36 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
37 | |||
38 | #define BASE_DIR "testdir" | ||
39 | |||
40 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
41 | |||
42 | /** | ||
43 | * The name for a specific test environment directory. | ||
44 | * | ||
45 | */ | ||
46 | char *testdir; | ||
47 | |||
48 | /** | ||
49 | * The name for the configuration file of the specific node. | ||
50 | * | ||
51 | */ | ||
52 | char *cfgname; | ||
53 | |||
54 | /** | ||
55 | * Flag indicating if all peers have been started. | ||
56 | * | ||
57 | */ | ||
58 | unsigned int are_all_peers_started; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | ||
63 | * received. | ||
64 | * | ||
65 | */ | ||
66 | static int | ||
67 | check_test (void *cls, | ||
68 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
69 | { | ||
70 | return GNUNET_OK; | ||
71 | } | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE | ||
76 | * being received. | ||
77 | * | ||
78 | */ | ||
79 | static void | ||
80 | handle_test (void *cls, | ||
81 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
82 | { | ||
83 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
84 | "message received\n"); | ||
85 | } | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 | ||
90 | * being received. | ||
91 | * | ||
92 | */ | ||
93 | static int | ||
94 | check_test2 (void *cls, | ||
95 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
96 | { | ||
97 | return GNUNET_OK; | ||
98 | } | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 | ||
103 | * being received. | ||
104 | * | ||
105 | */ | ||
106 | static void | ||
107 | handle_test2 (void *cls, | ||
108 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
109 | { | ||
110 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
111 | "message received\n"); | ||
112 | } | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | ||
117 | * | ||
118 | */ | ||
119 | static void | ||
120 | all_peers_started () | ||
121 | { | ||
122 | are_all_peers_started = GNUNET_YES; | ||
123 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
124 | "setting are_all_peers_started: %d\n", | ||
125 | are_all_peers_started); | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Function to start a local test case. | ||
131 | * | ||
132 | * @param write_message Callback to send a message to the master loop. | ||
133 | * @param router_ip Global address of the network namespace. | ||
134 | * @param node_ip Local address of a node i a network namespace. | ||
135 | * @param m The number of the node in a network namespace. | ||
136 | * @param n The number of the network namespace. | ||
137 | * @param local_m The number of nodes in a network namespace. | ||
138 | */ | ||
139 | static void | ||
140 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | ||
141 | char *node_ip, | ||
142 | char *m, | ||
143 | char *n, | ||
144 | char *local_m) | ||
145 | { | ||
146 | |||
147 | unsigned int n_int, m_int, local_m_int, num; | ||
148 | |||
149 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
150 | GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); | ||
151 | |||
152 | sscanf (m, "%u", &m_int); | ||
153 | sscanf (n, "%u", &n_int); | ||
154 | sscanf (local_m, "%u", &local_m_int); | ||
155 | |||
156 | |||
157 | if (0 == m_int) | ||
158 | num = n_int; | ||
159 | else | ||
160 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | ||
161 | |||
162 | GNUNET_asprintf (&cfgname, | ||
163 | "test_transport_api2_tcp_node1.conf"); | ||
164 | |||
165 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
166 | "plugin cfgname: %s\n", | ||
167 | cfgname); | ||
168 | |||
169 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
170 | "node ip: %s\n", | ||
171 | node_ip); | ||
172 | |||
173 | GNUNET_asprintf (&testdir, | ||
174 | "%s%s%s", | ||
175 | BASE_DIR, | ||
176 | m, | ||
177 | n); | ||
178 | |||
179 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
180 | GNUNET_MQ_hd_var_size (test, | ||
181 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | ||
182 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
183 | NULL), | ||
184 | GNUNET_MQ_hd_var_size (test2, | ||
185 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2, | ||
186 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
187 | NULL), | ||
188 | GNUNET_MQ_handler_end () | ||
189 | }; | ||
190 | |||
191 | struct GNUNET_TESTING_Command commands[] = { | ||
192 | GNUNET_TESTING_cmd_system_create ("system-create", | ||
193 | testdir), | ||
194 | GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer", | ||
195 | "system-create", | ||
196 | num, | ||
197 | node_ip, | ||
198 | handlers, | ||
199 | cfgname), | ||
200 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | ||
201 | write_message), | ||
202 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block", | ||
203 | &are_all_peers_started), | ||
204 | GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers", | ||
205 | "start-peer", | ||
206 | "system-create", | ||
207 | num), | ||
208 | GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple", | ||
209 | "start-peer", | ||
210 | num), | ||
211 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | ||
212 | "start-peer"), | ||
213 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | ||
214 | "system-create"), | ||
215 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished", | ||
216 | write_message) | ||
217 | }; | ||
218 | |||
219 | GNUNET_TESTING_run (NULL, | ||
220 | commands, | ||
221 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
222 | |||
223 | } | ||
224 | |||
225 | |||
226 | /** | ||
227 | * Entry point for the plugin. | ||
228 | * | ||
229 | * @param cls NULL | ||
230 | * @return the exported block API | ||
231 | */ | ||
232 | void * | ||
233 | libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls) | ||
234 | { | ||
235 | struct GNUNET_TESTING_PluginFunctions *api; | ||
236 | |||
237 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | ||
238 | api->start_testcase = &start_testcase; | ||
239 | api->all_peers_started = &all_peers_started; | ||
240 | return api; | ||
241 | } | ||
242 | |||
243 | |||
244 | /** | ||
245 | * Exit point from the plugin. | ||
246 | * | ||
247 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init | ||
248 | * @return NULL | ||
249 | */ | ||
250 | void * | ||
251 | libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls) | ||
252 | { | ||
253 | struct GNUNET_TESTING_PluginFunctions *api = cls; | ||
254 | |||
255 | GNUNET_free (api); | ||
256 | GNUNET_free (testdir); | ||
257 | GNUNET_free (cfgname); | ||
258 | return NULL; | ||
259 | } | ||
260 | |||
261 | |||
262 | /* end of plugin_cmd_simple_send.c */ | ||