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