-remove debug message
[oweals/gnunet.git] / testbed / testbed_api_hosts.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_hosts.h
23  * @brief internal API to access the 'hosts' subsystem
24  * @author Christian Grothoff
25  */
26
27 #ifndef NEW_TESTING_API_HOSTS_H
28 #define NEW_TESTING_API_HOSTS_H
29
30 //#include "gnunet_testbed_service.h"
31 //#include "testbed_helper.h"
32 #include "testbed.h"
33
34
35 /**
36  * Lookup a host by ID.
37  *
38  * @param id global host ID assigned to the host; 0 is
39  *        reserved to always mean 'localhost'
40  * @return handle to the host, NULL on error
41  */
42 struct GNUNET_TESTBED_Host *
43 GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id);
44
45
46 /**
47  * Create a host by ID; given this host handle, we could not
48  * run peers at the host, but we can talk about the host
49  * internally.
50  *
51  * @param id global host ID assigned to the host; 0 is
52  *        reserved to always mean 'localhost'
53  * @param cfg the configuration to use as a template while starting a controller
54  *          on this host.  Operation queue sizes specific to a host are also
55  *          read from this configuration handle
56  * @return handle to the host, NULL on error
57  */
58 struct GNUNET_TESTBED_Host *
59 GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
60                                    const struct GNUNET_CONFIGURATION_Handle
61                                    *cfg);
62
63
64 /**
65  * Obtain a host's unique global ID.
66  *
67  * @param host handle to the host, NULL means 'localhost'
68  * @return id global host ID assigned to the host (0 is
69  *         'localhost', but then obviously not globally unique)
70  */
71 uint32_t
72 GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host);
73
74
75 /**
76  * Obtain the host's username
77  *
78  * @param host handle to the host, NULL means 'localhost'
79  * @return username to login to the host
80  */
81 const char *
82 GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host);
83
84
85 /**
86  * Obtain the host's ssh port
87  *
88  * @param host handle to the host, NULL means 'localhost'
89  * @return username to login to the host
90  */
91 uint16_t
92 GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host);
93
94
95 /**
96  * Obtain the host's configuration template
97  *
98  * @param host handle to the host
99  * @return the host's configuration template
100  */
101 const struct GNUNET_CONFIGURATION_Handle *
102 GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host);
103
104
105 /**
106  * Marks a host as registered with a controller
107  *
108  * @param host the host to mark
109  * @param controller the controller at which this host is registered
110  */
111 void
112 GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
113                                          const struct GNUNET_TESTBED_Controller
114                                          *controller);
115
116
117 /**
118  * Checks whether a host has been registered with the given controller
119  *
120  * @param host the host to check
121  * @param controller the controller at which host's registration is checked
122  * @return GNUNET_YES if registered; GNUNET_NO if not
123  */
124 int
125 GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
126                                     const struct GNUNET_TESTBED_Controller
127                                     *controller);
128
129
130 /**
131  * (re)sets the operation queue for parallel overlay connects
132  *
133  * @param h the host handle
134  * @param npoc the number of parallel overlay connects - the queue size
135  */
136 void
137 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
138                                                    GNUNET_TESTBED_Host *h,
139                                                    unsigned int npoc);
140
141
142 /**
143  * Releases a time slot thus making it available for be used again
144  *
145  * @param h the host handle
146  * @param index the index of the the time slot
147  * @param key the key to prove ownership of the timeslot
148  * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if the
149  *           time slot cannot be removed - this could be because of the index
150  *           greater than existing number of time slots or `key' being different
151  */
152 int
153 GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Host *h,
154                                    unsigned int index, void *key);
155
156
157 /**
158  * Function to update a time slot
159  *
160  * @param h the host handle
161  * @param index the index of the time slot to update
162  * @param key the key to identify ownership of the slot
163  * @param time the new time
164  * @param failed should this reading be treated as coming from a fail event
165  */
166 void
167 GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Host *h,
168                                   unsigned int index, void *key,
169                                   struct GNUNET_TIME_Relative time, int failed);
170
171
172 /**
173  * Returns a timing slot which will be exclusively locked
174  *
175  * @param h the host handle
176  * @param key a pointer which is associated to the returned slot; should not be
177  *          NULL. It serves as a key to determine the correct owner of the slot
178  * @return the time slot index in the array of time slots in the controller
179  *           handle
180  */
181 unsigned int
182 GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Host *h, void *key);
183
184
185 /**
186  * Queues the given operation in the queue for parallel overlay connects of the
187  * given host
188  *
189  * @param h the host handle
190  * @param op the operation to queue in the given host's parally overlay connect
191  *          queue 
192  */
193 void
194 GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h, 
195                                struct GNUNET_TESTBED_Operation *op);
196
197
198 /**
199  * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
200  * controller (testbed service)
201  *
202  * @param c the controller handler
203  * @param msg message received
204  * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
205  *           not
206  */
207 int
208 GNUNET_TESTBED_host_handle_addhostconfirm_ (struct GNUNET_TESTBED_Controller *c,
209                                             const struct
210                                             GNUNET_TESTBED_HostConfirmedMessage
211                                             *msg);
212
213 #endif
214 /* end of testbed_api_hosts.h */