aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing-cmds.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing-cmds.h')
-rw-r--r--src/transport/transport-testing-cmds.h347
1 files changed, 0 insertions, 347 deletions
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
deleted file mode 100644
index 5a3fb22d6..000000000
--- a/src/transport/transport-testing-cmds.h
+++ /dev/null
@@ -1,347 +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 transport-testing.h
23 * @brief testing lib for transport service
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#ifndef TRANSPORT_TESTING_CMDS_H
28#define TRANSPORT_TESTING_CMDS_H
29#include "gnunet_testing_lib.h"
30
31
32typedef void *
33(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
34 const struct GNUNET_PeerIdentity *peer);
35
36/**
37 * Struct to store information needed in callbacks.
38 *
39 */
40struct ConnectPeersState
41{
42 /**
43 * Context for our asynchronous completion.
44 */
45 struct GNUNET_TESTING_AsyncContext ac;
46
47 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
48
49 /**
50 * The testing system of this node.
51 */
52 const struct GNUNET_TESTING_System *tl_system;
53
54 // Label of the cmd which started the test system.
55 const char *create_label;
56
57 /**
58 * Number globally identifying the node.
59 *
60 */
61 uint32_t num;
62
63 /**
64 * Label of the cmd to start a peer.
65 *
66 */
67 const char *start_peer_label;
68
69 /**
70 * The topology of the test setup.
71 */
72 struct GNUNET_TESTING_NetjailTopology *topology;
73
74 /**
75 * Connections to other peers.
76 */
77 struct GNUNET_TESTING_NodeConnection *node_connections_head;
78
79 struct GNUNET_TESTING_Interpreter *is;
80
81 /**
82 * Number of connections.
83 */
84 unsigned int con_num;
85
86 /**
87 * Number of additional connects this cmd will wait for not triggered by this cmd.
88 */
89 unsigned int additional_connects;
90
91 /**
92 * Number of connections we already have a notification for.
93 */
94 unsigned int con_num_notified;
95
96 /**
97 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
98 */
99 unsigned int additional_connects_notified;
100};
101
102struct StartPeerState
103{
104 /**
105 * Context for our asynchronous completion.
106 */
107 struct GNUNET_TESTING_AsyncContext ac;
108
109 /**
110 * The ip of a node.
111 */
112 char *node_ip;
113
114 /**
115 * Receive callback
116 */
117 struct GNUNET_MQ_MessageHandler *handlers;
118
119 const char *cfgname;
120
121 /**
122 * Peer's configuration
123 */
124 struct GNUNET_CONFIGURATION_Handle *cfg;
125
126 struct GNUNET_TESTING_Peer *peer;
127
128 /**
129 * Peer identity
130 */
131 struct GNUNET_PeerIdentity id;
132
133 /**
134 * Peer's transport service handle
135 */
136 struct GNUNET_TRANSPORT_CoreHandle *th;
137
138 /**
139 * Application handle
140 */
141 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
142
143 /**
144 * Peer's PEERSTORE Handle
145 */
146 struct GNUNET_PEERSTORE_Handle *ph;
147
148 /**
149 * Hello get task
150 */
151 struct GNUNET_SCHEDULER_Task *rh_task;
152
153 /**
154 * Peer's transport get hello handle to retrieve peer's HELLO message
155 */
156 struct GNUNET_PEERSTORE_IterateContext *pic;
157
158 /**
159 * Hello
160 */
161 char *hello;
162
163 /**
164 * Hello size
165 */
166 size_t hello_size;
167
168 char *m;
169
170 char *n;
171
172 char *local_m;
173
174 const char *system_label;
175
176 /**
177 * An unique number to identify the peer
178 */
179 unsigned int no;
180
181 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
182
183 const struct GNUNET_TESTING_System *tl_system;
184
185 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
186
187 /**
188 * Flag indicating, if udp broadcast should be switched on.
189 */
190 enum GNUNET_GenericReturnValue broadcast;
191};
192
193
194/**
195 * Create command.
196 *
197 * @param label name for command.
198 * @param system_label Label of the cmd to setup a test environment.
199 * @param m The number of the local node of the actual network namespace.
200 * @param n The number of the actual namespace.
201 * @param local_m Number of local nodes in each namespace.
202 * @param handlers Handler for messages received by this peer.
203 * @param cfgname Configuration file name for this peer.
204 * @param notify_connect Method which will be called, when a peer connects.
205 * @param broadcast Flag indicating, if broadcast should be switched on.
206 * @return command.
207 */
208struct GNUNET_TESTING_Command
209GNUNET_TRANSPORT_cmd_start_peer (const char *label,
210 const char *system_label,
211 uint32_t no,
212 char *node_ip,
213 struct GNUNET_MQ_MessageHandler *handlers,
214 const char *cfgname,
215 GNUNET_TRANSPORT_notify_connect_cb
216 notify_connect,
217 unsigned int broadcast);
218
219
220struct GNUNET_TESTING_Command
221GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
222 const char *start_label);
223
224
225/**
226 * Create command
227 *
228 * @param label name for command
229 * @param start_peer_label Label of the cmd to start a peer.
230 * @param create_peer_label Label of the cmd which started the test system.
231 * @param num Number globally identifying the node.
232 * @param The topology for the test setup.
233 * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
234 * @return command.
235 */
236struct GNUNET_TESTING_Command
237GNUNET_TRANSPORT_cmd_connect_peers (
238 const char *label,
239 const char *start_peer_label,
240 const char *create_label,
241 uint32_t num,
242 struct GNUNET_TESTING_NetjailTopology *topology,
243 unsigned int additional_connects);
244
245
246/**
247 * Create command.
248 *
249 * @param label name for command.
250 * @param start_peer_label Label of the cmd to start a peer.
251 * @param create_peer_label Label of the cmd which started the test system.
252 * @param num Number globally identifying the node.
253 * @param The topology for the test setup.
254 * @return command.
255 */
256struct GNUNET_TESTING_Command
257GNUNET_TRANSPORT_cmd_send_simple (const char *label,
258 const char *start_peer_label,
259 const char *create_label,
260 uint32_t num,
261 struct GNUNET_TESTING_NetjailTopology *
262 topology);
263
264
265/**
266 * Create command.
267 *
268 * @param label name for command.
269 * @param start_peer_label Label of the cmd to start a peer.
270 * @param create_label Label of the cmd to create the testing system.
271 * @param num Number globally identifying the node.
272 * @param node_n The number of the node in a network namespace.
273 * @param namespace_n The number of the network namespace.
274 * @param The topology for the test setup.
275 * @return command.
276 */
277struct GNUNET_TESTING_Command
278GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
279 const char *start_peer_label,
280 const char *create_label,
281 uint32_t num,
282 unsigned int node_n,
283 unsigned int namespace_n,
284 struct GNUNET_TESTING_NetjailTopology *
285 topology);
286
287
288/**
289 * Create headers for a trait with name @a name for
290 * statically allocated data of type @a type.
291 */
292#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
293 enum GNUNET_GenericReturnValue \
294 GNUNET_TRANSPORT_get_trait_ ## name ( \
295 const struct GNUNET_TESTING_Command *cmd, \
296 type **ret); \
297 struct GNUNET_TESTING_Trait \
298 GNUNET_TRANSPORT_make_trait_ ## name ( \
299 type * value);
300
301
302/**
303 * Create C implementation for a trait with name @a name for statically
304 * allocated data of type @a type.
305 */
306#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
307 enum GNUNET_GenericReturnValue \
308 GNUNET_TRANSPORT_get_trait_ ## name ( \
309 const struct GNUNET_TESTING_Command *cmd, \
310 type **ret) \
311 { \
312 if (NULL == cmd->traits) return GNUNET_SYSERR; \
313 return cmd->traits (cmd->cls, \
314 (const void **) ret, \
315 GNUNET_S (name), \
316 0); \
317 } \
318 struct GNUNET_TESTING_Trait \
319 GNUNET_TRANSPORT_make_trait_ ## name ( \
320 type * value) \
321 { \
322 struct GNUNET_TESTING_Trait ret = { \
323 .trait_name = GNUNET_S (name), \
324 .ptr = (const void *) value \
325 }; \
326 return ret; \
327 }
328
329
330/**
331 * Call #op on all simple traits.
332 */
333#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
334 op (peer_id, const struct GNUNET_PeerIdentity) \
335 op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
336 op (hello_size, const size_t) \
337 op (hello, const char) \
338 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
339 op (connect_peer_state, const struct ConnectPeersState) \
340 op (state, const struct StartPeerState) \
341 op (broadcast, const enum GNUNET_GenericReturnValue)
342
343GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
344
345
346#endif
347/* end of transport_testing.h */