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"
33 * Enumeration of operations
38 * Peer create operation
43 * Peer start operation
53 * Peer destroy operation
58 * Get peer information operation
63 * Overlay connection operation
73 * Link controllers operation
78 * Service connect operation
86 * Testbed operation structure
88 struct GNUNET_TESTBED_Operation
91 * next pointer for DLL
93 struct GNUNET_TESTBED_Operation *next;
96 * prev pointer for DLL
98 struct GNUNET_TESTBED_Operation *prev;
101 * The controller on which this operation operates
103 struct GNUNET_TESTBED_Controller *controller;
106 * The ID for the operation;
108 uint64_t operation_id;
111 * The type of operation
113 enum OperationType type;
116 * Data specific to OperationType
123 * The message queue for sending messages to the controller service
128 * Structure for a controller link
130 struct ControllerLink;
134 * Enumeration of states of OperationContext
136 enum OperationContextState
139 * The initial state where the associated operation has just been created
140 * and is waiting in the operation queues to be started
145 * The operation has been started. It may occupy some resources which are to
146 * be freed if cancelled.
151 * The operation has finished. The end results of this operation may occupy
152 * some resources which are to be freed by operation_done
159 * Context information for GNUNET_TESTBED_Operation
161 struct OperationContext
166 struct OperationContext *next;
171 struct OperationContext *prev;
174 * The controller to which this operation context belongs to
176 struct GNUNET_TESTBED_Controller *c;
181 struct GNUNET_TESTBED_Operation *op;
184 * Data relevant to the operation
189 * The id of the opearation
194 * The type of operation
196 enum OperationType type;
199 * The state of the operation
201 enum OperationContextState state;
206 * Handle to interact with a GNUnet testbed controller. Each
207 * controller has at least one master handle which is created when the
208 * controller is created; this master handle interacts with the
209 * controller process, destroying it destroys the controller (by
210 * closing stdin of the controller process). Additionally,
211 * controllers can interact with each other (in a P2P fashion); those
212 * links are established via TCP/IP on the controller's service port.
214 struct GNUNET_TESTBED_Controller
218 * The host where the controller is running
220 struct GNUNET_TESTBED_Host *host;
223 * The controller callback
225 GNUNET_TESTBED_ControllerCallback cc;
228 * The closure for controller callback
233 * The configuration to use while connecting to controller
235 struct GNUNET_CONFIGURATION_Handle *cfg;
238 * The client connection handle to the controller service
240 struct GNUNET_CLIENT_Connection *client;
243 * The head of the message queue
245 struct MessageQueue *mq_head;
248 * The tail of the message queue
250 struct MessageQueue *mq_tail;
253 * The head of the ControllerLink list
255 struct ControllerLink *cl_head;
258 * The tail of the ControllerLink list
260 struct ControllerLink *cl_tail;
263 * The client transmit handle
265 struct GNUNET_CLIENT_TransmitHandle *th;
268 * The host registration handle; NULL if no current registration requests are
271 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
274 * The head of the opeartion context queue
276 struct OperationContext *ocq_head;
279 * The tail of the operation context queue
281 struct OperationContext *ocq_tail;
284 * Operation queue for simultaneous operations
286 struct OperationQueue *opq_parallel_operations;
289 * Operation queue for simultaneous service connections
291 struct OperationQueue *opq_parallel_service_connections;
294 * The operation id counter. use current value and increment
296 uint64_t operation_counter;
299 * The controller event mask
304 * Did we start the receive loop yet?
309 * Did we create the host for this?
316 * Queues a message in send queue for sending to the service
318 * @param controller the handle to the controller
319 * @param msg the message to queue
322 GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
323 struct GNUNET_MessageHeader *msg);
327 * Compresses given configuration using zlib compress
329 * @param config the serialized configuration
330 * @param size the size of config
331 * @param xconfig will be set to the compressed configuration (memory is fresly
333 * @return the size of the xconfig
336 GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
341 * Adds an operation to the queue of operations
343 * @param op the operation to add
346 GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op);
350 * Creates a helper initialization message. Only for testing.
352 * @param cname the ip address of the controlling host
353 * @param cfg the configuration that has to used to start the testbed service
355 * @return the initialization message
357 struct GNUNET_TESTBED_HelperInit *
358 GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
360 GNUNET_CONFIGURATION_Handle *cfg);
364 * Sends the given message as an operation. The given callback is called when a
365 * reply for the operation is available. Call
366 * GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned
367 * operation context if the cc hasn't been called
369 * @param controller the controller to which the message has to be sent
370 * @param operation_id the operation id of the message
371 * @param msg the message to send
372 * @param cc the callback to call when reply is available
373 * @param cc_cls the closure for the above callback
374 * @return the operation context which can be used to cancel the forwarded
377 struct OperationContext *
378 GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
380 uint64_t operation_id,
381 const struct GNUNET_MessageHeader *msg,
382 GNUNET_CLIENT_MessageHandler cc,
386 * Function to cancel an operation created by simply forwarding an operation
389 * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
392 GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc);
396 /* end of testbed_api.h */