testbed_api_hosts.h 6.1 KB

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