glitch in the license text detected by hyazinthe, thank you!
[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
16 /**
17  * @file testbed/testbed_api_hosts.h
18  * @brief internal API to access the 'hosts' subsystem
19  * @author Christian Grothoff
20  */
21
22 #ifndef TESTBED_API_HOSTS_H
23 #define TESTBED_API_HOSTS_H
24
25 //#include "gnunet_testbed_service.h"
26 //#include "testbed_helper.h"
27 #include "testbed.h"
28
29
30 /**
31  * handle for host registration
32  */
33 struct GNUNET_TESTBED_HostRegistrationHandle
34 {
35   /**
36    * The host being registered
37    */
38   struct GNUNET_TESTBED_Host *host;
39
40   /**
41    * The controller at which this host is being registered
42    */
43   struct GNUNET_TESTBED_Controller *c;
44
45   /**
46    * The Registartion completion callback
47    */
48   GNUNET_TESTBED_HostRegistrationCompletion cc;
49
50   /**
51    * The closure for above callback
52    */
53   void *cc_cls;
54 };
55
56
57 /**
58  * Lookup a host by ID.
59  *
60  * @param id global host ID assigned to the host; 0 is
61  *        reserved to always mean 'localhost'
62  * @return handle to the host, NULL on error
63  */
64 struct GNUNET_TESTBED_Host *
65 GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id);
66
67
68 /**
69  * Create a host by ID; given this host handle, we could not
70  * run peers at the host, but we can talk about the host
71  * internally.
72  *
73  * @param id global host ID assigned to the host; 0 is
74  *        reserved to always mean 'localhost'
75  * @param cfg the configuration to use as a template while starting a controller
76  *          on this host.  Operation queue sizes specific to a host are also
77  *          read from this configuration handle
78  * @return handle to the host, NULL on error
79  */
80 struct GNUNET_TESTBED_Host *
81 GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
82                                    const struct GNUNET_CONFIGURATION_Handle
83                                    *cfg);
84
85
86 /**
87  * Obtain a host's unique global ID.
88  *
89  * @param host handle to the host, NULL means 'localhost'
90  * @return id global host ID assigned to the host (0 is
91  *         'localhost', but then obviously not globally unique)
92  */
93 uint32_t
94 GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host);
95
96
97 /**
98  * Obtain the host's username
99  *
100  * @param host handle to the host, NULL means 'localhost'
101  * @return username to login to the host
102  */
103 const char *
104 GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host);
105
106
107 /**
108  * Obtain the host's ssh port
109  *
110  * @param host handle to the host, NULL means 'localhost'
111  * @return username to login to the host
112  */
113 uint16_t
114 GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host);
115
116
117 /**
118  * Obtain the host's configuration template
119  *
120  * @param host handle to the host
121  * @return the host's configuration template
122  */
123 const struct GNUNET_CONFIGURATION_Handle *
124 GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host);
125
126
127 /**
128  * Function to replace host's configuration
129  *
130  * @param host the host handle
131  * @param new_cfg the new configuration to replace the old one
132  */
133 void
134 GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
135                                   const struct GNUNET_CONFIGURATION_Handle *new_cfg);
136
137
138 /**
139  * Marks a host as registered with a controller
140  *
141  * @param host the host to mark
142  * @param controller the controller at which this host is registered
143  */
144 void
145 GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
146                                          const struct GNUNET_TESTBED_Controller
147                                          *controller);
148
149
150 /**
151  * Unmarks a host registered at a controller
152  *
153  * @param host the host to unmark
154  * @param controller the controller at which this host has to be unmarked
155  */
156 void
157 GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
158                                     const struct GNUNET_TESTBED_Controller
159                                     *const controller);
160
161
162 /**
163  * Checks whether a host has been registered with the given controller
164  *
165  * @param host the host to check
166  * @param controller the controller at which host's registration is checked
167  * @return GNUNET_YES if registered; GNUNET_NO if not
168  */
169 int
170 GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
171                                     const struct GNUNET_TESTBED_Controller
172                                     *controller);
173
174
175 /**
176  * Queues the given operation in the queue for parallel overlay connects of the
177  * given host
178  *
179  * @param h the host handle
180  * @param op the operation to queue in the given host's parally overlay connect
181  *          queue
182  */
183 void
184 GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h,
185                                struct GNUNET_TESTBED_Operation *op);
186
187
188 /**
189  * Sends termination signal to the controller's helper process
190  *
191  * @param cproc the handle to the controller's helper process
192  */
193 void
194 GNUNET_TESTBED_controller_kill_ (struct GNUNET_TESTBED_ControllerProc *cproc);
195
196
197 /**
198  * Cleans-up the controller's helper process handle
199  *
200  * @param cproc the handle to the controller's helper process
201  */
202 void
203 GNUNET_TESTBED_controller_destroy_ (struct GNUNET_TESTBED_ControllerProc
204                                     *cproc);
205
206
207 /**
208  * Resolves the hostname of the host to an ip address
209  *
210  * @param host the host whose hostname is to be resolved
211  */
212 void
213 GNUNET_TESTBED_host_resolve_ (struct GNUNET_TESTBED_Host *host);
214
215
216 #endif
217 /* end of testbed_api_hosts.h */