You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1365 lines
44 KiB

  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012, 2013 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. * @author Gabor X Toth
  18. * @author Christian Grothoff
  19. *
  20. * @file
  21. * PSYC service
  22. *
  23. * @defgroup psyc PSYC service
  24. * Send/receive messages in PSYC channels and access the PSYC Store.
  25. *
  26. * Note that clients of this API are NOT expected to understand the PSYC message
  27. * format, only the semantics! Parsing (and serializing) the PSYC stream format
  28. * is done within the implementation of the libgnunetpsyc library, and this API
  29. * deliberately exposes as little as possible of the actual data stream format
  30. * to the application!
  31. *
  32. * NOTE:
  33. * - this API does not know about PSYC's "root" and "places";
  34. * there is no 'root' in GNUnet-PSYC as we're decentralized;
  35. * 'places' and 'persons' are combined within the same
  36. * abstraction, that of a "channel". Channels are identified
  37. * and accessed in this API using a public/private key.
  38. * Higher-level applications should use NAMES within GNS
  39. * to obtain public keys, and the distinction between
  40. * 'places' and 'persons' can then be made with the help
  41. * of the naming system (and/or conventions).
  42. * Channels are (as in PSYC) organized into a hierarchy; each
  43. * channel master (the one with the private key) is then
  44. * the operator of the multicast group (its Origin in
  45. * the terminology of the multicast API).
  46. * - The API supports passing large amounts of data using
  47. * 'streaming' for the argument passed to a method. State
  48. * and variables must fit into memory and cannot be streamed
  49. * (thus, no passing of 4 GB of data in a variable;
  50. * once we implement this, we might want to create a
  51. * @c \#define for the maximum size of a variable).
  52. * - PSYC defines standard variables, methods, etc. This
  53. * library deliberately abstracts over all of these; a
  54. * higher-level API should combine the naming system (GNS)
  55. * and standard methods (_converse, _notice, _request,
  56. * _warning, _error etc) and variables (_action, _color,
  57. * _time, etc). However, this API does take over the
  58. * routing variables, specifically '_context' (channel),
  59. * and '_source'. We only kind-of support '_target', as
  60. * the target is either everyone in the group or the
  61. * origin, and never just a single member of the group;
  62. * for such individual messages, an application needs to
  63. * construct an 'inbox' channel where the master (only)
  64. * receives messages (but never forwards; private responses
  65. * would be transmitted by joining the senders 'inbox'
  66. * channel -- or a inbox#bob subchannel). The
  67. * goal for all of this is to keep the abstractions in this
  68. * API minimal: interaction with multicast, try \& slice,
  69. * state/variable/channel management. Higher-level
  70. * operations belong elsewhere (so maybe this API should
  71. * be called 'PSYC-low', whereas a higher-level API
  72. * implementing defaults for standard methods and
  73. * variables might be called 'PSYC-std' or 'PSYC-high'.
  74. *
  75. * In PSYC terminology this is simply called the "PSYC
  76. * routing layer" and the abstractions, for instance in
  77. * psyced, are quite similar. The higher one is called
  78. * "PSYC entity layer." In the text rendering of the
  79. * protocol the two are separated by an empty line. See
  80. * http://about.psyc.eu/Spec:Packet and related. --lynX
  81. *
  82. * @{
  83. */
  84. #ifndef GNUNET_PSYC_SERVICE_H
  85. #define GNUNET_PSYC_SERVICE_H
  86. #ifdef __cplusplus
  87. extern "C"
  88. {
  89. #if 0 /* keep Emacsens' auto-indent happy */
  90. }
  91. #endif
  92. #endif
  93. #include "gnunet_util_lib.h"
  94. #include "gnunet_multicast_service.h"
  95. //Mingw work around
  96. #ifdef MINGW
  97. # ifndef UINT64_MAX
  98. # define UINT64_MAX 0xffffffffffffffffULL
  99. # endif
  100. #endif
  101. /**
  102. * Version number of GNUnet-PSYC API.
  103. */
  104. #define GNUNET_PSYC_VERSION 0x00000000
  105. /**
  106. * Policy flags for a channel.
  107. */
  108. enum GNUNET_PSYC_ChannelFlags
  109. {
  110. /**
  111. * Admission must be confirmed by the master.
  112. */
  113. GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL = 1 << 0,
  114. /**
  115. * Past messages are only available to slaves who were admitted at the time
  116. * they were sent to the channel.
  117. */
  118. GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1
  119. };
  120. /**
  121. * PSYC channel policies.
  122. */
  123. enum GNUNET_PSYC_Policy
  124. {
  125. /**
  126. * Anyone can join the channel, without announcing their presence;
  127. * all messages are always public and can be distributed freely.
  128. * Joins may be announced, but this is not required.
  129. */
  130. GNUNET_PSYC_CHANNEL_ANONYMOUS = 0,
  131. /**
  132. * The master must approve membership to the channel, messages must only be
  133. * distributed to current channel slaves. This includes the channel
  134. * state as well as transient messages.
  135. */
  136. GNUNET_PSYC_CHANNEL_PRIVATE
  137. = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL
  138. | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY
  139. #if IDEAS_FOR_FUTURE
  140. /**
  141. * Anyone can freely join the channel (no approval required);
  142. * however, messages must only be distributed to current channel
  143. * slaves, so the master must still acknowledge that the slave
  144. * joined before transient messages are delivered. As approval is
  145. * guaranteed, the presistent channel state can be synchronized freely
  146. * immediately, prior to master confirmation.
  147. */
  148. GNUNET_PSYC_CHANNEL_OPEN
  149. = GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY,
  150. /**
  151. * The master must approve joins to the channel, but past messages can be
  152. * freely distributed to slaves.
  153. */
  154. GNUNET_PSYC_CHANNEL_CLOSED
  155. = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL,
  156. #endif
  157. };
  158. enum GNUNET_PSYC_MessageFlags
  159. {
  160. /**
  161. * Default / no flags.
  162. */
  163. GNUNET_PSYC_MESSAGE_DEFAULT = 0,
  164. /**
  165. * Historic message, retrieved from PSYCstore.
  166. */
  167. GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 0,
  168. /**
  169. * Request from slave to master.
  170. */
  171. GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1,
  172. /**
  173. * Message can be delivered out of order.
  174. */
  175. GNUNET_PSYC_MESSAGE_ORDER_ANY = 1 << 2
  176. };
  177. /**
  178. * Values for the @a state_delta field of GNUNET_PSYC_MessageHeader.
  179. */
  180. enum GNUNET_PSYC_StateDeltaValues
  181. {
  182. GNUNET_PSYC_STATE_RESET = 0,
  183. GNUNET_PSYC_STATE_NOT_MODIFIED = UINT64_MAX
  184. };
  185. GNUNET_NETWORK_STRUCT_BEGIN
  186. /**
  187. * A PSYC message.
  188. *
  189. * Used for single-fragment messages e.g. in a join request or response.
  190. */
  191. struct GNUNET_PSYC_Message
  192. {
  193. /**
  194. * Message header with size and type information.
  195. */
  196. struct GNUNET_MessageHeader header;
  197. /* Followed by concatenated PSYC message parts:
  198. * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types
  199. */
  200. };
  201. /**
  202. * Header of a PSYC message.
  203. *
  204. * The PSYC service adds this when delivering the message to local clients,
  205. * not present on the multicast layer.
  206. */
  207. struct GNUNET_PSYC_MessageHeader
  208. {
  209. /**
  210. * Generic message header with size and type information.
  211. */
  212. struct GNUNET_MessageHeader header;
  213. /**
  214. * Flags for this message fragment.
  215. *
  216. * @see enum GNUNET_PSYC_MessageFlags
  217. */
  218. uint32_t flags GNUNET_PACKED;
  219. /**
  220. * Number of the message this message part belongs to.
  221. * Monotonically increasing from 1.
  222. */
  223. uint64_t message_id GNUNET_PACKED;
  224. /**
  225. * Byte offset of this @e fragment of the @e message.
  226. */
  227. uint64_t fragment_offset GNUNET_PACKED;
  228. /**
  229. * Sending slave's public key.
  230. * Not set if the message is from the master.
  231. */
  232. struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key;
  233. /* Followed by concatenated PSYC message parts:
  234. * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types
  235. */
  236. };
  237. /**
  238. * The method of a message.
  239. */
  240. struct GNUNET_PSYC_MessageMethod
  241. {
  242. /**
  243. * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
  244. */
  245. struct GNUNET_MessageHeader header;
  246. /**
  247. * OR'ed GNUNET_PSYC_MasterTransmitFlags
  248. */
  249. uint32_t flags GNUNET_PACKED;
  250. /**
  251. * Number of message IDs since the last message that contained state
  252. * operations. @see enum GNUNET_PSYC_StateDeltaValues
  253. */
  254. uint64_t state_delta GNUNET_PACKED;
  255. /* Followed by NUL-terminated method name. */
  256. };
  257. /**
  258. * A modifier of a message.
  259. */
  260. struct GNUNET_PSYC_MessageModifier
  261. {
  262. /**
  263. * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
  264. */
  265. struct GNUNET_MessageHeader header;
  266. /**
  267. * Size of value.
  268. */
  269. uint32_t value_size GNUNET_PACKED;
  270. /**
  271. * Size of name, including NUL terminator.
  272. */
  273. uint16_t name_size GNUNET_PACKED;
  274. /**
  275. * enum GNUNET_PSYC_Operator
  276. */
  277. uint8_t oper;
  278. /* Followed by NUL-terminated name, then the value. */
  279. };
  280. struct GNUNET_PSYC_CountersResultMessage
  281. {
  282. /**
  283. * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS
  284. */
  285. struct GNUNET_MessageHeader header;
  286. /**
  287. * Status code for the operation.
  288. */
  289. uint32_t result_code GNUNET_PACKED;
  290. /**
  291. * Last message ID sent to the channel.
  292. */
  293. uint64_t max_message_id GNUNET_PACKED;
  294. };
  295. /**
  296. * Join request sent to a PSYC master.
  297. */
  298. struct GNUNET_PSYC_JoinRequestMessage
  299. {
  300. /**
  301. * Type: GNUNET_MESSAGE_TYPE_PSYC_MASTER_JOIN_REQUEST
  302. */
  303. struct GNUNET_MessageHeader header;
  304. /**
  305. * Public key of the joining slave.
  306. */
  307. struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key;
  308. /* Followed by struct GNUNET_MessageHeader join_request */
  309. };
  310. /**
  311. * Join decision sent in reply to a join request.
  312. */
  313. struct GNUNET_PSYC_JoinDecisionMessage
  314. {
  315. /**
  316. * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION
  317. */
  318. struct GNUNET_MessageHeader header;
  319. /**
  320. * #GNUNET_YES if the slave was admitted.
  321. */
  322. int32_t is_admitted;
  323. /**
  324. * Public key of the joining slave.
  325. * Only set when the master is sending the decision,
  326. * not set when a slave is receiving it.
  327. */
  328. struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key;
  329. /* Followed by struct GNUNET_MessageHeader join_response */
  330. };
  331. enum GNUNET_PSYC_HistoryReplayFlags
  332. {
  333. /**
  334. * Replay locally available messages.
  335. */
  336. GNUNET_PSYC_HISTORY_REPLAY_LOCAL = 0,
  337. /**
  338. * Replay messages from remote peers if not found locally.
  339. */
  340. GNUNET_PSYC_HISTORY_REPLAY_REMOTE = 1,
  341. };
  342. struct GNUNET_PSYC_HistoryRequestMessage
  343. {
  344. /**
  345. * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_HISTORY_REPLAY
  346. */
  347. struct GNUNET_MessageHeader header;
  348. /**
  349. * @see enum GNUNET_PSYC_HistoryReplayFlags
  350. */
  351. uint32_t flags GNUNET_PACKED;
  352. /**
  353. * ID for this operation.
  354. */
  355. uint64_t op_id GNUNET_PACKED;
  356. uint64_t start_message_id GNUNET_PACKED;
  357. uint64_t end_message_id GNUNET_PACKED;
  358. uint64_t message_limit GNUNET_PACKED;
  359. /* Followed by NUL-terminated method name prefix. */
  360. };
  361. struct GNUNET_PSYC_StateRequestMessage
  362. {
  363. /**
  364. * Types:
  365. * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET
  366. * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET_PREFIX
  367. */
  368. struct GNUNET_MessageHeader header;
  369. uint32_t reserved GNUNET_PACKED;
  370. /**
  371. * ID for this operation.
  372. */
  373. uint64_t op_id GNUNET_PACKED;
  374. /* Followed by NUL-terminated name. */
  375. };
  376. /**** service -> library ****/
  377. /**
  378. * Answer from service to client about last operation.
  379. */
  380. struct GNUNET_PSYC_OperationResultMessage
  381. {
  382. /**
  383. * Types:
  384. * - GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE
  385. * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_RESULT
  386. */
  387. struct GNUNET_MessageHeader header;
  388. uint32_t reserved GNUNET_PACKED;
  389. /**
  390. * Operation ID.
  391. */
  392. uint64_t op_id GNUNET_PACKED;
  393. /**
  394. * Status code for the operation.
  395. */
  396. uint64_t result_code GNUNET_PACKED;
  397. /* Followed by:
  398. * - on error: NUL-terminated error message
  399. * - on success: one of the following message types
  400. *
  401. * For a STATE_RESULT, one of:
  402. * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
  403. * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT
  404. * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END
  405. */
  406. };
  407. GNUNET_NETWORK_STRUCT_END
  408. #define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD \
  409. GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
  410. - sizeof (struct GNUNET_PSYC_MessageModifier)
  411. #define GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD \
  412. GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
  413. - sizeof (struct GNUNET_MessageHeader)
  414. #define GNUNET_PSYC_DATA_MAX_PAYLOAD \
  415. GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
  416. - sizeof (struct GNUNET_MessageHeader)
  417. /**
  418. * PSYC message part processing states.
  419. */
  420. enum GNUNET_PSYC_MessageState
  421. {
  422. GNUNET_PSYC_MESSAGE_STATE_START = 0,
  423. GNUNET_PSYC_MESSAGE_STATE_HEADER = 1,
  424. GNUNET_PSYC_MESSAGE_STATE_METHOD = 2,
  425. GNUNET_PSYC_MESSAGE_STATE_MODIFIER = 3,
  426. GNUNET_PSYC_MESSAGE_STATE_MOD_CONT = 4,
  427. GNUNET_PSYC_MESSAGE_STATE_DATA = 5,
  428. GNUNET_PSYC_MESSAGE_STATE_END = 6,
  429. GNUNET_PSYC_MESSAGE_STATE_CANCEL = 7,
  430. GNUNET_PSYC_MESSAGE_STATE_ERROR = 8,
  431. };
  432. /**
  433. * Handle that identifies a join request.
  434. *
  435. * Used to match calls to #GNUNET_PSYC_JoinCallback to the
  436. * corresponding calls to GNUNET_PSYC_join_decision().
  437. */
  438. struct GNUNET_PSYC_JoinHandle;
  439. /**
  440. * Method called from PSYC upon receiving a message.
  441. *
  442. * @param cls Closure.
  443. * @param message_id Sequence number of the message.
  444. * @param flags OR'ed GNUNET_PSYC_MessageFlags
  445. * @param msg Message part, one of the following types:
  446. */
  447. typedef void
  448. (*GNUNET_PSYC_MessageCallback) (void *cls,
  449. const struct GNUNET_PSYC_MessageHeader *msg);
  450. /**
  451. * Method called from PSYC upon receiving part of a message.
  452. *
  453. * @param cls
  454. * Closure.
  455. * @param slave_pub_key
  456. * Public key of the slave sending the message.
  457. * Only set for channel master.
  458. * @param message_id
  459. * Sequence number of the message.
  460. * @param flags
  461. * OR'ed GNUNET_PSYC_MessageFlags
  462. * @param fragment_offset
  463. * Multicast message fragment offset.
  464. * @param msg Message part, one of the following types:
  465. * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
  466. * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
  467. * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
  468. * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT
  469. * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
  470. * or NULL if an error occurred while receiving a message.
  471. */
  472. typedef void
  473. (*GNUNET_PSYC_MessagePartCallback) (void *cls,
  474. const struct GNUNET_PSYC_MessageHeader *msg,
  475. const struct GNUNET_MessageHeader *pmsg);
  476. /**
  477. * Method called from PSYC upon receiving a join request.
  478. *
  479. * @param cls
  480. * Closure.
  481. * @param slave_pub_key
  482. * Public key of the slave requesting join.
  483. * @param join_msg
  484. * Join message sent along with the request.
  485. * @param jh
  486. * Join handle to use with GNUNET_PSYC_join_decision()
  487. */
  488. typedef void
  489. (*GNUNET_PSYC_JoinRequestCallback) (void *cls,
  490. const struct GNUNET_PSYC_JoinRequestMessage *req,
  491. const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
  492. const struct GNUNET_PSYC_Message *join_msg,
  493. struct GNUNET_PSYC_JoinHandle *jh);
  494. /**
  495. * Function to call with the decision made for a join request.
  496. *
  497. * Must be called once and only once in response to an invocation of the
  498. * #GNUNET_PSYC_JoinCallback.
  499. *
  500. * @param jh Join request handle.
  501. * @param is_admitted
  502. * #GNUNET_YES if the join is approved,
  503. * #GNUNET_NO if it is disapproved,
  504. * #GNUNET_SYSERR if we cannot answer the request.
  505. * @param relay_count Number of relays given.
  506. * @param relays Array of suggested peers that might be useful relays to use
  507. * when joining the multicast group (essentially a list of peers that
  508. * are already part of the multicast group and might thus be willing
  509. * to help with routing). If empty, only this local peer (which must
  510. * be the multicast origin) is a good candidate for building the
  511. * multicast tree. Note that it is unnecessary to specify our own
  512. * peer identity in this array.
  513. * @param join_resp Application-dependent join response message to send along
  514. * with the decision.
  515. *
  516. * @return #GNUNET_OK on success,
  517. * #GNUNET_SYSERR if @a join_resp is too large.
  518. */
  519. int
  520. GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
  521. int is_admitted,
  522. uint32_t relay_count,
  523. const struct GNUNET_PeerIdentity *relays,
  524. const struct GNUNET_PSYC_Message *join_resp);
  525. /**
  526. * Handle for the master of a PSYC channel.
  527. */
  528. struct GNUNET_PSYC_Master;
  529. /**
  530. * Function called once we are connected to the PSYC service
  531. * and the channel master is started.
  532. *
  533. * Also called when we reconnected to the service
  534. * after the connection closed unexpectedly.
  535. *
  536. * @param cls
  537. * Closure.
  538. * @param result
  539. * #GNUNET_YES if there were already messages sent to the channel,
  540. * #GNUNET_NO if the message history is empty,
  541. * #GNUNET_SYSERR on error.
  542. * @param max_message_id
  543. * Last message ID sent to the channel.
  544. */
  545. typedef void
  546. (*GNUNET_PSYC_MasterStartCallback) (void *cls, int result,
  547. uint64_t max_message_id);
  548. /**
  549. * Start a PSYC master channel.
  550. *
  551. * Will start a multicast group identified by the given ECC key. Messages
  552. * received from group members will be given to the respective handler methods.
  553. * If a new member wants to join a group, the "join" method handler will be
  554. * invoked; the join handler must then generate a "join" message to approve the
  555. * joining of the new member. The channel can also change group membership
  556. * without explicit requests. Note that PSYC doesn't itself "understand" join
  557. * or part messages, the respective methods must call other PSYC functions to
  558. * inform PSYC about the meaning of the respective events.
  559. *
  560. * @param cfg Configuration to use (to connect to PSYC service).
  561. * @param channel_key ECC key that will be used to sign messages for this
  562. * PSYC session. The public key is used to identify the PSYC channel.
  563. * Note that end-users will usually not use the private key directly, but
  564. * rather look it up in GNS for places managed by other users, or select
  565. * a file with the private key(s) when setting up their own channels
  566. * FIXME: we'll likely want to use NOT the p521 curve here, but a cheaper
  567. * one in the future.
  568. * @param policy Channel policy specifying join and history restrictions.
  569. * Used to automate join decisions.
  570. * @param master_start_cb Function to invoke after the channel master started.
  571. * @param join_request_cb Function to invoke when a slave wants to join.
  572. * @param message_cb Function to invoke on message parts sent to the channel
  573. * and received from slaves
  574. * @param cls Closure for @a method and @a join_cb.
  575. *
  576. * @return Handle for the channel master, NULL on error.
  577. */
  578. struct GNUNET_PSYC_Master *
  579. GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
  580. const struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key,
  581. enum GNUNET_PSYC_Policy policy,
  582. GNUNET_PSYC_MasterStartCallback master_start_cb,
  583. GNUNET_PSYC_JoinRequestCallback join_request_cb,
  584. GNUNET_PSYC_MessageCallback message_cb,
  585. GNUNET_PSYC_MessagePartCallback message_part_cb,
  586. void *cls);
  587. /**
  588. * Function called to provide data for a transmission via PSYC.
  589. *
  590. * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
  591. * invalidates the respective transmission handle.
  592. *
  593. * @param cls Closure.
  594. * @param[in,out] data_size Initially set to the number of bytes available in
  595. * @a data, should be set to the number of bytes written to data.
  596. * @param[out] data Where to write the body of the message to give to the
  597. * method. The function must copy at most @a data_size bytes to @a data.
  598. * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
  599. * #GNUNET_NO on success, if more data is to be transmitted later.
  600. * Should be used if @a data_size was not big enough to take all the
  601. * data. If 0 is returned in @a data_size the transmission is paused,
  602. * and can be resumed with GNUNET_PSYC_master_transmit_resume().
  603. * #GNUNET_YES if this completes the transmission (all data supplied)
  604. */
  605. typedef int
  606. (*GNUNET_PSYC_TransmitNotifyData) (void *cls,
  607. uint16_t *data_size,
  608. void *data);
  609. /**
  610. * Function called to provide a modifier for a transmission via PSYC.
  611. *
  612. * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
  613. * invalidates the respective transmission handle.
  614. *
  615. * @param cls Closure.
  616. * @param[in,out] data_size Initially set to the number of bytes available in
  617. * @a data, should be set to the number of bytes written to data.
  618. * @param[out] data Where to write the modifier's name and value.
  619. * The function must copy at most @a data_size bytes to @a data.
  620. * When this callback is first called for a modifier, @a data should
  621. * contain: "name\0value". If the whole value does not fit, subsequent
  622. * calls to this function should write continuations of the value to
  623. * @a data.
  624. * @param[out] oper Where to write the operator of the modifier.
  625. * Only needed during the first call to this callback at the beginning
  626. * of the modifier. In case of subsequent calls asking for value
  627. * continuations @a oper is set to #NULL.
  628. * @param[out] full_value_size Where to write the full size of the value.
  629. * Only needed during the first call to this callback at the beginning
  630. * of the modifier. In case of subsequent calls asking for value
  631. * continuations @a value_size is set to #NULL.
  632. * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
  633. * #GNUNET_NO on success, if more data is to be transmitted later.
  634. * Should be used if @a data_size was not big enough to take all the
  635. * data for the modifier's value (the name must be always returned
  636. * during the first call to this callback).
  637. * If 0 is returned in @a data_size the transmission is paused,
  638. * and can be resumed with GNUNET_PSYC_master_transmit_resume().
  639. * #GNUNET_YES if this completes the modifier (the whole value is supplied).
  640. */
  641. typedef int
  642. (*GNUNET_PSYC_TransmitNotifyModifier) (void *cls,
  643. uint16_t *data_size,
  644. void *data,
  645. uint8_t *oper,
  646. uint32_t *full_value_size);
  647. /**
  648. * Flags for transmitting messages to a channel by the master.
  649. */
  650. enum GNUNET_PSYC_MasterTransmitFlags
  651. {
  652. GNUNET_PSYC_MASTER_TRANSMIT_NONE = 0,
  653. /**
  654. * Whether this message should reset the channel state,
  655. * i.e. remove all previously stored state variables.
  656. */
  657. GNUNET_PSYC_MASTER_TRANSMIT_STATE_RESET = 1 << 0,
  658. /**
  659. * Whether this message contains any state modifiers.
  660. */
  661. GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY = 1 << 1,
  662. /**
  663. * Add PSYC header variable with the hash of the current channel state.
  664. */
  665. GNUNET_PSYC_MASTER_TRANSMIT_STATE_HASH = 1 << 2,
  666. /**
  667. * Whether we need to increment the group generation counter after
  668. * transmitting this message.
  669. */
  670. GNUNET_PSYC_MASTER_TRANSMIT_INC_GROUP_GEN = 1 << 3
  671. };
  672. /**
  673. * Handle for a pending PSYC transmission operation.
  674. */
  675. struct GNUNET_PSYC_MasterTransmitHandle;
  676. /**
  677. * Send a message to call a method to all members in the PSYC channel.
  678. *
  679. * @param master Handle to the PSYC channel.
  680. * @param method_name Which method should be invoked.
  681. * @param notify_mod Function to call to obtain modifiers.
  682. * @param notify_data Function to call to obtain fragments of the data.
  683. * @param notify_cls Closure for @a notify_mod and @a notify_data.
  684. * @param flags Flags for the message being transmitted.
  685. * @return Transmission handle, NULL on error (i.e. more than one request queued).
  686. */
  687. struct GNUNET_PSYC_MasterTransmitHandle *
  688. GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master,
  689. const char *method_name,
  690. GNUNET_PSYC_TransmitNotifyModifier notify_mod,
  691. GNUNET_PSYC_TransmitNotifyData notify_data,
  692. void *notify_cls,
  693. enum GNUNET_PSYC_MasterTransmitFlags flags);
  694. /**
  695. * Resume transmission to the channel.
  696. *
  697. * @param th Handle of the request that is being resumed.
  698. */
  699. void
  700. GNUNET_PSYC_master_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle *th);
  701. /**
  702. * Abort transmission request to channel.
  703. *
  704. * @param th Handle of the request that is being aborted.
  705. */
  706. void
  707. GNUNET_PSYC_master_transmit_cancel (struct GNUNET_PSYC_MasterTransmitHandle *th);
  708. /**
  709. * Relay a message
  710. *
  711. * @param master Handle to the PSYC channel.
  712. * @param method_name Which method should be invoked.
  713. * @param notify_mod Function to call to obtain modifiers.
  714. * @param notify_data Function to call to obtain fragments of the data.
  715. * @param notify_cls Closure for @a notify_mod and @a notify_data.
  716. * @param flags Flags for the message being transmitted.
  717. * @return Transmission handle, NULL on error (i.e. more than one request queued).
  718. */
  719. struct GNUNET_PSYC_MasterTransmitHandle *
  720. GNUNET_PSYC_master_relay (struct GNUNET_PSYC_Master *master,
  721. uint64_t message_id);
  722. /**
  723. * Stop a PSYC master channel.
  724. *
  725. * @param master
  726. * PSYC channel master to stop.
  727. * @param keep_active
  728. * Keep place active after last application disconnected.
  729. * @param stop_cb
  730. * Function called after the master stopped
  731. * and disconnected from the psyc service.
  732. * @param stop_cls
  733. * Closure for @a part_cb.
  734. */
  735. void
  736. GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *master,
  737. int keep_active,
  738. GNUNET_ContinuationCallback stop_cb,
  739. void *stop_cls);
  740. /**
  741. * Handle for a PSYC channel slave.
  742. */
  743. struct GNUNET_PSYC_Slave;
  744. /**
  745. * Function called after the slave connected to the PSYC service.
  746. *
  747. * Also called when reconnected to the service
  748. * after the connection closed unexpectedly.
  749. *
  750. * @param cls
  751. * Closure.
  752. * @param result
  753. * #GNUNET_YES if there were already messages sent to the channel,
  754. * #GNUNET_NO if the message history is empty,
  755. * #GNUNET_SYSERR on error.
  756. * @param max_message_id
  757. * Last message ID sent to the channel.
  758. */
  759. typedef void
  760. (*GNUNET_PSYC_SlaveConnectCallback) (void *cls, int result,
  761. uint64_t max_message_id);
  762. /**
  763. * Method called to inform about the decision in response to a join request.
  764. *
  765. * If @a is_admitted is not #GNUNET_YES, then sending messages to the channel is
  766. * not possible, but earlier history can be still queried.
  767. *
  768. * @param cls Closure.
  769. * @param is_admitted #GNUNET_YES or #GNUNET_NO or #GNUNET_SYSERR
  770. * @param join_msg Application-dependent join message from the origin.
  771. */
  772. typedef void
  773. (*GNUNET_PSYC_JoinDecisionCallback) (void *cls,
  774. const struct GNUNET_PSYC_JoinDecisionMessage *dcsn,
  775. int is_admitted,
  776. const struct GNUNET_PSYC_Message *join_msg);
  777. /**
  778. * Flags for GNUNET_PSYC_slave_join()
  779. */
  780. enum GNUNET_PSYC_SlaveJoinFlags
  781. {
  782. GNUNET_PSYC_SLAVE_JOIN_NONE = 0,
  783. /**
  784. * Local join for history access, no network connection is established.
  785. */
  786. GNUNET_PSYC_SLAVE_JOIN_LOCAL = 1,
  787. };
  788. /**
  789. * Join a PSYC channel.
  790. *
  791. * The entity joining is always the local peer. The user must immediately use
  792. * the GNUNET_PSYC_slave_transmit() functions to transmit a @e join_msg to the
  793. * channel; if the join request succeeds, the channel state (and @e recent
  794. * method calls) will be replayed to the joining member. There is no explicit
  795. * notification on failure (as the channel may simply take days to approve,
  796. * and disapproval is simply being ignored).
  797. *
  798. * @param cfg
  799. * Configuration to use.
  800. * @param channel_pub_key
  801. * ECC public key that identifies the channel we wish to join.
  802. * @param slave_pub_key
  803. * ECC private-public key pair that identifies the slave, and
  804. * used by multicast to sign the join request and subsequent unicast
  805. * requests sent to the master.
  806. * @param flags
  807. * Join flags.
  808. * @param origin
  809. * Peer identity of the origin.
  810. * @param relay_count
  811. * Number of peers in the @a relays array.
  812. * @param relays
  813. * Peer identities of members of the multicast group, which serve
  814. * as relays and used to join the group at.
  815. * @param message_cb
  816. * Function to invoke on message fragments received from the channel.
  817. * @param message_part_cb
  818. * Function to invoke on message parts received from the channel.
  819. * @param slave_connect_cb
  820. * Function invoked once we have connected to the PSYC service.
  821. * @param join_decision_cb
  822. * Function invoked once we have received a join decision.
  823. * @param cls
  824. * Closure for @a message_cb and @a slave_joined_cb.
  825. * @param join_msg
  826. * Join message.
  827. *
  828. * @return Handle for the slave, NULL on error.
  829. */
  830. struct GNUNET_PSYC_Slave *
  831. GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
  832. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_pub_key,
  833. const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_pub_key,
  834. enum GNUNET_PSYC_SlaveJoinFlags flags,
  835. const struct GNUNET_PeerIdentity *origin,
  836. uint32_t relay_count,
  837. const struct GNUNET_PeerIdentity *relays,
  838. GNUNET_PSYC_MessageCallback message_cb,
  839. GNUNET_PSYC_MessagePartCallback message_part_cb,
  840. GNUNET_PSYC_SlaveConnectCallback slave_connect_cb,
  841. GNUNET_PSYC_JoinDecisionCallback join_decision_cb,
  842. void *cls,
  843. const struct GNUNET_PSYC_Message *join_msg);
  844. /**
  845. * Part a PSYC channel.
  846. *
  847. * Will terminate the connection to the PSYC service. Polite clients should
  848. * first explicitly send a part request (via GNUNET_PSYC_slave_transmit()).
  849. *
  850. * @param slave
  851. * Slave handle.
  852. * @param keep_active
  853. * Keep place active after last application disconnected.
  854. * @param part_cb
  855. * Function called after the slave parted the channel
  856. * and disconnected from the psyc service.
  857. * @param part_cls
  858. * Closure for @a part_cb.
  859. */
  860. void
  861. GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave,
  862. int keep_active,
  863. GNUNET_ContinuationCallback part_cb,
  864. void *part_cls);
  865. /**
  866. * Flags for transmitting messages to the channel master by a slave.
  867. */
  868. enum GNUNET_PSYC_SlaveTransmitFlags
  869. {
  870. GNUNET_PSYC_SLAVE_TRANSMIT_NONE = 0
  871. };
  872. /**
  873. * Handle for a pending PSYC transmission operation.
  874. */
  875. struct GNUNET_PSYC_SlaveTransmitHandle;
  876. /**
  877. * Request a message to be sent to the channel master.
  878. *
  879. * @param slave Slave handle.
  880. * @param method_name Which (PSYC) method should be invoked (on host).
  881. * @param notify_mod Function to call to obtain modifiers.
  882. * @param notify_data Function to call to obtain fragments of the data.
  883. * @param notify_cls Closure for @a notify.
  884. * @param flags Flags for the message being transmitted.
  885. * @return Transmission handle, NULL on error (i.e. more than one request queued).
  886. */
  887. struct GNUNET_PSYC_SlaveTransmitHandle *
  888. GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave,
  889. const char *method_name,
  890. GNUNET_PSYC_TransmitNotifyModifier notify_mod,
  891. GNUNET_PSYC_TransmitNotifyData notify_data,
  892. void *notify_cls,
  893. enum GNUNET_PSYC_SlaveTransmitFlags flags);
  894. /**
  895. * Resume transmission to the master.
  896. *
  897. * @param th Handle of the request that is being resumed.
  898. */
  899. void
  900. GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_SlaveTransmitHandle *th);
  901. /**
  902. * Abort transmission request to master.
  903. *
  904. * @param th Handle of the request that is being aborted.
  905. */
  906. void
  907. GNUNET_PSYC_slave_transmit_cancel (struct GNUNET_PSYC_SlaveTransmitHandle *th);
  908. /**
  909. * Handle to access PSYC channel operations for both the master and slaves.
  910. */
  911. struct GNUNET_PSYC_Channel;
  912. /**
  913. * Convert a channel @a master to a @e channel handle to access the @e channel
  914. * APIs.
  915. *
  916. * @param master Channel master handle.
  917. * @return Channel handle, valid for as long as @a master is valid.
  918. */
  919. struct GNUNET_PSYC_Channel *
  920. GNUNET_PSYC_master_get_channel (struct GNUNET_PSYC_Master *master);
  921. /**
  922. * Convert @a slave to a @e channel handle to access the @e channel APIs.
  923. *
  924. * @param slave Slave handle.
  925. * @return Channel handle, valid for as long as @a slave is valid.
  926. */
  927. struct GNUNET_PSYC_Channel *
  928. GNUNET_PSYC_slave_get_channel (struct GNUNET_PSYC_Slave *slave);
  929. /**
  930. * Add a slave to the channel's membership list.
  931. *
  932. * Note that this will NOT generate any PSYC traffic, it will merely update the
  933. * local database to modify how we react to <em>membership test</em> queries.
  934. * The channel master still needs to explicitly transmit a @e join message to
  935. * notify other channel members and they then also must still call this function
  936. * in their respective methods handling the @e join message. This way, how @e
  937. * join and @e part operations are exactly implemented is still up to the
  938. * application; for example, there might be a @e part_all method to kick out
  939. * everyone.
  940. *
  941. * Note that channel slaves are explicitly trusted to execute such methods
  942. * correctly; not doing so correctly will result in either denying other slaves
  943. * access or offering access to channel data to non-members.
  944. *
  945. * @param channel
  946. * Channel handle.
  947. * @param slave_pub_key
  948. * Identity of channel slave to add.
  949. * @param announced_at
  950. * ID of the message that announced the membership change.
  951. * @param effective_since
  952. * Addition of slave is in effect since this message ID.
  953. * @param result_cb
  954. * Function to call with the result of the operation.
  955. * The @e result_code argument is #GNUNET_OK on success, or
  956. * #GNUNET_SYSERR on error. In case of an error, the @e data argument
  957. * can contain an optional error message.
  958. * @param cls
  959. * Closure for @a result_cb.
  960. */
  961. void
  962. GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel,
  963. const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
  964. uint64_t announced_at,
  965. uint64_t effective_since,
  966. GNUNET_ResultCallback result_cb,
  967. void *cls);
  968. /**
  969. * Remove a slave from the channel's membership list.
  970. *
  971. * Note that this will NOT generate any PSYC traffic, it will merely update the
  972. * local database to modify how we react to <em>membership test</em> queries.
  973. * The channel master still needs to explicitly transmit a @e part message to
  974. * notify other channel members and they then also must still call this function
  975. * in their respective methods handling the @e part message. This way, how
  976. * @e join and @e part operations are exactly implemented is still up to the
  977. * application; for example, there might be a @e part_all message to kick out
  978. * everyone.
  979. *
  980. * Note that channel members are explicitly trusted to perform these
  981. * operations correctly; not doing so correctly will result in either
  982. * denying members access or offering access to channel data to
  983. * non-members.
  984. *
  985. * @param channel
  986. * Channel handle.
  987. * @param slave_pub_key
  988. * Identity of channel slave to remove.
  989. * @param announced_at
  990. * ID of the message that announced the membership change.
  991. * @param result_cb
  992. * Function to call with the result of the operation.
  993. * The @e result_code argument is #GNUNET_OK on success, or
  994. * #GNUNET_SYSERR on error. In case of an error, the @e data argument
  995. * can contain an optional error message.
  996. * @param cls
  997. * Closure for @a result_cb.
  998. */
  999. void
  1000. GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel,
  1001. const struct GNUNET_CRYPTO_EcdsaPublicKey
  1002. *slave_pub_key,
  1003. uint64_t announced_at,
  1004. GNUNET_ResultCallback result_cb,
  1005. void *cls);
  1006. /**
  1007. * History request handle.
  1008. */
  1009. struct GNUNET_PSYC_HistoryRequest;
  1010. /**
  1011. * Request to replay a part of the message history of the channel.
  1012. *
  1013. * Historic messages (but NOT the state at the time) will be replayed (given to
  1014. * the normal method handlers) if available and if access is permitted.
  1015. *
  1016. * @param channel
  1017. * Which channel should be replayed?
  1018. * @param start_message_id
  1019. * Earliest interesting point in history.
  1020. * @param end_message_id
  1021. * Last (inclusive) interesting point in history.
  1022. * @param method_prefix
  1023. * Retrieve only messages with a matching method prefix.
  1024. * @param flags
  1025. * OR'ed enum GNUNET_PSYC_HistoryReplayFlags
  1026. * @param result_cb
  1027. * Function to call when the requested history has been fully replayed.
  1028. * Once this function has been called, the client must not call
  1029. * GNUNET_PSYC_channel_history_replay_cancel() anymore.
  1030. * @param cls
  1031. * Closure for the callbacks.
  1032. *
  1033. * @return Handle to cancel history replay operation.
  1034. */
  1035. struct GNUNET_PSYC_HistoryRequest *
  1036. GNUNET_PSYC_channel_history_replay (struct GNUNET_PSYC_Channel *channel,
  1037. uint64_t start_message_id,
  1038. uint64_t end_message_id,
  1039. const char *method_prefix,
  1040. uint32_t flags,
  1041. GNUNET_PSYC_MessageCallback message_cb,
  1042. GNUNET_PSYC_MessagePartCallback message_part_cb,
  1043. GNUNET_ResultCallback result_cb,
  1044. void *cls);
  1045. /**
  1046. * Request to replay the latest messages from the message history of the channel.
  1047. *
  1048. * Historic messages (but NOT the state at the time) will be replayed (given to
  1049. * the normal method handlers) if available and if access is permitted.
  1050. *
  1051. * @param channel
  1052. * Which channel should be replayed?
  1053. * @param message_limit
  1054. * Maximum number of messages to replay.
  1055. * @param flags
  1056. * OR'ed enum GNUNET_PSYC_HistoryReplayFlags
  1057. * @param finish_cb
  1058. * Function to call when the requested history has been fully replayed
  1059. * (counting message IDs might not suffice, as some messages might be
  1060. * secret and thus the listener would not know the story is finished
  1061. * without being told explicitly)o once this function has been called, the
  1062. * client must not call GNUNET_PSYC_channel_history_replay_cancel() anymore.
  1063. * @param cls
  1064. * Closure for the callbacks.
  1065. *
  1066. * @return Handle to cancel history replay operation.
  1067. */
  1068. struct GNUNET_PSYC_HistoryRequest *
  1069. GNUNET_PSYC_channel_history_replay_latest (struct GNUNET_PSYC_Channel *channel,
  1070. uint64_t message_limit,
  1071. const char *method_prefix,
  1072. uint32_t flags,
  1073. GNUNET_PSYC_MessageCallback message_cb,
  1074. GNUNET_PSYC_MessagePartCallback message_part_cb,
  1075. GNUNET_ResultCallback result_cb,
  1076. void *cls);
  1077. void
  1078. GNUNET_PSYC_channel_history_replay_cancel (struct GNUNET_PSYC_Channel *channel,
  1079. struct GNUNET_PSYC_HistoryRequest *hr);
  1080. /**
  1081. * Function called to inform a member about stored state values for a channel.
  1082. *
  1083. * If @a full_value_size > value_size then this function is called multiple
  1084. * times until the whole value arrived.
  1085. *
  1086. * @param cls
  1087. * Closure.
  1088. * @param name
  1089. * Name of the state variable.
  1090. * NULL if there are no more state variables to be returned.
  1091. * @param value
  1092. * Value of the state variable.
  1093. * @param value_size
  1094. * Number of bytes in @a value.
  1095. * @param full_value_size
  1096. * Number of bytes in the full value, including continuations.
  1097. * Only set for the first part of a variable,
  1098. * in case of a continuation it is 0.
  1099. */
  1100. typedef void
  1101. (*GNUNET_PSYC_StateVarCallback) (void *cls,
  1102. const struct GNUNET_MessageHeader *mod,
  1103. const char *name,
  1104. const void *value,
  1105. uint32_t value_size,
  1106. uint32_t full_value_size);
  1107. /**
  1108. * State request handle.
  1109. */
  1110. struct GNUNET_PSYC_StateRequest;
  1111. /**
  1112. * Retrieve the best matching channel state variable.
  1113. *
  1114. * If the requested variable name is not present in the state, the nearest
  1115. * less-specific name is matched; for example, requesting "_a_b" will match "_a"
  1116. * if "_a_b" does not exist.
  1117. *
  1118. * @param channel
  1119. * Channel handle.
  1120. * @param full_name
  1121. * Full name of the requested variable.
  1122. * The actual variable returned might have a shorter name.
  1123. * @param var_cb
  1124. * Function called once when a matching state variable is found.
  1125. * Not called if there's no matching state variable.
  1126. * @param result_cb
  1127. * Function called after the operation finished.
  1128. * (i.e. all state variables have been returned via @a state_cb)
  1129. * @param cls
  1130. * Closure for the callbacks.
  1131. */
  1132. struct GNUNET_PSYC_StateRequest *
  1133. GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel,
  1134. const char *full_name,
  1135. GNUNET_PSYC_StateVarCallback var_cb,
  1136. GNUNET_ResultCallback result_cb,
  1137. void *cls);
  1138. /**
  1139. * Return all channel state variables whose name matches a given prefix.
  1140. *
  1141. * A name matches if it starts with the given @a name_prefix, thus requesting
  1142. * the empty prefix ("") will match all values; requesting "_a_b" will also
  1143. * return values stored under "_a_b_c".
  1144. *
  1145. * The @a state_cb is invoked on all matching state variables asynchronously, as
  1146. * the state is stored in and retrieved from the PSYCstore,
  1147. *
  1148. * @param channel
  1149. * Channel handle.
  1150. * @param name_prefix
  1151. * Prefix of the state variable name to match.
  1152. * @param var_cb
  1153. * Function called once when a matching state variable is found.
  1154. * Not called if there's no matching state variable.
  1155. * @param result_cb
  1156. * Function called after the operation finished.
  1157. * (i.e. all state variables have been returned via @a state_cb)
  1158. * @param cls
  1159. * Closure for the callbacks.
  1160. */
  1161. struct GNUNET_PSYC_StateRequest *
  1162. GNUNET_PSYC_channel_state_get_prefix (struct GNUNET_PSYC_Channel *channel,
  1163. const char *name_prefix,
  1164. GNUNET_PSYC_StateVarCallback var_cb,
  1165. GNUNET_ResultCallback result_cb,
  1166. void *cls);
  1167. /**
  1168. * Cancel a state request operation.
  1169. *
  1170. * @param sr
  1171. * Handle for the operation to cancel.
  1172. */
  1173. void
  1174. GNUNET_PSYC_channel_state_get_cancel (struct GNUNET_PSYC_StateRequest *sr);
  1175. #if 0 /* keep Emacsens' auto-indent happy */
  1176. {
  1177. #endif
  1178. #ifdef __cplusplus
  1179. }
  1180. #endif
  1181. /* ifndef GNUNET_PSYC_SERVICE_H */
  1182. #endif
  1183. /** @} */ /* end of group */