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