aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_psyc_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
committerGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
commit3cf8ba0b60f8495892fa76635e9c23555d0a304c (patch)
tree5f27648bdb3cf3409628e4e5edc26f811cbd03a5 /src/include/gnunet_psyc_service.h
parent252b5599987b7ba03b879a8c2d1c455ad4c9834a (diff)
downloadgnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.tar.gz
gnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.zip
social: implement enter/leave/messaging; psyc: improvements and fixes
- social: implement enter/leave, send/receive messages, slicer - psyc, social: add struct GNUNET_PSYC_Message for single-fragment join messages - psyc: add message callback in addition to message part callback - client_manager, social, psyc, multicast: add disconnect callback
Diffstat (limited to 'src/include/gnunet_psyc_service.h')
-rw-r--r--src/include/gnunet_psyc_service.h111
1 files changed, 92 insertions, 19 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index 2ea282fa3..7097c46a8 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -190,6 +190,24 @@ enum GNUNET_PSYC_StateDeltaValues
190GNUNET_NETWORK_STRUCT_BEGIN 190GNUNET_NETWORK_STRUCT_BEGIN
191 191
192/** 192/**
193 * A PSYC message.
194 *
195 * Used for single-fragment messages e.g. in a join request or response.
196 */
197struct GNUNET_PSYC_Message
198{
199 /**
200 * Message header with size and type information.
201 */
202 struct GNUNET_MessageHeader header;
203
204 /* Followed by concatenated PSYC message parts:
205 * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types
206 */
207};
208
209
210/**
193 * Header of a PSYC message. 211 * Header of a PSYC message.
194 * 212 *
195 * Only present when receiving a message. 213 * Only present when receiving a message.
@@ -215,6 +233,12 @@ struct GNUNET_PSYC_MessageHeader
215 uint64_t message_id GNUNET_PACKED; 233 uint64_t message_id GNUNET_PACKED;
216 234
217 /** 235 /**
236 * Byte offset of this @e fragment of the @e message.
237 * FIXME: use data_offset instead
238 */
239 uint64_t fragment_offset GNUNET_PACKED;
240
241 /**
218 * Sending slave's public key. 242 * Sending slave's public key.
219 * Not set if the message is from the master. 243 * Not set if the message is from the master.
220 */ 244 */
@@ -299,6 +323,9 @@ struct GNUNET_PSYC_CountersResultMessage
299}; 323};
300 324
301 325
326/**
327 * Join request sent to a PSYC master.
328 */
302struct GNUNET_PSYC_JoinRequestMessage 329struct GNUNET_PSYC_JoinRequestMessage
303{ 330{
304 /** 331 /**
@@ -314,6 +341,9 @@ struct GNUNET_PSYC_JoinRequestMessage
314}; 341};
315 342
316 343
344/**
345 * Join decision sent in reply to a join request.
346 */
317struct GNUNET_PSYC_JoinDecisionMessage 347struct GNUNET_PSYC_JoinDecisionMessage
318{ 348{
319 /** 349 /**
@@ -379,23 +409,42 @@ struct GNUNET_PSYC_JoinHandle;
379 409
380 410
381/** 411/**
382 * Method called from PSYC upon receiving part of a message. 412 * Method called from PSYC upon receiving a message.
383 * 413 *
384 * @param cls Closure. 414 * @param cls Closure.
385 * @param message_id Sequence number of the message. 415 * @param message_id Sequence number of the message.
386 * @param flags OR'ed GNUNET_PSYC_MessageFlags 416 * @param flags OR'ed GNUNET_PSYC_MessageFlags
387 * @param msg Message part, one of the following types: 417 * @param msg Message part, one of the following types:
388 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
389 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
390 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
391 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT
392 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
393 */ 418 */
394typedef void 419typedef void
395(*GNUNET_PSYC_MessageCallback) (void *cls, 420(*GNUNET_PSYC_MessageCallback) (void *cls,
396 uint64_t message_id, 421 uint64_t message_id,
397 uint32_t flags, 422 uint32_t flags,
398 const struct GNUNET_MessageHeader *msg); 423 const struct GNUNET_PSYC_MessageHeader *msg);
424
425
426/**
427 * Method called from PSYC upon receiving part of a message.
428 *
429 * @param cls Closure.
430 * @param message_id Sequence number of the message.
431 * @param data_offset Byte offset of data, only set if @a msg has a type
432 * #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
433 * @param flags OR'ed GNUNET_PSYC_MessageFlags
434 * @param msg Message part, one of the following types:
435 * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
436 * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
437 * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
438 * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT
439 * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
440 * or NULL if an error occurred while receiving a message.
441 */
442typedef void
443(*GNUNET_PSYC_MessagePartCallback) (void *cls,
444 uint64_t message_id,
445 uint64_t data_offset,
446 uint32_t flags,
447 const struct GNUNET_MessageHeader *msg);
399 448
400 449
401/** 450/**
@@ -408,10 +457,9 @@ typedef void
408 */ 457 */
409typedef void 458typedef void
410(*GNUNET_PSYC_JoinRequestCallback) (void *cls, 459(*GNUNET_PSYC_JoinRequestCallback) (void *cls,
411 const struct 460 const struct GNUNET_PSYC_JoinRequestMessage *req,
412 GNUNET_CRYPTO_EcdsaPublicKey *slave_key, 461 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
413 const struct 462 const struct GNUNET_PSYC_Message *join_msg,
414 GNUNET_PSYC_MessageHeader *join_msg,
415 struct GNUNET_PSYC_JoinHandle *jh); 463 struct GNUNET_PSYC_JoinHandle *jh);
416 464
417 465
@@ -445,7 +493,7 @@ GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
445 int is_admitted, 493 int is_admitted,
446 uint32_t relay_count, 494 uint32_t relay_count,
447 const struct GNUNET_PeerIdentity *relays, 495 const struct GNUNET_PeerIdentity *relays,
448 const struct GNUNET_PSYC_MessageHeader *join_resp); 496 const struct GNUNET_PSYC_Message *join_resp);
449 497
450 498
451/** 499/**
@@ -501,6 +549,7 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
501 GNUNET_PSYC_MasterStartCallback master_start_cb, 549 GNUNET_PSYC_MasterStartCallback master_start_cb,
502 GNUNET_PSYC_JoinRequestCallback join_request_cb, 550 GNUNET_PSYC_JoinRequestCallback join_request_cb,
503 GNUNET_PSYC_MessageCallback message_cb, 551 GNUNET_PSYC_MessageCallback message_cb,
552 GNUNET_PSYC_MessagePartCallback message_part_cb,
504 void *cls); 553 void *cls);
505 554
506 555
@@ -645,10 +694,21 @@ GNUNET_PSYC_master_transmit_cancel (struct GNUNET_PSYC_MasterTransmitHandle *th)
645/** 694/**
646 * Stop a PSYC master channel. 695 * Stop a PSYC master channel.
647 * 696 *
648 * @param master PSYC channel master to stop. 697 * @param master
698 * PSYC channel master to stop.
699 * @param keep_active
700 * Keep place active after last application disconnected.
701 * @param stop_cb
702 * Function called after the master stopped
703 * and disconnected from the psyc service.
704 * @param stop_cls
705 * Closure for @a part_cb.
649 */ 706 */
650void 707void
651GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *master); 708GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *master,
709 int keep_active,
710 GNUNET_ContinuationCallback stop_cb,
711 void *stop_cls);
652 712
653 713
654/** 714/**
@@ -679,9 +739,9 @@ typedef void
679 */ 739 */
680typedef void 740typedef void
681(*GNUNET_PSYC_JoinDecisionCallback) (void *cls, 741(*GNUNET_PSYC_JoinDecisionCallback) (void *cls,
742 const struct GNUNET_PSYC_JoinDecisionMessage *dcsn,
682 int is_admitted, 743 int is_admitted,
683 const struct 744 const struct GNUNET_PSYC_Message *join_msg);
684 GNUNET_PSYC_MessageHeader *join_msg);
685 745
686 746
687/** 747/**
@@ -726,10 +786,11 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
726 uint32_t relay_count, 786 uint32_t relay_count,
727 const struct GNUNET_PeerIdentity *relays, 787 const struct GNUNET_PeerIdentity *relays,
728 GNUNET_PSYC_MessageCallback message_cb, 788 GNUNET_PSYC_MessageCallback message_cb,
789 GNUNET_PSYC_MessagePartCallback message_part_cb,
729 GNUNET_PSYC_SlaveConnectCallback slave_connect_cb, 790 GNUNET_PSYC_SlaveConnectCallback slave_connect_cb,
730 GNUNET_PSYC_JoinDecisionCallback join_decision_cb, 791 GNUNET_PSYC_JoinDecisionCallback join_decision_cb,
731 void *cls, 792 void *cls,
732 const struct GNUNET_MessageHeader *join_msg); 793 const struct GNUNET_PSYC_Message *join_msg);
733 794
734 795
735/** 796/**
@@ -738,10 +799,21 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
738 * Will terminate the connection to the PSYC service. Polite clients should 799 * Will terminate the connection to the PSYC service. Polite clients should
739 * first explicitly send a part request (via GNUNET_PSYC_slave_transmit()). 800 * first explicitly send a part request (via GNUNET_PSYC_slave_transmit()).
740 * 801 *
741 * @param slave Slave handle. 802 * @param slave
803 * Slave handle.
804 * @param keep_active
805 * Keep place active after last application disconnected.
806 * @param part_cb
807 * Function called after the slave parted the channel
808 * and disconnected from the psyc service.
809 * @param part_cls
810 * Closure for @a part_cb.
742 */ 811 */
743void 812void
744GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave); 813GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave,
814 int keep_active,
815 GNUNET_ContinuationCallback part_cb,
816 void *part_cls);
745 817
746 818
747/** 819/**
@@ -937,6 +1009,7 @@ GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel,
937 uint64_t start_message_id, 1009 uint64_t start_message_id,
938 uint64_t end_message_id, 1010 uint64_t end_message_id,
939 GNUNET_PSYC_MessageCallback message_cb, 1011 GNUNET_PSYC_MessageCallback message_cb,
1012 GNUNET_PSYC_MessagePartCallback message_part_cb,
940 GNUNET_PSYC_FinishCallback finish_cb, 1013 GNUNET_PSYC_FinishCallback finish_cb,
941 void *cls); 1014 void *cls);
942 1015