uncrustify as demanded.
[oweals/gnunet.git] / src / testbed / testbed_api_hosts.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2008--2013 GNUnet e.V.
4
5       GNUnet is free software: you can redistribute it and/or modify it
6       under the terms of the GNU Affero General Public License as published
7       by the Free Software Foundation, either version 3 of the License,
8       or (at your 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       Affero General Public License for more details.
14
15       You should have received a copy of the GNU Affero General Public License
16       along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
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 TESTBED_API_HOSTS_H
28 #define TESTBED_API_HOSTS_H
29
30 //#include "gnunet_testbed_service.h"
31 //#include "testbed_helper.h"
32 #include "testbed.h"
33
34
35 /**
36  * handle for host registration
37  */
38 struct GNUNET_TESTBED_HostRegistrationHandle {
39   /**
40    * The host being registered
41    */
42   struct GNUNET_TESTBED_Host *host;
43
44   /**
45    * The controller at which this host is being registered
46    */
47   struct GNUNET_TESTBED_Controller *c;
48
49   /**
50    * The Registartion completion callback
51    */
52   GNUNET_TESTBED_HostRegistrationCompletion cc;
53
54   /**
55    * The closure for above callback
56    */
57   void *cc_cls;
58 };
59
60
61 /**
62  * Lookup a host by ID.
63  *
64  * @param id global host ID assigned to the host; 0 is
65  *        reserved to always mean 'localhost'
66  * @return handle to the host, NULL on error
67  */
68 struct GNUNET_TESTBED_Host *
69 GNUNET_TESTBED_host_lookup_by_id_(uint32_t id);
70
71
72 /**
73  * Create a host by ID; given this host handle, we could not
74  * run peers at the host, but we can talk about the host
75  * internally.
76  *
77  * @param id global host ID assigned to the host; 0 is
78  *        reserved to always mean 'localhost'
79  * @param cfg the configuration to use as a template while starting a controller
80  *          on this host.  Operation queue sizes specific to a host are also
81  *          read from this configuration handle
82  * @return handle to the host, NULL on error
83  */
84 struct GNUNET_TESTBED_Host *
85 GNUNET_TESTBED_host_create_by_id_(uint32_t id,
86                                   const struct GNUNET_CONFIGURATION_Handle
87                                   *cfg);
88
89
90 /**
91  * Obtain a host's unique global ID.
92  *
93  * @param host handle to the host, NULL means 'localhost'
94  * @return id global host ID assigned to the host (0 is
95  *         'localhost', but then obviously not globally unique)
96  */
97 uint32_t
98 GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host);
99
100
101 /**
102  * Obtain the host's username
103  *
104  * @param host handle to the host, NULL means 'localhost'
105  * @return username to login to the host
106  */
107 const char *
108 GNUNET_TESTBED_host_get_username_(const struct GNUNET_TESTBED_Host *host);
109
110
111 /**
112  * Obtain the host's ssh port
113  *
114  * @param host handle to the host, NULL means 'localhost'
115  * @return username to login to the host
116  */
117 uint16_t
118 GNUNET_TESTBED_host_get_ssh_port_(const struct GNUNET_TESTBED_Host *host);
119
120
121 /**
122  * Obtain the host's configuration template
123  *
124  * @param host handle to the host
125  * @return the host's configuration template
126  */
127 const struct GNUNET_CONFIGURATION_Handle *
128 GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host);
129
130
131 /**
132  * Function to replace host's configuration
133  *
134  * @param host the host handle
135  * @param new_cfg the new configuration to replace the old one
136  */
137 void
138 GNUNET_TESTBED_host_replace_cfg_(struct GNUNET_TESTBED_Host *host,
139                                  const struct GNUNET_CONFIGURATION_Handle *new_cfg);
140
141
142 /**
143  * Marks a host as registered with a controller
144  *
145  * @param host the host to mark
146  * @param controller the controller at which this host is registered
147  */
148 void
149 GNUNET_TESTBED_mark_host_registered_at_(struct GNUNET_TESTBED_Host *host,
150                                         const struct GNUNET_TESTBED_Controller
151                                         *controller);
152
153
154 /**
155  * Unmarks a host registered at a controller
156  *
157  * @param host the host to unmark
158  * @param controller the controller at which this host has to be unmarked
159  */
160 void
161 GNUNET_TESTBED_deregister_host_at_(struct GNUNET_TESTBED_Host *host,
162                                    const struct GNUNET_TESTBED_Controller
163                                    *const controller);
164
165
166 /**
167  * Checks whether a host has been registered with the given controller
168  *
169  * @param host the host to check
170  * @param controller the controller at which host's registration is checked
171  * @return GNUNET_YES if registered; GNUNET_NO if not
172  */
173 int
174 GNUNET_TESTBED_is_host_registered_(const struct GNUNET_TESTBED_Host *host,
175                                    const struct GNUNET_TESTBED_Controller
176                                    *controller);
177
178
179 /**
180  * Queues the given operation in the queue for parallel overlay connects of the
181  * given host
182  *
183  * @param h the host handle
184  * @param op the operation to queue in the given host's parally overlay connect
185  *          queue
186  */
187 void
188 GNUNET_TESTBED_host_queue_oc_(struct GNUNET_TESTBED_Host *h,
189                               struct GNUNET_TESTBED_Operation *op);
190
191
192 /**
193  * Sends termination signal to the controller's helper process
194  *
195  * @param cproc the handle to the controller's helper process
196  */
197 void
198 GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc);
199
200
201 /**
202  * Cleans-up the controller's helper process handle
203  *
204  * @param cproc the handle to the controller's helper process
205  */
206 void
207 GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc
208                                    *cproc);
209
210
211 /**
212  * Resolves the hostname of the host to an ip address
213  *
214  * @param host the host whose hostname is to be resolved
215  */
216 void
217 GNUNET_TESTBED_host_resolve_(struct GNUNET_TESTBED_Host *host);
218
219
220 #endif
221 /* end of testbed_api_hosts.h */