ats.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2015 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 ats/ats.h
  19. * @brief automatic transport selection messages
  20. * @author Christian Grothoff
  21. * @author Matthias Wachs
  22. */
  23. #ifndef ATS_H
  24. #define ATS_H
  25. #include "gnunet_util_lib.h"
  26. /**
  27. * Flag used to indicate which type of client is connecting
  28. * to the ATS service.
  29. */
  30. enum StartFlag
  31. {
  32. /**
  33. * This is a scheduling client (aka transport service)
  34. */
  35. START_FLAG_SCHEDULING = 0,
  36. /**
  37. * Performance monitoring client that wants to learn about
  38. * changes in performance characteristics.
  39. */
  40. START_FLAG_PERFORMANCE_WITH_PIC = 1,
  41. /**
  42. * Performance monitoring client that does NOT want to learn
  43. * about changes in performance characteristics.
  44. */
  45. START_FLAG_PERFORMANCE_NO_PIC = 2,
  46. /**
  47. * Connection suggestion handle.
  48. */
  49. START_FLAG_CONNECTION_SUGGESTION = 3
  50. };
  51. GNUNET_NETWORK_STRUCT_BEGIN
  52. /**
  53. * First message any client sends to ATS, used to self-identify
  54. * (what type of client this is).
  55. */
  56. struct ClientStartMessage
  57. {
  58. /**
  59. * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
  60. */
  61. struct GNUNET_MessageHeader header;
  62. /**
  63. * NBO value of an `enum StartFlag`.
  64. */
  65. uint32_t start_flag GNUNET_PACKED;
  66. };
  67. /**
  68. * Scheduling client to ATS service: we would like to have
  69. * address suggestions for this peer.
  70. */
  71. struct RequestAddressMessage
  72. {
  73. /**
  74. * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
  75. * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
  76. * suggestions.
  77. */
  78. struct GNUNET_MessageHeader header;
  79. /**
  80. * Always zero.
  81. */
  82. uint32_t reserved GNUNET_PACKED;
  83. /**
  84. * Peer to get address suggestions for.
  85. */
  86. struct GNUNET_PeerIdentity peer;
  87. };
  88. /**
  89. * ATS client to ATS service: here is another address you can use.
  90. */
  91. struct AddressAddMessage
  92. {
  93. /**
  94. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
  95. */
  96. struct GNUNET_MessageHeader header;
  97. /**
  98. * Length of the `struct GNUNET_ATS_Information` array that follows this struct.
  99. */
  100. uint32_t ats_count GNUNET_PACKED;
  101. /**
  102. * Identity of the peer that this address is for.
  103. */
  104. struct GNUNET_PeerIdentity peer;
  105. /**
  106. * Number of bytes in the address that follows this struct.
  107. */
  108. uint16_t address_length GNUNET_PACKED;
  109. /**
  110. * Number of bytes in the plugin name that follows this struct.
  111. */
  112. uint16_t plugin_name_length GNUNET_PACKED;
  113. /**
  114. * Internal number this client will henceforth use to
  115. * refer to this address.
  116. */
  117. uint32_t session_id GNUNET_PACKED;
  118. /**
  119. * Local-only information of the address, see
  120. * `enum GNUNET_HELLO_AddressInfo`.
  121. */
  122. uint32_t address_local_info GNUNET_PACKED;
  123. /* followed by:
  124. * - struct GNUNET_ATS_Information [ats_count];
  125. * - char address[address_length]
  126. * - char plugin_name[plugin_name_length] (including '\0'-termination).
  127. */
  128. };
  129. /**
  130. * Message used to notify ATS that the performance
  131. * characteristics for an address have changed.
  132. */
  133. struct AddressUpdateMessage
  134. {
  135. /**
  136. * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
  137. */
  138. struct GNUNET_MessageHeader header;
  139. /**
  140. * Length of the `struct GNUNET_ATS_Information` array that follows.
  141. */
  142. uint32_t ats_count GNUNET_PACKED;
  143. /**
  144. * Which peer is this about? (Technically redundant, as the
  145. * @e session_id should be sufficient, but enables ATS service
  146. * to find the session faster).
  147. */
  148. struct GNUNET_PeerIdentity peer;
  149. /**
  150. * Internal number this client uses to refer to this address.
  151. */
  152. uint32_t session_id GNUNET_PACKED;
  153. /* followed by:
  154. * - struct GNUNET_ATS_Information [ats_count];
  155. */
  156. };
  157. /**
  158. * Message sent by ATS client to ATS service when an address
  159. * was destroyed and must thus henceforth no longer be considered
  160. * for scheduling.
  161. */
  162. struct AddressDestroyedMessage
  163. {
  164. /**
  165. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
  166. */
  167. struct GNUNET_MessageHeader header;
  168. /**
  169. * Internal number this client uses to refer to this address.
  170. */
  171. uint32_t session_id GNUNET_PACKED;
  172. /**
  173. * Which peer is this about? (Technically redundant, as the
  174. * @e session_id should be sufficient, but enables ATS service
  175. * to find the session faster).
  176. */
  177. struct GNUNET_PeerIdentity peer;
  178. };
  179. /**
  180. * Message sent by ATS service to client to confirm that it is done
  181. * using the given session ID.
  182. */
  183. struct SessionReleaseMessage
  184. {
  185. /**
  186. * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
  187. */
  188. struct GNUNET_MessageHeader header;
  189. /**
  190. * Number the client used to identify the session.
  191. */
  192. uint32_t session_id GNUNET_PACKED;
  193. /**
  194. * Which peer is this about? (Technically redundant, as the
  195. * @e session_id should be sufficient, but may enable client
  196. * to find the session faster).
  197. */
  198. struct GNUNET_PeerIdentity peer;
  199. };
  200. /**
  201. * ATS Service suggests to the transport service to use the address
  202. * identified by the given @e session_id for the given @e peer with
  203. * the given @e bandwidth_in and @e bandwidth_out limits from now on.
  204. */
  205. struct AddressSuggestionMessage
  206. {
  207. /**
  208. * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
  209. */
  210. struct GNUNET_MessageHeader header;
  211. /**
  212. * Internal number this client uses to refer to the address this
  213. * suggestion is about.
  214. */
  215. uint32_t session_id GNUNET_PACKED;
  216. /**
  217. * Which peer is this about? (Technically redundant, as the
  218. * @e session_id should be sufficient, but may enable client
  219. * to find the session faster and/or check consistency).
  220. */
  221. struct GNUNET_PeerIdentity peer;
  222. /**
  223. * How much bandwidth we are allowed for sending.
  224. */
  225. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
  226. /**
  227. * How much bandwidth we are allowed for receiving.
  228. */
  229. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
  230. };
  231. struct PeerInformationMessage
  232. {
  233. struct GNUNET_MessageHeader header;
  234. uint32_t ats_count GNUNET_PACKED;
  235. uint32_t address_active GNUNET_PACKED;
  236. uint32_t id GNUNET_PACKED;
  237. struct GNUNET_PeerIdentity peer;
  238. uint16_t address_length GNUNET_PACKED;
  239. uint16_t plugin_name_length GNUNET_PACKED;
  240. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
  241. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
  242. /* followed by:
  243. * - struct GNUNET_ATS_Information [ats_count];
  244. * - char address[address_length]
  245. * - char plugin_name[plugin_name_length] (including '\0'-termination).
  246. */
  247. };
  248. /**
  249. * Client to service: please give us an overview of the addresses.
  250. */
  251. struct AddressListRequestMessage
  252. {
  253. /**
  254. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
  255. */
  256. struct GNUNET_MessageHeader header;
  257. /**
  258. * ID used to match replies to this request.
  259. */
  260. uint32_t id GNUNET_PACKED;
  261. /**
  262. * Which peer do we care about? All zeros for all.
  263. */
  264. struct GNUNET_PeerIdentity peer;
  265. /**
  266. * #GNUNET_YES to get information about all addresses,
  267. * #GNUNET_NO to only return addresses that are in use.
  268. */
  269. int32_t all GNUNET_PACKED;
  270. };
  271. struct ReservationRequestMessage
  272. {
  273. struct GNUNET_MessageHeader header;
  274. int32_t amount GNUNET_PACKED;
  275. struct GNUNET_PeerIdentity peer;
  276. };
  277. struct ReservationResultMessage
  278. {
  279. struct GNUNET_MessageHeader header;
  280. int32_t amount GNUNET_PACKED;
  281. struct GNUNET_PeerIdentity peer;
  282. struct GNUNET_TIME_RelativeNBO res_delay;
  283. };
  284. struct PreferenceInformation
  285. {
  286. uint32_t preference_kind GNUNET_PACKED;
  287. float preference_value GNUNET_PACKED;
  288. };
  289. struct ChangePreferenceMessage
  290. {
  291. struct GNUNET_MessageHeader header;
  292. uint32_t num_preferences GNUNET_PACKED;
  293. struct GNUNET_PeerIdentity peer;
  294. /* followed by 'num_preferences'
  295. * struct PreferenceInformation values */
  296. };
  297. /**
  298. * Message containing application feedback for a peer
  299. */
  300. struct FeedbackPreferenceMessage
  301. {
  302. struct GNUNET_MessageHeader header;
  303. /**
  304. * Number of feedback values included
  305. */
  306. uint32_t num_feedback GNUNET_PACKED;
  307. /**
  308. * Relative time describing for which time interval this feedback is
  309. */
  310. struct GNUNET_TIME_RelativeNBO scope;
  311. /**
  312. * Peer this feedback is for
  313. */
  314. struct GNUNET_PeerIdentity peer;
  315. /* followed by 'num_feedback'
  316. * struct PreferenceInformation values */
  317. };
  318. GNUNET_NETWORK_STRUCT_END
  319. #endif