53e4607ff3140df6b3347f5a67c1f7b0e0f1d002
[oweals/gnunet.git] / src / testbed / testbed_api.h
1 /*
2       This file is part of GNUnet
3       (C) 2012 Christian Grothoff (and other contributing authors)
4
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.
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       General Public License for more details.
14
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.
19  */
20
21 /**
22  * @file testbed/testbed_api.h
23  * @brief Interface for functions internally exported from testbed_api.c
24  * @author Sree Harsha Totakura
25  */
26
27 #ifndef TESTBED_API_H
28 #define TESTBED_API_H
29
30
31 /**
32  * Enumeration of operations
33  */
34 enum OperationType
35   {
36     /**
37      * Peer destroy operation
38      */
39     OP_PEER_DESTROY
40   };
41
42
43 /**
44  * The counter for generating unique operation ids. Use its current value and
45  * increment it (defined in testbed_api.c)
46  */
47 extern uint64_t GNUNET_TESTBED_operation_id;
48
49 /**
50  * Testbed operation structure
51  */
52 struct GNUNET_TESTBED_Operation
53 {
54   /**
55    * next pointer for DLL
56    */
57   struct GNUNET_TESTBED_Operation *next;
58
59   /**
60    * prev pointer for DLL
61    */
62   struct GNUNET_TESTBED_Operation *prev;
63
64   /**
65    * The ID for the operation;
66    */
67   uint64_t operation_id;
68
69   /**
70    * The type of operation
71    */
72   enum OperationType type;
73
74   /**
75    * Data specific to OperationType
76    */
77   void *data;
78 };
79
80
81 /**
82  * Queues a message in send queue for sending to the service
83  *
84  * @param controller the handle to the controller
85  * @param msg the message to queue
86  */
87 void
88 GNUNET_TESTBED_queue_message (struct GNUNET_TESTBED_Controller *controller,
89                               struct GNUNET_MessageHeader *msg);
90
91
92 /**
93  * Compresses given configuration using zlib compress
94  *
95  * @param config the serialized configuration
96  * @param size the size of config
97  * @param xconfig will be set to the compressed configuration (memory is fresly
98  *          allocated) 
99  * @return the size of the xconfig
100  */
101 size_t
102 GNUNET_TESTBED_compress_config (const char *config, size_t size,
103                                 char **xconfig);
104
105
106 /**
107  * Adds an operation to the queue of operations
108  *
109  * @param op the operation to add
110  */
111 void
112 GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op);
113
114 #endif