transport.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2014 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 transport/transport.h
  18. * @brief common internal definitions for transport service
  19. * @author Christian Grothoff
  20. */
  21. #ifndef TRANSPORT_H
  22. #define TRANSPORT_H
  23. #include "gnunet_crypto_lib.h"
  24. #include "gnunet_time_lib.h"
  25. #include "gnunet_constants.h"
  26. #define DEBUG_TRANSPORT GNUNET_EXTRA_LOGGING
  27. /**
  28. * For how long do we allow unused bandwidth
  29. * from the past to carry over into the future? (in seconds)
  30. */
  31. #define MAX_BANDWIDTH_CARRY_S GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S
  32. /**
  33. * How often do we (at most) do a full quota
  34. * recalculation? (in ms)
  35. */
  36. #define MIN_QUOTA_REFRESH_TIME 2000
  37. /**
  38. * What's the maximum number of sockets transport uses for validation and
  39. * neighbors
  40. */
  41. #define DEFAULT_MAX_FDS 256
  42. /**
  43. * Maximum frequency for re-evaluating latencies for all transport addresses.
  44. */
  45. #define LATENCY_EVALUATION_MAX_DELAY \
  46. GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
  47. /**
  48. * Maximum frequency for re-evaluating latencies for connected addresses.
  49. */
  50. #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY \
  51. GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
  52. /**
  53. * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
  54. * included here. These values are not required outside transport_api
  55. *
  56. * @param cls closure
  57. * @param peer the peer that connected
  58. * @param bandwidth_in inbound bandwidth in NBO
  59. * @param bandwidth_out outbound bandwidth in NBO
  60. *
  61. */
  62. typedef void (*NotifyConnect) (
  63. void *cls,
  64. const struct GNUNET_PeerIdentity *peer,
  65. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
  66. struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
  67. GNUNET_NETWORK_STRUCT_BEGIN
  68. /**
  69. * Message from the transport service to the library
  70. * asking to check if both processes agree about this
  71. * peers identity.
  72. */
  73. struct StartMessage
  74. {
  75. /**
  76. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_START
  77. */
  78. struct GNUNET_MessageHeader header;
  79. /**
  80. * 0: no options
  81. * 1: The @e self field should be checked
  82. * 2: this client is interested in payload traffic
  83. */
  84. uint32_t options;
  85. /**
  86. * Identity we think we have. If it does not match, the
  87. * receiver should print out an error message and disconnect.
  88. */
  89. struct GNUNET_PeerIdentity self;
  90. };
  91. /**
  92. * Message from the transport service to the library
  93. * informing about neighbors.
  94. */
  95. struct ConnectInfoMessage
  96. {
  97. /**
  98. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
  99. */
  100. struct GNUNET_MessageHeader header;
  101. #if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
  102. defined(GNUNET_TRANSPORT_CORE_VERSION))
  103. /**
  104. * Always zero, for alignment.
  105. */
  106. uint32_t reserved GNUNET_PACKED;
  107. #else
  108. /**
  109. * Current outbound quota for this peer
  110. */
  111. struct GNUNET_BANDWIDTH_Value32NBO quota_out;
  112. #endif
  113. /**
  114. * Identity of the new neighbour.
  115. */
  116. struct GNUNET_PeerIdentity id;
  117. };
  118. /**
  119. * Message from the transport service to the library
  120. * informing about disconnects.
  121. */
  122. struct DisconnectInfoMessage
  123. {
  124. /**
  125. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
  126. */
  127. struct GNUNET_MessageHeader header;
  128. /**
  129. * Reserved, always zero.
  130. */
  131. uint32_t reserved GNUNET_PACKED;
  132. /**
  133. * Who got disconnected?
  134. */
  135. struct GNUNET_PeerIdentity peer;
  136. };
  137. /**
  138. * Message used to set a particular bandwidth quota. Sent TO the
  139. * service to set an incoming quota, sent FROM the service to update
  140. * an outgoing quota.
  141. *
  142. * NOTE: no longer used in TNG!
  143. */
  144. struct QuotaSetMessage
  145. {
  146. /**
  147. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
  148. */
  149. struct GNUNET_MessageHeader header;
  150. /**
  151. * Quota.
  152. */
  153. struct GNUNET_BANDWIDTH_Value32NBO quota;
  154. /**
  155. * About which peer are we talking here?
  156. */
  157. struct GNUNET_PeerIdentity peer;
  158. };
  159. /**
  160. * Message used to notify the transport API about a message
  161. * received from the network. The actual message follows.
  162. */
  163. struct InboundMessage
  164. {
  165. /**
  166. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
  167. */
  168. struct GNUNET_MessageHeader header;
  169. /**
  170. * Which peer sent the message?
  171. */
  172. struct GNUNET_PeerIdentity peer;
  173. };
  174. /**
  175. * Message used to notify the transport API that it can
  176. * send another message to the transport service.
  177. */
  178. struct SendOkMessage
  179. {
  180. /**
  181. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
  182. */
  183. struct GNUNET_MessageHeader header;
  184. #if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
  185. defined(GNUNET_TRANSPORT_CORE_VERSION))
  186. uint32_t reserved GNUNET_PACKED;
  187. #else
  188. /**
  189. * #GNUNET_OK if the transmission succeeded,
  190. * #GNUNET_SYSERR if it failed (i.e. network disconnect);
  191. * in either case, it is now OK for this client to
  192. * send us another message for the given peer.
  193. */
  194. uint16_t success GNUNET_PACKED;
  195. /**
  196. * Size of message sent
  197. */
  198. uint16_t bytes_msg GNUNET_PACKED;
  199. /**
  200. * Size of message sent over wire.
  201. * Includes plugin and protocol specific overheads.
  202. */
  203. uint32_t bytes_physical GNUNET_PACKED;
  204. #endif
  205. /**
  206. * Which peer can send more now?
  207. */
  208. struct GNUNET_PeerIdentity peer;
  209. };
  210. /**
  211. * Message used to notify the transport API that it can
  212. * send another message to the transport service.
  213. * (Used to implement flow control.)
  214. */
  215. struct RecvOkMessage
  216. {
  217. /**
  218. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK
  219. */
  220. struct GNUNET_MessageHeader header;
  221. /**
  222. * Number of messages by which to increase the window, greater or
  223. * equal to one.
  224. */
  225. uint32_t increase_window_delta GNUNET_PACKED;
  226. /**
  227. * Which peer can CORE handle more from now?
  228. */
  229. struct GNUNET_PeerIdentity peer;
  230. };
  231. /**
  232. * Message used to notify the transport service about a message
  233. * to be transmitted to another peer. The actual message follows.
  234. */
  235. struct OutboundMessage
  236. {
  237. /**
  238. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
  239. */
  240. struct GNUNET_MessageHeader header;
  241. /**
  242. * An `enum GNUNET_MQ_PriorityPreferences` in NBO.
  243. */
  244. uint32_t priority GNUNET_PACKED;
  245. #if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
  246. defined(GNUNET_TRANSPORT_CORE_VERSION))
  247. /**
  248. * Allowed delay.
  249. */
  250. struct GNUNET_TIME_RelativeNBO timeout;
  251. #endif
  252. /**
  253. * Which peer should receive the message?
  254. */
  255. struct GNUNET_PeerIdentity peer;
  256. };
  257. #if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
  258. defined(GNUNET_TRANSPORT_CORE_VERSION))
  259. /**
  260. * Message used to notify the transport API about an address to string
  261. * conversion. Message is followed by the string with the humand-readable
  262. * address. For each lookup, multiple results may be returned. The
  263. * last message must have a @e res of #GNUNET_OK and an @e addr_len
  264. * of zero.
  265. */
  266. struct AddressToStringResultMessage
  267. {
  268. /**
  269. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
  270. */
  271. struct GNUNET_MessageHeader header;
  272. /**
  273. * #GNUNET_OK if the conversion succeeded,
  274. * #GNUNET_SYSERR if it failed
  275. */
  276. uint32_t res GNUNET_PACKED;
  277. /**
  278. * Length of the following string, zero if @e is #GNUNET_SYSERR
  279. */
  280. uint32_t addr_len GNUNET_PACKED;
  281. };
  282. /**
  283. * Message from the library to the transport service
  284. * asking for converting a transport address to a
  285. * human-readable UTF-8 string.
  286. */
  287. struct AddressLookupMessage
  288. {
  289. /**
  290. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
  291. */
  292. struct GNUNET_MessageHeader header;
  293. /**
  294. * Should the conversion use numeric IP addresses (otherwise
  295. * a reverse DNS lookup is OK -- if applicable).
  296. */
  297. int16_t numeric_only GNUNET_PACKED;
  298. /**
  299. * Length of the (binary) address in bytes, in big-endian.
  300. */
  301. uint16_t addrlen GNUNET_PACKED;
  302. /**
  303. * timeout to give up (for DNS resolution timeout mostly)
  304. */
  305. struct GNUNET_TIME_RelativeNBO timeout;
  306. /* followed by @e addrlen bytes of the actual address, then
  307. * followed by the 0-terminated name of the transport */
  308. };
  309. /**
  310. * Message from the transport service to the library containing information
  311. * about a peer. Information contained are:
  312. * - current address used to communicate with this peer
  313. * - state
  314. * - state timeout
  315. *
  316. * Memory layout:
  317. * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
  318. */
  319. struct ValidationIterateResponseMessage
  320. {
  321. /**
  322. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE
  323. */
  324. struct GNUNET_MessageHeader header;
  325. /**
  326. * For alignment.
  327. */
  328. uint32_t reserved;
  329. /**
  330. * Peer identity
  331. */
  332. struct GNUNET_PeerIdentity peer;
  333. /**
  334. * Local info about the address
  335. */
  336. uint32_t local_address_info GNUNET_PACKED;
  337. /**
  338. * Address length
  339. */
  340. uint32_t addrlen GNUNET_PACKED;
  341. /**
  342. * Length of the plugin name
  343. */
  344. uint32_t pluginlen GNUNET_PACKED;
  345. /**
  346. * State
  347. */
  348. uint32_t state GNUNET_PACKED;
  349. /**
  350. * At what time did we successfully validate the address last.
  351. * Will be NEVER if the address failed validation.
  352. */
  353. struct GNUNET_TIME_AbsoluteNBO last_validation;
  354. /**
  355. * Until when is the address believed to be valid.
  356. * Will be ZERO if the address is not belived to be valid.
  357. */
  358. struct GNUNET_TIME_AbsoluteNBO valid_until;
  359. /**
  360. * When will we next try to validate the address (typically
  361. * done before @e valid_until happens).
  362. */
  363. struct GNUNET_TIME_AbsoluteNBO next_validation;
  364. };
  365. /**
  366. * Message from the library to the transport service
  367. * asking for binary addresses known for a peer.
  368. */
  369. struct ValidationMonitorMessage
  370. {
  371. /**
  372. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST
  373. */
  374. struct GNUNET_MessageHeader header;
  375. /**
  376. * One shot call or continous replies?
  377. */
  378. uint32_t one_shot GNUNET_PACKED;
  379. /**
  380. * The identity of the peer to look up.
  381. */
  382. struct GNUNET_PeerIdentity peer;
  383. };
  384. /**
  385. * Message from the library to the transport service
  386. * asking for binary addresses known for a peer.
  387. */
  388. struct PeerMonitorMessage
  389. {
  390. /**
  391. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST
  392. */
  393. struct GNUNET_MessageHeader header;
  394. /**
  395. * One shot call or continous replies?
  396. */
  397. uint32_t one_shot GNUNET_PACKED;
  398. /**
  399. * The identity of the peer to look up.
  400. */
  401. struct GNUNET_PeerIdentity peer;
  402. };
  403. /**
  404. * Message from the library to the transport service
  405. * asking for binary addresses known for a peer.
  406. */
  407. struct TrafficMetricMessage
  408. {
  409. /**
  410. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
  411. */
  412. struct GNUNET_MessageHeader header;
  413. /**
  414. * Always zero.
  415. */
  416. uint32_t reserved GNUNET_PACKED;
  417. /**
  418. * The identity of the peer to look up.
  419. */
  420. struct GNUNET_PeerIdentity peer;
  421. /**
  422. * Fake properties to generate.
  423. */
  424. struct GNUNET_ATS_PropertiesNBO properties;
  425. /**
  426. * Fake delay to add on inbound traffic.
  427. */
  428. struct GNUNET_TIME_RelativeNBO delay_in;
  429. /**
  430. * Fake delay to add on outbound traffic.
  431. */
  432. struct GNUNET_TIME_RelativeNBO delay_out;
  433. };
  434. /**
  435. * Message from the transport service to the library containing information
  436. * about a peer. Information contained are:
  437. * - current address used to communicate with this peer
  438. * - state
  439. * - state timeout
  440. *
  441. * Memory layout:
  442. * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
  443. */
  444. struct PeerIterateResponseMessage
  445. {
  446. /**
  447. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
  448. */
  449. struct GNUNET_MessageHeader header;
  450. /**
  451. * For alignment.
  452. */
  453. uint32_t reserved;
  454. /**
  455. * Peer identity
  456. */
  457. struct GNUNET_PeerIdentity peer;
  458. /**
  459. * Timeout for the state this peer is in
  460. */
  461. struct GNUNET_TIME_AbsoluteNBO state_timeout;
  462. /**
  463. * Local info about the address
  464. */
  465. uint32_t local_address_info GNUNET_PACKED;
  466. /**
  467. * State this peer is in as an `enum GNUNET_TRANSPORT_PeerState`
  468. */
  469. uint32_t state GNUNET_PACKED;
  470. /**
  471. * Address length
  472. */
  473. uint32_t addrlen GNUNET_PACKED;
  474. /**
  475. * Length of the plugin name
  476. */
  477. uint32_t pluginlen GNUNET_PACKED;
  478. };
  479. /**
  480. * Change in blacklisting (either request or notification,
  481. * depending on which direction it is going).
  482. */
  483. struct BlacklistMessage
  484. {
  485. /**
  486. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
  487. * #GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
  488. */
  489. struct GNUNET_MessageHeader header;
  490. /**
  491. * 0 for the query, #GNUNET_OK (allowed) or #GNUNET_SYSERR (disallowed)
  492. * for the response.
  493. */
  494. uint32_t is_allowed GNUNET_PACKED;
  495. /**
  496. * Which peer is being blacklisted or queried?
  497. */
  498. struct GNUNET_PeerIdentity peer;
  499. };
  500. /**
  501. * Transport-level connection status update.
  502. */
  503. struct TransportPluginMonitorMessage
  504. {
  505. /**
  506. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
  507. */
  508. struct GNUNET_MessageHeader header;
  509. /**
  510. * An `enum GNUNET_TRANSPORT_SessionState` in NBO.
  511. */
  512. uint16_t session_state GNUNET_PACKED;
  513. /**
  514. * #GNUNET_YES if this is an inbound connection,
  515. * #GNUNET_NO if this is an outbound connection,
  516. * #GNUNET_SYSERR if connections of this plugin
  517. * are so fundamentally bidirectional
  518. * that they have no 'initiator'
  519. * Value given in NBO.
  520. */
  521. int16_t is_inbound GNUNET_PACKED;
  522. /**
  523. * Number of messages waiting transmission.
  524. */
  525. uint32_t msgs_pending GNUNET_PACKED;
  526. /**
  527. * Number of bytes waiting for transmission.
  528. */
  529. uint32_t bytes_pending GNUNET_PACKED;
  530. /**
  531. * When will this transport plugin session time out?
  532. */
  533. struct GNUNET_TIME_AbsoluteNBO timeout;
  534. /**
  535. * Until how long is this plugin currently blocked from reading?
  536. */
  537. struct GNUNET_TIME_AbsoluteNBO delay;
  538. /**
  539. * Which peer is this connection for?
  540. */
  541. struct GNUNET_PeerIdentity peer;
  542. /**
  543. * Unique identifier for the session.
  544. */
  545. uint64_t session_id;
  546. /**
  547. * Length of the plugin name in bytes, including 0-termination.
  548. */
  549. uint16_t plugin_name_len GNUNET_PACKED;
  550. /**
  551. * Length of the plugin address in bytes.
  552. */
  553. uint16_t plugin_address_len GNUNET_PACKED;
  554. /* followed by 0-terminated plugin name and
  555. @e plugin_address_len bytes of plugin address */
  556. };
  557. #else
  558. /* *********************** TNG messages ***************** */
  559. /**
  560. * Communicator goes online. Note which addresses it can
  561. * work with.
  562. */
  563. struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
  564. {
  565. /**
  566. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR.
  567. */
  568. struct GNUNET_MessageHeader header;
  569. /**
  570. * NBO encoding of `enum GNUNET_TRANSPORT_CommunicatorCharacteristics`
  571. */
  572. uint32_t cc;
  573. /* Followed by the address prefix of the communicator */
  574. };
  575. /**
  576. * Add address to the list.
  577. */
  578. struct GNUNET_TRANSPORT_AddAddressMessage
  579. {
  580. /**
  581. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS.
  582. */
  583. struct GNUNET_MessageHeader header;
  584. /**
  585. * Address identifier (used during deletion).
  586. */
  587. uint32_t aid GNUNET_PACKED;
  588. /**
  589. * When does the address expire?
  590. */
  591. struct GNUNET_TIME_RelativeNBO expiration;
  592. /**
  593. * An `enum GNUNET_NetworkType` in NBO.
  594. */
  595. uint32_t nt;
  596. /* followed by UTF-8 encoded, 0-terminated human-readable address */
  597. };
  598. /**
  599. * Remove address from the list.
  600. */
  601. struct GNUNET_TRANSPORT_DelAddressMessage
  602. {
  603. /**
  604. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS.
  605. */
  606. struct GNUNET_MessageHeader header;
  607. /**
  608. * Address identifier.
  609. */
  610. uint32_t aid GNUNET_PACKED;
  611. };
  612. /**
  613. * Inform transport about an incoming message.
  614. */
  615. struct GNUNET_TRANSPORT_IncomingMessage
  616. {
  617. /**
  618. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG.
  619. */
  620. struct GNUNET_MessageHeader header;
  621. /**
  622. * Do we use flow control or not?
  623. */
  624. uint32_t fc_on GNUNET_PACKED;
  625. /**
  626. * 64-bit number to identify the matching ACK.
  627. */
  628. uint64_t fc_id GNUNET_PACKED;
  629. /**
  630. * How long does the communicator believe the address on which
  631. * the message was received to remain valid?
  632. */
  633. struct GNUNET_TIME_RelativeNBO expected_address_validity;
  634. /**
  635. * Sender identifier.
  636. */
  637. struct GNUNET_PeerIdentity sender;
  638. /* followed by the message */
  639. };
  640. /**
  641. * Transport informs us about being done with an incoming message.
  642. * (only sent if fc_on was set).
  643. */
  644. struct GNUNET_TRANSPORT_IncomingMessageAck
  645. {
  646. /**
  647. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK.
  648. */
  649. struct GNUNET_MessageHeader header;
  650. /**
  651. * Reserved (0)
  652. */
  653. uint32_t reserved GNUNET_PACKED;
  654. /**
  655. * Which message is being ACKed?
  656. */
  657. uint64_t fc_id GNUNET_PACKED;
  658. /**
  659. * Sender identifier of the original message.
  660. */
  661. struct GNUNET_PeerIdentity sender;
  662. };
  663. /**
  664. * Add queue to the transport
  665. */
  666. struct GNUNET_TRANSPORT_AddQueueMessage
  667. {
  668. /**
  669. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
  670. */
  671. struct GNUNET_MessageHeader header;
  672. /**
  673. * Queue identifier (used to identify the queue).
  674. */
  675. uint32_t qid GNUNET_PACKED;
  676. /**
  677. * Receiver that can be addressed via the queue.
  678. */
  679. struct GNUNET_PeerIdentity receiver;
  680. /**
  681. * An `enum GNUNET_NetworkType` in NBO.
  682. */
  683. uint32_t nt;
  684. /**
  685. * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
  686. */
  687. uint32_t mtu;
  688. /**
  689. * Queue length, in NBO. Defines how many messages may be
  690. * send through this queue. UINT64_MAX for unlimited.
  691. */
  692. uint64_t q_len;
  693. /**
  694. * Priority of the queue in relation to other queues.
  695. */
  696. uint32_t priority;
  697. /**
  698. * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
  699. */
  700. uint32_t cs;
  701. /* followed by UTF-8 encoded, 0-terminated human-readable address */
  702. };
  703. /**
  704. * Update queue
  705. */
  706. struct GNUNET_TRANSPORT_UpdateQueueMessage
  707. {
  708. /**
  709. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
  710. */
  711. struct GNUNET_MessageHeader header;
  712. /**
  713. * Queue identifier (used to identify the queue).
  714. */
  715. uint32_t qid GNUNET_PACKED;
  716. /**
  717. * Receiver that can be addressed via the queue.
  718. */
  719. struct GNUNET_PeerIdentity receiver;
  720. /**
  721. * An `enum GNUNET_NetworkType` in NBO.
  722. */
  723. uint32_t nt;
  724. /**
  725. * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
  726. */
  727. uint32_t mtu;
  728. /**
  729. * Queue length, in NBO. Defines how many messages may be
  730. * send through this queue. UINT64_MAX for unlimited.
  731. */
  732. uint64_t q_len;
  733. /**
  734. * Priority of the queue in relation to other queues.
  735. */
  736. uint32_t priority;
  737. /**
  738. * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
  739. */
  740. uint32_t cs;
  741. };
  742. /**
  743. * Remove queue, it is no longer available.
  744. */
  745. struct GNUNET_TRANSPORT_DelQueueMessage
  746. {
  747. /**
  748. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN.
  749. */
  750. struct GNUNET_MessageHeader header;
  751. /**
  752. * Address identifier.
  753. */
  754. uint32_t qid GNUNET_PACKED;
  755. /**
  756. * Receiver that can be addressed via the queue.
  757. */
  758. struct GNUNET_PeerIdentity receiver;
  759. };
  760. /**
  761. * Transport tells communicator that it wants a new queue.
  762. */
  763. struct GNUNET_TRANSPORT_CreateQueue
  764. {
  765. /**
  766. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE.
  767. */
  768. struct GNUNET_MessageHeader header;
  769. /**
  770. * Unique ID for the request.
  771. */
  772. uint32_t request_id GNUNET_PACKED;
  773. /**
  774. * Receiver that can be addressed via the queue.
  775. */
  776. struct GNUNET_PeerIdentity receiver;
  777. /* followed by UTF-8 encoded, 0-terminated human-readable address */
  778. };
  779. /**
  780. * Communicator tells transport how queue creation went down.
  781. */
  782. struct GNUNET_TRANSPORT_CreateQueueResponse
  783. {
  784. /**
  785. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or
  786. * #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL.
  787. */
  788. struct GNUNET_MessageHeader header;
  789. /**
  790. * Unique ID for the request.
  791. */
  792. uint32_t request_id GNUNET_PACKED;
  793. };
  794. /**
  795. * Inform communicator about transport's desire to send a message.
  796. */
  797. struct GNUNET_TRANSPORT_SendMessageTo
  798. {
  799. /**
  800. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG.
  801. */
  802. struct GNUNET_MessageHeader header;
  803. /**
  804. * Which queue should we use?
  805. */
  806. uint32_t qid GNUNET_PACKED;
  807. /**
  808. * Message ID, used for flow control.
  809. */
  810. uint64_t mid GNUNET_PACKED;
  811. /**
  812. * Receiver identifier.
  813. */
  814. struct GNUNET_PeerIdentity receiver;
  815. /* followed by the message */
  816. };
  817. /**
  818. * Inform transport that message was sent.
  819. */
  820. struct GNUNET_TRANSPORT_SendMessageToAck
  821. {
  822. /**
  823. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK.
  824. */
  825. struct GNUNET_MessageHeader header;
  826. /**
  827. * Success (#GNUNET_OK), failure (#GNUNET_SYSERR).
  828. */
  829. uint32_t status GNUNET_PACKED;
  830. /**
  831. * Message ID of the original message.
  832. */
  833. uint64_t mid GNUNET_PACKED;
  834. /**
  835. * Receiver identifier.
  836. */
  837. struct GNUNET_PeerIdentity receiver;
  838. };
  839. /**
  840. * Message from communicator to transport service asking for
  841. * transmission of a backchannel message with the given peer @e pid
  842. * and communicator.
  843. */
  844. struct GNUNET_TRANSPORT_CommunicatorBackchannel
  845. {
  846. /**
  847. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
  848. */
  849. struct GNUNET_MessageHeader header;
  850. /**
  851. * Always zero, for alignment.
  852. */
  853. uint32_t reserved;
  854. /**
  855. * Target peer.
  856. */
  857. struct GNUNET_PeerIdentity pid;
  858. /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
  859. message to the communicator */
  860. /* Followed by the 0-terminated string specifying the desired
  861. communicator at the target (@e pid) peer */
  862. };
  863. /**
  864. * Message from transport to communicator passing along a backchannel
  865. * message from the given peer @e pid.
  866. */
  867. struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
  868. {
  869. /**
  870. * Type will be
  871. * #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
  872. */
  873. struct GNUNET_MessageHeader header;
  874. /**
  875. * Always zero, for alignment.
  876. */
  877. uint32_t reserved;
  878. /**
  879. * Origin peer.
  880. */
  881. struct GNUNET_PeerIdentity pid;
  882. /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
  883. message to the communicator */
  884. };
  885. /**
  886. * Request to start monitoring.
  887. */
  888. struct GNUNET_TRANSPORT_MonitorStart
  889. {
  890. /**
  891. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START.
  892. */
  893. struct GNUNET_MessageHeader header;
  894. /**
  895. * #GNUNET_YES for one-shot montoring, #GNUNET_NO for continuous monitoring.
  896. */
  897. uint32_t one_shot;
  898. /**
  899. * Target identifier to monitor, all zeros for "all peers".
  900. */
  901. struct GNUNET_PeerIdentity peer;
  902. };
  903. /**
  904. * Monitoring data.
  905. */
  906. struct GNUNET_TRANSPORT_MonitorData
  907. {
  908. /**
  909. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA.
  910. */
  911. struct GNUNET_MessageHeader header;
  912. /**
  913. * Network type (an `enum GNUNET_NetworkType` in NBO).
  914. */
  915. uint32_t nt GNUNET_PACKED;
  916. /**
  917. * Target identifier.
  918. */
  919. struct GNUNET_PeerIdentity peer;
  920. /**
  921. * @deprecated To be discussed if we keep these...
  922. */
  923. struct GNUNET_TIME_AbsoluteNBO last_validation;
  924. struct GNUNET_TIME_AbsoluteNBO valid_until;
  925. struct GNUNET_TIME_AbsoluteNBO next_validation;
  926. /**
  927. * Current round-trip time estimate.
  928. */
  929. struct GNUNET_TIME_RelativeNBO rtt;
  930. /**
  931. * Connection status (in NBO).
  932. */
  933. uint32_t cs GNUNET_PACKED;
  934. /**
  935. * Messages pending (in NBO).
  936. */
  937. uint32_t num_msg_pending GNUNET_PACKED;
  938. /**
  939. * Bytes pending (in NBO).
  940. */
  941. uint32_t num_bytes_pending GNUNET_PACKED;
  942. /* Followed by 0-terminated address of the peer */
  943. };
  944. /**
  945. * Request to verify address.
  946. */
  947. struct GNUNET_TRANSPORT_AddressToVerify
  948. {
  949. /**
  950. * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY.
  951. */
  952. struct GNUNET_MessageHeader header;
  953. /**
  954. * Reserved. 0.
  955. */
  956. uint32_t reserved;
  957. /**
  958. * Peer the address is from.
  959. */
  960. struct GNUNET_PeerIdentity peer;
  961. /* followed by variable-size raw address */
  962. };
  963. /**
  964. * Application client to TRANSPORT service: we would like to have
  965. * address suggestions for this peer.
  966. */
  967. struct ExpressPreferenceMessage
  968. {
  969. /**
  970. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST or
  971. * #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL to stop
  972. * suggestions.
  973. */
  974. struct GNUNET_MessageHeader header;
  975. /**
  976. * What type of performance preference does the client have?
  977. * A `enum GNUNET_MQ_PreferenceKind` in NBO.
  978. */
  979. uint32_t pk GNUNET_PACKED;
  980. /**
  981. * Peer to get address suggestions for.
  982. */
  983. struct GNUNET_PeerIdentity peer;
  984. /**
  985. * How much bandwidth in bytes/second does the application expect?
  986. */
  987. struct GNUNET_BANDWIDTH_Value32NBO bw;
  988. };
  989. /**
  990. * We got an address of another peer, TRANSPORT service
  991. * should validate it. There is no response.
  992. */
  993. struct RequestHelloValidationMessage
  994. {
  995. /**
  996. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION.
  997. */
  998. struct GNUNET_MessageHeader header;
  999. /**
  1000. * What type of network does the other peer claim this is?
  1001. * A `enum GNUNET_NetworkType` in NBO.
  1002. */
  1003. uint32_t nt GNUNET_PACKED;
  1004. /**
  1005. * Peer to the address is presumably for.
  1006. */
  1007. struct GNUNET_PeerIdentity peer;
  1008. /* followed by 0-terminated address to validate */
  1009. };
  1010. #endif
  1011. GNUNET_NETWORK_STRUCT_END
  1012. /* end of transport.h */
  1013. #endif