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 d64279aeb..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 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 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 unsigned int broadcast;
191};
192
193
194/**
195 * Function to get the trait with the struct ConnectPeersState.
196 *
197 * @param[out] sps struct ConnectPeersState.
198 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
199 *
200 */
201int
202GNUNET_TRANSPORT_get_trait_connect_peer_state (
203 const struct GNUNET_TESTING_Command *cmd,
204 struct ConnectPeersState **cps);
205
206
207int
208GNUNET_TRANSPORT_get_trait_state (const struct
209 GNUNET_TESTING_Command
210 *cmd,
211 struct StartPeerState **sps);
212
213
214/**
215 * Create command.
216 *
217 * @param label name for command.
218 * @param system_label Label of the cmd to setup a test environment.
219 * @param m The number of the local node of the actual network namespace.
220 * @param n The number of the actual namespace.
221 * @param local_m Number of local nodes in each namespace.
222 * @param handlers Handler for messages received by this peer.
223 * @param cfgname Configuration file name for this peer.
224 * @param notify_connect Method which will be called, when a peer connects.
225 * @param broadcast Flag indicating, if broadcast should be switched on.
226 * @return command.
227 */
228struct GNUNET_TESTING_Command
229GNUNET_TRANSPORT_cmd_start_peer (const char *label,
230 const char *system_label,
231 uint32_t no,
232 char *node_ip,
233 struct GNUNET_MQ_MessageHandler *handlers,
234 const char *cfgname,
235 GNUNET_TRANSPORT_notify_connect_cb
236 notify_connect,
237 unsigned int broadcast);
238
239
240struct GNUNET_TESTING_Command
241GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
242 const char *start_label);
243
244
245/**
246 * Create command
247 *
248 * @param label name for command
249 * @param start_peer_label Label of the cmd to start a peer.
250 * @param create_peer_label Label of the cmd which started the test system.
251 * @param num Number globally identifying the node.
252 * @param The topology for the test setup.
253 * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
254 * @return command.
255 */
256struct GNUNET_TESTING_Command
257GNUNET_TRANSPORT_cmd_connect_peers (
258 const char *label,
259 const char *start_peer_label,
260 const char *create_label,
261 uint32_t num,
262 struct GNUNET_TESTING_NetjailTopology *topology,
263 unsigned int additional_connects);
264
265
266/**
267 * Create command.
268 *
269 * @param label name for command.
270 * @param start_peer_label Label of the cmd to start a peer.
271 * @param create_peer_label Label of the cmd which started the test system.
272 * @param num Number globally identifying the node.
273 * @param The topology for the test setup.
274 * @return command.
275 */
276struct GNUNET_TESTING_Command
277GNUNET_TRANSPORT_cmd_send_simple (const char *label,
278 const char *start_peer_label,
279 const char *create_label,
280 uint32_t num,
281 struct GNUNET_TESTING_NetjailTopology *
282 topology);
283
284
285/**
286 * Create command.
287 *
288 * @param label name for command.
289 * @param start_peer_label Label of the cmd to start a peer.
290 * @param create_label Label of the cmd to create the testing system.
291 * @param num Number globally identifying the node.
292 * @param node_n The number of the node in a network namespace.
293 * @param namespace_n The number of the network namespace.
294 * @param The topology for the test setup.
295 * @return command.
296 */
297struct GNUNET_TESTING_Command
298GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
299 const char *start_peer_label,
300 const char *create_label,
301 uint32_t num,
302 unsigned int node_n,
303 unsigned int namespace_n,
304 struct GNUNET_TESTING_NetjailTopology *
305 topology);
306
307
308
309
310
311int
312GNUNET_TRANSPORT_get_trait_peer_id (const struct
313 GNUNET_TESTING_Command *cmd,
314 struct GNUNET_PeerIdentity **id);
315
316
317int
318GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
319 GNUNET_TESTING_Command
320 *cmd,
321 struct
322 GNUNET_CONTAINER_MultiShortmap
323 *
324 *
325 connected_peers_map);
326int
327GNUNET_TRANSPORT_get_trait_hello_size (const struct
328 GNUNET_TESTING_Command
329 *cmd,
330 size_t **hello_size);
331
332int
333GNUNET_TRANSPORT_get_trait_hello (const struct
334 GNUNET_TESTING_Command
335 *cmd,
336 char **hello);
337
338
339int
340GNUNET_TRANSPORT_get_trait_application_handle (const struct
341 GNUNET_TESTING_Command *cmd,
342 struct
343 GNUNET_TRANSPORT_ApplicationHandle
344 **ah);
345
346#endif
347/* end of transport_testing.h */