ats.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. #include "gnunet_ats_service.h"
  27. /**
  28. * Flag used to indicate which type of client is connecting
  29. * to the ATS service.
  30. */
  31. enum StartFlag
  32. {
  33. /**
  34. * This is a scheduling client (aka transport service)
  35. */
  36. START_FLAG_SCHEDULING = 0,
  37. /**
  38. * Performance monitoring client that wants to learn about
  39. * changes in performance characteristics.
  40. */
  41. START_FLAG_PERFORMANCE_WITH_PIC = 1,
  42. /**
  43. * Performance monitoring client that does NOT want to learn
  44. * about changes in performance characteristics.
  45. */
  46. START_FLAG_PERFORMANCE_NO_PIC = 2,
  47. /**
  48. * Connection suggestion handle.
  49. */
  50. START_FLAG_CONNECTION_SUGGESTION = 3
  51. };
  52. GNUNET_NETWORK_STRUCT_BEGIN
  53. /**
  54. * First message any client sends to ATS, used to self-identify
  55. * (what type of client this is).
  56. */
  57. struct ClientStartMessage
  58. {
  59. /**
  60. * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
  61. */
  62. struct GNUNET_MessageHeader header;
  63. /**
  64. * NBO value of an `enum StartFlag`.
  65. */
  66. uint32_t start_flag GNUNET_PACKED;
  67. };
  68. /**
  69. * Scheduling client to ATS service: we would like to have
  70. * address suggestions for this peer.
  71. */
  72. struct RequestAddressMessage
  73. {
  74. /**
  75. * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
  76. * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
  77. * suggestions.
  78. */
  79. struct GNUNET_MessageHeader header;
  80. /**
  81. * Always zero.
  82. */
  83. uint32_t reserved GNUNET_PACKED;
  84. /**
  85. * Peer to get address suggestions for.
  86. */
  87. struct GNUNET_PeerIdentity peer;
  88. };
  89. /**
  90. * ATS client to ATS service: here is another address you can use.
  91. */
  92. struct AddressAddMessage
  93. {
  94. /**
  95. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
  96. */
  97. struct GNUNET_MessageHeader header;
  98. /**
  99. * Number of bytes in the address that follows this struct.
  100. */
  101. uint16_t address_length GNUNET_PACKED;
  102. /**
  103. * Number of bytes in the plugin name that follows this struct.
  104. */
  105. uint16_t plugin_name_length GNUNET_PACKED;
  106. /**
  107. * Identity of the peer that this address is for.
  108. */
  109. struct GNUNET_PeerIdentity peer;
  110. /**
  111. * Internal number this client will henceforth use to
  112. * refer to this address.
  113. */
  114. uint32_t session_id GNUNET_PACKED;
  115. /**
  116. * Local-only information of the address, see
  117. * `enum GNUNET_HELLO_AddressInfo`.
  118. */
  119. uint32_t address_local_info GNUNET_PACKED;
  120. /**
  121. * Performance properties of the address.
  122. */
  123. struct GNUNET_ATS_PropertiesNBO properties;
  124. /* followed by:
  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. * Internal number this client uses to refer to this address.
  141. */
  142. uint32_t session_id 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. * Performance properties of the address.
  151. */
  152. struct GNUNET_ATS_PropertiesNBO properties;
  153. };
  154. /**
  155. * Message sent by ATS client to ATS service when an address
  156. * was destroyed and must thus henceforth no longer be considered
  157. * for scheduling.
  158. */
  159. struct AddressDestroyedMessage
  160. {
  161. /**
  162. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
  163. */
  164. struct GNUNET_MessageHeader header;
  165. /**
  166. * Internal number this client uses to refer to this address.
  167. */
  168. uint32_t session_id GNUNET_PACKED;
  169. /**
  170. * Which peer is this about? (Technically redundant, as the
  171. * @e session_id should be sufficient, but enables ATS service
  172. * to find the session faster).
  173. */
  174. struct GNUNET_PeerIdentity peer;
  175. };
  176. /**
  177. * Message sent by ATS service to client to confirm that it is done
  178. * using the given session ID.
  179. */
  180. struct SessionReleaseMessage
  181. {
  182. /**
  183. * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
  184. */
  185. struct GNUNET_MessageHeader header;
  186. /**
  187. * Number the client used to identify the session.
  188. */
  189. uint32_t session_id GNUNET_PACKED;
  190. /**
  191. * Which peer is this about? (Technically redundant, as the
  192. * @e session_id should be sufficient, but may enable client
  193. * to find the session faster).
  194. */
  195. struct GNUNET_PeerIdentity peer;
  196. };
  197. /**
  198. * ATS Service suggests to the transport service to use the address
  199. * identified by the given @e session_id for the given @e peer with
  200. * the given @e bandwidth_in and @e bandwidth_out limits from now on.
  201. */
  202. struct AddressSuggestionMessage
  203. {
  204. /**
  205. * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
  206. */
  207. struct GNUNET_MessageHeader header;
  208. /**
  209. * Internal number this client uses to refer to the address this
  210. * suggestion is about.
  211. */
  212. uint32_t session_id GNUNET_PACKED;
  213. /**
  214. * Which peer is this about? (Technically redundant, as the
  215. * @e session_id should be sufficient, but may enable client
  216. * to find the session faster and/or check consistency).
  217. */
  218. struct GNUNET_PeerIdentity peer;
  219. /**
  220. * How much bandwidth we are allowed for sending.
  221. */
  222. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
  223. /**
  224. * How much bandwidth we are allowed for receiving.
  225. */
  226. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
  227. };
  228. /**
  229. *
  230. */
  231. struct PeerInformationMessage
  232. {
  233. /**
  234. * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
  235. */
  236. struct GNUNET_MessageHeader header;
  237. /**
  238. *
  239. */
  240. uint16_t address_length GNUNET_PACKED;
  241. /**
  242. *
  243. */
  244. uint16_t plugin_name_length GNUNET_PACKED;
  245. /**
  246. *
  247. */
  248. struct GNUNET_PeerIdentity peer;
  249. /**
  250. *
  251. */
  252. uint32_t address_active GNUNET_PACKED;
  253. /**
  254. *
  255. */
  256. uint32_t id GNUNET_PACKED;
  257. /**
  258. *
  259. */
  260. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
  261. /**
  262. *
  263. */
  264. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
  265. /**
  266. * Performance properties of the address.
  267. */
  268. struct GNUNET_ATS_PropertiesNBO properties;
  269. /* followed by:
  270. * - char address[address_length]
  271. * - char plugin_name[plugin_name_length] (including '\0'-termination).
  272. */
  273. };
  274. /**
  275. * Client to service: please give us an overview of the addresses.
  276. */
  277. struct AddressListRequestMessage
  278. {
  279. /**
  280. * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
  281. */
  282. struct GNUNET_MessageHeader header;
  283. /**
  284. * ID used to match replies to this request.
  285. */
  286. uint32_t id GNUNET_PACKED;
  287. /**
  288. * Which peer do we care about? All zeros for all.
  289. */
  290. struct GNUNET_PeerIdentity peer;
  291. /**
  292. * #GNUNET_YES to get information about all addresses,
  293. * #GNUNET_NO to only return addresses that are in use.
  294. */
  295. int32_t all GNUNET_PACKED;
  296. };
  297. /**
  298. *
  299. */
  300. struct ReservationRequestMessage
  301. {
  302. /**
  303. * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
  304. */
  305. struct GNUNET_MessageHeader header;
  306. /**
  307. *
  308. */
  309. int32_t amount GNUNET_PACKED;
  310. /**
  311. *
  312. */
  313. struct GNUNET_PeerIdentity peer;
  314. };
  315. /**
  316. *
  317. */
  318. struct ReservationResultMessage
  319. {
  320. /**
  321. * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
  322. */
  323. struct GNUNET_MessageHeader header;
  324. /**
  325. *
  326. */
  327. int32_t amount GNUNET_PACKED;
  328. /**
  329. *
  330. */
  331. struct GNUNET_PeerIdentity peer;
  332. /**
  333. *
  334. */
  335. struct GNUNET_TIME_RelativeNBO res_delay;
  336. };
  337. /**
  338. * Variable-size entry in a `struct ChangePreferenceMessage` or
  339. * `struct FeedbackPreferenceMessage`.
  340. */
  341. struct PreferenceInformation
  342. {
  343. /**
  344. * An `enum GNUNET_ATS_PreferenceKind` in NBO.
  345. */
  346. uint32_t preference_kind GNUNET_PACKED;
  347. /**
  348. * Degree of preference (or appreciation) for this @e
  349. * preference_kind being expressed.
  350. */
  351. float preference_value GNUNET_PACKED;
  352. };
  353. /**
  354. * Client to ATS: I have a performance preference for a peer.
  355. */
  356. struct ChangePreferenceMessage
  357. {
  358. /**
  359. * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
  360. */
  361. struct GNUNET_MessageHeader header;
  362. /**
  363. * How many `struct PreferenceInformation` entries follow
  364. * this struct?
  365. */
  366. uint32_t num_preferences GNUNET_PACKED;
  367. /**
  368. * Which peer is the preference being expressed for?
  369. */
  370. struct GNUNET_PeerIdentity peer;
  371. /* followed by 'num_preferences'
  372. * struct PreferenceInformation values */
  373. };
  374. /**
  375. * Message containing application feedback for a peer
  376. */
  377. struct FeedbackPreferenceMessage
  378. {
  379. /**
  380. * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
  381. */
  382. struct GNUNET_MessageHeader header;
  383. /**
  384. * Number of feedback values included
  385. */
  386. uint32_t num_feedback GNUNET_PACKED;
  387. /**
  388. * Relative time describing for which time interval this feedback is
  389. */
  390. struct GNUNET_TIME_RelativeNBO scope;
  391. /**
  392. * Peer this feedback is for
  393. */
  394. struct GNUNET_PeerIdentity peer;
  395. /* followed by 'num_feedback'
  396. * struct PreferenceInformation values */
  397. };
  398. GNUNET_NETWORK_STRUCT_END
  399. #endif