2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file testbed/testbed_api.h
23 * @brief Interface for functions internally exported from testbed_api.c
24 * @author Sree Harsha Totakura
30 #include "gnunet_testbed_service.h"
34 * Enumeration of operations
39 * Peer create operation
44 * Peer start operation
54 * Peer destroy operation
59 * Get peer information operation
64 * Overlay connection operation
74 * Link controllers operation
82 * Testbed operation structure
84 struct GNUNET_TESTBED_Operation
87 * next pointer for DLL
89 struct GNUNET_TESTBED_Operation *next;
92 * prev pointer for DLL
94 struct GNUNET_TESTBED_Operation *prev;
97 * The controller on which this operation operates
99 struct GNUNET_TESTBED_Controller *controller;
102 * The ID for the operation;
104 uint64_t operation_id;
107 * The type of operation
109 enum OperationType type;
112 * Data specific to OperationType
119 * The message queue for sending messages to the controller service
124 * Structure for a controller link
126 struct ControllerLink;
130 * Enumeration of states of OperationContext
132 enum OperationContextState
135 * The initial state where the associated operation has just been created
136 * and is waiting in the operation queues to be started
141 * The operation has been started. It may occupy some resources which are to
142 * be freed if cancelled.
147 * The operation has finished. The end results of this operation may occupy
148 * some resources which are to be freed by operation_done
155 * Context information for GNUNET_TESTBED_Operation
157 struct OperationContext
162 struct OperationContext *next;
167 struct OperationContext *prev;
170 * The controller to which this operation context belongs to
172 struct GNUNET_TESTBED_Controller *c;
177 struct GNUNET_TESTBED_Operation *op;
180 * Data relevant to the operation
185 * The id of the opearation
190 * The type of operation
192 enum OperationType type;
195 * The state of the operation
197 enum OperationContextState state;
202 * Handle to interact with a GNUnet testbed controller. Each
203 * controller has at least one master handle which is created when the
204 * controller is created; this master handle interacts with the
205 * controller process, destroying it destroys the controller (by
206 * closing stdin of the controller process). Additionally,
207 * controllers can interact with each other (in a P2P fashion); those
208 * links are established via TCP/IP on the controller's service port.
210 struct GNUNET_TESTBED_Controller
214 * The host where the controller is running
216 struct GNUNET_TESTBED_Host *host;
219 * The controller callback
221 GNUNET_TESTBED_ControllerCallback cc;
224 * The closure for controller callback
229 * The configuration to use while connecting to controller
231 struct GNUNET_CONFIGURATION_Handle *cfg;
234 * The client connection handle to the controller service
236 struct GNUNET_CLIENT_Connection *client;
239 * The head of the message queue
241 struct MessageQueue *mq_head;
244 * The tail of the message queue
246 struct MessageQueue *mq_tail;
249 * The head of the ControllerLink list
251 struct ControllerLink *cl_head;
254 * The tail of the ControllerLink list
256 struct ControllerLink *cl_tail;
259 * The client transmit handle
261 struct GNUNET_CLIENT_TransmitHandle *th;
264 * The host registration handle; NULL if no current registration requests are
267 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
270 * The head of the opeartion context queue
272 struct OperationContext *ocq_head;
275 * The tail of the operation context queue
277 struct OperationContext *ocq_tail;
280 * Operation queue for simultaneous operations
282 struct OperationQueue *opq_parallel_operations;
285 * Operation queue for simultaneous service connections
287 struct OperationQueue *opq_parallel_service_connections;
290 * The operation id counter. use current value and increment
292 uint64_t operation_counter;
295 * The controller event mask
300 * Did we start the receive loop yet?
305 * Did we create the host for this?
312 * Queues a message in send queue for sending to the service
314 * @param controller the handle to the controller
315 * @param msg the message to queue
318 GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
319 struct GNUNET_MessageHeader *msg);
323 * Compresses given configuration using zlib compress
325 * @param config the serialized configuration
326 * @param size the size of config
327 * @param xconfig will be set to the compressed configuration (memory is fresly
329 * @return the size of the xconfig
332 GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
337 * Adds an operation to the queue of operations
339 * @param op the operation to add
342 GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op);
346 * Creates a helper initialization message. Only for testing.
348 * @param cname the ip address of the controlling host
349 * @param cfg the configuration that has to used to start the testbed service
351 * @return the initialization message
353 struct GNUNET_TESTBED_HelperInit *
354 GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
355 const struct GNUNET_CONFIGURATION_Handle
360 * Sends the given message as an operation. The given callback is called when a
361 * reply for the operation is available. Call
362 * GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned
363 * operation context if the cc hasn't been called
365 * @param controller the controller to which the message has to be sent
366 * @param operation_id the operation id of the message
367 * @param msg the message to send
368 * @param cc the callback to call when reply is available
369 * @param cc_cls the closure for the above callback
370 * @return the operation context which can be used to cancel the forwarded
373 struct OperationContext *
374 GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
375 *controller, uint64_t operation_id,
376 const struct GNUNET_MessageHeader *msg,
377 GNUNET_CLIENT_MessageHandler cc,
381 * Function to cancel an operation created by simply forwarding an operation
384 * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
387 GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc);
391 * Generates configuration by parsing Peer configuration information reply message
393 * @param msg the peer configuration information message
394 * @return handle to the parsed configuration
396 struct GNUNET_CONFIGURATION_Handle *
397 GNUNET_TESTBED_get_config_from_peerinfo_msg_ (const struct
398 GNUNET_TESTBED_PeerConfigurationInformationMessage
403 * Checks the integrity of the OpeationFailureEventMessage and if good returns
404 * the error message it contains.
406 * @param msg the OperationFailureEventMessage
407 * @return the error message
410 GNUNET_TESTBED_parse_error_string_ (const struct
411 GNUNET_TESTBED_OperationFailureEventMessage
415 /* end of testbed_api.h */