diff options
author | Gabor X Toth <*@tg-x.net> | 2014-07-23 16:19:49 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-07-23 16:19:49 +0000 |
commit | 3cf8ba0b60f8495892fa76635e9c23555d0a304c (patch) | |
tree | 5f27648bdb3cf3409628e4e5edc26f811cbd03a5 /src/include | |
parent | 252b5599987b7ba03b879a8c2d1c455ad4c9834a (diff) | |
download | gnunet-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')
-rw-r--r-- | src/include/gnunet_client_manager_lib.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_common.h | 9 | ||||
-rw-r--r-- | src/include/gnunet_multicast_service.h | 8 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 22 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 111 | ||||
-rw-r--r-- | src/include/gnunet_psyc_util_lib.h | 28 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 261 |
7 files changed, 329 insertions, 116 deletions
diff --git a/src/include/gnunet_client_manager_lib.h b/src/include/gnunet_client_manager_lib.h index 6ed2ddb17..07d9d2807 100644 --- a/src/include/gnunet_client_manager_lib.h +++ b/src/include/gnunet_client_manager_lib.h | |||
@@ -119,10 +119,14 @@ GNUNET_CLIENT_MANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
119 | * | 119 | * |
120 | * @param mgr Client manager connection. | 120 | * @param mgr Client manager connection. |
121 | * @param transmit_queue Transmit pending messages in queue before disconnecting. | 121 | * @param transmit_queue Transmit pending messages in queue before disconnecting. |
122 | * @param disconnect_cb Function called after disconnected from the service. | ||
123 | * @param disconnect_cls Closure for @a disconnect_cb. | ||
122 | */ | 124 | */ |
123 | void | 125 | void |
124 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 126 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
125 | int transmit_queue); | 127 | int transmit_queue, |
128 | GNUNET_ContinuationCallback disconnect_cb, | ||
129 | void *disconnect_cls); | ||
126 | 130 | ||
127 | 131 | ||
128 | /** | 132 | /** |
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index d8444e100..2b501f91f 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -264,6 +264,15 @@ typedef int | |||
264 | const char *filename); | 264 | const char *filename); |
265 | 265 | ||
266 | 266 | ||
267 | /** | ||
268 | * Generic continuation callback. | ||
269 | * | ||
270 | * @param cls Closure. | ||
271 | */ | ||
272 | typedef void | ||
273 | (*GNUNET_ContinuationCallback) (void *cls); | ||
274 | |||
275 | |||
267 | /* ****************************** logging ***************************** */ | 276 | /* ****************************** logging ***************************** */ |
268 | 277 | ||
269 | /** | 278 | /** |
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index 41227b925..5b8ff1894 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -666,7 +666,9 @@ GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginTransmitHan | |||
666 | * @param origin Multicast group to stop. | 666 | * @param origin Multicast group to stop. |
667 | */ | 667 | */ |
668 | void | 668 | void |
669 | GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin); | 669 | GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin, |
670 | GNUNET_ContinuationCallback stop_cb, | ||
671 | void *stop_cls); | ||
670 | 672 | ||
671 | 673 | ||
672 | /** | 674 | /** |
@@ -795,7 +797,9 @@ GNUNET_MULTICAST_member_replay_cancel (struct GNUNET_MULTICAST_MemberReplayHandl | |||
795 | * @param member Membership handle. | 797 | * @param member Membership handle. |
796 | */ | 798 | */ |
797 | void | 799 | void |
798 | GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member); | 800 | GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member, |
801 | GNUNET_ContinuationCallback part_cb, | ||
802 | void *part_cls); | ||
799 | 803 | ||
800 | 804 | ||
801 | /** | 805 | /** |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 3451cdbf4..cff78eea6 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2158,32 +2158,34 @@ extern "C" | |||
2158 | /** C->S: request to add channel slave to the membership database */ | 2158 | /** C->S: request to add channel slave to the membership database */ |
2159 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 | 2159 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 |
2160 | 2160 | ||
2161 | 2161 | /** S<--C: PSYC message which contains one or more message parts. */ | |
2162 | /** M<->S<->C: PSYC message which contains one or more message parts. */ | ||
2163 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 | 2162 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 |
2164 | 2163 | ||
2164 | /** M<->S<->C: PSYC message which contains a header and one or more message parts. */ | ||
2165 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER 692 // FIXME: start using this where appropriate | ||
2166 | |||
2165 | /** Message part: method */ | 2167 | /** Message part: method */ |
2166 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 692 | 2168 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 |
2167 | 2169 | ||
2168 | /** Message part: modifier */ | 2170 | /** Message part: modifier */ |
2169 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 693 | 2171 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 694 |
2170 | 2172 | ||
2171 | /** Message part: modifier continuation */ | 2173 | /** Message part: modifier continuation */ |
2172 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 694 | 2174 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 695 |
2173 | 2175 | ||
2174 | /** Message part: data */ | 2176 | /** Message part: data */ |
2175 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 695 | 2177 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 696 |
2176 | 2178 | ||
2177 | /** Message part: end of message */ | 2179 | /** Message part: end of message */ |
2178 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 696 | 2180 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 697 |
2179 | 2181 | ||
2180 | /** Message part: message cancelled */ | 2182 | /** Message part: message cancelled */ |
2181 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 | 2183 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 698 |
2182 | 2184 | ||
2183 | /** S->C: message acknowledgement */ | 2185 | /** S->C: message acknowledgement */ |
2184 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 | 2186 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 699 |
2185 | 2187 | ||
2186 | /* 699-700 */ | 2188 | /* 700 */ |
2187 | 2189 | ||
2188 | /** C->S: client requests channel history from PSYCstore. */ | 2190 | /** C->S: client requests channel history from PSYCstore. */ |
2189 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 | 2191 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 |
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 | |||
190 | GNUNET_NETWORK_STRUCT_BEGIN | 190 | GNUNET_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 | */ | ||
197 | struct 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 | */ | ||
302 | struct GNUNET_PSYC_JoinRequestMessage | 329 | struct 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 | */ | ||
317 | struct GNUNET_PSYC_JoinDecisionMessage | 347 | struct 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 | */ |
394 | typedef void | 419 | typedef 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 | */ | ||
442 | typedef 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 | */ |
409 | typedef void | 458 | typedef 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 | */ |
650 | void | 707 | void |
651 | GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *master); | 708 | GNUNET_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 | */ |
680 | typedef void | 740 | typedef 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 | */ |
743 | void | 812 | void |
744 | GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave); | 813 | GNUNET_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 | ||
diff --git a/src/include/gnunet_psyc_util_lib.h b/src/include/gnunet_psyc_util_lib.h index f356b245b..b71f52910 100644 --- a/src/include/gnunet_psyc_util_lib.h +++ b/src/include/gnunet_psyc_util_lib.h | |||
@@ -55,12 +55,36 @@ extern "C" | |||
55 | * @return Message header with size information, | 55 | * @return Message header with size information, |
56 | * followed by the message parts. | 56 | * followed by the message parts. |
57 | */ | 57 | */ |
58 | struct GNUNET_MessageHeader * | 58 | struct GNUNET_PSYC_Message * |
59 | GNUNET_PSYC_message_create (const char *method_name, | 59 | GNUNET_PSYC_message_create (const char *method_name, |
60 | const struct GNUNET_ENV_Environment *env, | 60 | const struct GNUNET_ENV_Environment *env, |
61 | const void *data, | 61 | const void *data, |
62 | size_t data_size); | 62 | size_t data_size); |
63 | 63 | ||
64 | /** | ||
65 | * Parse PSYC message. | ||
66 | * | ||
67 | * @param msg | ||
68 | * The PSYC message to parse. | ||
69 | * @param env | ||
70 | * The environment for the message with a list of modifiers. | ||
71 | * @param[out] method_name | ||
72 | * Pointer to the method name inside @a pmsg. | ||
73 | * @param[out] data | ||
74 | * Pointer to data inside @a pmsg. | ||
75 | * @param[out] data_size | ||
76 | * Size of @data is written here. | ||
77 | * | ||
78 | * @return #GNUNET_OK on success, | ||
79 | * #GNUNET_SYSERR on parse error. | ||
80 | */ | ||
81 | int | ||
82 | GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_Message *msg, | ||
83 | const char **method_name, | ||
84 | struct GNUNET_ENV_Environment *env, | ||
85 | const void **data, | ||
86 | uint16_t *data_size); | ||
87 | |||
64 | 88 | ||
65 | void | 89 | void |
66 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | 90 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, |
@@ -150,7 +174,7 @@ struct GNUNET_PSYC_ReceiveHandle; | |||
150 | */ | 174 | */ |
151 | struct GNUNET_PSYC_ReceiveHandle * | 175 | struct GNUNET_PSYC_ReceiveHandle * |
152 | GNUNET_PSYC_receive_create (GNUNET_PSYC_MessageCallback message_cb, | 176 | GNUNET_PSYC_receive_create (GNUNET_PSYC_MessageCallback message_cb, |
153 | GNUNET_PSYC_MessageCallback hist_message_cb, | 177 | GNUNET_PSYC_MessagePartCallback message_part_cb, |
154 | void *cb_cls); | 178 | void *cb_cls); |
155 | 179 | ||
156 | 180 | ||
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index f8b24c161..ca1578820 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -81,6 +81,8 @@ struct GNUNET_SOCIAL_Slicer; | |||
81 | * | 81 | * |
82 | * @param cls | 82 | * @param cls |
83 | * Closure. | 83 | * Closure. |
84 | * @param msg | ||
85 | * Message part, as it arrived from the network. | ||
84 | * @param message_id | 86 | * @param message_id |
85 | * Message counter, monotonically increasing from 1. | 87 | * Message counter, monotonically increasing from 1. |
86 | * @param nym | 88 | * @param nym |
@@ -92,12 +94,53 @@ struct GNUNET_SOCIAL_Slicer; | |||
92 | * Original method name from PSYC. | 94 | * Original method name from PSYC. |
93 | * May be more specific than the registered method name due to | 95 | * May be more specific than the registered method name due to |
94 | * try-and-slice matching. | 96 | * try-and-slice matching. |
95 | * @param env | 97 | */ |
96 | * Environment with operations and variables for the message. | 98 | typedef void |
97 | * Only set for the first call of this function for each @a message_id, | 99 | (*GNUNET_SOCIAL_MethodCallback) (void *cls, |
98 | * NULL when notifying about further data fragments. | 100 | const struct GNUNET_PSYC_MessageMethod *msg, |
99 | * It has to be freed using GNUNET_ENV_environment_destroy() | 101 | uint64_t message_id, |
100 | * when it is not needed anymore. | 102 | uint32_t flags, |
103 | const struct GNUNET_SOCIAL_Nym *nym, | ||
104 | const char *method_name); | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Function called upon receiving a data fragment of a message. | ||
109 | * | ||
110 | * @param cls | ||
111 | * Closure. | ||
112 | * @param message_id | ||
113 | * Message ID this data fragment belongs to. | ||
114 | * @param msg | ||
115 | * Message part, as it arrived from the network. | ||
116 | * @param oper | ||
117 | * Operation to perform. | ||
118 | * @param name | ||
119 | * Name of the modifier. | ||
120 | * @param value | ||
121 | * Value of the modifier. | ||
122 | * @param value_size | ||
123 | * Size of @value. | ||
124 | */ | ||
125 | typedef void | ||
126 | (*GNUNET_SOCIAL_ModifierCallback) (void *cls, | ||
127 | const struct GNUNET_PSYC_MessageModifier *msg, | ||
128 | uint64_t message_id, | ||
129 | enum GNUNET_ENV_Operator oper, | ||
130 | const char *name, | ||
131 | const void *value, | ||
132 | uint16_t value_size); | ||
133 | |||
134 | |||
135 | /** | ||
136 | * Function called upon receiving a data fragment of a message. | ||
137 | * | ||
138 | * @param cls | ||
139 | * Closure. | ||
140 | * @param message_id | ||
141 | * Message ID this data fragment belongs to. | ||
142 | * @param msg | ||
143 | * Message part, as it arrived from the network. | ||
101 | * @param data_offset | 144 | * @param data_offset |
102 | * Byte offset of @a data in the overall data of the method. | 145 | * Byte offset of @a data in the overall data of the method. |
103 | * @param data_size | 146 | * @param data_size |
@@ -106,21 +149,37 @@ struct GNUNET_SOCIAL_Slicer; | |||
106 | * Data stream given to the method. | 149 | * Data stream given to the method. |
107 | * @param end | 150 | * @param end |
108 | * End of message? | 151 | * End of message? |
109 | * #GNUNET_NO if there are further fragments, | 152 | * #GNUNET_NO if there are further fragments, |
110 | * #GNUNET_YES if this is the last fragment, | 153 | * #GNUNET_YES if this is the last fragment, |
111 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. | 154 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. |
112 | */ | 155 | */ |
113 | typedef void | 156 | typedef void |
114 | (*GNUNET_SOCIAL_MethodCallback) (void *cls, | 157 | (*GNUNET_SOCIAL_DataCallback) (void *cls, |
115 | uint64_t message_id, | 158 | const struct GNUNET_MessageHeader *msg, |
116 | uint32_t flags, | 159 | uint64_t message_id, |
117 | const struct GNUNET_SOCIAL_Nym *nym, | 160 | uint64_t data_offset, |
118 | const char *method_name, | 161 | const void *data, |
119 | struct GNUNET_ENV_Environment *env, | 162 | uint16_t data_size); |
120 | uint64_t data_offset, | 163 | |
121 | size_t data_size, | 164 | |
122 | const void *data, | 165 | /** |
123 | int end); | 166 | * End of message. |
167 | * | ||
168 | * @param cls | ||
169 | * Closure. | ||
170 | * @param msg | ||
171 | * Message part, as it arrived from the network. | ||
172 | * @param message_id | ||
173 | * Message ID this data fragment belongs to. | ||
174 | * @param cancelled. | ||
175 | * #GNUNET_YES if the message was cancelled, | ||
176 | * #GNUNET_NO if the message is complete. | ||
177 | */ | ||
178 | typedef void | ||
179 | (*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls, | ||
180 | const struct GNUNET_MessageHeader *msg, | ||
181 | uint64_t message_id, | ||
182 | uint8_t cancelled); | ||
124 | 183 | ||
125 | 184 | ||
126 | /** | 185 | /** |
@@ -148,20 +207,27 @@ void | |||
148 | GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, | 207 | GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, |
149 | const char *method_name, | 208 | const char *method_name, |
150 | GNUNET_SOCIAL_MethodCallback method_cb, | 209 | GNUNET_SOCIAL_MethodCallback method_cb, |
210 | GNUNET_SOCIAL_ModifierCallback modifier_cb, | ||
211 | GNUNET_SOCIAL_DataCallback data_cb, | ||
212 | GNUNET_SOCIAL_EndOfMessageCallback eom_cb, | ||
151 | void *cls); | 213 | void *cls); |
152 | 214 | ||
153 | 215 | ||
154 | /** | 216 | /** |
155 | * Remove a registered method from the try-and-slice instance. | 217 | * Remove a registered method handler from the try-and-slice instance. |
156 | * | 218 | * |
157 | * @param slicer The try-and-slice instance. | 219 | * @param slicer The try-and-slice instance. |
158 | * @param method_name Name of the method to remove. | 220 | * @param method_name Name of the method to remove. |
159 | * @param method Method handler. | 221 | * @param method Method handler. |
160 | */ | 222 | */ |
161 | void | 223 | int |
162 | GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, | 224 | GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, |
163 | const char *method_name, | 225 | const char *method_name, |
164 | GNUNET_SOCIAL_MethodCallback method_cb); | 226 | GNUNET_SOCIAL_MethodCallback method_cb, |
227 | GNUNET_SOCIAL_ModifierCallback modifier_cb, | ||
228 | GNUNET_SOCIAL_DataCallback data_cb, | ||
229 | GNUNET_SOCIAL_EndOfMessageCallback eom_cb); | ||
230 | |||
165 | 231 | ||
166 | /** | 232 | /** |
167 | * Destroy a given try-and-slice instance. | 233 | * Destroy a given try-and-slice instance. |
@@ -257,7 +323,7 @@ typedef void | |||
257 | */ | 323 | */ |
258 | struct GNUNET_SOCIAL_Host * | 324 | struct GNUNET_SOCIAL_Host * |
259 | GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | 325 | GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, |
260 | struct GNUNET_IDENTITY_Ego *ego, | 326 | const struct GNUNET_IDENTITY_Ego *ego, |
261 | const struct GNUNET_CRYPTO_EddsaPrivateKey *place_key, | 327 | const struct GNUNET_CRYPTO_EddsaPrivateKey *place_key, |
262 | enum GNUNET_PSYC_Policy policy, | 328 | enum GNUNET_PSYC_Policy policy, |
263 | struct GNUNET_SOCIAL_Slicer *slicer, | 329 | struct GNUNET_SOCIAL_Slicer *slicer, |
@@ -268,17 +334,32 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
268 | 334 | ||
269 | 335 | ||
270 | /** | 336 | /** |
271 | * Admit @a nym to the place. | 337 | * Decision whether to admit @a nym into the place or refuse entry. |
272 | * | ||
273 | * The @a nym reference will remain valid until either the @a host or @a nym | ||
274 | * leaves the place. | ||
275 | * | 338 | * |
276 | * @param host Host of the place. | 339 | * @param hst |
277 | * @param nym Handle for the entity that wants to enter. | 340 | * Host of the place. |
341 | * @param nym | ||
342 | * Handle for the entity that wanted to enter. | ||
343 | * @param is_admitted | ||
344 | * #GNUNET_YES if @a nym is admitted, | ||
345 | * #GNUNET_NO if @a nym is refused entry, | ||
346 | * #GNUNET_SYSERR if we cannot answer the request. | ||
347 | * @param method_name | ||
348 | * Method name for the rejection message. | ||
349 | * @param env | ||
350 | * Environment containing variables for the message, or NULL. | ||
351 | * @param data | ||
352 | * Data for the rejection message to send back. | ||
353 | * @param data_size | ||
354 | * Number of bytes in @a data for method. | ||
355 | * @return #GNUNET_OK on success, | ||
356 | * #GNUNET_SYSERR if the message is too large. | ||
278 | */ | 357 | */ |
279 | void | 358 | int |
280 | GNUNET_SOCIAL_host_admit (struct GNUNET_SOCIAL_Host *host, | 359 | GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst, |
281 | struct GNUNET_SOCIAL_Nym *nym); | 360 | struct GNUNET_SOCIAL_Nym *nym, |
361 | int is_admitted, | ||
362 | const struct GNUNET_PSYC_Message *entry_resp); | ||
282 | 363 | ||
283 | 364 | ||
284 | /** | 365 | /** |
@@ -297,35 +378,17 @@ GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, | |||
297 | 378 | ||
298 | 379 | ||
299 | /** | 380 | /** |
300 | * Refuse @a nym entry into the place. | ||
301 | * | ||
302 | * @param host Host of the place. | ||
303 | * @param nym Handle for the entity that wanted to enter. | ||
304 | * @param method_name Method name for the rejection message. | ||
305 | * @param env Environment containing variables for the message, or NULL. | ||
306 | * @param data Data for the rejection message to send back. | ||
307 | * @param data_size Number of bytes in @a data for method. | ||
308 | */ | ||
309 | void | ||
310 | GNUNET_SOCIAL_host_refuse_entry (struct GNUNET_SOCIAL_Host *host, | ||
311 | struct GNUNET_SOCIAL_Nym *nym, | ||
312 | const char *method_name, | ||
313 | const struct GNUNET_ENV_Environment *env, | ||
314 | const void *data, | ||
315 | size_t data_size); | ||
316 | |||
317 | |||
318 | /** | ||
319 | * Get the public key of a @a nym. | 381 | * Get the public key of a @a nym. |
320 | * | 382 | * |
321 | * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). | 383 | * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). |
322 | * | 384 | * |
323 | * @param nym Pseudonym to map to a cryptographic identifier. | 385 | * @param nym |
324 | * @param[out] nym_key Set to the public key of the nym. | 386 | * Pseudonym to map to a cryptographic identifier. |
387 | * | ||
388 | * @return Public key of nym; | ||
325 | */ | 389 | */ |
326 | void | 390 | struct GNUNET_CRYPTO_EcdsaPublicKey * |
327 | GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym, | 391 | GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym); |
328 | struct GNUNET_CRYPTO_EddsaPublicKey *nym_key); | ||
329 | 392 | ||
330 | 393 | ||
331 | /** | 394 | /** |
@@ -418,9 +481,20 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, | |||
418 | 481 | ||
419 | 482 | ||
420 | /** | 483 | /** |
484 | * Resume transmitting announcement. | ||
485 | * | ||
486 | * @param a | ||
487 | * The announcement to resume. | ||
488 | */ | ||
489 | void | ||
490 | GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a); | ||
491 | |||
492 | |||
493 | /** | ||
421 | * Cancel announcement. | 494 | * Cancel announcement. |
422 | * | 495 | * |
423 | * @param a The announcement to cancel. | 496 | * @param a |
497 | * The announcement to cancel. | ||
424 | */ | 498 | */ |
425 | void | 499 | void |
426 | GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); | 500 | GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); |
@@ -431,7 +505,8 @@ GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); | |||
431 | * | 505 | * |
432 | * The returned handle can be used to access the place API. | 506 | * The returned handle can be used to access the place API. |
433 | * | 507 | * |
434 | * @param host Handle for the host. | 508 | * @param host |
509 | * Handle for the host. | ||
435 | * | 510 | * |
436 | * @return Handle for the hosted place, valid as long as @a host is valid. | 511 | * @return Handle for the hosted place, valid as long as @a host is valid. |
437 | */ | 512 | */ |
@@ -444,11 +519,21 @@ GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host); | |||
444 | * | 519 | * |
445 | * Invalidates host handle. | 520 | * Invalidates host handle. |
446 | * | 521 | * |
447 | * @param host Host leaving the place. | 522 | * @param host |
448 | * @param keep_active Keep the place active after last host disconnected. | 523 | * Host leaving the place. |
524 | * @param keep_active | ||
525 | * Keep the place active after last host disconnected. | ||
526 | * @param leave_cb | ||
527 | * Function called after the host left the place | ||
528 | * and disconnected from the social service. | ||
529 | * @param leave_cls | ||
530 | * Closure for @a leave_cb. | ||
449 | */ | 531 | */ |
450 | void | 532 | void |
451 | GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active); | 533 | GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, |
534 | int keep_active, | ||
535 | GNUNET_ContinuationCallback leave_cb, | ||
536 | void *leave_cls); | ||
452 | 537 | ||
453 | 538 | ||
454 | /** | 539 | /** |
@@ -493,13 +578,10 @@ typedef void | |||
493 | * @param data | 578 | * @param data |
494 | * Payload of the message. | 579 | * Payload of the message. |
495 | */ | 580 | */ |
496 | typedef int | 581 | typedef void |
497 | (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, | 582 | (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, |
498 | int is_admitted, | 583 | int is_admitted, |
499 | const char *method_name, | 584 | const struct GNUNET_PSYC_Message *entry_resp); |
500 | struct GNUNET_ENV_Environment *env, | ||
501 | size_t data_size, | ||
502 | const void *data); | ||
503 | 585 | ||
504 | 586 | ||
505 | /** | 587 | /** |
@@ -521,15 +603,12 @@ typedef int | |||
521 | */ | 603 | */ |
522 | struct GNUNET_SOCIAL_Guest * | 604 | struct GNUNET_SOCIAL_Guest * |
523 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | 605 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, |
524 | struct GNUNET_IDENTITY_Ego *ego, | 606 | const struct GNUNET_IDENTITY_Ego *ego, |
525 | struct GNUNET_CRYPTO_EddsaPublicKey *place_key, | 607 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_key, |
526 | struct GNUNET_PeerIdentity *origin, | 608 | const struct GNUNET_PeerIdentity *origin, |
527 | uint32_t relay_count, | 609 | uint32_t relay_count, |
528 | struct GNUNET_PeerIdentity *relays, | 610 | const struct GNUNET_PeerIdentity *relays, |
529 | const char *method_name, | 611 | const struct GNUNET_PSYC_Message *entry_msg, |
530 | const struct GNUNET_ENV_Environment *env, | ||
531 | const void *data, | ||
532 | size_t data_size, | ||
533 | struct GNUNET_SOCIAL_Slicer *slicer, | 612 | struct GNUNET_SOCIAL_Slicer *slicer, |
534 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 613 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
535 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, | 614 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, |
@@ -558,10 +637,7 @@ struct GNUNET_SOCIAL_Guest * | |||
558 | GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg, | 637 | GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg, |
559 | struct GNUNET_IDENTITY_Ego *ego, | 638 | struct GNUNET_IDENTITY_Ego *ego, |
560 | char *gns_name, | 639 | char *gns_name, |
561 | const char *method_name, | 640 | const struct GNUNET_PSYC_Message *join_msg, |
562 | const struct GNUNET_ENV_Environment *env, | ||
563 | const void *data, | ||
564 | size_t data_size, | ||
565 | struct GNUNET_SOCIAL_Slicer *slicer, | 641 | struct GNUNET_SOCIAL_Slicer *slicer, |
566 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 642 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
567 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, | 643 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, |
@@ -612,9 +688,20 @@ GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, | |||
612 | 688 | ||
613 | 689 | ||
614 | /** | 690 | /** |
691 | * Resume talking to the host of the place. | ||
692 | * | ||
693 | * @param tr | ||
694 | * Talk request to resume. | ||
695 | */ | ||
696 | void | ||
697 | GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr); | ||
698 | |||
699 | |||
700 | /** | ||
615 | * Cancel talking to the host of the place. | 701 | * Cancel talking to the host of the place. |
616 | * | 702 | * |
617 | * @param tr Talk request to cancel. | 703 | * @param tr |
704 | * Talk request to cancel. | ||
618 | */ | 705 | */ |
619 | void | 706 | void |
620 | GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); | 707 | GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); |
@@ -625,11 +712,21 @@ GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); | |||
625 | * | 712 | * |
626 | * Notifies the owner of the place about leaving, and destroys the place handle. | 713 | * Notifies the owner of the place about leaving, and destroys the place handle. |
627 | * | 714 | * |
628 | * @param place Place to leave permanently. | 715 | * @param place |
629 | * @param keep_active Keep place active after last application disconnected. | 716 | * Place to leave permanently. |
717 | * @param keep_active | ||
718 | * Keep place active after last application disconnected. | ||
719 | * @param leave_cb | ||
720 | * Function called after the guest left the place | ||
721 | * and disconnected from the social service. | ||
722 | * @param leave_cls | ||
723 | * Closure for @a leave_cb. | ||
630 | */ | 724 | */ |
631 | void | 725 | void |
632 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *guest, int keep_active); | 726 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *guest, |
727 | int keep_active, | ||
728 | GNUNET_ContinuationCallback leave_cb, | ||
729 | void *leave_cls); | ||
633 | 730 | ||
634 | 731 | ||
635 | /** | 732 | /** |