2 This file is part of GNUnet
3 Copyright (C) 2008--2013 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file testbed/testbed_api_peers.h
23 * @brief internal API to access the 'peers' subsystem
24 * @author Christian Grothoff
25 * @author Sree Harsha Totakura
28 #ifndef NEW_TESTING_API_PEERS_H
29 #define NEW_TESTING_API_PEERS_H
31 #include "gnunet_testbed_service.h"
32 #include "gnunet_helper_lib.h"
36 * Enumeration of possible states a peer could be in
40 * State to signify that this peer is invalid
45 * The peer has been created
62 * A peer controlled by the testing framework. A peer runs
63 * at a particular host.
65 struct GNUNET_TESTBED_Peer {
69 struct GNUNET_TESTBED_Peer *next;
74 struct GNUNET_TESTBED_Peer *prev;
77 * Our controller context (not necessarily the controller
78 * that is responsible for starting/running the peer!).
80 struct GNUNET_TESTBED_Controller *controller;
83 * Which host does this peer run on?
85 struct GNUNET_TESTBED_Host *host;
88 * Globally unique ID of the peer.
98 * Has an underlay model already set for this peer?
100 uint8_t underlay_model_exists;
105 * Data for the OperationType OP_PEER_CREATE
107 struct PeerCreateData {
109 * The host where the peer has to be created
111 struct GNUNET_TESTBED_Host *host;
114 * The template configuration of the peer
116 const struct GNUNET_CONFIGURATION_Handle *cfg;
119 * The call back to call when we receive peer create success message
121 GNUNET_TESTBED_PeerCreateCallback cb;
124 * The closure for the above callback
129 * The peer structure to return when we get success message
131 struct GNUNET_TESTBED_Peer *peer;
136 * Data for OperationType OP_PEER_START and OP_PEER_STOP
138 struct PeerEventData {
140 * The handle of the peer to start
142 struct GNUNET_TESTBED_Peer *peer;
145 * The Peer churn callback to call when this operation is completed
147 GNUNET_TESTBED_PeerChurnCallback pcc;
150 * Closure for the above callback
157 * Data for the OperationType OP_PEER_DESTROY;
159 struct PeerDestroyData {
163 struct GNUNET_TESTBED_Peer *peer;
170 * Data for the OperationType OP_PEER_INFO
172 struct PeerInfoData {
174 * The peer whose information has been requested
176 struct GNUNET_TESTBED_Peer *peer;
179 * The Peer info callback to call when this operation has completed
181 GNUNET_TESTBED_PeerInfoCallback cb;
184 * The closure for peer info callback
189 * The type of peer information requested
191 enum GNUNET_TESTBED_PeerInformationType pit;
196 * Data for the operations of type OP_PEER_RECONFIGURE
198 struct PeerReconfigureData {
200 * The peer whose information has been requested
202 struct GNUNET_TESTBED_Peer *peer;
205 * The serialized new configuration template
210 * the size of the serialized configuration
217 * Data structure for OperationType OP_OVERLAY_CONNECT
219 struct OverlayConnectData {
221 * Peer A to connect to peer B
223 struct GNUNET_TESTBED_Peer *p1;
228 struct GNUNET_TESTBED_Peer *p2;
231 * The operation completion callback to call once this operation is done
233 GNUNET_TESTBED_OperationCompletionCallback cb;
236 * The closure for the above callback
241 * OperationContext for forwarded operations generated when peer1's controller doesn't have the
242 * configuration of peer2's controller for linking laterally to attemp an
243 * overlay connection between peer 1 and peer 2.
245 struct OperationContext *sub_opc;
249 struct ManageServiceData {
250 GNUNET_TESTBED_OperationCompletionCallback cb;
254 struct GNUNET_TESTBED_Peer *peer;
265 * Generate PeerGetConfigurationMessage
267 * @param peer_id the id of the peer whose information we have to get
268 * @param operation_id the ip of the operation that should be represented in
270 * @return the PeerGetConfigurationMessage
272 struct GNUNET_TESTBED_PeerGetConfigurationMessage *
273 GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id,
274 uint64_t operation_id);
278 * Adds a peer to the peer list
280 * @param peer the peer to add to the peer list
283 GNUNET_TESTBED_peer_register_(struct GNUNET_TESTBED_Peer *peer);
287 * Removes a peer from the peer list
289 * @param peer the peer to remove
292 GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer);
299 GNUNET_TESTBED_cleanup_peers_(void);
302 /* end of testbed_api_peers.h */