testcases for peer get information
[oweals/gnunet.git] / src / testbed / testbed_api_peers.h
1 /*
2       This file is part of GNUnet
3       (C) 2008--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_peers.h
23  * @brief internal API to access the 'peers' subsystem
24  * @author Christian Grothoff
25  */
26 #ifndef NEW_TESTING_API_PEERS_H
27 #define NEW_TESTING_API_PEERS_H
28
29 #include "gnunet_testbed_service.h"
30 #include "gnunet_helper_lib.h"
31
32
33 /**
34  * Details about a peer; kept in a separate struct to avoid bloating
35  * memory consumption everywhere...
36  */
37 struct PeerDetails
38 {
39   /**
40    * Configuration of the peer; NULL if we are not sure what the peer's correct
41    * configuration actually is; non-NULL if this peer is controlled by this
42    * process.
43    */
44   struct GNUNET_CONFIGURATION_Handle *cfg;
45
46   //PEER_DETAILS
47 };
48
49
50 /**
51  * A peer controlled by the testing framework.  A peer runs
52  * at a particular host.
53  */ 
54 struct GNUNET_TESTBED_Peer
55 {
56   /**
57    * Our controller context (not necessarily the controller
58    * that is responsible for starting/running the peer!).
59    */
60   struct GNUNET_TESTBED_Controller *controller;
61                            
62   /**
63    * Which host does this peer run on?
64    */
65   struct GNUNET_TESTBED_Host *host;
66
67   /**
68    * Globally unique ID of the peer.
69    */
70   uint32_t unique_id;
71
72   /**
73    * Internals of the peer for the controlling process; NULL if 
74    * this process is not controlling this peer.
75    */
76   struct PeerDetails *details;
77
78 };
79
80
81 /**
82  * Data for the OperationType OP_PEER_CREATE
83  */
84 struct PeerCreateData
85 {
86   /**
87    * THe call back to call when we receive peer create success message
88    */
89   GNUNET_TESTBED_PeerCreateCallback cb;
90   
91   /**
92    * The closure for the above callback
93    */
94   void *cls;
95
96   /**
97    * The peer structure to return when we get success message
98    */
99   struct GNUNET_TESTBED_Peer *peer;
100
101 };
102
103
104 /**
105  * Data for the OperationType OP_PEER_DESTROY;
106  */
107 struct PeerDestroyData
108 {
109   /**
110    * The peer structure
111    */
112   struct GNUNET_TESTBED_Peer *peer;
113
114   //PEERDESTROYDATA
115 };
116
117
118 /**
119  * Data for the OperationType OP_PEER_INFO
120  */
121 struct PeerInfoData
122 {
123   /**
124    * The peer whose information has been requested
125    */
126   struct GNUNET_TESTBED_Peer *peer;
127   
128   /**
129    * The type of peer information requested
130    */
131   enum GNUNET_TESTBED_PeerInformationType pit;
132 };
133
134
135 /**
136  * Create the given peer at the specified host using the given
137  * controller.  If the given controller is not running on the target
138  * host, it should find or create a controller at the target host and
139  * delegate creating the peer.  Explicit delegation paths can be setup
140  * using 'GNUNET_TESTBED_controller_link'.  If no explicit delegation
141  * path exists, a direct link with a subordinate controller is setup
142  * for the first delegated peer to a particular host; the subordinate
143  * controller is then destroyed once the last peer that was delegated
144  * to the remote host is stopped.  This function is used in particular
145  * if some other controller has already assigned a unique ID to the
146  * peer.
147  *
148  * Creating the peer only creates the handle to manipulate and further
149  * configure the peer; use "GNUNET_TESTBED_peer_start" and
150  * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
151  * processes.
152  *
153  * Note that the given configuration will be adjusted by the
154  * controller to avoid port/path conflicts with other peers.
155  * The "final" configuration can be obtained using
156  * 'GNUNET_TESTBED_peer_get_information'.
157  *
158  * @param unique_id unique ID for this peer
159  * @param controller controller process to use
160  * @param host host to run the peer on
161  * @param cfg configuration to use for the peer
162  * @param cb the callback to call when the peer has been created
163  * @param cls the closure to the above callback
164  * @return the operation handle
165  */
166 struct GNUNET_TESTBED_Operation *
167 GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id,
168                                      struct GNUNET_TESTBED_Controller *controller,
169                                      struct GNUNET_TESTBED_Host *host,
170                                      const struct GNUNET_CONFIGURATION_Handle *cfg,
171                                      GNUNET_TESTBED_PeerCreateCallback cb,
172                                      void *cls);
173
174
175
176 #endif
177 /* end of testbed_api_peers.h */