gnunet-service-testbed_links.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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/gnunet-service-testbed_links.h
  18. * @brief TESTBED service components that deals with starting slave controllers
  19. * and establishing lateral links between controllers
  20. * @author Sree Harsha Totakura
  21. */
  22. /**
  23. * A connected controller which is not our child
  24. */
  25. struct Neighbour;
  26. /**
  27. * Structure representing a connected(directly-linked) controller
  28. */
  29. struct Slave
  30. {
  31. /**
  32. * The controller process handle if we had started the controller
  33. */
  34. struct GNUNET_TESTBED_ControllerProc *controller_proc;
  35. /**
  36. * The controller handle
  37. */
  38. struct GNUNET_TESTBED_Controller *controller;
  39. /**
  40. * handle to lcc which is associated with this slave startup. Should be set to
  41. * NULL when the slave has successfully started up
  42. */
  43. struct LinkControllersContext *lcc;
  44. /**
  45. * Head of the host registration DLL
  46. */
  47. struct HostRegistration *hr_dll_head;
  48. /**
  49. * Tail of the host registration DLL
  50. */
  51. struct HostRegistration *hr_dll_tail;
  52. /**
  53. * The current host registration handle
  54. */
  55. struct GNUNET_TESTBED_HostRegistrationHandle *rhandle;
  56. /**
  57. * Hashmap to hold Registered host contexts
  58. */
  59. struct GNUNET_CONTAINER_MultiHashMap *reghost_map;
  60. /**
  61. * The id of the host this controller is running on
  62. */
  63. uint32_t host_id;
  64. };
  65. /**
  66. * A list of directly linked neighbours
  67. */
  68. extern struct Slave **GST_slave_list;
  69. /**
  70. * The size of directly linked neighbours list
  71. */
  72. extern unsigned int GST_slave_list_size;
  73. /**
  74. * Cleans up the neighbour list
  75. */
  76. void
  77. GST_neighbour_list_clean (void);
  78. /**
  79. * Get a neighbour from the neighbour list
  80. *
  81. * @param id the index of the neighbour in the neighbour list
  82. * @return the Neighbour; NULL if the given index in invalid (index greater than
  83. * the list size or neighbour at that index is NULL)
  84. */
  85. struct Neighbour *
  86. GST_get_neighbour (uint32_t id);
  87. /**
  88. * Function to cleanup the neighbour connect contexts
  89. */
  90. void
  91. GST_free_nccq (void);
  92. /**
  93. * Notification context to be used to notify when connection to the neighbour's
  94. * controller is opened
  95. */
  96. struct NeighbourConnectNotification;
  97. /**
  98. * The notification callback to call when we are connect to neighbour
  99. *
  100. * @param cls the closure given to GST_neighbour_get_connection()
  101. * @param controller the controller handle to the neighbour
  102. */
  103. typedef void
  104. (*GST_NeigbourConnectNotifyCallback) (void *cls,
  105. struct GNUNET_TESTBED_Controller *
  106. controller);
  107. /**
  108. * Try to open a connection to the given neigbour. If the connection is open
  109. * already, then it is re-used. If not, the request is queued in the operation
  110. * queues responsible for bounding the total number of file descriptors. The
  111. * actual connection will happen when the operation queue marks the
  112. * corresponding operation as active.
  113. *
  114. * @param n the neighbour to open a connection to
  115. * @param cb the notification callback to call when the connection is opened
  116. * @param cb_cls the closure for the above callback
  117. */
  118. struct NeighbourConnectNotification *
  119. GST_neighbour_get_connection (struct Neighbour *n,
  120. GST_NeigbourConnectNotifyCallback cb,
  121. void *cb_cls);
  122. /**
  123. * Cancel the request for opening a connection to the neighbour
  124. *
  125. * @param h the notification handle
  126. */
  127. void
  128. GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h);
  129. /**
  130. * Release the connection to the neighbour. The actual connection will be
  131. * closed if connections to other neighbour are waiting (to maintain a bound on
  132. * the total number of connections that are open).
  133. *
  134. * @param n the neighbour whose connection can be closed
  135. */
  136. void
  137. GST_neighbour_release_connection (struct Neighbour *n);
  138. /**
  139. * Function to create a neigbour and add it into the neighbour list
  140. *
  141. * @param host the host of the neighbour
  142. */
  143. struct Neighbour *
  144. GST_create_neighbour (struct GNUNET_TESTBED_Host *host);
  145. /**
  146. * Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
  147. *
  148. * @param cls identification of the client
  149. * @param msg the actual message
  150. */
  151. void
  152. handle_link_controllers (void *cls,
  153. const struct
  154. GNUNET_TESTBED_ControllerLinkRequest *msg);
  155. /**
  156. * Clean up @a client handle if we stored any via #handle_link_controllers(),
  157. * the given client disconnected.
  158. *
  159. * @param client the client that is history
  160. */
  161. void
  162. GST_link_notify_disconnect (struct GNUNET_SERVICE_Client *client);
  163. /**
  164. * Cleans up the slave list
  165. */
  166. void
  167. GST_slave_list_clear (void);