transport.h 22 KB

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