testbed_api_hosts.h 6.0 KB

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