aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_transport_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_testing_transport_lib.h')
-rw-r--r--src/include/gnunet_testing_transport_lib.h205
1 files changed, 205 insertions, 0 deletions
diff --git a/src/include/gnunet_testing_transport_lib.h b/src/include/gnunet_testing_transport_lib.h
new file mode 100644
index 000000000..db2749661
--- /dev/null
+++ b/src/include/gnunet_testing_transport_lib.h
@@ -0,0 +1,205 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021-2023 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 * @brief API for cmds working with transport sub system.
23 * @author t3sserakt
24 */
25#ifndef GNUNET_TRANSPORT_TESTING_NG_LIB_H
26#define GNUNET_TRANSPORT_TESTING_NG_LIB_H
27
28
29#include "gnunet_util_lib.h"
30#include "gnunet_testing_lib.h"
31
32/**
33 * Application handle; FIXME: what exactly is this?
34 */
35struct GNUNET_TRANSPORT_ApplicationHandle;
36
37
38// FIXME: breaks naming conventions
39typedef void *
40(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
41 const struct GNUNET_PeerIdentity *peer);
42
43
44// FIXME: breaks naming conventions! Needed public?
45struct GNUNET_TESTING_StartPeerState
46{
47 /**
48 * Context for our asynchronous completion.
49 */
50 struct GNUNET_TESTING_AsyncContext ac;
51
52 /**
53 * The ip of a node.
54 */
55 char *node_ip;
56
57 /**
58 * Receive callback
59 */
60 struct GNUNET_MQ_MessageHandler *handlers;
61
62 /**
63 * GNUnet configuration file used to start a peer.
64 */
65 char *cfgname;
66
67 /**
68 * Peer's configuration
69 */
70 struct GNUNET_CONFIGURATION_Handle *cfg;
71
72 /**
73 * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
74 */
75 struct GNUNET_TESTING_Peer *peer;
76
77 /**
78 * Peer identity
79 */
80 struct GNUNET_PeerIdentity id;
81
82 /**
83 * Peer's transport service handle
84 */
85 struct GNUNET_TRANSPORT_CoreHandle *th;
86
87 /**
88 * Application handle
89 */
90 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
91
92 /**
93 * Peer's PEERSTORE Handle
94 */
95 struct GNUNET_PEERSTORE_Handle *ph;
96
97 /**
98 * Hello get task
99 */
100 struct GNUNET_SCHEDULER_Task *rh_task;
101
102 /**
103 * Peer's transport get hello handle to retrieve peer's HELLO message
104 */
105 struct GNUNET_PEERSTORE_IterateContext *pic;
106
107 /**
108 * Hello
109 */
110 char *hello;
111
112 /**
113 * Hello size
114 */
115 size_t hello_size;
116
117 /**
118 * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
119 */
120 char *system_label;
121
122 /**
123 * An unique number to identify the peer
124 */
125 unsigned int no;
126
127 /**
128 * A map with struct GNUNET_MQ_Handle values for each peer this peer
129 * is connected to.
130 */
131 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
132
133 /**
134 * Test setup for this peer.
135 */
136 const struct GNUNET_TESTING_System *tl_system;
137
138 /**
139 * Callback which is called on neighbour connect events.
140 */
141 GNUNET_TESTING_notify_connect_cb notify_connect;
142
143 /**
144 * Flag indicating, if udp broadcast should be switched on.
145 */
146 enum GNUNET_GenericReturnValue broadcast;
147};
148
149
150/**
151 * Create command.
152 *
153 * @param label name for command.
154 * @param system_label Label of the cmd to setup a test environment.
155 * @param no Decimal number representing the last byte of the IP address of this peer.
156 * @param node_ip The IP address of this node.
157 * @param cfgname Configuration file name for this peer.
158 * @param broadcast Flag indicating, if broadcast should be switched on.
159 * @return command.
160 */
161struct GNUNET_TESTING_Command
162GNUNET_TESTING_cmd_start_peer (const char *label,
163 const char *system_label,
164 uint32_t no,
165 const char *node_ip,
166 const char *cfgname,
167 unsigned int broadcast);
168
169
170struct GNUNET_TESTING_Command
171GNUNET_TESTING_cmd_stop_peer (const char *label,
172 const char *start_label);
173
174
175/**
176 * Retrieve peer identity from the test system with the unique node id.
177 *
178 * @param num The unique node id.
179 * @param tl_system The test system.
180 * @return The peer identity wrapping the public key.
181 */
182struct GNUNET_PeerIdentity *
183GNUNET_TESTING_get_peer (unsigned int num,
184 const struct GNUNET_TESTING_System *tl_system);
185
186
187/**
188 * Call #op on all simple traits.
189 */
190#define GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS(op, prefix) \
191 op (prefix, connected_peers_map, const struct \
192 GNUNET_CONTAINER_MultiShortmap) \
193 op (prefix, peer_id, const struct GNUNET_PeerIdentity) \
194 op (prefix, hello_size, const size_t) \
195 op (prefix, hello, const char) \
196 op (prefix, application_handle, const struct \
197 GNUNET_TRANSPORT_ApplicationHandle) \
198 op (prefix, state, const struct GNUNET_TESTING_StartPeerState) \
199 op (prefix, broadcast, const enum GNUNET_GenericReturnValue)
200
201
202GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT,
203 GNUNET_TRANSPORT_TESTING)
204
205#endif