gnunet-service-testbed_links.h 5.1 KB

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