-host registration with controller
[oweals/gnunet.git] / src / testbed / testbed_api_hosts.h
1 /*
2       This file is part of GNUnet
3       (C) 2008--2012 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 #ifndef NEW_TESTING_API_HOSTS_H
27 #define NEW_TESTING_API_HOSTS_H
28
29 #include "gnunet_testbed_service.h"
30 #include "gnunet_helper_lib.h"
31
32
33 /**
34  * Lookup a host by ID.
35  * 
36  * @param id global host ID assigned to the host; 0 is
37  *        reserved to always mean 'localhost'
38  * @return handle to the host, NULL on error
39  */
40 struct GNUNET_TESTBED_Host *
41 GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id);
42
43
44 /**
45  * Create a host by ID; given this host handle, we could not
46  * run peers at the host, but we can talk about the host
47  * internally.
48  * 
49  * @param id global host ID assigned to the host; 0 is
50  *        reserved to always mean 'localhost'
51  * @return handle to the host, NULL on error
52  */
53 struct GNUNET_TESTBED_Host *
54 GNUNET_TESTBED_host_create_by_id_ (uint32_t id);
55
56
57 /**
58  * Obtain a host's unique global ID.
59  * 
60  * @param host handle to the host, NULL means 'localhost'
61  * @return id global host ID assigned to the host (0 is
62  *         'localhost', but then obviously not globally unique)
63  */
64 uint32_t
65 GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host);
66
67
68 /**
69  * Obtain the host's hostname.
70  * 
71  * @param host handle to the host, NULL means 'localhost'
72  * @return hostname of the host
73  */
74 const char *
75 GNUNET_TESTBED_host_get_hostname_ (const struct GNUNET_TESTBED_Host *host);
76
77
78 /**
79  * Obtain the host's username
80  * 
81  * @param host handle to the host, NULL means 'localhost'
82  * @return username to login to the host
83  */
84 const char *
85 GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host);
86
87
88 /**
89  * Obtain the host's ssh port
90  * 
91  * @param host handle to the host, NULL means 'localhost'
92  * @return username to login to the host
93  */
94 uint16_t
95 GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host);
96
97
98 /**
99  * Opaque wrapper around GNUNET_HELPER_Handle
100  */
101 struct GNUNET_TESTBED_HelperHandle;
102
103
104 /**
105  * Run a given helper process at the given host.  Communication
106  * with the helper will be via GNUnet messages on stdin/stdout.
107  * Runs the process via 'ssh' at the specified host, or locally.
108  * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API.
109  * 
110  * @param host host to use, use "NULL" for localhost
111  * @param binary_argv binary name and command-line arguments to give to the binary
112  * @return handle to terminate the command, NULL on error
113  */
114 struct GNUNET_TESTBED_HelperHandle *
115 GNUNET_TESTBED_host_run_ (const struct GNUNET_TESTBED_Host *host,
116                           char *const binary_argv[]);
117
118
119 /**
120  * Stops a helper in the HelperHandle using GNUNET_HELPER_stop
121  *
122  * @param handle the handle returned from GNUNET_TESTBED_host_start_
123  */
124 void
125 GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle);
126
127
128 /**
129  * Marks a host as registered with a controller
130  *
131  * @param host the host to mark
132  * @param controller the controller at which this host is registered
133  */
134 void
135 GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host,
136                                          const struct GNUNET_TESTBED_Controller
137                                          *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 #endif
153 /* end of testbed_api_hosts.h */