diff options
author | Gabor X Toth <*@tg-x.net> | 2016-01-15 22:12:29 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-01-15 22:12:29 +0000 |
commit | 377e7340cce5136867734fb19e89a5fc51ac0c99 (patch) | |
tree | 8dbf1f5ccec45b91367c32b67a031a7a73a4ab2d /src/social | |
parent | 61e8794662ce2fc6ca669906822840a3743b4b78 (diff) | |
download | gnunet-377e7340cce5136867734fb19e89a5fc51ac0c99.tar.gz gnunet-377e7340cce5136867734fb19e89a5fc51ac0c99.zip |
social: set/clear msg proc flags
Diffstat (limited to 'src/social')
-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 |
3 files changed, 374 insertions, 136 deletions
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 | ||