testbed_api_peers.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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_peers.h
  19. * @brief internal API to access the 'peers' subsystem
  20. * @author Christian Grothoff
  21. * @author Sree Harsha Totakura
  22. */
  23. #ifndef NEW_TESTING_API_PEERS_H
  24. #define NEW_TESTING_API_PEERS_H
  25. #include "gnunet_testbed_service.h"
  26. #include "gnunet_helper_lib.h"
  27. /**
  28. * Enumeration of possible states a peer could be in
  29. */
  30. enum PeerState
  31. {
  32. /**
  33. * State to signify that this peer is invalid
  34. */
  35. TESTBED_PS_INVALID,
  36. /**
  37. * The peer has been created
  38. */
  39. TESTBED_PS_CREATED,
  40. /**
  41. * The peer is running
  42. */
  43. TESTBED_PS_STARTED,
  44. /**
  45. * The peer is stopped
  46. */
  47. TESTBED_PS_STOPPED,
  48. };
  49. /**
  50. * A peer controlled by the testing framework. A peer runs
  51. * at a particular host.
  52. */
  53. struct GNUNET_TESTBED_Peer
  54. {
  55. /**
  56. * peer list DLL
  57. */
  58. struct GNUNET_TESTBED_Peer *next;
  59. /**
  60. * peer list DLL
  61. */
  62. struct GNUNET_TESTBED_Peer *prev;
  63. /**
  64. * Our controller context (not necessarily the controller
  65. * that is responsible for starting/running the peer!).
  66. */
  67. struct GNUNET_TESTBED_Controller *controller;
  68. /**
  69. * Which host does this peer run on?
  70. */
  71. struct GNUNET_TESTBED_Host *host;
  72. /**
  73. * Globally unique ID of the peer.
  74. */
  75. uint32_t unique_id;
  76. /**
  77. * Peer's state
  78. */
  79. enum PeerState state;
  80. /**
  81. * Has an underlay model already set for this peer?
  82. */
  83. uint8_t underlay_model_exists;
  84. };
  85. /**
  86. * Data for the OperationType OP_PEER_CREATE
  87. */
  88. struct PeerCreateData
  89. {
  90. /**
  91. * The host where the peer has to be created
  92. */
  93. struct GNUNET_TESTBED_Host *host;
  94. /**
  95. * The template configuration of the peer
  96. */
  97. const struct GNUNET_CONFIGURATION_Handle *cfg;
  98. /**
  99. * The call back to call when we receive peer create success message
  100. */
  101. GNUNET_TESTBED_PeerCreateCallback cb;
  102. /**
  103. * The closure for the above callback
  104. */
  105. void *cls;
  106. /**
  107. * The peer structure to return when we get success message
  108. */
  109. struct GNUNET_TESTBED_Peer *peer;
  110. };
  111. /**
  112. * Data for OperationType OP_PEER_START and OP_PEER_STOP
  113. */
  114. struct PeerEventData
  115. {
  116. /**
  117. * The handle of the peer to start
  118. */
  119. struct GNUNET_TESTBED_Peer *peer;
  120. /**
  121. * The Peer churn callback to call when this operation is completed
  122. */
  123. GNUNET_TESTBED_PeerChurnCallback pcc;
  124. /**
  125. * Closure for the above callback
  126. */
  127. void *pcc_cls;
  128. };
  129. /**
  130. * Data for the OperationType OP_PEER_DESTROY;
  131. */
  132. struct PeerDestroyData
  133. {
  134. /**
  135. * The peer structure
  136. */
  137. struct GNUNET_TESTBED_Peer *peer;
  138. //PEERDESTROYDATA
  139. };
  140. /**
  141. * Data for the OperationType OP_PEER_INFO
  142. */
  143. struct PeerInfoData
  144. {
  145. /**
  146. * The peer whose information has been requested
  147. */
  148. struct GNUNET_TESTBED_Peer *peer;
  149. /**
  150. * The Peer info callback to call when this operation has completed
  151. */
  152. GNUNET_TESTBED_PeerInfoCallback cb;
  153. /**
  154. * The closure for peer info callback
  155. */
  156. void *cb_cls;
  157. /**
  158. * The type of peer information requested
  159. */
  160. enum GNUNET_TESTBED_PeerInformationType pit;
  161. };
  162. /**
  163. * Data for the operations of type OP_PEER_RECONFIGURE
  164. */
  165. struct PeerReconfigureData
  166. {
  167. /**
  168. * The peer whose information has been requested
  169. */
  170. struct GNUNET_TESTBED_Peer *peer;
  171. /**
  172. * The serialized new configuration template
  173. */
  174. char *config;
  175. /**
  176. * the size of the serialized configuration
  177. */
  178. uint16_t cfg_size;
  179. };
  180. /**
  181. * Data structure for OperationType OP_OVERLAY_CONNECT
  182. */
  183. struct OverlayConnectData
  184. {
  185. /**
  186. * Peer A to connect to peer B
  187. */
  188. struct GNUNET_TESTBED_Peer *p1;
  189. /**
  190. * Peer B
  191. */
  192. struct GNUNET_TESTBED_Peer *p2;
  193. /**
  194. * The operation completion callback to call once this operation is done
  195. */
  196. GNUNET_TESTBED_OperationCompletionCallback cb;
  197. /**
  198. * The closure for the above callback
  199. */
  200. void *cb_cls;
  201. /**
  202. * OperationContext for forwarded operations generated when peer1's controller doesn't have the
  203. * configuration of peer2's controller for linking laterally to attemp an
  204. * overlay connection between peer 1 and peer 2.
  205. */
  206. struct OperationContext *sub_opc;
  207. };
  208. struct ManageServiceData {
  209. GNUNET_TESTBED_OperationCompletionCallback cb;
  210. void *cb_cls;
  211. struct GNUNET_TESTBED_Peer *peer;
  212. char *service_name;
  213. unsigned int start;
  214. uint16_t msize;
  215. };
  216. /**
  217. * Generate PeerGetConfigurationMessage
  218. *
  219. * @param peer_id the id of the peer whose information we have to get
  220. * @param operation_id the ip of the operation that should be represented in
  221. * the message
  222. * @return the PeerGetConfigurationMessage
  223. */
  224. struct GNUNET_TESTBED_PeerGetConfigurationMessage *
  225. GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
  226. uint64_t operation_id);
  227. /**
  228. * Adds a peer to the peer list
  229. *
  230. * @param peer the peer to add to the peer list
  231. */
  232. void
  233. GNUNET_TESTBED_peer_register_ (struct GNUNET_TESTBED_Peer *peer);
  234. /**
  235. * Removes a peer from the peer list
  236. *
  237. * @param peer the peer to remove
  238. */
  239. void
  240. GNUNET_TESTBED_peer_deregister_ (struct GNUNET_TESTBED_Peer *peer);
  241. /**
  242. * Frees all peers
  243. */
  244. void
  245. GNUNET_TESTBED_cleanup_peers_ (void);
  246. #endif
  247. /* end of testbed_api_peers.h */