fix 2893: Move adaptive parallelisation mechanism to operation queues
[oweals/gnunet.git] / src / testbed / testbed_api_hosts.h
1 /*
2       This file is part of GNUnet
3       (C) 2008--2013 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  * Function to replace host's configuration
107  *
108  * @param host the host handle
109  * @param new_cfg the new configuration to replace the old one
110  */
111 void
112 GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
113                                   const struct GNUNET_CONFIGURATION_Handle *new_cfg);
114
115
116 /**
117  * Marks a host as registered with a controller
118  *
119  * @param host the host to mark
120  * @param controller the controller at which this host is registered
121  */
122 void
123 GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
124                                          const struct GNUNET_TESTBED_Controller
125                                          *controller);
126
127
128 /**
129  * Unmarks a host registered at a controller
130  *
131  * @param host the host to unmark
132  * @param controller the controller at which this host has to be unmarked
133  */
134 void
135 GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
136                                     const struct GNUNET_TESTBED_Controller
137                                     *const controller);
138
139
140 /**
141  * Checks whether a host has been registered with the given controller
142  *
143  * @param host the host to check
144  * @param controller the controller at which host's registration is checked
145  * @return GNUNET_YES if registered; GNUNET_NO if not
146  */
147 int
148 GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
149                                     const struct GNUNET_TESTBED_Controller
150                                     *controller);
151
152
153 /**
154  * Queues the given operation in the queue for parallel overlay connects of the
155  * given host
156  *
157  * @param h the host handle
158  * @param op the operation to queue in the given host's parally overlay connect
159  *          queue 
160  */
161 void
162 GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h, 
163                                struct GNUNET_TESTBED_Operation *op);
164
165
166 /**
167  * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
168  * controller (testbed service)
169  *
170  * @param c the controller handler
171  * @param msg message received
172  * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
173  *           not
174  */
175 int
176 GNUNET_TESTBED_host_handle_addhostconfirm_ (struct GNUNET_TESTBED_Controller *c,
177                                             const struct
178                                             GNUNET_TESTBED_HostConfirmedMessage
179                                             *msg);
180
181
182 /**
183  * Sends termination signal to the controller's helper process
184  *
185  * @param cproc the handle to the controller's helper process
186  */
187 void
188 GNUNET_TESTBED_controller_kill_ (struct GNUNET_TESTBED_ControllerProc *cproc);
189
190
191 /**
192  * Cleans-up the controller's helper process handle
193  *
194  * @param cproc the handle to the controller's helper process
195  */
196 void
197 GNUNET_TESTBED_controller_destroy_ (struct GNUNET_TESTBED_ControllerProc
198                                     *cproc);
199
200
201 /**
202  * Resolves the hostname of the host to an ip address
203  *
204  * @param host the host whose hostname is to be resolved
205  */
206 void
207 GNUNET_TESTBED_host_resolve_ (struct GNUNET_TESTBED_Host *host);
208
209
210 #endif
211 /* end of testbed_api_hosts.h */