aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testbed_ng_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_testbed_ng_service.h')
-rw-r--r--src/include/gnunet_testbed_ng_service.h247
1 files changed, 247 insertions, 0 deletions
diff --git a/src/include/gnunet_testbed_ng_service.h b/src/include/gnunet_testbed_ng_service.h
new file mode 100644
index 000000000..a6f30889f
--- /dev/null
+++ b/src/include/gnunet_testbed_ng_service.h
@@ -0,0 +1,247 @@
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 * @author t3sserakt
23 *
24 * @file
25 * API for writing tests and creating large-scale emulation testbeds for GNUnet with command pattern.
26 *
27 * @defgroup testbed Testbed service
28 * Writing tests and creating large-scale emulation testbeds for GNUnet with command pattern.
29 *
30 * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-NG-Subsystem)
31 *
32 * @{
33 */
34
35#ifndef GNUNET_TESTBED_NG_SERVICE_H
36#define GNUNET_TESTBED_NG_SERVICE_H
37
38#include "gnunet_util_lib.h"
39#include "gnunet_testing_ng_lib.h"
40
41struct ServiceState
42{
43 /**
44 * Handle to operation
45 */
46 struct GNUNET_TESTBED_Operation *operation;
47
48 /**
49 * Flag indicating if service is ready.
50 */
51 int service_ready;
52
53 /**
54 * Abort task identifier
55 */
56 struct GNUNET_SCHEDULER_Task *abort_task;
57
58 /**
59 * Label of peer command.
60 */
61 const char *peer_label;
62
63 /**
64 * Name of service to start.
65 */
66 const char *servicename;
67};
68
69struct PeerCmdState
70{
71 /**
72 * The label of a controller command.
73 */
74 const char *controller_label;
75
76 /**
77 * Handle to operation
78 */
79 struct GNUNET_TESTBED_Operation *operation;
80
81 /**
82 * Name of the host, use "NULL" for localhost.
83 */
84 const char *hostname;
85
86 /**
87 * Username to use for the login; may be NULL.
88 */
89 const char *username;
90
91 /**
92 * Port number to use for ssh; use 0 to let ssh decide.
93 */
94 uint16_t port;
95
96 /**
97 * The configuration to use as a template while starting a controller
98 * on this host. Operation queue sizes specific to a host are also
99 * read from this configuration handle.
100 */
101 struct GNUNET_CONFIGURATION_Handle *cfg;
102
103 /**
104 * The host to run peers and controllers on
105 */
106 struct GNUNET_TESTBED_Host *host;
107
108 /**
109 * Abort task identifier
110 */
111 struct GNUNET_SCHEDULER_Task *abort_task;
112
113 /**
114 * Handle for host registration
115 */
116 struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
117
118 /**
119 * Flag indicating if peer is ready.
120 */
121 int peer_ready;
122
123 /**
124 * Flag indicating controller is going down.
125 */
126 int peer_going_down;
127
128 /**
129 * Interpreter state.
130 */
131 struct GNUNET_TESTING_Interpreter *is;
132
133 /**
134 * Peer to start
135 */
136 struct GNUNET_TESTBED_Peer *peer;
137};
138
139struct ControllerState
140{
141 /**
142 * The ip address of the controller which will be set as TRUSTED
143 * HOST(all connections form this ip are permitted by the testbed) when
144 * starting testbed controller at host. This can either be a single ip
145 * address or a network address in CIDR notation.
146 */
147 const char *trusted_ip;
148
149 /**
150 * Name of the host, use "NULL" for localhost.
151 */
152 const char *hostname;
153
154 /**
155 * Username to use for the login; may be NULL.
156 */
157 const char *username;
158
159 /**
160 * Port number to use for ssh; use 0 to let ssh decide.
161 */
162 uint16_t port;
163
164 /**
165 * The configuration to use as a template while starting a controller
166 * on this host. Operation queue sizes specific to a host are also
167 * read from this configuration handle.
168 */
169 struct GNUNET_CONFIGURATION_Handle *cfg;
170
171 /**
172 * The host to run peers and controllers on
173 */
174 struct GNUNET_TESTBED_Host *host;
175
176 /**
177 * The controller process
178 */
179 struct GNUNET_TESTBED_ControllerProc *cp;
180
181 /**
182 * The controller handle
183 */
184 struct GNUNET_TESTBED_Controller *controller;
185
186 /**
187 * A bit mask with set of events to call the controller for.
188 */
189 uint64_t event_mask;
190
191 /**
192 * Abort task identifier
193 */
194 struct GNUNET_SCHEDULER_Task *abort_task;
195
196 /**
197 * Handle for host registration
198 */
199 struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
200
201 /**
202 * Flag indicating if host create with controller is ready.
203 */
204 int host_ready;
205
206 /**
207 * Flag indicating controller is going down.
208 */
209 int controller_going_down;
210
211 /**
212 * Interpreter state.
213 */
214 struct GNUNET_TESTING_Interpreter *is;
215};
216
217/**
218 * Offer data from trait
219 *
220 * @param cmd command to extract the controller from.
221 * @param pt pointer to controller.
222 * @return #GNUNET_OK on success.
223 */
224int
225GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd,
226 struct GNUNET_TESTBED_Controller **
227 controller);
228
229struct GNUNET_TESTING_Command
230GNUNET_TESTBED_cmd_controller (const char *label,
231 const char *trusted_ip,
232 const char *hostname,
233 const char *username,
234 uint16_t port,
235 struct GNUNET_CONFIGURATION_Handle *cfg,
236 uint64_t event_mask);
237
238void
239GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs);
240
241void
242GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps);
243
244void
245GNUNET_TESTBED_shutdown_service (struct ServiceState *ss);
246
247#endif