diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_protocols.h | 7 | ||||
-rw-r--r-- | src/include/gnunet_psyc_slicer.h | 73 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 28 | ||||
-rw-r--r-- | src/psycutil/psyc_slicer.c | 101 | ||||
-rw-r--r-- | src/social/gnunet-service-social.c | 379 | ||||
-rw-r--r-- | src/social/social.h | 13 | ||||
-rw-r--r-- | src/social/social_api.c | 118 |
7 files changed, 556 insertions, 163 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 0251c57fe..7c63f60a3 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2646,8 +2646,11 @@ extern "C" | |||
2646 | /** S->C: notify about an existing place */ | 2646 | /** S->C: notify about an existing place */ |
2647 | #define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE 854 | 2647 | #define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE 854 |
2648 | 2648 | ||
2649 | /** S->C: */ | 2649 | /** C->S: set message processing flags */ |
2650 | #define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_RELAY 855 | 2650 | #define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET 860 |
2651 | |||
2652 | /** C->S: clear message processing flags */ | ||
2653 | #define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR 860 | ||
2651 | 2654 | ||
2652 | /******************************************************************************* | 2655 | /******************************************************************************* |
2653 | * X-VINE DHT messages | 2656 | * X-VINE DHT messages |
diff --git a/src/include/gnunet_psyc_slicer.h b/src/include/gnunet_psyc_slicer.h index 1851a6002..077c0c5bd 100644 --- a/src/include/gnunet_psyc_slicer.h +++ b/src/include/gnunet_psyc_slicer.h | |||
@@ -250,9 +250,9 @@ GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer, | |||
250 | */ | 250 | */ |
251 | void | 251 | void |
252 | GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer, | 252 | GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer, |
253 | const char *object_filter, | 253 | const char *object_filter, |
254 | GNUNET_PSYC_ModifierCallback modifier_cb, | 254 | GNUNET_PSYC_ModifierCallback modifier_cb, |
255 | void *cls); | 255 | void *cls); |
256 | 256 | ||
257 | 257 | ||
258 | /** | 258 | /** |
@@ -270,30 +270,75 @@ GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer, | |||
270 | */ | 270 | */ |
271 | int | 271 | int |
272 | GNUNET_PSYC_slicer_modifier_remove (struct GNUNET_PSYC_Slicer *slicer, | 272 | GNUNET_PSYC_slicer_modifier_remove (struct GNUNET_PSYC_Slicer *slicer, |
273 | const char *object_filter, | 273 | const char *object_filter, |
274 | GNUNET_PSYC_ModifierCallback modifier_cb); | 274 | GNUNET_PSYC_ModifierCallback modifier_cb); |
275 | |||
276 | |||
277 | /** | ||
278 | * Process an incoming message and call matching handlers. | ||
279 | * | ||
280 | * @param slicer | ||
281 | * The slicer to use. | ||
282 | * @param msg | ||
283 | * The message as it arrived from the network. | ||
284 | */ | ||
285 | void | ||
286 | GNUNET_PSYC_slicer_message (struct GNUNET_PSYC_Slicer *slicer, | ||
287 | const struct GNUNET_PSYC_MessageHeader *msg); | ||
275 | 288 | ||
276 | 289 | ||
277 | /** | 290 | /** |
278 | * Process an incoming message part and call matching handlers. | 291 | * Process an incoming message part and call matching handlers. |
279 | * | 292 | * |
280 | * @param cls | 293 | * @param slicer |
281 | * Closure. | 294 | * The slicer to use. |
282 | * @param message_id | 295 | * @param message_id |
283 | * ID of the message. | 296 | * ID of the message. |
284 | * @param flags | 297 | * @param flags |
285 | * Flags for the message. | 298 | * Flags for the message. |
286 | * @see enum GNUNET_PSYC_MessageFlags | 299 | * @see enum GNUNET_PSYC_MessageFlags |
300 | * @param fragment offset | ||
301 | * Fragment offset of the message. | ||
287 | * @param msg | 302 | * @param msg |
288 | * The message part. as it arrived from the network. | 303 | * The message part as it arrived from the network. |
304 | */ | ||
305 | void | ||
306 | GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer, | ||
307 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, | ||
308 | uint64_t message_id, | ||
309 | uint32_t flags, | ||
310 | uint64_t fragment_offset, | ||
311 | const struct GNUNET_MessageHeader *msg); | ||
312 | |||
313 | |||
314 | /** | ||
315 | * Remove all registered method handlers. | ||
316 | * | ||
317 | * @param slicer | ||
318 | * Slicer to clear. | ||
319 | */ | ||
320 | void | ||
321 | GNUNET_PSYC_slicer_method_clear (struct GNUNET_PSYC_Slicer *slicer); | ||
322 | |||
323 | |||
324 | /** | ||
325 | * Remove all registered modifier handlers. | ||
326 | * | ||
327 | * @param slicer | ||
328 | * Slicer to clear. | ||
329 | */ | ||
330 | void | ||
331 | GNUNET_PSYC_slicer_modifier_clear (struct GNUNET_PSYC_Slicer *slicer); | ||
332 | |||
333 | |||
334 | /** | ||
335 | * Remove all registered method & modifier handlers. | ||
336 | * | ||
337 | * @param slicer | ||
338 | * Slicer to clear. | ||
289 | */ | 339 | */ |
290 | void | 340 | void |
291 | GNUNET_PSYC_slicer_message (void *cls, | 341 | GNUNET_PSYC_slicer_clear (struct GNUNET_PSYC_Slicer *slicer); |
292 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, | ||
293 | uint64_t message_id, | ||
294 | uint32_t flags, | ||
295 | uint64_t fragment_offset, | ||
296 | const struct GNUNET_MessageHeader *msg); | ||
297 | 342 | ||
298 | 343 | ||
299 | /** | 344 | /** |
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index 4ad6036a9..75038407b 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -232,6 +232,12 @@ extern "C" | |||
232 | */ | 232 | */ |
233 | #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256 | 233 | #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256 |
234 | 234 | ||
235 | enum GNUNET_SOCIAL_MsgProcFlags { | ||
236 | GNUNET_SOCIAL_MSG_PROC_NONE = 0, | ||
237 | GNUNET_SOCIAL_MSG_PROC_RELAY = 1, | ||
238 | GNUNET_SOCIAL_MSG_PROC_SAVE= 2, | ||
239 | }; | ||
240 | |||
235 | /** | 241 | /** |
236 | * Handle for an application. | 242 | * Handle for an application. |
237 | */ | 243 | */ |
@@ -1063,6 +1069,28 @@ struct GNUNET_SOCIAL_HistoryRequest; | |||
1063 | 1069 | ||
1064 | 1070 | ||
1065 | /** | 1071 | /** |
1072 | * Set message processing @a flags for a @a method_prefix. | ||
1073 | * | ||
1074 | * @param plc | ||
1075 | * Place. | ||
1076 | * @param method_prefix | ||
1077 | * Method prefix @a flags apply to. | ||
1078 | * @param flags | ||
1079 | * The flags that apply to a matching @a method_prefix. | ||
1080 | */ | ||
1081 | void | ||
1082 | GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc, | ||
1083 | const char *method_prefix, | ||
1084 | enum GNUNET_SOCIAL_MsgProcFlags flags); | ||
1085 | |||
1086 | /** | ||
1087 | * Clear all message processing flags previously set for this place. | ||
1088 | */ | ||
1089 | void | ||
1090 | GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc); | ||
1091 | |||
1092 | |||
1093 | /** | ||
1066 | * Learn about the history of a place. | 1094 | * Learn about the history of a place. |
1067 | * | 1095 | * |
1068 | * Messages are returned through the @a slicer function | 1096 | * Messages are returned through the @a slicer function |
diff --git a/src/psycutil/psyc_slicer.c b/src/psycutil/psyc_slicer.c index fe9912416..e372d3ae2 100644 --- a/src/psycutil/psyc_slicer.c +++ b/src/psycutil/psyc_slicer.c | |||
@@ -50,6 +50,11 @@ struct GNUNET_PSYC_Slicer | |||
50 | struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers; | 50 | struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Receive handle for incoming messages. | ||
54 | */ | ||
55 | struct GNUNET_PSYC_ReceiveHandle *recv; | ||
56 | |||
57 | /** | ||
53 | * Currently being processed message part. | 58 | * Currently being processed message part. |
54 | */ | 59 | */ |
55 | const struct GNUNET_MessageHeader *msg; | 60 | const struct GNUNET_MessageHeader *msg; |
@@ -151,7 +156,7 @@ struct SlicerModifierRemoveClosure | |||
151 | /** | 156 | /** |
152 | * Call a method handler for an incoming message part. | 157 | * Call a method handler for an incoming message part. |
153 | */ | 158 | */ |
154 | int | 159 | static int |
155 | slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key, | 160 | slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key, |
156 | void *value) | 161 | void *value) |
157 | { | 162 | { |
@@ -229,7 +234,7 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key, | |||
229 | /** | 234 | /** |
230 | * Call a method handler for an incoming message part. | 235 | * Call a method handler for an incoming message part. |
231 | */ | 236 | */ |
232 | int | 237 | static int |
233 | slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key, | 238 | slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key, |
234 | void *value) | 239 | void *value) |
235 | { | 240 | { |
@@ -244,6 +249,22 @@ slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key, | |||
244 | 249 | ||
245 | 250 | ||
246 | /** | 251 | /** |
252 | * Process an incoming message and call matching handlers. | ||
253 | * | ||
254 | * @param slicer | ||
255 | * The slicer to use. | ||
256 | * @param msg | ||
257 | * The message as it arrived from the network. | ||
258 | */ | ||
259 | void | ||
260 | GNUNET_PSYC_slicer_message (struct GNUNET_PSYC_Slicer *slicer, | ||
261 | const struct GNUNET_PSYC_MessageHeader *msg) | ||
262 | { | ||
263 | GNUNET_PSYC_receive_message (slicer->recv, msg); | ||
264 | } | ||
265 | |||
266 | |||
267 | /** | ||
247 | * Process an incoming message part and call matching handlers. | 268 | * Process an incoming message part and call matching handlers. |
248 | * | 269 | * |
249 | * @param cls | 270 | * @param cls |
@@ -257,11 +278,13 @@ slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key, | |||
257 | * The message part. as it arrived from the network. | 278 | * The message part. as it arrived from the network. |
258 | */ | 279 | */ |
259 | void | 280 | void |
260 | GNUNET_PSYC_slicer_message (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, | 281 | GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer, |
261 | uint64_t message_id, uint32_t flags, uint64_t fragment_offset, | 282 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, |
262 | const struct GNUNET_MessageHeader *msg) | 283 | uint64_t message_id, |
284 | uint32_t flags, | ||
285 | uint64_t fragment_offset, | ||
286 | const struct GNUNET_MessageHeader *msg) | ||
263 | { | 287 | { |
264 | struct GNUNET_PSYC_Slicer *slicer = cls; | ||
265 | slicer->nym_pub_key = *slave_pub_key; | 288 | slicer->nym_pub_key = *slave_pub_key; |
266 | 289 | ||
267 | uint16_t ptype = ntohs (msg->type); | 290 | uint16_t ptype = ntohs (msg->type); |
@@ -381,6 +404,10 @@ GNUNET_PSYC_slicer_create (void) | |||
381 | struct GNUNET_PSYC_Slicer *slicer = GNUNET_malloc (sizeof (*slicer)); | 404 | struct GNUNET_PSYC_Slicer *slicer = GNUNET_malloc (sizeof (*slicer)); |
382 | slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 405 | slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
383 | slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 406 | slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
407 | slicer->recv = GNUNET_PSYC_receive_create (NULL, | ||
408 | (GNUNET_PSYC_MessagePartCallback) | ||
409 | GNUNET_PSYC_slicer_message_part, | ||
410 | slicer); | ||
384 | return slicer; | 411 | return slicer; |
385 | } | 412 | } |
386 | 413 | ||
@@ -430,7 +457,7 @@ GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer, | |||
430 | } | 457 | } |
431 | 458 | ||
432 | 459 | ||
433 | int | 460 | static int |
434 | slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value) | 461 | slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value) |
435 | { | 462 | { |
436 | struct SlicerMethodRemoveClosure *rm_cls = cls; | 463 | struct SlicerMethodRemoveClosure *rm_cls = cls; |
@@ -531,7 +558,7 @@ GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer, | |||
531 | } | 558 | } |
532 | 559 | ||
533 | 560 | ||
534 | int | 561 | static int |
535 | slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value) | 562 | slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value) |
536 | { | 563 | { |
537 | struct SlicerModifierRemoveClosure *rm_cls = cls; | 564 | struct SlicerModifierRemoveClosure *rm_cls = cls; |
@@ -585,7 +612,7 @@ GNUNET_PSYC_slicer_modifier_remove (struct GNUNET_PSYC_Slicer *slicer, | |||
585 | } | 612 | } |
586 | 613 | ||
587 | 614 | ||
588 | int | 615 | static int |
589 | slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value) | 616 | slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value) |
590 | { | 617 | { |
591 | struct SlicerMethodCallbacks *cbs = value; | 618 | struct SlicerMethodCallbacks *cbs = value; |
@@ -594,6 +621,57 @@ slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
594 | } | 621 | } |
595 | 622 | ||
596 | 623 | ||
624 | static int | ||
625 | slicer_modifier_free (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
626 | { | ||
627 | struct SlicerModifierCallbacks *cbs = value; | ||
628 | GNUNET_free (cbs); | ||
629 | return GNUNET_YES; | ||
630 | } | ||
631 | |||
632 | |||
633 | /** | ||
634 | * Remove all registered method handlers. | ||
635 | * | ||
636 | * @param slicer | ||
637 | * Slicer to clear. | ||
638 | */ | ||
639 | void | ||
640 | GNUNET_PSYC_slicer_method_clear (struct GNUNET_PSYC_Slicer *slicer) | ||
641 | { | ||
642 | GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers, | ||
643 | slicer_method_free, NULL); | ||
644 | } | ||
645 | |||
646 | |||
647 | /** | ||
648 | * Remove all registered modifier handlers. | ||
649 | * | ||
650 | * @param slicer | ||
651 | * Slicer to clear. | ||
652 | */ | ||
653 | void | ||
654 | GNUNET_PSYC_slicer_modifier_clear (struct GNUNET_PSYC_Slicer *slicer) | ||
655 | { | ||
656 | GNUNET_CONTAINER_multihashmap_iterate (slicer->modifier_handlers, | ||
657 | slicer_modifier_free, NULL); | ||
658 | } | ||
659 | |||
660 | |||
661 | /** | ||
662 | * Remove all registered method & modifier handlers. | ||
663 | * | ||
664 | * @param slicer | ||
665 | * Slicer to clear. | ||
666 | */ | ||
667 | void | ||
668 | GNUNET_PSYC_slicer_clear (struct GNUNET_PSYC_Slicer *slicer) | ||
669 | { | ||
670 | GNUNET_PSYC_slicer_method_clear (slicer); | ||
671 | GNUNET_PSYC_slicer_modifier_clear (slicer); | ||
672 | } | ||
673 | |||
674 | |||
597 | /** | 675 | /** |
598 | * Destroy a given try-and-slice instance. | 676 | * Destroy a given try-and-slice instance. |
599 | * | 677 | * |
@@ -603,8 +681,9 @@ slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
603 | void | 681 | void |
604 | GNUNET_PSYC_slicer_destroy (struct GNUNET_PSYC_Slicer *slicer) | 682 | GNUNET_PSYC_slicer_destroy (struct GNUNET_PSYC_Slicer *slicer) |
605 | { | 683 | { |
606 | GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers, | 684 | GNUNET_PSYC_slicer_clear (slicer); |
607 | slicer_method_free, NULL); | ||
608 | GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers); | 685 | GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers); |
686 | GNUNET_CONTAINER_multihashmap_destroy (slicer->modifier_handlers); | ||
687 | GNUNET_PSYC_receive_destroy (slicer->recv); | ||
609 | GNUNET_free (slicer); | 688 | GNUNET_free (slicer); |
610 | } | 689 | } |
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index d4dfe9b0f..f3eacd6f9 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -229,10 +229,10 @@ struct Place | |||
229 | */ | 229 | */ |
230 | struct GNUNET_HashCode ego_pub_hash; | 230 | struct GNUNET_HashCode ego_pub_hash; |
231 | 231 | ||
232 | uint64_t file_message_id; | 232 | /** |
233 | uint64_t file_fragment_offset; | 233 | * Slicer for processing incoming messages. |
234 | uint64_t file_size; | 234 | */ |
235 | uint64_t file_offset; | 235 | struct GNUNET_PSYC_Slicer *slicer; |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * Last message ID received for the place. | 238 | * Last message ID received for the place. |
@@ -241,6 +241,16 @@ struct Place | |||
241 | uint64_t max_message_id; | 241 | uint64_t max_message_id; |
242 | 242 | ||
243 | /** | 243 | /** |
244 | * Offset where the file is currently being written. | ||
245 | */ | ||
246 | uint64_t file_offset; | ||
247 | |||
248 | /** | ||
249 | * Whether or not to save the file (#GNUNET_YES or #GNUNET_NO) | ||
250 | */ | ||
251 | uint8_t file_save; | ||
252 | |||
253 | /** | ||
244 | * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)? | 254 | * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)? |
245 | */ | 255 | */ |
246 | uint8_t is_host; | 256 | uint8_t is_host; |
@@ -509,6 +519,8 @@ cleanup_place (struct Place *plc) | |||
509 | (GNUNET_YES == plc->is_host) | 519 | (GNUNET_YES == plc->is_host) |
510 | ? cleanup_host ((struct Host *) plc) | 520 | ? cleanup_host ((struct Host *) plc) |
511 | : cleanup_guest ((struct Guest *) plc); | 521 | : cleanup_guest ((struct Guest *) plc); |
522 | |||
523 | GNUNET_PSYC_slicer_destroy (plc->slicer); | ||
512 | GNUNET_free (plc); | 524 | GNUNET_free (plc); |
513 | } | 525 | } |
514 | 526 | ||
@@ -728,34 +740,132 @@ psyc_recv_join_dcsn (void *cls, | |||
728 | place_send_msg (&gst->plc, &dcsn->header); | 740 | place_send_msg (&gst->plc, &dcsn->header); |
729 | } | 741 | } |
730 | 742 | ||
743 | |||
731 | /** | 744 | /** |
732 | * Save _file data to disk. | 745 | * Called when a PSYC master or slave receives a message. |
733 | */ | 746 | */ |
734 | void | 747 | static void |
735 | psyc_recv_file (struct Place *plc, const struct GNUNET_PSYC_MessageHeader *msg, | 748 | psyc_recv_message (void *cls, |
736 | uint32_t flags, uint64_t message_id, uint64_t fragment_offset, | 749 | uint64_t message_id, |
737 | const char *method_name, struct GNUNET_PSYC_Environment *env, | 750 | uint32_t flags, |
738 | const void *data, uint16_t data_size) | 751 | const struct GNUNET_PSYC_MessageHeader *msg) |
752 | { | ||
753 | struct Place *plc = cls; | ||
754 | |||
755 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&msg->slave_pub_key); | ||
756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
757 | "%p Received PSYC message of size %u from %s.\n", | ||
758 | plc, ntohs (msg->header.size), str); | ||
759 | GNUNET_free (str); | ||
760 | |||
761 | GNUNET_PSYC_slicer_message (plc->slicer, msg); | ||
762 | |||
763 | place_send_msg (plc, &msg->header); | ||
764 | } | ||
765 | |||
766 | |||
767 | static void | ||
768 | place_recv_relay_method (void *cls, | ||
769 | const struct GNUNET_PSYC_MessageMethod *meth, | ||
770 | uint64_t message_id, | ||
771 | uint32_t flags, | ||
772 | const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key, | ||
773 | const char *method_name) | ||
774 | { | ||
775 | struct Host *hst = cls; | ||
776 | struct Place *plc = &hst->plc; | ||
777 | |||
778 | // FIXME: relay message | ||
779 | } | ||
780 | |||
781 | |||
782 | static void | ||
783 | place_recv_relay_modifier (void *cls, | ||
784 | const struct GNUNET_MessageHeader *msg, | ||
785 | uint64_t message_id, | ||
786 | enum GNUNET_PSYC_Operator oper, | ||
787 | const char *name, | ||
788 | const void *value, | ||
789 | uint16_t value_size, | ||
790 | uint16_t full_value_size) | ||
739 | { | 791 | { |
740 | if (plc->file_message_id != message_id) | ||
741 | { | ||
742 | if (0 != fragment_offset) | ||
743 | { | ||
744 | /* unexpected message ID */ | ||
745 | GNUNET_break (0); | ||
746 | return; | ||
747 | } | ||
748 | 792 | ||
749 | /* new file */ | 793 | } |
750 | plc->file_offset = 0; | 794 | |
795 | |||
796 | static void | ||
797 | place_recv_relay_eom (void *cls, | ||
798 | const struct GNUNET_MessageHeader *msg, | ||
799 | uint64_t message_id, | ||
800 | uint8_t cancelled) | ||
801 | { | ||
802 | |||
803 | } | ||
804 | |||
805 | |||
806 | static void | ||
807 | place_recv_relay_data (void *cls, | ||
808 | const struct GNUNET_MessageHeader *msg, | ||
809 | uint64_t message_id, | ||
810 | uint64_t data_offset, | ||
811 | const void *data, | ||
812 | uint16_t data_size) | ||
813 | { | ||
814 | |||
815 | } | ||
816 | |||
817 | |||
818 | static void | ||
819 | place_recv_save_method (void *cls, | ||
820 | const struct GNUNET_PSYC_MessageMethod *meth, | ||
821 | uint64_t message_id, | ||
822 | uint32_t flags, | ||
823 | const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key, | ||
824 | const char *method_name) | ||
825 | { | ||
826 | struct Place *plc = cls; | ||
827 | plc->file_offset = 0; | ||
828 | plc->file_save = GNUNET_NO; | ||
829 | |||
830 | struct GNUNET_CRYPTO_HashAsciiEncoded place_pub_hash_ascii; | ||
831 | memcpy (&place_pub_hash_ascii.encoding, | ||
832 | GNUNET_h2s_full (&plc->pub_key_hash), sizeof (place_pub_hash_ascii)); | ||
833 | |||
834 | char *filename = NULL; | ||
835 | GNUNET_asprintf (&filename, "%s%c%s%c%s%c%.part" PRIu64, | ||
836 | dir_social, DIR_SEPARATOR, | ||
837 | "files", DIR_SEPARATOR, | ||
838 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, | ||
839 | message_id); | ||
840 | |||
841 | /* save if does not already exist */ | ||
842 | if (GNUNET_NO == GNUNET_DISK_file_test (filename)) | ||
843 | { | ||
844 | plc->file_save = GNUNET_YES; | ||
751 | } | 845 | } |
752 | 846 | ||
847 | GNUNET_free (filename); | ||
848 | } | ||
849 | |||
850 | |||
851 | static void | ||
852 | place_recv_save_data (void *cls, | ||
853 | const struct GNUNET_MessageHeader *msg, | ||
854 | uint64_t message_id, | ||
855 | uint64_t data_offset, | ||
856 | const void *data, | ||
857 | uint16_t data_size) | ||
858 | { | ||
859 | struct Place *plc = cls; | ||
860 | if (GNUNET_YES != plc->file_save) | ||
861 | return; | ||
862 | |||
753 | struct GNUNET_CRYPTO_HashAsciiEncoded place_pub_hash_ascii; | 863 | struct GNUNET_CRYPTO_HashAsciiEncoded place_pub_hash_ascii; |
754 | memcpy (&place_pub_hash_ascii.encoding, | 864 | memcpy (&place_pub_hash_ascii.encoding, |
755 | GNUNET_h2s_full (&plc->pub_key_hash), sizeof (place_pub_hash_ascii)); | 865 | GNUNET_h2s_full (&plc->pub_key_hash), sizeof (place_pub_hash_ascii)); |
756 | 866 | ||
757 | char *filename = NULL; | 867 | char *filename = NULL; |
758 | GNUNET_asprintf (&filename, "%s%c%s%c%s%c%" PRIu64, | 868 | GNUNET_asprintf (&filename, "%s%c%s%c%s%c%.part" PRIu64, |
759 | dir_social, DIR_SEPARATOR, | 869 | dir_social, DIR_SEPARATOR, |
760 | "files", DIR_SEPARATOR, | 870 | "files", DIR_SEPARATOR, |
761 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, | 871 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, |
@@ -774,50 +884,38 @@ psyc_recv_file (struct Place *plc, const struct GNUNET_PSYC_MessageHeader *msg, | |||
774 | } | 884 | } |
775 | 885 | ||
776 | 886 | ||
777 | /** | ||
778 | * Called when a PSYC master or slave receives a message. | ||
779 | */ | ||
780 | static void | 887 | static void |
781 | psyc_recv_message (void *cls, | 888 | place_recv_save_eom (void *cls, |
782 | uint64_t message_id, | 889 | const struct GNUNET_MessageHeader *msg, |
783 | uint32_t flags, | 890 | uint64_t message_id, |
784 | const struct GNUNET_PSYC_MessageHeader *msg) | 891 | uint8_t cancelled) |
785 | { | 892 | { |
786 | struct Place *plc = cls; | 893 | struct Place *plc = cls; |
894 | if (GNUNET_YES != plc->file_save) | ||
895 | return; | ||
787 | 896 | ||
788 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&msg->slave_key); | 897 | struct GNUNET_CRYPTO_HashAsciiEncoded place_pub_hash_ascii; |
789 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 898 | memcpy (&place_pub_hash_ascii.encoding, |
790 | "%p Received PSYC message of size %u from %s.\n", | 899 | GNUNET_h2s_full (&plc->pub_key_hash), sizeof (place_pub_hash_ascii)); |
791 | plc, ntohs (msg->header.size), str); | ||
792 | GNUNET_free (str); | ||
793 | 900 | ||
794 | /* process message */ | 901 | char *fn_part = NULL; |
795 | /* FIXME: use slicer */ | 902 | GNUNET_asprintf (&fn_part, "%s%c%s%c%s%c%.part" PRIu64, |
796 | const char *method_name = NULL; | 903 | dir_social, DIR_SEPARATOR, |
797 | struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); | 904 | "files", DIR_SEPARATOR, |
798 | const void *data = NULL; | 905 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, |
799 | uint16_t data_size = 0; | 906 | message_id); |
800 | 907 | ||
801 | if (GNUNET_SYSERR == GNUNET_PSYC_message_parse (msg, &method_name, env, &data, &data_size)) | 908 | char *fn = NULL; |
802 | { | 909 | GNUNET_asprintf (&fn, "%s%c%s%c%s%c%" PRIu64, |
803 | GNUNET_break (0); | 910 | dir_social, DIR_SEPARATOR, |
804 | } | 911 | "files", DIR_SEPARATOR, |
805 | else | 912 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, |
806 | { | 913 | message_id); |
807 | char *method_found = strstr (method_name, "_file"); | ||
808 | if (method_name == method_found) | ||
809 | { | ||
810 | method_found += strlen ("_file"); | ||
811 | if (('\0' == *method_found) || ('_' == *method_found)) | ||
812 | { | ||
813 | psyc_recv_file (plc, msg, flags, message_id, GNUNET_ntohll (msg->fragment_offset), | ||
814 | method_name, env, data, data_size); | ||
815 | } | ||
816 | } | ||
817 | } | ||
818 | GNUNET_PSYC_env_destroy (env); | ||
819 | 914 | ||
820 | place_send_msg (plc, &msg->header); | 915 | rename (fn_part, fn); |
916 | |||
917 | GNUNET_free (fn); | ||
918 | GNUNET_free (fn_part); | ||
821 | } | 919 | } |
822 | 920 | ||
823 | 921 | ||
@@ -1118,6 +1216,7 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst) | |||
1118 | plc->is_host = GNUNET_YES; | 1216 | plc->is_host = GNUNET_YES; |
1119 | plc->pub_key = hreq->place_pub_key; | 1217 | plc->pub_key = hreq->place_pub_key; |
1120 | plc->pub_key_hash = place_pub_hash; | 1218 | plc->pub_key_hash = place_pub_hash; |
1219 | plc->slicer = GNUNET_PSYC_slicer_create (); | ||
1121 | 1220 | ||
1122 | GNUNET_CONTAINER_multihashmap_put (hosts, &plc->pub_key_hash, plc, | 1221 | GNUNET_CONTAINER_multihashmap_put (hosts, &plc->pub_key_hash, plc, |
1123 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1222 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
@@ -1125,7 +1224,7 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst) | |||
1125 | &psyc_master_started, | 1224 | &psyc_master_started, |
1126 | &psyc_recv_join_request, | 1225 | &psyc_recv_join_request, |
1127 | &psyc_recv_message, NULL, hst); | 1226 | &psyc_recv_message, NULL, hst); |
1128 | hst->plc.channel = GNUNET_PSYC_master_get_channel (hst->master); | 1227 | plc->channel = GNUNET_PSYC_master_get_channel (hst->master); |
1129 | ret = GNUNET_YES; | 1228 | ret = GNUNET_YES; |
1130 | } | 1229 | } |
1131 | 1230 | ||
@@ -1135,6 +1234,115 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst) | |||
1135 | } | 1234 | } |
1136 | 1235 | ||
1137 | 1236 | ||
1237 | const struct MsgProcRequest * | ||
1238 | relay_req_parse (const struct GNUNET_MessageHeader *msg, | ||
1239 | uint32_t *flags, | ||
1240 | const char **method_prefix, | ||
1241 | struct GNUNET_HashCode *method_hash) | ||
1242 | { | ||
1243 | const struct MsgProcRequest *mpreq = (const struct MsgProcRequest *) msg; | ||
1244 | uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); | ||
1245 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], | ||
1246 | method_size, 1, method_prefix); | ||
1247 | |||
1248 | if (0 == offset || offset != method_size || *method_prefix == NULL) | ||
1249 | { | ||
1250 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1251 | "offset = %u, method_size = %u, method_name = %s\n", | ||
1252 | offset, method_size, *method_prefix); | ||
1253 | return NULL; | ||
1254 | } | ||
1255 | |||
1256 | GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); | ||
1257 | *flags = ntohl (mpreq->flags); | ||
1258 | return mpreq; | ||
1259 | } | ||
1260 | |||
1261 | |||
1262 | /** | ||
1263 | * Handle a client setting message proccesing flags for a method prefix. | ||
1264 | */ | ||
1265 | static void | ||
1266 | client_recv_msg_proc_set (void *cls, struct GNUNET_SERVER_Client *client, | ||
1267 | const struct GNUNET_MessageHeader *msg) | ||
1268 | { | ||
1269 | struct Client * | ||
1270 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | ||
1271 | GNUNET_assert (NULL != ctx); | ||
1272 | struct Place *plc = ctx->plc; | ||
1273 | |||
1274 | const char *method_prefix = NULL; | ||
1275 | uint32_t flags = 0; | ||
1276 | struct GNUNET_HashCode method_hash; | ||
1277 | const struct MsgProcRequest * | ||
1278 | mpreq = relay_req_parse (msg, &flags, &method_prefix, &method_hash); | ||
1279 | |||
1280 | if (NULL == mpreq) { | ||
1281 | GNUNET_break (0); | ||
1282 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1283 | return; | ||
1284 | } | ||
1285 | |||
1286 | GNUNET_PSYC_slicer_method_remove (plc->slicer, method_prefix, | ||
1287 | place_recv_relay_method, | ||
1288 | place_recv_relay_modifier, | ||
1289 | place_recv_relay_data, | ||
1290 | place_recv_relay_eom); | ||
1291 | GNUNET_PSYC_slicer_method_remove (plc->slicer, method_prefix, | ||
1292 | place_recv_save_method, | ||
1293 | NULL, | ||
1294 | place_recv_save_data, | ||
1295 | place_recv_save_eom); | ||
1296 | |||
1297 | if (flags & GNUNET_SOCIAL_MSG_PROC_RELAY) | ||
1298 | { | ||
1299 | GNUNET_PSYC_slicer_method_add (plc->slicer, method_prefix, | ||
1300 | place_recv_relay_method, | ||
1301 | place_recv_relay_modifier, | ||
1302 | place_recv_relay_data, | ||
1303 | place_recv_relay_eom, | ||
1304 | plc); | ||
1305 | } | ||
1306 | if (flags & GNUNET_SOCIAL_MSG_PROC_SAVE) | ||
1307 | { | ||
1308 | GNUNET_PSYC_slicer_method_add (plc->slicer, method_prefix, | ||
1309 | place_recv_save_method, | ||
1310 | NULL, | ||
1311 | place_recv_save_data, | ||
1312 | place_recv_save_eom, | ||
1313 | plc); | ||
1314 | } | ||
1315 | |||
1316 | /** @todo Save flags to be able to resume relaying/saving after restart */ | ||
1317 | |||
1318 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1319 | } | ||
1320 | |||
1321 | |||
1322 | /** | ||
1323 | * Handle a connecting client requesting to clear all relay rules. | ||
1324 | */ | ||
1325 | static void | ||
1326 | client_recv_msg_proc_clear (void *cls, struct GNUNET_SERVER_Client *client, | ||
1327 | const struct GNUNET_MessageHeader *msg) | ||
1328 | { | ||
1329 | struct Client * | ||
1330 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | ||
1331 | GNUNET_assert (NULL != ctx); | ||
1332 | struct Place *plc = ctx->plc; | ||
1333 | if (GNUNET_YES != plc->is_host) { | ||
1334 | GNUNET_break (0); | ||
1335 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1336 | return; | ||
1337 | } | ||
1338 | struct Host *hst = (struct Host *) plc; | ||
1339 | |||
1340 | GNUNET_PSYC_slicer_clear (plc->slicer); | ||
1341 | |||
1342 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1343 | } | ||
1344 | |||
1345 | |||
1138 | /** | 1346 | /** |
1139 | * Handle a connecting client entering a place as host. | 1347 | * Handle a connecting client entering a place as host. |
1140 | */ | 1348 | */ |
@@ -1320,6 +1528,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1320 | plc->ego_pub_key = ego_pub_key; | 1528 | plc->ego_pub_key = ego_pub_key; |
1321 | plc->ego_pub_hash = ego_pub_hash; | 1529 | plc->ego_pub_hash = ego_pub_hash; |
1322 | plc->ego_key = ego->key; | 1530 | plc->ego_key = ego->key; |
1531 | plc->slicer = GNUNET_PSYC_slicer_create (); | ||
1323 | 1532 | ||
1324 | if (NULL == plc_gst) | 1533 | if (NULL == plc_gst) |
1325 | { | 1534 | { |
@@ -1339,7 +1548,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1339 | &psyc_slave_connected, | 1548 | &psyc_slave_connected, |
1340 | &psyc_recv_join_dcsn, | 1549 | &psyc_recv_join_dcsn, |
1341 | gst, join_msg); | 1550 | gst, join_msg); |
1342 | gst->plc.channel = GNUNET_PSYC_slave_get_channel (gst->slave); | 1551 | plc->channel = GNUNET_PSYC_slave_get_channel (gst->slave); |
1343 | ret = GNUNET_YES; | 1552 | ret = GNUNET_YES; |
1344 | } | 1553 | } |
1345 | 1554 | ||
@@ -1805,7 +2014,11 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
1805 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 2014 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); |
1806 | GNUNET_assert (NULL != ctx); | 2015 | GNUNET_assert (NULL != ctx); |
1807 | struct Place *plc = ctx->plc; | 2016 | struct Place *plc = ctx->plc; |
1808 | GNUNET_assert (GNUNET_YES == plc->is_host); | 2017 | if (GNUNET_YES != plc->is_host) { |
2018 | GNUNET_break (0); | ||
2019 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
2020 | return; | ||
2021 | } | ||
1809 | struct Host *hst = (struct Host *) plc; | 2022 | struct Host *hst = (struct Host *) plc; |
1810 | 2023 | ||
1811 | struct GNUNET_PSYC_JoinDecisionMessage * | 2024 | struct GNUNET_PSYC_JoinDecisionMessage * |
@@ -1817,20 +2030,20 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
1817 | ? (struct GNUNET_PSYC_Message *) &dcsn[1] | 2030 | ? (struct GNUNET_PSYC_Message *) &dcsn[1] |
1818 | : NULL; | 2031 | : NULL; |
1819 | 2032 | ||
1820 | struct GNUNET_HashCode slave_key_hash; | 2033 | struct GNUNET_HashCode slave_pub_hash; |
1821 | GNUNET_CRYPTO_hash (&dcsn->slave_key, sizeof (dcsn->slave_key), | 2034 | GNUNET_CRYPTO_hash (&dcsn->slave_pub_key, sizeof (dcsn->slave_pub_key), |
1822 | &slave_key_hash); | 2035 | &slave_pub_hash); |
1823 | 2036 | ||
1824 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1825 | "%p Got join decision (%d) from client for place %s..\n", | 2038 | "%p Got join decision (%d) from client for place %s..\n", |
1826 | hst, jcls.is_admitted, GNUNET_h2s (&plc->pub_key_hash)); | 2039 | hst, jcls.is_admitted, GNUNET_h2s (&plc->pub_key_hash)); |
1827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1828 | "%p ..and slave %s.\n", | 2041 | "%p ..and slave %s.\n", |
1829 | hst, GNUNET_h2s (&slave_key_hash)); | 2042 | hst, GNUNET_h2s (&slave_pub_hash)); |
1830 | 2043 | ||
1831 | GNUNET_CONTAINER_multihashmap_get_multiple (hst->join_reqs, &slave_key_hash, | 2044 | GNUNET_CONTAINER_multihashmap_get_multiple (hst->join_reqs, &slave_pub_hash, |
1832 | &psyc_send_join_decision, &jcls); | 2045 | &psyc_send_join_decision, &jcls); |
1833 | GNUNET_CONTAINER_multihashmap_remove_all (hst->join_reqs, &slave_key_hash); | 2046 | GNUNET_CONTAINER_multihashmap_remove_all (hst->join_reqs, &slave_pub_hash); |
1834 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2047 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1835 | } | 2048 | } |
1836 | 2049 | ||
@@ -2832,45 +3045,51 @@ client_recv_zone_add_nym (void *cls, struct GNUNET_SERVER_Client *client, | |||
2832 | 3045 | ||
2833 | 3046 | ||
2834 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 3047 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
2835 | { &client_recv_host_enter, NULL, | 3048 | { client_recv_host_enter, NULL, |
2836 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 0 }, | 3049 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 0 }, |
2837 | 3050 | ||
2838 | { &client_recv_guest_enter, NULL, | 3051 | { client_recv_guest_enter, NULL, |
2839 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, 0 }, | 3052 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, 0 }, |
2840 | 3053 | ||
2841 | { &client_recv_guest_enter_by_name, NULL, | 3054 | { client_recv_guest_enter_by_name, NULL, |
2842 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, 0 }, | 3055 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, 0 }, |
2843 | 3056 | ||
2844 | { &client_recv_join_decision, NULL, | 3057 | { client_recv_join_decision, NULL, |
2845 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, 0 }, | 3058 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, 0 }, |
2846 | 3059 | ||
2847 | { &client_recv_psyc_message, NULL, | 3060 | { client_recv_psyc_message, NULL, |
2848 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 0 }, | 3061 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 0 }, |
2849 | 3062 | ||
2850 | { &client_recv_history_replay, NULL, | 3063 | { client_recv_history_replay, NULL, |
2851 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 0 }, | 3064 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 0 }, |
2852 | 3065 | ||
2853 | { &client_recv_state_get, NULL, | 3066 | { client_recv_state_get, NULL, |
2854 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, | 3067 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, |
2855 | 3068 | ||
2856 | { &client_recv_state_get, NULL, | 3069 | { client_recv_state_get, NULL, |
2857 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 }, | 3070 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 }, |
2858 | 3071 | ||
2859 | { &client_recv_zone_add_place, NULL, | 3072 | { client_recv_zone_add_place, NULL, |
2860 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, 0 }, | 3073 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, 0 }, |
2861 | 3074 | ||
2862 | { &client_recv_zone_add_nym, NULL, | 3075 | { client_recv_zone_add_nym, NULL, |
2863 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, 0 }, | 3076 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, 0 }, |
2864 | 3077 | ||
2865 | { &client_recv_app_connect, NULL, | 3078 | { client_recv_app_connect, NULL, |
2866 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, 0 }, | 3079 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, 0 }, |
2867 | 3080 | ||
2868 | { &client_recv_app_detach, NULL, | 3081 | { client_recv_app_detach, NULL, |
2869 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, 0 }, | 3082 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, 0 }, |
2870 | 3083 | ||
2871 | { &client_recv_place_leave, NULL, | 3084 | { client_recv_place_leave, NULL, |
2872 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, 0 }, | 3085 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, 0 }, |
2873 | 3086 | ||
3087 | { client_recv_msg_proc_set, NULL, | ||
3088 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, 0 }, | ||
3089 | |||
3090 | { client_recv_msg_proc_clear, NULL, | ||
3091 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, 0 }, | ||
3092 | |||
2874 | { NULL, NULL, 0, 0 } | 3093 | { NULL, NULL, 0, 0 } |
2875 | }; | 3094 | }; |
2876 | 3095 | ||
diff --git a/src/social/social.h b/src/social/social.h index 0980cbf5c..d24515309 100644 --- a/src/social/social.h +++ b/src/social/social.h | |||
@@ -80,16 +80,19 @@ struct AppDetachRequest | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | struct HostRelayRequest | 83 | struct MsgProcRequest |
84 | { | 84 | { |
85 | /** | 85 | /** |
86 | * Types: | 86 | * Type: GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET |
87 | * - GNUNET_MESSAGE_TYPE_SOCIAL_HOST_RELAY_START | ||
88 | * - GNUNET_MESSAGE_TYPE_SOCIAL_HOST_RELAY_STOP | ||
89 | */ | 87 | */ |
90 | struct GNUNET_MessageHeader header; | 88 | struct GNUNET_MessageHeader header; |
91 | 89 | ||
92 | /* Followed by char *method_name */ | 90 | /** |
91 | * @see enum GNUNET_SOCIAL_MsgProcFlags | ||
92 | */ | ||
93 | uint32_t flags; | ||
94 | |||
95 | /* Followed by char *method_prefix */ | ||
93 | }; | 96 | }; |
94 | 97 | ||
95 | 98 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index 3404160a9..a8433ee24 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -149,12 +149,7 @@ struct GNUNET_SOCIAL_Place | |||
149 | struct GNUNET_PSYC_TransmitHandle *tmit; | 149 | struct GNUNET_PSYC_TransmitHandle *tmit; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Receipt handle. | 152 | * Slicer for processing incoming messages. |
153 | */ | ||
154 | struct GNUNET_PSYC_ReceiveHandle *recv; | ||
155 | |||
156 | /** | ||
157 | * Slicer for processing incoming methods. | ||
158 | */ | 153 | */ |
159 | struct GNUNET_PSYC_Slicer *slicer; | 154 | struct GNUNET_PSYC_Slicer *slicer; |
160 | 155 | ||
@@ -204,12 +199,7 @@ struct GNUNET_SOCIAL_Host | |||
204 | struct GNUNET_SOCIAL_Place plc; | 199 | struct GNUNET_SOCIAL_Place plc; |
205 | 200 | ||
206 | /** | 201 | /** |
207 | * Receipt handle. | 202 | * Slicer for processing incoming messages from guests. |
208 | */ | ||
209 | struct GNUNET_PSYC_ReceiveHandle *recv; | ||
210 | |||
211 | /** | ||
212 | * Slicer for processing incoming methods. | ||
213 | */ | 203 | */ |
214 | struct GNUNET_PSYC_Slicer *slicer; | 204 | struct GNUNET_PSYC_Slicer *slicer; |
215 | 205 | ||
@@ -236,16 +226,6 @@ struct GNUNET_SOCIAL_Guest | |||
236 | { | 226 | { |
237 | struct GNUNET_SOCIAL_Place plc; | 227 | struct GNUNET_SOCIAL_Place plc; |
238 | 228 | ||
239 | /** | ||
240 | * Receipt handle. | ||
241 | */ | ||
242 | struct GNUNET_PSYC_ReceiveHandle *recv; | ||
243 | |||
244 | /** | ||
245 | * Slicer for processing incoming methods. | ||
246 | */ | ||
247 | struct GNUNET_PSYC_Slicer *slicer; | ||
248 | |||
249 | GNUNET_SOCIAL_GuestEnterCallback enter_cb; | 229 | GNUNET_SOCIAL_GuestEnterCallback enter_cb; |
250 | 230 | ||
251 | GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb; | 231 | GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb; |
@@ -298,9 +278,9 @@ struct GNUNET_SOCIAL_HistoryRequest | |||
298 | uint64_t op_id; | 278 | uint64_t op_id; |
299 | 279 | ||
300 | /** | 280 | /** |
301 | * Message handler. | 281 | * Slicer for processing incoming messages. |
302 | */ | 282 | */ |
303 | struct GNUNET_PSYC_ReceiveHandle *recv; | 283 | struct GNUNET_PSYC_Slicer *slicer; |
304 | 284 | ||
305 | /** | 285 | /** |
306 | * Function to call when the operation finished. | 286 | * Function to call when the operation finished. |
@@ -519,6 +499,7 @@ app_send_connect_msg (struct GNUNET_SOCIAL_App *app) | |||
519 | struct GNUNET_MessageHeader * cmsg = GNUNET_malloc (cmsg_size); | 499 | struct GNUNET_MessageHeader * cmsg = GNUNET_malloc (cmsg_size); |
520 | memcpy (cmsg, app->connect_msg, cmsg_size); | 500 | memcpy (cmsg, app->connect_msg, cmsg_size); |
521 | GNUNET_CLIENT_MANAGER_transmit_now (app->client, cmsg); | 501 | GNUNET_CLIENT_MANAGER_transmit_now (app->client, cmsg); |
502 | GNUNET_free (cmsg); | ||
522 | } | 503 | } |
523 | 504 | ||
524 | 505 | ||
@@ -545,6 +526,7 @@ place_send_connect_msg (struct GNUNET_SOCIAL_Place *plc) | |||
545 | struct GNUNET_MessageHeader * cmsg = GNUNET_malloc (cmsg_size); | 526 | struct GNUNET_MessageHeader * cmsg = GNUNET_malloc (cmsg_size); |
546 | memcpy (cmsg, plc->connect_msg, cmsg_size); | 527 | memcpy (cmsg, plc->connect_msg, cmsg_size); |
547 | GNUNET_CLIENT_MANAGER_transmit_now (plc->client, cmsg); | 528 | GNUNET_CLIENT_MANAGER_transmit_now (plc->client, cmsg); |
529 | GNUNET_free (cmsg); | ||
548 | } | 530 | } |
549 | 531 | ||
550 | 532 | ||
@@ -625,7 +607,6 @@ op_recv_history_result (void *cls, int64_t result, | |||
625 | if (NULL != hist->result_cb) | 607 | if (NULL != hist->result_cb) |
626 | hist->result_cb (hist->cls, result, err_msg, err_msg_size); | 608 | hist->result_cb (hist->cls, result, err_msg, err_msg_size); |
627 | 609 | ||
628 | GNUNET_PSYC_receive_destroy (hist->recv); | ||
629 | GNUNET_free (hist); | 610 | GNUNET_free (hist); |
630 | } | 611 | } |
631 | 612 | ||
@@ -684,8 +665,8 @@ place_recv_history_result (void *cls, | |||
684 | return; | 665 | return; |
685 | } | 666 | } |
686 | 667 | ||
687 | GNUNET_PSYC_receive_message (hist->recv, | 668 | GNUNET_PSYC_slicer_message (hist->slicer, |
688 | (const struct GNUNET_PSYC_MessageHeader *) pmsg); | 669 | (const struct GNUNET_PSYC_MessageHeader *) pmsg); |
689 | } | 670 | } |
690 | 671 | ||
691 | 672 | ||
@@ -781,7 +762,7 @@ place_recv_message (void *cls, | |||
781 | { | 762 | { |
782 | struct GNUNET_SOCIAL_Place * | 763 | struct GNUNET_SOCIAL_Place * |
783 | plc = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*plc)); | 764 | plc = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*plc)); |
784 | GNUNET_PSYC_receive_message (plc->recv, | 765 | GNUNET_PSYC_slicer_message (plc->slicer, |
785 | (const struct GNUNET_PSYC_MessageHeader *) msg); | 766 | (const struct GNUNET_PSYC_MessageHeader *) msg); |
786 | } | 767 | } |
787 | 768 | ||
@@ -793,10 +774,10 @@ host_recv_message (void *cls, | |||
793 | { | 774 | { |
794 | struct GNUNET_SOCIAL_Host * | 775 | struct GNUNET_SOCIAL_Host * |
795 | hst = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (hst->plc)); | 776 | hst = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (hst->plc)); |
796 | GNUNET_PSYC_receive_message (hst->recv, | 777 | GNUNET_PSYC_slicer_message (hst->slicer, |
797 | (const struct GNUNET_PSYC_MessageHeader *) msg); | 778 | (const struct GNUNET_PSYC_MessageHeader *) msg); |
798 | GNUNET_PSYC_receive_message (hst->plc.recv, | 779 | GNUNET_PSYC_slicer_message (hst->plc.slicer, |
799 | (const struct GNUNET_PSYC_MessageHeader *) msg); | 780 | (const struct GNUNET_PSYC_MessageHeader *) msg); |
800 | } | 781 | } |
801 | 782 | ||
802 | 783 | ||
@@ -855,7 +836,7 @@ host_recv_enter_request (void *cls, | |||
855 | &data, &data_size)) | 836 | &data, &data_size)) |
856 | { | 837 | { |
857 | GNUNET_break_op (0); | 838 | GNUNET_break_op (0); |
858 | str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&req->slave_key); | 839 | str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&req->slave_pub_key); |
859 | LOG (GNUNET_ERROR_TYPE_WARNING, | 840 | LOG (GNUNET_ERROR_TYPE_WARNING, |
860 | "Ignoring invalid entry request from nym %s.\n", | 841 | "Ignoring invalid entry request from nym %s.\n", |
861 | str); | 842 | str); |
@@ -864,7 +845,7 @@ host_recv_enter_request (void *cls, | |||
864 | } | 845 | } |
865 | } | 846 | } |
866 | 847 | ||
867 | struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&req->slave_key); | 848 | struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&req->slave_pub_key); |
868 | hst->answer_door_cb (hst->cb_cls, nym, method_name, env, | 849 | hst->answer_door_cb (hst->cb_cls, nym, method_name, env, |
869 | data_size, data); | 850 | data_size, data); |
870 | } while (0); | 851 | } while (0); |
@@ -1098,8 +1079,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) | |||
1098 | { | 1079 | { |
1099 | if (NULL != plc->tmit) | 1080 | if (NULL != plc->tmit) |
1100 | GNUNET_PSYC_transmit_destroy (plc->tmit); | 1081 | GNUNET_PSYC_transmit_destroy (plc->tmit); |
1101 | if (NULL != plc->recv) | ||
1102 | GNUNET_PSYC_receive_destroy (plc->recv); | ||
1103 | if (NULL != plc->connect_msg) | 1082 | if (NULL != plc->connect_msg) |
1104 | GNUNET_free (plc->connect_msg); | 1083 | GNUNET_free (plc->connect_msg); |
1105 | if (NULL != plc->disconnect_cb) | 1084 | if (NULL != plc->disconnect_cb) |
@@ -1112,11 +1091,6 @@ host_cleanup (void *cls) | |||
1112 | { | 1091 | { |
1113 | struct GNUNET_SOCIAL_Host *hst = cls; | 1092 | struct GNUNET_SOCIAL_Host *hst = cls; |
1114 | place_cleanup (&hst->plc); | 1093 | place_cleanup (&hst->plc); |
1115 | if (NULL != hst->recv) | ||
1116 | { | ||
1117 | GNUNET_PSYC_receive_destroy (hst->recv); | ||
1118 | hst->recv = NULL; | ||
1119 | } | ||
1120 | if (NULL != hst->slicer) | 1094 | if (NULL != hst->slicer) |
1121 | { | 1095 | { |
1122 | GNUNET_PSYC_slicer_destroy (hst->slicer); | 1096 | GNUNET_PSYC_slicer_destroy (hst->slicer); |
@@ -1191,14 +1165,12 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, | |||
1191 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); | 1165 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); |
1192 | 1166 | ||
1193 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); | 1167 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); |
1194 | plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer); | ||
1195 | 1168 | ||
1196 | hst->slicer = GNUNET_PSYC_slicer_create (); | 1169 | hst->slicer = GNUNET_PSYC_slicer_create (); |
1197 | GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", | 1170 | GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", |
1198 | host_recv_notice_place_leave_method, | 1171 | host_recv_notice_place_leave_method, |
1199 | host_recv_notice_place_leave_modifier, | 1172 | host_recv_notice_place_leave_modifier, |
1200 | NULL, host_recv_notice_place_leave_eom, hst); | 1173 | NULL, host_recv_notice_place_leave_eom, hst); |
1201 | hst->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, hst->slicer); | ||
1202 | 1174 | ||
1203 | uint16_t app_id_size = strlen (app->id) + 1; | 1175 | uint16_t app_id_size = strlen (app->id) + 1; |
1204 | struct HostEnterRequest *hreq = GNUNET_malloc (sizeof (*hreq) + app_id_size); | 1176 | struct HostEnterRequest *hreq = GNUNET_malloc (sizeof (*hreq) + app_id_size); |
@@ -1263,14 +1235,12 @@ GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, | |||
1263 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); | 1235 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); |
1264 | 1236 | ||
1265 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); | 1237 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); |
1266 | plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer); | ||
1267 | 1238 | ||
1268 | hst->slicer = GNUNET_PSYC_slicer_create (); | 1239 | hst->slicer = GNUNET_PSYC_slicer_create (); |
1269 | GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", | 1240 | GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", |
1270 | host_recv_notice_place_leave_method, | 1241 | host_recv_notice_place_leave_method, |
1271 | host_recv_notice_place_leave_modifier, | 1242 | host_recv_notice_place_leave_modifier, |
1272 | NULL, host_recv_notice_place_leave_eom, hst); | 1243 | NULL, host_recv_notice_place_leave_eom, hst); |
1273 | hst->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, hst->slicer); | ||
1274 | 1244 | ||
1275 | hreq->header.size = htons (sizeof (*hreq) + app_id_size); | 1245 | hreq->header.size = htons (sizeof (*hreq) + app_id_size); |
1276 | hreq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER); | 1246 | hreq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER); |
@@ -1325,12 +1295,13 @@ GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst, | |||
1325 | dcsn->header.size = htons (sizeof (*dcsn) + entry_resp_size); | 1295 | dcsn->header.size = htons (sizeof (*dcsn) + entry_resp_size); |
1326 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); | 1296 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); |
1327 | dcsn->is_admitted = htonl (is_admitted); | 1297 | dcsn->is_admitted = htonl (is_admitted); |
1328 | dcsn->slave_key = nym->pub_key; | 1298 | dcsn->slave_pub_key = nym->pub_key; |
1329 | 1299 | ||
1330 | if (0 < entry_resp_size) | 1300 | if (0 < entry_resp_size) |
1331 | memcpy (&dcsn[1], entry_resp, entry_resp_size); | 1301 | memcpy (&dcsn[1], entry_resp, entry_resp_size); |
1332 | 1302 | ||
1333 | GNUNET_CLIENT_MANAGER_transmit (hst->plc.client, &dcsn->header); | 1303 | GNUNET_CLIENT_MANAGER_transmit (hst->plc.client, &dcsn->header); |
1304 | GNUNET_free (dcsn); | ||
1334 | return GNUNET_OK; | 1305 | return GNUNET_OK; |
1335 | } | 1306 | } |
1336 | 1307 | ||
@@ -1690,7 +1661,6 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, | |||
1690 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); | 1661 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); |
1691 | 1662 | ||
1692 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); | 1663 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); |
1693 | plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer); | ||
1694 | 1664 | ||
1695 | struct GuestEnterRequest * | 1665 | struct GuestEnterRequest * |
1696 | greq = guest_enter_request_create (app->id, &ego->pub_key, &plc->pub_key, | 1666 | greq = guest_enter_request_create (app->id, &ego->pub_key, &plc->pub_key, |
@@ -1782,7 +1752,6 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
1782 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); | 1752 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); |
1783 | 1753 | ||
1784 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); | 1754 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); |
1785 | plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer); | ||
1786 | 1755 | ||
1787 | plc->connect_msg = &greq->header; | 1756 | plc->connect_msg = &greq->header; |
1788 | place_send_connect_msg (plc); | 1757 | place_send_connect_msg (plc); |
@@ -1842,7 +1811,6 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn | |||
1842 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); | 1811 | GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); |
1843 | 1812 | ||
1844 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); | 1813 | plc->tmit = GNUNET_PSYC_transmit_create (plc->client); |
1845 | plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer); | ||
1846 | 1814 | ||
1847 | plc->connect_msg = &greq->header; | 1815 | plc->connect_msg = &greq->header; |
1848 | place_send_connect_msg (plc); | 1816 | place_send_connect_msg (plc); |
@@ -1994,6 +1962,52 @@ GNUNET_SOCIAL_place_get_key (struct GNUNET_SOCIAL_Place *plc) | |||
1994 | } | 1962 | } |
1995 | 1963 | ||
1996 | 1964 | ||
1965 | /** | ||
1966 | * Set message processing @a flags for a @a method_prefix. | ||
1967 | * | ||
1968 | * @param plc | ||
1969 | * Place. | ||
1970 | * @param method_prefix | ||
1971 | * Method prefix @a flags apply to. | ||
1972 | * @param flags | ||
1973 | * The flags that apply to a matching @a method_prefix. | ||
1974 | */ | ||
1975 | void | ||
1976 | GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc, | ||
1977 | const char *method_prefix, | ||
1978 | enum GNUNET_SOCIAL_MsgProcFlags flags) | ||
1979 | { | ||
1980 | GNUNET_assert (NULL != method_prefix); | ||
1981 | struct MsgProcRequest *mpreq; | ||
1982 | uint16_t method_size = strnlen (method_prefix, | ||
1983 | GNUNET_SERVER_MAX_MESSAGE_SIZE | ||
1984 | - sizeof (*mpreq)) + 1; | ||
1985 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); | ||
1986 | mpreq = GNUNET_malloc (sizeof (*mpreq) + method_size); | ||
1987 | |||
1988 | mpreq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET); | ||
1989 | mpreq->header.size = htons (sizeof (*mpreq) + method_size); | ||
1990 | mpreq->flags = htonl (flags); | ||
1991 | memcpy (&mpreq[1], method_prefix, method_size); | ||
1992 | |||
1993 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &mpreq->header); | ||
1994 | GNUNET_free (mpreq); | ||
1995 | } | ||
1996 | |||
1997 | |||
1998 | /** | ||
1999 | * Clear all message processing flags previously set for this place. | ||
2000 | */ | ||
2001 | void | ||
2002 | GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc) | ||
2003 | { | ||
2004 | struct GNUNET_MessageHeader req; | ||
2005 | req.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR); | ||
2006 | req.size = htons (sizeof (req)); | ||
2007 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &req); | ||
2008 | } | ||
2009 | |||
2010 | |||
1997 | static struct GNUNET_SOCIAL_HistoryRequest * | 2011 | static struct GNUNET_SOCIAL_HistoryRequest * |
1998 | place_history_replay (struct GNUNET_SOCIAL_Place *plc, | 2012 | place_history_replay (struct GNUNET_SOCIAL_Place *plc, |
1999 | uint64_t start_message_id, | 2013 | uint64_t start_message_id, |
@@ -2008,7 +2022,7 @@ place_history_replay (struct GNUNET_SOCIAL_Place *plc, | |||
2008 | struct GNUNET_PSYC_HistoryRequestMessage *req; | 2022 | struct GNUNET_PSYC_HistoryRequestMessage *req; |
2009 | struct GNUNET_SOCIAL_HistoryRequest *hist = GNUNET_malloc (sizeof (*hist)); | 2023 | struct GNUNET_SOCIAL_HistoryRequest *hist = GNUNET_malloc (sizeof (*hist)); |
2010 | hist->plc = plc; | 2024 | hist->plc = plc; |
2011 | hist->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, slicer); | 2025 | hist->slicer = slicer; |
2012 | hist->result_cb = result_cb; | 2026 | hist->result_cb = result_cb; |
2013 | hist->cls = cls; | 2027 | hist->cls = cls; |
2014 | hist->op_id = GNUNET_CLIENT_MANAGER_op_add (plc->client, | 2028 | hist->op_id = GNUNET_CLIENT_MANAGER_op_add (plc->client, |
@@ -2030,6 +2044,7 @@ place_history_replay (struct GNUNET_SOCIAL_Place *plc, | |||
2030 | memcpy (&req[1], method_prefix, method_size); | 2044 | memcpy (&req[1], method_prefix, method_size); |
2031 | 2045 | ||
2032 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &req->header); | 2046 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &req->header); |
2047 | GNUNET_free (req); | ||
2033 | return hist; | 2048 | return hist; |
2034 | } | 2049 | } |
2035 | 2050 | ||
@@ -2118,7 +2133,6 @@ GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc, | |||
2118 | void | 2133 | void |
2119 | GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist) | 2134 | GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist) |
2120 | { | 2135 | { |
2121 | GNUNET_PSYC_receive_destroy (hist->recv); | ||
2122 | GNUNET_CLIENT_MANAGER_op_cancel (hist->plc->client, hist->op_id); | 2136 | GNUNET_CLIENT_MANAGER_op_cancel (hist->plc->client, hist->op_id); |
2123 | GNUNET_free (hist); | 2137 | GNUNET_free (hist); |
2124 | } | 2138 | } |
@@ -2152,6 +2166,7 @@ place_state_get (struct GNUNET_SOCIAL_Place *plc, | |||
2152 | memcpy (&req[1], name, name_size); | 2166 | memcpy (&req[1], name, name_size); |
2153 | 2167 | ||
2154 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &req->header); | 2168 | GNUNET_CLIENT_MANAGER_transmit (plc->client, &req->header); |
2169 | GNUNET_free (req); | ||
2155 | return look; | 2170 | return look; |
2156 | } | 2171 | } |
2157 | 2172 | ||
@@ -2314,6 +2329,7 @@ GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app, | |||
2314 | op_recv_zone_add_place_result, | 2329 | op_recv_zone_add_place_result, |
2315 | add_plc)); | 2330 | add_plc)); |
2316 | GNUNET_CLIENT_MANAGER_transmit_now (app->client, &preq->header); | 2331 | GNUNET_CLIENT_MANAGER_transmit_now (app->client, &preq->header); |
2332 | GNUNET_free (preq); | ||
2317 | return GNUNET_OK; | 2333 | return GNUNET_OK; |
2318 | } | 2334 | } |
2319 | 2335 | ||