gnunet-service-testbed_links.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 *controller);
  106. /**
  107. * Try to open a connection to the given neigbour. If the connection is open
  108. * already, then it is re-used. If not, the request is queued in the operation
  109. * queues responsible for bounding the total number of file descriptors. The
  110. * actual connection will happen when the operation queue marks the
  111. * corresponding operation as active.
  112. *
  113. * @param n the neighbour to open a connection to
  114. * @param cb the notification callback to call when the connection is opened
  115. * @param cb_cls the closure for the above callback
  116. */
  117. struct NeighbourConnectNotification *
  118. GST_neighbour_get_connection (struct Neighbour *n,
  119. GST_NeigbourConnectNotifyCallback cb,
  120. void *cb_cls);
  121. /**
  122. * Cancel the request for opening a connection to the neighbour
  123. *
  124. * @param h the notification handle
  125. */
  126. void
  127. GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h);
  128. /**
  129. * Release the connection to the neighbour. The actual connection will be
  130. * closed if connections to other neighbour are waiting (to maintain a bound on
  131. * the total number of connections that are open).
  132. *
  133. * @param n the neighbour whose connection can be closed
  134. */
  135. void
  136. GST_neighbour_release_connection (struct Neighbour *n);
  137. /**
  138. * Function to create a neigbour and add it into the neighbour list
  139. *
  140. * @param host the host of the neighbour
  141. */
  142. struct Neighbour *
  143. GST_create_neighbour (struct GNUNET_TESTBED_Host *host);
  144. /**
  145. * Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
  146. *
  147. * @param cls identification of the client
  148. * @param msg the actual message
  149. */
  150. void
  151. handle_link_controllers (void *cls,
  152. const struct GNUNET_TESTBED_ControllerLinkRequest *msg);
  153. /**
  154. * Clean up @a client handle if we stored any via #handle_link_controllers(),
  155. * the given client disconnected.
  156. *
  157. * @param client the client that is history
  158. */
  159. void
  160. GST_link_notify_disconnect (struct GNUNET_SERVICE_Client *client);
  161. /**
  162. * Cleans up the slave list
  163. */
  164. void
  165. GST_slave_list_clear (void);