transport.h 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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. * Similar 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 believed 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 continuous 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 continuous 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