diff options
author | Gabor X Toth <*@tg-x.net> | 2016-01-06 12:28:47 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-01-06 12:28:47 +0000 |
commit | 80d2de6cdc4d253c7fbc6a4bc067d856aab9cca9 (patch) | |
tree | 86e33af618c53b82afd0cb4855d7da595fcd5acd /src/social | |
parent | 7d1dfe26d99376a341bb150eb89ba717bb883077 (diff) | |
download | gnunet-80d2de6cdc4d253c7fbc6a4bc067d856aab9cca9.tar.gz gnunet-80d2de6cdc4d253c7fbc6a4bc067d856aab9cca9.zip |
psyc/social: local join flag; social service: leave place, save _file
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 179 | ||||
-rw-r--r-- | src/social/social.conf.in | 2 | ||||
-rw-r--r-- | src/social/social.h | 4 | ||||
-rw-r--r-- | src/social/social_api.c | 55 | ||||
-rw-r--r-- | src/social/test_social.c | 15 |
5 files changed, 216 insertions, 39 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index b7cf1f856..ec4b18d0b 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -95,6 +95,12 @@ static struct GNUNET_CONTAINER_MultiHashMap *places; | |||
95 | static struct GNUNET_CONTAINER_MultiHashMap *apps_places; | 95 | static struct GNUNET_CONTAINER_MultiHashMap *apps_places; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Application subscriptions per place. | ||
99 | * H(place_pub_key) -> H(app_id) | ||
100 | */ | ||
101 | static struct GNUNET_CONTAINER_MultiHashMap *places_apps; | ||
102 | |||
103 | /** | ||
98 | * Connected applications. | 104 | * Connected applications. |
99 | * H(app_id) -> struct Application | 105 | * H(app_id) -> struct Application |
100 | */ | 106 | */ |
@@ -108,7 +114,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *egos; | |||
108 | 114 | ||
109 | /** | 115 | /** |
110 | * Directory for storing social data. | 116 | * Directory for storing social data. |
111 | * Default: ~/.local/share/gnunet/social | 117 | * Default: $GNUNET_DATA_HOME/social |
112 | */ | 118 | */ |
113 | static char *dir_social; | 119 | static char *dir_social; |
114 | 120 | ||
@@ -223,6 +229,11 @@ struct Place | |||
223 | */ | 229 | */ |
224 | struct GNUNET_HashCode ego_pub_hash; | 230 | struct GNUNET_HashCode ego_pub_hash; |
225 | 231 | ||
232 | uint64_t file_message_id; | ||
233 | uint64_t file_fragment_offset; | ||
234 | uint64_t file_size; | ||
235 | uint64_t file_offset; | ||
236 | |||
226 | /** | 237 | /** |
227 | * Last message ID received for the place. | 238 | * Last message ID received for the place. |
228 | * 0 if there is no such message. | 239 | * 0 if there is no such message. |
@@ -326,6 +337,10 @@ struct Guest | |||
326 | */ | 337 | */ |
327 | struct GNUNET_PSYC_JoinDecisionMessage *join_dcsn; | 338 | struct GNUNET_PSYC_JoinDecisionMessage *join_dcsn; |
328 | 339 | ||
340 | /** | ||
341 | * Join flags for the PSYC service. | ||
342 | */ | ||
343 | enum GNUNET_PSYC_SlaveJoinFlags join_flags; | ||
329 | }; | 344 | }; |
330 | 345 | ||
331 | 346 | ||
@@ -713,6 +728,51 @@ psyc_recv_join_dcsn (void *cls, | |||
713 | place_send_msg (&gst->plc, &dcsn->header); | 728 | place_send_msg (&gst->plc, &dcsn->header); |
714 | } | 729 | } |
715 | 730 | ||
731 | /** | ||
732 | * Save _file data to disk. | ||
733 | */ | ||
734 | void | ||
735 | psyc_recv_file (struct Place *plc, const struct GNUNET_PSYC_MessageHeader *msg, | ||
736 | uint32_t flags, uint64_t message_id, uint64_t fragment_offset, | ||
737 | const char *method_name, struct GNUNET_ENV_Environment *env, | ||
738 | const void *data, uint16_t data_size) | ||
739 | { | ||
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 | |||
749 | /* new file */ | ||
750 | plc->file_offset = 0; | ||
751 | } | ||
752 | |||
753 | struct GNUNET_CRYPTO_HashAsciiEncoded place_pub_hash_ascii; | ||
754 | memcpy (&place_pub_hash_ascii.encoding, | ||
755 | GNUNET_h2s_full (&plc->pub_key_hash), sizeof (place_pub_hash_ascii)); | ||
756 | |||
757 | char *filename = NULL; | ||
758 | GNUNET_asprintf (&filename, "%s%c%s%c%s%c%" PRIu64, | ||
759 | dir_social, DIR_SEPARATOR, | ||
760 | "files", DIR_SEPARATOR, | ||
761 | place_pub_hash_ascii.encoding, DIR_SEPARATOR, | ||
762 | message_id); | ||
763 | GNUNET_DISK_directory_create_for_file (filename); | ||
764 | struct GNUNET_DISK_FileHandle * | ||
765 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE, | ||
766 | GNUNET_DISK_PERM_USER_READ | ||
767 | | GNUNET_DISK_PERM_USER_WRITE); | ||
768 | GNUNET_free (filename); | ||
769 | |||
770 | GNUNET_DISK_file_seek (fh, plc->file_offset, GNUNET_DISK_SEEK_SET); | ||
771 | GNUNET_DISK_file_write (fh, data, data_size); | ||
772 | GNUNET_DISK_file_close (fh); | ||
773 | plc->file_offset += data_size; | ||
774 | } | ||
775 | |||
716 | 776 | ||
717 | /** | 777 | /** |
718 | * Called when a PSYC master or slave receives a message. | 778 | * Called when a PSYC master or slave receives a message. |
@@ -731,9 +791,33 @@ psyc_recv_message (void *cls, | |||
731 | plc, ntohs (msg->header.size), str); | 791 | plc, ntohs (msg->header.size), str); |
732 | GNUNET_free (str); | 792 | GNUNET_free (str); |
733 | 793 | ||
734 | place_send_msg (plc, &msg->header); | 794 | /* process message */ |
795 | /* FIXME: use slicer */ | ||
796 | const char *method_name = NULL; | ||
797 | struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); | ||
798 | const void *data = NULL; | ||
799 | uint16_t data_size = 0; | ||
800 | |||
801 | if (GNUNET_SYSERR == GNUNET_PSYC_message_parse (msg, &method_name, env, &data, &data_size)) | ||
802 | { | ||
803 | GNUNET_break (0); | ||
804 | } | ||
805 | else | ||
806 | { | ||
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_ENV_environment_destroy (env); | ||
735 | 819 | ||
736 | /* FIXME: further processing */ | 820 | place_send_msg (plc, &msg->header); |
737 | } | 821 | } |
738 | 822 | ||
739 | 823 | ||
@@ -838,13 +922,39 @@ app_place_add (const char *app_id, | |||
838 | if (GNUNET_SYSERR == place_add (ereq)) | 922 | if (GNUNET_SYSERR == place_add (ereq)) |
839 | return GNUNET_SYSERR; | 923 | return GNUNET_SYSERR; |
840 | 924 | ||
841 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, | 925 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, |
842 | NULL, 0)) | 926 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
843 | { | 927 | { |
844 | GNUNET_break (0); | 928 | GNUNET_break (0); |
845 | return GNUNET_SYSERR; | 929 | return GNUNET_SYSERR; |
846 | } | 930 | } |
847 | 931 | ||
932 | struct GNUNET_HashCode place_pub_hash; | ||
933 | GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); | ||
934 | |||
935 | struct GNUNET_CONTAINER_MultiHashMap * | ||
936 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | ||
937 | if (NULL == place_apps) | ||
938 | { | ||
939 | place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | ||
940 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, | ||
941 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | ||
942 | { | ||
943 | GNUNET_break (0); | ||
944 | } | ||
945 | } | ||
946 | |||
947 | |||
948 | size_t app_id_size = strlen (app_id); | ||
949 | void *app_id_value = GNUNET_malloc (app_id_size); | ||
950 | memcpy (app_id_value, app_id, app_id_size); | ||
951 | |||
952 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, | ||
953 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
954 | { | ||
955 | GNUNET_break (0); | ||
956 | } | ||
957 | |||
848 | return GNUNET_OK; | 958 | return GNUNET_OK; |
849 | } | 959 | } |
850 | 960 | ||
@@ -948,6 +1058,19 @@ app_place_remove (const char *app_id, | |||
948 | if (NULL != app_places) | 1058 | if (NULL != app_places) |
949 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); | 1059 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); |
950 | 1060 | ||
1061 | struct GNUNET_CONTAINER_MultiHashMap * | ||
1062 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | ||
1063 | if (NULL != place_apps) | ||
1064 | { | ||
1065 | void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); | ||
1066 | if (NULL != app_id_value) | ||
1067 | { | ||
1068 | GNUNET_free (app_id_value); | ||
1069 | GNUNET_CONTAINER_multihashmap_remove_all (place_apps, &app_id_hash); | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | |||
951 | int ret = unlink (app_place_filename); | 1074 | int ret = unlink (app_place_filename); |
952 | GNUNET_free (app_place_filename); | 1075 | GNUNET_free (app_place_filename); |
953 | if (0 != ret) | 1076 | if (0 != ret) |
@@ -1187,6 +1310,8 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1187 | memcpy (gst->relays, relays, relay_size); | 1310 | memcpy (gst->relays, relays, relay_size); |
1188 | } | 1311 | } |
1189 | 1312 | ||
1313 | gst->join_flags = ntohl (greq->flags); | ||
1314 | |||
1190 | struct Place *plc = &gst->plc; | 1315 | struct Place *plc = &gst->plc; |
1191 | place_init (plc); | 1316 | place_init (plc); |
1192 | plc->is_host = GNUNET_NO; | 1317 | plc->is_host = GNUNET_NO; |
@@ -1208,9 +1333,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1208 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1333 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1209 | gst->slave | 1334 | gst->slave |
1210 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, | 1335 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, |
1211 | &gst->origin, gst->relay_count, gst->relays, | 1336 | gst->join_flags, &gst->origin, |
1212 | &psyc_recv_message, NULL, &psyc_slave_connected, | 1337 | gst->relay_count, gst->relays, |
1213 | &psyc_recv_join_dcsn, gst, join_msg); | 1338 | &psyc_recv_message, NULL, |
1339 | &psyc_slave_connected, | ||
1340 | &psyc_recv_join_dcsn, | ||
1341 | gst, join_msg); | ||
1214 | gst->plc.channel = GNUNET_PSYC_slave_get_channel (gst->slave); | 1342 | gst->plc.channel = GNUNET_PSYC_slave_get_channel (gst->slave); |
1215 | ret = GNUNET_YES; | 1343 | ret = GNUNET_YES; |
1216 | } | 1344 | } |
@@ -1442,6 +1570,8 @@ app_notify_place (struct GNUNET_MessageHeader *msg, | |||
1442 | struct AppPlaceMessage amsg; | 1570 | struct AppPlaceMessage amsg; |
1443 | amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); | 1571 | amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); |
1444 | amsg.header.size = htons (sizeof (amsg)); | 1572 | amsg.header.size = htons (sizeof (amsg)); |
1573 | // FIXME: also notify about not entered places | ||
1574 | amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; | ||
1445 | 1575 | ||
1446 | switch (ntohs (msg->type)) | 1576 | switch (ntohs (msg->type)) |
1447 | { | 1577 | { |
@@ -1492,7 +1622,7 @@ app_notify_ego (struct Ego *ego, struct GNUNET_SERVER_Client *client) | |||
1492 | 1622 | ||
1493 | 1623 | ||
1494 | int | 1624 | int |
1495 | app_place_entry (void *cls, const struct GNUNET_HashCode *key, void *value) | 1625 | app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) |
1496 | { | 1626 | { |
1497 | struct GNUNET_MessageHeader * | 1627 | struct GNUNET_MessageHeader * |
1498 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); | 1628 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); |
@@ -1539,7 +1669,7 @@ client_recv_app_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1539 | struct GNUNET_CONTAINER_MultiHashMap * | 1669 | struct GNUNET_CONTAINER_MultiHashMap * |
1540 | app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash); | 1670 | app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash); |
1541 | if (NULL != app_places) | 1671 | if (NULL != app_places) |
1542 | GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry, client); | 1672 | GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify, client); |
1543 | 1673 | ||
1544 | struct ClientListItem *cli = GNUNET_new (struct ClientListItem); | 1674 | struct ClientListItem *cli = GNUNET_new (struct ClientListItem); |
1545 | cli->client = client; | 1675 | cli->client = client; |
@@ -1585,6 +1715,14 @@ client_recv_app_detach (void *cls, struct GNUNET_SERVER_Client *client, | |||
1585 | } | 1715 | } |
1586 | 1716 | ||
1587 | 1717 | ||
1718 | int | ||
1719 | app_places_entry_remove (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
1720 | { | ||
1721 | app_place_remove (value, cls); | ||
1722 | return GNUNET_YES; | ||
1723 | } | ||
1724 | |||
1725 | |||
1588 | /** | 1726 | /** |
1589 | * Handle application detach request. | 1727 | * Handle application detach request. |
1590 | */ | 1728 | */ |
@@ -1597,8 +1735,18 @@ client_recv_place_leave (void *cls, struct GNUNET_SERVER_Client *client, | |||
1597 | GNUNET_assert (NULL != ctx); | 1735 | GNUNET_assert (NULL != ctx); |
1598 | struct Place *plc = ctx->plc; | 1736 | struct Place *plc = ctx->plc; |
1599 | 1737 | ||
1600 | /* Disconnect all clients connected to the place */ | 1738 | /* FIXME: remove all app subscriptions and leave this place */ |
1739 | |||
1740 | struct GNUNET_CONTAINER_MultiHashMap * | ||
1741 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); | ||
1742 | if (NULL != place_apps) | ||
1743 | { | ||
1744 | GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, &plc->pub_key); | ||
1745 | } | ||
1746 | |||
1601 | /* FIXME: disconnect from the network, but keep local connection for history access */ | 1747 | /* FIXME: disconnect from the network, but keep local connection for history access */ |
1748 | |||
1749 | /* Disconnect all clients connected to the place */ | ||
1602 | struct ClientListItem *cli = plc->clients_head, *next; | 1750 | struct ClientListItem *cli = plc->clients_head, *next; |
1603 | while (NULL != cli) | 1751 | while (NULL != cli) |
1604 | { | 1752 | { |
@@ -2832,7 +2980,7 @@ file_ego_place_load (void *cls, const char *place_filename) | |||
2832 | * | 2980 | * |
2833 | * @param dir_ego | 2981 | * @param dir_ego |
2834 | * Data directory of an application ego. | 2982 | * Data directory of an application ego. |
2835 | * e.g. ~/.local/share/gnunet/social/apps/$app_id/$ego_pub_hash_str/ | 2983 | * $GNUNET_DATA_HOME/social/apps/$app_id/$ego_pub_hash_str/ |
2836 | */ | 2984 | */ |
2837 | int | 2985 | int |
2838 | scan_app_ego_dir (void *cls, const char *dir_ego) | 2986 | scan_app_ego_dir (void *cls, const char *dir_ego) |
@@ -2851,7 +2999,7 @@ scan_app_ego_dir (void *cls, const char *dir_ego) | |||
2851 | * | 2999 | * |
2852 | * @param dir_app | 3000 | * @param dir_app |
2853 | * Data directory of an application. | 3001 | * Data directory of an application. |
2854 | * e.g. ~/.local/share/gnunet/social/apps/$app_id/ | 3002 | * $GNUNET_DATA_HOME/social/apps/$app_id/ |
2855 | */ | 3003 | */ |
2856 | int | 3004 | int |
2857 | scan_app_dir (void *cls, const char *dir_app) | 3005 | scan_app_dir (void *cls, const char *dir_app) |
@@ -2941,6 +3089,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2941 | apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 3089 | apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
2942 | places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | 3090 | places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); |
2943 | apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | 3091 | apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); |
3092 | places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | ||
2944 | 3093 | ||
2945 | core = GNUNET_CORE_connect (cfg, NULL, core_connected, NULL, NULL, | 3094 | core = GNUNET_CORE_connect (cfg, NULL, core_connected, NULL, NULL, |
2946 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | 3095 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); |
@@ -2950,11 +3099,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2950 | stats = GNUNET_STATISTICS_create ("social", cfg); | 3099 | stats = GNUNET_STATISTICS_create ("social", cfg); |
2951 | 3100 | ||
2952 | if (GNUNET_OK != | 3101 | if (GNUNET_OK != |
2953 | GNUNET_CONFIGURATION_get_value_filename (cfg, "social", "SOCIAL_DATA_DIR", | 3102 | GNUNET_CONFIGURATION_get_value_filename (cfg, "social", "DATA_HOME", |
2954 | &dir_social)) | 3103 | &dir_social)) |
2955 | { | 3104 | { |
2956 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 3105 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
2957 | "social", "SOCIAL_DATA_DIR"); | 3106 | "social", "DATA_HOME"); |
2958 | GNUNET_break (0); | 3107 | GNUNET_break (0); |
2959 | return; | 3108 | return; |
2960 | } | 3109 | } |
diff --git a/src/social/social.conf.in b/src/social/social.conf.in index e52318bc3..9149b65a1 100644 --- a/src/social/social.conf.in +++ b/src/social/social.conf.in | |||
@@ -10,3 +10,5 @@ UNIX_MATCH_GID = YES | |||
10 | HOSTNAME = localhost | 10 | HOSTNAME = localhost |
11 | ACCEPT_FROM = 127.0.0.1; | 11 | ACCEPT_FROM = 127.0.0.1; |
12 | ACCEPT_FROM6 = ::1; | 12 | ACCEPT_FROM6 = ::1; |
13 | |||
14 | DATA_HOME = $GNUNET_DATA_HOME/social | ||
diff --git a/src/social/social.h b/src/social/social.h index 651338c51..b797a89ac 100644 --- a/src/social/social.h +++ b/src/social/social.h | |||
@@ -114,6 +114,8 @@ struct GuestEnterRequest | |||
114 | 114 | ||
115 | struct GNUNET_PeerIdentity origin; | 115 | struct GNUNET_PeerIdentity origin; |
116 | 116 | ||
117 | uint32_t flags GNUNET_PACKED; | ||
118 | |||
117 | /* Followed by char *app_id */ | 119 | /* Followed by char *app_id */ |
118 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | 120 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ |
119 | /* Followed by struct GNUNET_MessageHeader *join_msg */ | 121 | /* Followed by struct GNUNET_MessageHeader *join_msg */ |
@@ -236,6 +238,8 @@ struct AppPlaceMessage | |||
236 | struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key; | 238 | struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key; |
237 | 239 | ||
238 | uint8_t is_host; | 240 | uint8_t is_host; |
241 | |||
242 | uint8_t place_state; | ||
239 | }; | 243 | }; |
240 | 244 | ||
241 | 245 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index 6c85ba294..3d5e9853f 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -1558,14 +1558,14 @@ app_recv_place (void *cls, | |||
1558 | struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof (*hconn)); | 1558 | struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof (*hconn)); |
1559 | hconn->app = app; | 1559 | hconn->app = app; |
1560 | hconn->plc_msg = *pmsg; | 1560 | hconn->plc_msg = *pmsg; |
1561 | app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key); | 1561 | app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, pmsg->place_state); |
1562 | } | 1562 | } |
1563 | else | 1563 | else |
1564 | { | 1564 | { |
1565 | struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof (*gconn)); | 1565 | struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof (*gconn)); |
1566 | gconn->app = app; | 1566 | gconn->app = app; |
1567 | gconn->plc_msg = *pmsg; | 1567 | gconn->plc_msg = *pmsg; |
1568 | app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key); | 1568 | app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, pmsg->place_state); |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
1571 | 1571 | ||
@@ -1717,8 +1717,8 @@ guest_cleanup (void *cls) | |||
1717 | * A place is created upon first entering, and it is active until permanently | 1717 | * A place is created upon first entering, and it is active until permanently |
1718 | * left using GNUNET_SOCIAL_host_leave(). | 1718 | * left using GNUNET_SOCIAL_host_leave(). |
1719 | * | 1719 | * |
1720 | * @param cfg | 1720 | * @param app |
1721 | * Configuration to contact the social service. | 1721 | * Application handle. |
1722 | * @param ego | 1722 | * @param ego |
1723 | * Identity of the host. | 1723 | * Identity of the host. |
1724 | * @param place_key | 1724 | * @param place_key |
@@ -1808,7 +1808,7 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, | |||
1808 | * | 1808 | * |
1809 | * @return Handle for the host. | 1809 | * @return Handle for the host. |
1810 | */ | 1810 | */ |
1811 | struct GNUNET_SOCIAL_Host * | 1811 | struct GNUNET_SOCIAL_Host * |
1812 | GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, | 1812 | GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, |
1813 | struct GNUNET_SOCIAL_Slicer *slicer, | 1813 | struct GNUNET_SOCIAL_Slicer *slicer, |
1814 | GNUNET_SOCIAL_HostEnterCallback enter_cb, | 1814 | GNUNET_SOCIAL_HostEnterCallback enter_cb, |
@@ -2202,20 +2202,34 @@ guest_enter_request_create (const char *app_id, | |||
2202 | return greq; | 2202 | return greq; |
2203 | } | 2203 | } |
2204 | 2204 | ||
2205 | |||
2205 | /** | 2206 | /** |
2206 | * Request entry to a place as a guest. | 2207 | * Request entry to a place as a guest. |
2207 | * | 2208 | * |
2208 | * @param cfg Configuration to contact the social service. | 2209 | * @param app |
2209 | * @param ego Identity of the guest. | 2210 | * Application handle. |
2210 | * @param crypto_address Public key of the place to enter. | 2211 | * @param ego |
2211 | * @param origin Peer identity of the origin of the underlying multicast group. | 2212 | * Identity of the guest. |
2212 | * @param relay_count Number of elements in the @a relays array. | 2213 | * @param place_pub_key |
2213 | * @param relays Relays for the underlying multicast group. | 2214 | * Public key of the place to enter. |
2214 | * @param method_name Method name for the message. | 2215 | * @param flags |
2215 | * @param env Environment containing variables for the message, or NULL. | 2216 | * Flags for the entry. |
2216 | * @param data Payload for the message to give to the enter callback. | 2217 | * @param origin |
2217 | * @param data_size Number of bytes in @a data. | 2218 | * Peer identity of the origin of the underlying multicast group. |
2218 | * @param slicer Slicer to use for processing incoming requests from guests. | 2219 | * @param relay_count |
2220 | * Number of elements in the @a relays array. | ||
2221 | * @param relays | ||
2222 | * Relays for the underlying multicast group. | ||
2223 | * @param method_name | ||
2224 | * Method name for the message. | ||
2225 | * @param env | ||
2226 | * Environment containing variables for the message, or NULL. | ||
2227 | * @param data | ||
2228 | * Payload for the message to give to the enter callback. | ||
2229 | * @param data_size | ||
2230 | * Number of bytes in @a data. | ||
2231 | * @param slicer | ||
2232 | * Slicer to use for processing incoming requests from guests. | ||
2219 | * | 2233 | * |
2220 | * @return NULL on errors, otherwise handle for the guest. | 2234 | * @return NULL on errors, otherwise handle for the guest. |
2221 | */ | 2235 | */ |
@@ -2223,6 +2237,7 @@ struct GNUNET_SOCIAL_Guest * | |||
2223 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, | 2237 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, |
2224 | const struct GNUNET_SOCIAL_Ego *ego, | 2238 | const struct GNUNET_SOCIAL_Ego *ego, |
2225 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, | 2239 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, |
2240 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
2226 | const struct GNUNET_PeerIdentity *origin, | 2241 | const struct GNUNET_PeerIdentity *origin, |
2227 | uint32_t relay_count, | 2242 | uint32_t relay_count, |
2228 | const struct GNUNET_PeerIdentity *relays, | 2243 | const struct GNUNET_PeerIdentity *relays, |
@@ -2263,8 +2278,8 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, | |||
2263 | /** | 2278 | /** |
2264 | * Request entry to a place by name as a guest. | 2279 | * Request entry to a place by name as a guest. |
2265 | * | 2280 | * |
2266 | * @param cfg | 2281 | * @param app |
2267 | * Configuration to contact the social service. | 2282 | * Application handle. |
2268 | * @param ego | 2283 | * @param ego |
2269 | * Identity of the guest. | 2284 | * Identity of the guest. |
2270 | * @param gns_name | 2285 | * @param gns_name |
@@ -2356,6 +2371,8 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
2356 | * @param gconn | 2371 | * @param gconn |
2357 | * Guest connection handle. | 2372 | * Guest connection handle. |
2358 | * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback() | 2373 | * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback() |
2374 | * @param flags | ||
2375 | * Flags for the entry. | ||
2359 | * @param slicer | 2376 | * @param slicer |
2360 | * Slicer to use for processing incoming requests from guests. | 2377 | * Slicer to use for processing incoming requests from guests. |
2361 | * @param local_enter_cb | 2378 | * @param local_enter_cb |
@@ -2367,6 +2384,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
2367 | */ | 2384 | */ |
2368 | struct GNUNET_SOCIAL_Guest * | 2385 | struct GNUNET_SOCIAL_Guest * |
2369 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, | 2386 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, |
2387 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
2370 | struct GNUNET_SOCIAL_Slicer *slicer, | 2388 | struct GNUNET_SOCIAL_Slicer *slicer, |
2371 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 2389 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
2372 | void *cls) | 2390 | void *cls) |
@@ -2381,6 +2399,7 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn | |||
2381 | greq->header.size = htons (greq_size); | 2399 | greq->header.size = htons (greq_size); |
2382 | greq->ego_pub_key = gconn->plc_msg.ego_pub_key; | 2400 | greq->ego_pub_key = gconn->plc_msg.ego_pub_key; |
2383 | greq->place_pub_key = gconn->plc_msg.place_pub_key; | 2401 | greq->place_pub_key = gconn->plc_msg.place_pub_key; |
2402 | greq->flags = htonl (flags); | ||
2384 | 2403 | ||
2385 | memcpy (&greq[1], gconn->app->id, app_id_size); | 2404 | memcpy (&greq[1], gconn->app->id, app_id_size); |
2386 | 2405 | ||
diff --git a/src/social/test_social.c b/src/social/test_social.c index 38710cd1a..1fb9cc568 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c | |||
@@ -402,7 +402,8 @@ static void | |||
402 | app_recv_host (void *cls, | 402 | app_recv_host (void *cls, |
403 | struct GNUNET_SOCIAL_HostConnection *hconn, | 403 | struct GNUNET_SOCIAL_HostConnection *hconn, |
404 | struct GNUNET_SOCIAL_Ego *ego, | 404 | struct GNUNET_SOCIAL_Ego *ego, |
405 | const struct GNUNET_CRYPTO_EddsaPublicKey *host_pub_key) | 405 | const struct GNUNET_CRYPTO_EddsaPublicKey *host_pub_key, |
406 | enum GNUNET_SOCIAL_PlaceState place_state) | ||
406 | { | 407 | { |
407 | struct GNUNET_HashCode host_pub_hash; | 408 | struct GNUNET_HashCode host_pub_hash; |
408 | GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash); | 409 | GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash); |
@@ -424,9 +425,10 @@ app_recv_host (void *cls, | |||
424 | 425 | ||
425 | static void | 426 | static void |
426 | app_recv_guest (void *cls, | 427 | app_recv_guest (void *cls, |
427 | struct GNUNET_SOCIAL_GuestConnection *gconn, | 428 | struct GNUNET_SOCIAL_GuestConnection *gconn, |
428 | struct GNUNET_SOCIAL_Ego *ego, | 429 | struct GNUNET_SOCIAL_Ego *ego, |
429 | const struct GNUNET_CRYPTO_EddsaPublicKey *guest_pub_key) | 430 | const struct GNUNET_CRYPTO_EddsaPublicKey *guest_pub_key, |
431 | enum GNUNET_SOCIAL_PlaceState place_state) | ||
430 | { | 432 | { |
431 | struct GNUNET_HashCode guest_pub_hash; | 433 | struct GNUNET_HashCode guest_pub_hash; |
432 | GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash); | 434 | GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash); |
@@ -439,8 +441,8 @@ app_recv_guest (void *cls, | |||
439 | { | 441 | { |
440 | if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key))) | 442 | if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key))) |
441 | { | 443 | { |
442 | gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, guest_slicer, | 444 | gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE, |
443 | guest_reconnected, NULL); | 445 | guest_slicer, guest_reconnected, NULL); |
444 | } | 446 | } |
445 | } | 447 | } |
446 | } | 448 | } |
@@ -1122,6 +1124,7 @@ guest_enter () | |||
1122 | emsg->data, emsg->data_size); | 1124 | emsg->data, emsg->data_size); |
1123 | 1125 | ||
1124 | gst = GNUNET_SOCIAL_guest_enter (app, guest_ego, &place_pub_key, | 1126 | gst = GNUNET_SOCIAL_guest_enter (app, guest_ego, &place_pub_key, |
1127 | GNUNET_PSYC_SLAVE_JOIN_NONE, | ||
1125 | &this_peer, 0, NULL, emsg->msg, guest_slicer, | 1128 | &this_peer, 0, NULL, emsg->msg, guest_slicer, |
1126 | guest_recv_local_enter, | 1129 | guest_recv_local_enter, |
1127 | guest_recv_entry_decision, NULL); | 1130 | guest_recv_entry_decision, NULL); |