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
32 * Enumeration of operations
37 * Peer create operation
42 * Peer start operation
52 * Peer destroy operation
57 * Get peer information operation
62 * Overlay connection operation
72 * Link controllers operation
80 * Testbed operation structure
82 struct GNUNET_TESTBED_Operation
85 * next pointer for DLL
87 struct GNUNET_TESTBED_Operation *next;
90 * prev pointer for DLL
92 struct GNUNET_TESTBED_Operation *prev;
95 * The controller on which this operation operates
97 struct GNUNET_TESTBED_Controller *controller;
100 * The ID for the operation;
102 uint64_t operation_id;
105 * The type of operation
107 enum OperationType type;
110 * Data specific to OperationType
117 * The message queue for sending messages to the controller service
122 * Structure for a controller link
124 struct ControllerLink;
128 * Enumeration of states of OperationContext
130 enum OperationContextState
133 * The initial state where the associated operation has just been created
134 * and is waiting in the operation queues to be started
139 * The operation has been started. It may occupy some resources which are to
140 * be freed if cancelled.
145 * The operation has finished. The end results of this operation may occupy
146 * some resources which are to be freed by operation_done
153 * Context information for GNUNET_TESTBED_Operation
155 struct OperationContext
160 struct OperationContext *next;
165 struct OperationContext *prev;
168 * The controller to which this operation context belongs to
170 struct GNUNET_TESTBED_Controller *c;
175 struct GNUNET_TESTBED_Operation *op;
178 * Data relevant to the operation
183 * The id of the opearation
188 * The type of operation
190 enum OperationType type;
193 * The state of the operation
195 enum OperationContextState state;
200 * Handle to interact with a GNUnet testbed controller. Each
201 * controller has at least one master handle which is created when the
202 * controller is created; this master handle interacts with the
203 * controller process, destroying it destroys the controller (by
204 * closing stdin of the controller process). Additionally,
205 * controllers can interact with each other (in a P2P fashion); those
206 * links are established via TCP/IP on the controller's service port.
208 struct GNUNET_TESTBED_Controller
212 * The host where the controller is running
214 struct GNUNET_TESTBED_Host *host;
217 * The controller callback
219 GNUNET_TESTBED_ControllerCallback cc;
222 * The closure for controller callback
227 * The configuration to use while connecting to controller
229 struct GNUNET_CONFIGURATION_Handle *cfg;
232 * The client connection handle to the controller service
234 struct GNUNET_CLIENT_Connection *client;
237 * The head of the message queue
239 struct MessageQueue *mq_head;
242 * The tail of the message queue
244 struct MessageQueue *mq_tail;
247 * The head of the ControllerLink list
249 struct ControllerLink *cl_head;
252 * The tail of the ControllerLink list
254 struct ControllerLink *cl_tail;
257 * The client transmit handle
259 struct GNUNET_CLIENT_TransmitHandle *th;
262 * The host registration handle; NULL if no current registration requests are
265 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
268 * The head of the opeartion context queue
270 struct OperationContext *ocq_head;
273 * The tail of the operation context queue
275 struct OperationContext *ocq_tail;
278 * Operation queue for simultaneous operations
280 struct OperationQueue *opq_parallel_operations;
283 * The operation id counter. use current value and increment
285 uint64_t operation_counter;
288 * The controller event mask
293 * Did we start the receive loop yet?
298 * Did we create the host for this?
305 * Queues a message in send queue for sending to the service
307 * @param controller the handle to the controller
308 * @param msg the message to queue
311 GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
312 struct GNUNET_MessageHeader *msg);
316 * Compresses given configuration using zlib compress
318 * @param config the serialized configuration
319 * @param size the size of config
320 * @param xconfig will be set to the compressed configuration (memory is fresly
322 * @return the size of the xconfig
325 GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
330 * Adds an operation to the queue of operations
332 * @param op the operation to add
335 GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op);
339 * Creates a helper initialization message. Only for testing.
341 * @param cname the ip address of the controlling host
342 * @param cfg the configuration that has to used to start the testbed service
344 * @return the initialization message
346 struct GNUNET_TESTBED_HelperInit *
347 GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
349 GNUNET_CONFIGURATION_Handle *cfg);
353 * Sends the given message as an operation. The given callback is called when a
354 * reply for the operation is available. Call
355 * GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned
356 * operation context if the cc hasn't been called
358 * @param controller the controller to which the message has to be sent
359 * @param operation_id the operation id of the message
360 * @param msg the message to send
361 * @param cc the callback to call when reply is available
362 * @param cc_cls the closure for the above callback
363 * @return the operation context which can be used to cancel the forwarded
366 struct OperationContext *
367 GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
369 uint64_t operation_id,
370 const struct GNUNET_MessageHeader *msg,
371 GNUNET_CLIENT_MessageHandler cc,
375 * Function to cancel an operation created by simply forwarding an operation
378 * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
381 GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc);
385 /* end of testbed_api.h */