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 | |
parent | 7d1dfe26d99376a341bb150eb89ba717bb883077 (diff) | |
download | gnunet-80d2de6cdc4d253c7fbc6a4bc067d856aab9cca9.tar.gz gnunet-80d2de6cdc4d253c7fbc6a4bc067d856aab9cca9.zip |
psyc/social: local join flag; social service: leave place, save _file
-rw-r--r-- | src/include/gnunet_psyc_service.h | 14 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 138 | ||||
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 34 | ||||
-rw-r--r-- | src/psyc/psyc.h | 4 | ||||
-rw-r--r-- | src/psyc/psyc_api.c | 9 | ||||
-rw-r--r-- | src/psyc/test_psyc.c | 4 | ||||
-rw-r--r-- | src/psycstore/psyc_util_lib.c | 7 | ||||
-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 |
12 files changed, 392 insertions, 73 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 80404f837..2bbe8cdd6 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -887,6 +887,19 @@ typedef void | |||
887 | int is_admitted, | 887 | int is_admitted, |
888 | const struct GNUNET_PSYC_Message *join_msg); | 888 | const struct GNUNET_PSYC_Message *join_msg); |
889 | 889 | ||
890 | /** | ||
891 | * Flags for GNUNET_PSYC_slave_join() | ||
892 | */ | ||
893 | enum GNUNET_PSYC_SlaveJoinFlags | ||
894 | { | ||
895 | GNUNET_PSYC_SLAVE_JOIN_NONE = 0, | ||
896 | |||
897 | /** | ||
898 | * Local join for history access, no network connection is established. | ||
899 | */ | ||
900 | GNUNET_PSYC_SLAVE_JOIN_LOCAL = 1, | ||
901 | }; | ||
902 | |||
890 | 903 | ||
891 | /** | 904 | /** |
892 | * Join a PSYC channel. | 905 | * Join a PSYC channel. |
@@ -926,6 +939,7 @@ struct GNUNET_PSYC_Slave * | |||
926 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 939 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
927 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 940 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
928 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, | 941 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
942 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
929 | const struct GNUNET_PeerIdentity *origin, | 943 | const struct GNUNET_PeerIdentity *origin, |
930 | uint32_t relay_count, | 944 | uint32_t relay_count, |
931 | const struct GNUNET_PeerIdentity *relays, | 945 | const struct GNUNET_PeerIdentity *relays, |
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index 47062fdaf..bde3dbceb 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -119,22 +119,66 @@ typedef void | |||
119 | 119 | ||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Notification about a place entered. | 122 | * Entry status of a place. |
123 | */ | ||
124 | enum GNUNET_SOCIAL_PlaceState | ||
125 | { | ||
126 | /** | ||
127 | * Place was once entered but left since. | ||
128 | */ | ||
129 | GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0, | ||
130 | /** | ||
131 | * Place is entered but not subscribed. | ||
132 | */ | ||
133 | GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1, | ||
134 | /** | ||
135 | * Place is entered and subscribed. | ||
136 | */ | ||
137 | GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2, | ||
138 | }; | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Notification about a home. | ||
143 | * | ||
144 | * @param cls | ||
145 | * Closure. | ||
146 | * @param hconn | ||
147 | * Host connection, to be used with GNUNET_SOCIAL_host_enter_reconnect() | ||
148 | * @param ego | ||
149 | * Ego used to enter the place. | ||
150 | * @param place_pub_key | ||
151 | * Public key of the place. | ||
152 | * @param place_state | ||
153 | * @see enum GNUNET_SOCIAL_PlaceState | ||
123 | */ | 154 | */ |
124 | typedef void | 155 | typedef void |
125 | (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls, | 156 | (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls, |
126 | struct GNUNET_SOCIAL_HostConnection *hconn, | 157 | struct GNUNET_SOCIAL_HostConnection *hconn, |
127 | struct GNUNET_SOCIAL_Ego *ego, | 158 | struct GNUNET_SOCIAL_Ego *ego, |
128 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key); | 159 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, |
160 | enum GNUNET_SOCIAL_PlaceState place_state); | ||
129 | 161 | ||
130 | /** | 162 | /** |
131 | h * Notification about a place entered. | 163 | * Notification about a place. |
164 | * | ||
165 | * @param cls | ||
166 | * Closure. | ||
167 | * @param gconn | ||
168 | * Guest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect() | ||
169 | * @param ego | ||
170 | * Ego used to enter the place. | ||
171 | * @param place_pub_key | ||
172 | * Public key of the place. | ||
173 | * @param place_state | ||
174 | * @see enum GNUNET_SOCIAL_PlaceState | ||
132 | */ | 175 | */ |
133 | typedef void | 176 | typedef void |
134 | (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls, | 177 | (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls, |
135 | struct GNUNET_SOCIAL_GuestConnection *gconn, | 178 | struct GNUNET_SOCIAL_GuestConnection *gconn, |
136 | struct GNUNET_SOCIAL_Ego *ego, | 179 | struct GNUNET_SOCIAL_Ego *ego, |
137 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key); | 180 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, |
181 | enum GNUNET_SOCIAL_PlaceState place_state); | ||
138 | 182 | ||
139 | 183 | ||
140 | /** | 184 | /** |
@@ -719,6 +763,47 @@ GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); | |||
719 | 763 | ||
720 | 764 | ||
721 | /** | 765 | /** |
766 | * Allow relaying messages from guests matching a given @a method_prefix. | ||
767 | * | ||
768 | * @param host | ||
769 | * The host. | ||
770 | * @param method_prefix | ||
771 | * Method prefix to allow. | ||
772 | */ | ||
773 | void | ||
774 | GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host, | ||
775 | const char *method_prefix); | ||
776 | |||
777 | |||
778 | /** | ||
779 | * Allow relaying changes to objects of the place. | ||
780 | * | ||
781 | * Only applies to messages with an allowed method name. | ||
782 | * @see GNUNET_SCOIAL_host_relay_allow_method() | ||
783 | * | ||
784 | * @param host | ||
785 | * The host. | ||
786 | * @param object_prefix | ||
787 | * Object prefix to allow modifying. | ||
788 | */ | ||
789 | void | ||
790 | GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host, | ||
791 | const char *object_prefix); | ||
792 | |||
793 | |||
794 | /** | ||
795 | * Stop relaying messages from guests. | ||
796 | * | ||
797 | * Remove all allowed relay rules. | ||
798 | * | ||
799 | * | ||
800 | * | ||
801 | */ | ||
802 | void | ||
803 | GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host); | ||
804 | |||
805 | |||
806 | /** | ||
722 | * Obtain handle for a hosted place. | 807 | * Obtain handle for a hosted place. |
723 | * | 808 | * |
724 | * The returned handle can be used to access the place API. | 809 | * The returned handle can be used to access the place API. |
@@ -824,17 +909,30 @@ typedef void | |||
824 | /** | 909 | /** |
825 | * Request entry to a place as a guest. | 910 | * Request entry to a place as a guest. |
826 | * | 911 | * |
827 | * @param cfg Configuration to contact the social service. | 912 | * @param app |
828 | * @param ego Identity of the guest. | 913 | * Application handle. |
829 | * @param crypto_address Public key of the place to enter. | 914 | * @param ego |
830 | * @param origin Peer identity of the origin of the underlying multicast group. | 915 | * Identity of the guest. |
831 | * @param relay_count Number of elements in the @a relays array. | 916 | * @param place_pub_key |
832 | * @param relays Relays for the underlying multicast group. | 917 | * Public key of the place to enter. |
833 | * @param method_name Method name for the message. | 918 | * @param flags |
834 | * @param env Environment containing variables for the message, or NULL. | 919 | * Flags for the entry. |
835 | * @param data Payload for the message to give to the enter callback. | 920 | * @param origin |
836 | * @param data_size Number of bytes in @a data. | 921 | * Peer identity of the origin of the underlying multicast group. |
837 | * @param slicer Slicer to use for processing incoming requests from guests. | 922 | * @param relay_count |
923 | * Number of elements in the @a relays array. | ||
924 | * @param relays | ||
925 | * Relays for the underlying multicast group. | ||
926 | * @param method_name | ||
927 | * Method name for the message. | ||
928 | * @param env | ||
929 | * Environment containing variables for the message, or NULL. | ||
930 | * @param data | ||
931 | * Payload for the message to give to the enter callback. | ||
932 | * @param data_size | ||
933 | * Number of bytes in @a data. | ||
934 | * @param slicer | ||
935 | * Slicer to use for processing incoming requests from guests. | ||
838 | * | 936 | * |
839 | * @return NULL on errors, otherwise handle for the guest. | 937 | * @return NULL on errors, otherwise handle for the guest. |
840 | */ | 938 | */ |
@@ -842,21 +940,22 @@ struct GNUNET_SOCIAL_Guest * | |||
842 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, | 940 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, |
843 | const struct GNUNET_SOCIAL_Ego *ego, | 941 | const struct GNUNET_SOCIAL_Ego *ego, |
844 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, | 942 | const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, |
943 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
845 | const struct GNUNET_PeerIdentity *origin, | 944 | const struct GNUNET_PeerIdentity *origin, |
846 | uint32_t relay_count, | 945 | uint32_t relay_count, |
847 | const struct GNUNET_PeerIdentity *relays, | 946 | const struct GNUNET_PeerIdentity *relays, |
848 | const struct GNUNET_PSYC_Message *entry_msg, | 947 | const struct GNUNET_PSYC_Message *entry_msg, |
849 | struct GNUNET_SOCIAL_Slicer *slicer, | 948 | struct GNUNET_SOCIAL_Slicer *slicer, |
850 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 949 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
851 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, | 950 | GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, |
852 | void *cls); | 951 | void *cls); |
853 | 952 | ||
854 | 953 | ||
855 | /** | 954 | /** |
856 | * Request entry to a place by name as a guest. | 955 | * Request entry to a place by name as a guest. |
857 | * | 956 | * |
858 | * @param cfg | 957 | * @param app |
859 | * Configuration to contact the social service. | 958 | * Application handle. |
860 | * @param ego | 959 | * @param ego |
861 | * Identity of the guest. | 960 | * Identity of the guest. |
862 | * @param gns_name | 961 | * @param gns_name |
@@ -896,6 +995,8 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
896 | * @param gconn | 995 | * @param gconn |
897 | * Guest connection handle. | 996 | * Guest connection handle. |
898 | * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback() | 997 | * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback() |
998 | * @param flags | ||
999 | * Flags for the entry. | ||
899 | * @param slicer | 1000 | * @param slicer |
900 | * Slicer to use for processing incoming requests from guests. | 1001 | * Slicer to use for processing incoming requests from guests. |
901 | * @param local_enter_cb | 1002 | * @param local_enter_cb |
@@ -907,6 +1008,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
907 | */ | 1008 | */ |
908 | struct GNUNET_SOCIAL_Guest * | 1009 | struct GNUNET_SOCIAL_Guest * |
909 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, | 1010 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, |
1011 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
910 | struct GNUNET_SOCIAL_Slicer *slicer, | 1012 | struct GNUNET_SOCIAL_Slicer *slicer, |
911 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 1013 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
912 | void *cls); | 1014 | void *cls); |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index e710b41a5..e9727c485 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -409,6 +409,11 @@ struct Slave | |||
409 | * Maximum request ID for this channel. | 409 | * Maximum request ID for this channel. |
410 | */ | 410 | */ |
411 | uint64_t max_request_id; | 411 | uint64_t max_request_id; |
412 | |||
413 | /** | ||
414 | * Join flags. | ||
415 | */ | ||
416 | enum GNUNET_PSYC_SlaveJoinFlags join_flags; | ||
412 | }; | 417 | }; |
413 | 418 | ||
414 | 419 | ||
@@ -812,7 +817,8 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
812 | 817 | ||
813 | client_send_msg (chn, &dcsn->header); | 818 | client_send_msg (chn, &dcsn->header); |
814 | 819 | ||
815 | if (GNUNET_YES == is_admitted) | 820 | if (GNUNET_YES == is_admitted |
821 | && ! (GNUNET_PSYC_SLAVE_JOIN_LOCAL & slv->join_flags)) | ||
816 | { | 822 | { |
817 | chn->is_ready = GNUNET_YES; | 823 | chn->is_ready = GNUNET_YES; |
818 | } | 824 | } |
@@ -1189,11 +1195,15 @@ fragment_queue_insert (struct Channel *chn, | |||
1189 | * Send fragments of a message in order to client, after all modifiers arrived | 1195 | * Send fragments of a message in order to client, after all modifiers arrived |
1190 | * from multicast. | 1196 | * from multicast. |
1191 | * | 1197 | * |
1192 | * @param chn Channel. | 1198 | * @param chn |
1193 | * @param msg_id ID of the message @a fragq belongs to. | 1199 | * Channel. |
1194 | * @param fragq Fragment queue of the message. | 1200 | * @param msg_id |
1195 | * @param drop Drop message without delivering to client? | 1201 | * ID of the message @a fragq belongs to. |
1196 | * #GNUNET_YES or #GNUNET_NO. | 1202 | * @param fragq |
1203 | * Fragment queue of the message. | ||
1204 | * @param drop | ||
1205 | * Drop message without delivering to client? | ||
1206 | * #GNUNET_YES or #GNUNET_NO. | ||
1197 | */ | 1207 | */ |
1198 | static void | 1208 | static void |
1199 | fragment_queue_run (struct Channel *chn, uint64_t msg_id, | 1209 | fragment_queue_run (struct Channel *chn, uint64_t msg_id, |
@@ -1739,7 +1749,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1739 | 1749 | ||
1740 | GNUNET_CRYPTO_ecdsa_key_get_public (&req->slave_key, &slv_pub_key); | 1750 | GNUNET_CRYPTO_ecdsa_key_get_public (&req->slave_key, &slv_pub_key); |
1741 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); | 1751 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); |
1742 | GNUNET_CRYPTO_hash (&req->channel_key, sizeof (req->channel_key), &pub_key_hash); | 1752 | GNUNET_CRYPTO_hash (&req->channel_pub_key, sizeof (req->channel_pub_key), &pub_key_hash); |
1743 | 1753 | ||
1744 | struct GNUNET_CONTAINER_MultiHashMap * | 1754 | struct GNUNET_CONTAINER_MultiHashMap * |
1745 | chn_slv = GNUNET_CONTAINER_multihashmap_get (channel_slaves, &pub_key_hash); | 1755 | chn_slv = GNUNET_CONTAINER_multihashmap_get (channel_slaves, &pub_key_hash); |
@@ -1758,6 +1768,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1758 | slv->pub_key_hash = slv_pub_key_hash; | 1768 | slv->pub_key_hash = slv_pub_key_hash; |
1759 | slv->origin = req->origin; | 1769 | slv->origin = req->origin; |
1760 | slv->relay_count = ntohl (req->relay_count); | 1770 | slv->relay_count = ntohl (req->relay_count); |
1771 | slv->join_flags = ntohl (req->flags); | ||
1761 | 1772 | ||
1762 | const struct GNUNET_PeerIdentity * | 1773 | const struct GNUNET_PeerIdentity * |
1763 | relays = (const struct GNUNET_PeerIdentity *) &req[1]; | 1774 | relays = (const struct GNUNET_PeerIdentity *) &req[1]; |
@@ -1791,7 +1802,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1791 | 1802 | ||
1792 | chn = &slv->chn; | 1803 | chn = &slv->chn; |
1793 | chn->is_master = GNUNET_NO; | 1804 | chn->is_master = GNUNET_NO; |
1794 | chn->pub_key = req->channel_key; | 1805 | chn->pub_key = req->channel_pub_key; |
1795 | chn->pub_key_hash = pub_key_hash; | 1806 | chn->pub_key_hash = pub_key_hash; |
1796 | channel_init (chn); | 1807 | channel_init (chn); |
1797 | 1808 | ||
@@ -1822,7 +1833,12 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1822 | GNUNET_SERVER_notification_context_unicast (nc, client, &res.header, | 1833 | GNUNET_SERVER_notification_context_unicast (nc, client, &res.header, |
1823 | GNUNET_NO); | 1834 | GNUNET_NO); |
1824 | 1835 | ||
1825 | if (NULL == slv->member) | 1836 | if (GNUNET_PSYC_SLAVE_JOIN_LOCAL & slv->join_flags) |
1837 | { | ||
1838 | mcast_recv_join_decision (slv, GNUNET_YES, | ||
1839 | NULL, 0, NULL, NULL); | ||
1840 | } | ||
1841 | else if (NULL == slv->member) | ||
1826 | { | 1842 | { |
1827 | slv->member | 1843 | slv->member |
1828 | = GNUNET_MULTICAST_member_join (cfg, &chn->pub_key, &slv->priv_key, | 1844 | = GNUNET_MULTICAST_member_join (cfg, &chn->pub_key, &slv->priv_key, |
diff --git a/src/psyc/psyc.h b/src/psyc/psyc.h index f89d170a5..cc7475df7 100644 --- a/src/psyc/psyc.h +++ b/src/psyc/psyc.h | |||
@@ -93,12 +93,14 @@ struct SlaveJoinRequest | |||
93 | 93 | ||
94 | uint32_t relay_count GNUNET_PACKED; | 94 | uint32_t relay_count GNUNET_PACKED; |
95 | 95 | ||
96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; | 96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; |
97 | 97 | ||
98 | struct GNUNET_CRYPTO_EcdsaPrivateKey slave_key; | 98 | struct GNUNET_CRYPTO_EcdsaPrivateKey slave_key; |
99 | 99 | ||
100 | struct GNUNET_PeerIdentity origin; | 100 | struct GNUNET_PeerIdentity origin; |
101 | 101 | ||
102 | uint32_t flags GNUNET_PACKED; | ||
103 | |||
102 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | 104 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ |
103 | 105 | ||
104 | /* Followed by struct GNUNET_MessageHeader join_msg */ | 106 | /* Followed by struct GNUNET_MessageHeader join_msg */ |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index 9392deeef..8152fc47f 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -847,7 +847,8 @@ GNUNET_PSYC_master_get_channel (struct GNUNET_PSYC_Master *master) | |||
847 | * notification on failure (as the channel may simply take days to approve, | 847 | * notification on failure (as the channel may simply take days to approve, |
848 | * and disapproval is simply being ignored). | 848 | * and disapproval is simply being ignored). |
849 | * | 849 | * |
850 | * @param cfg Configuration to use. | 850 | * @param cfg |
851 | * Configuration to use. | ||
851 | * @param channel_key ECC public key that identifies the channel we wish to join. | 852 | * @param channel_key ECC public key that identifies the channel we wish to join. |
852 | * @param slave_key ECC private-public key pair that identifies the slave, and | 853 | * @param slave_key ECC private-public key pair that identifies the slave, and |
853 | * used by multicast to sign the join request and subsequent unicast | 854 | * used by multicast to sign the join request and subsequent unicast |
@@ -873,8 +874,9 @@ GNUNET_PSYC_master_get_channel (struct GNUNET_PSYC_Master *master) | |||
873 | */ | 874 | */ |
874 | struct GNUNET_PSYC_Slave * | 875 | struct GNUNET_PSYC_Slave * |
875 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 876 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
876 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 877 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_pub_key, |
877 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, | 878 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
879 | enum GNUNET_PSYC_SlaveJoinFlags flags, | ||
878 | const struct GNUNET_PeerIdentity *origin, | 880 | const struct GNUNET_PeerIdentity *origin, |
879 | uint32_t relay_count, | 881 | uint32_t relay_count, |
880 | const struct GNUNET_PeerIdentity *relays, | 882 | const struct GNUNET_PeerIdentity *relays, |
@@ -898,10 +900,11 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
898 | req = GNUNET_malloc (sizeof (*req) + relay_size + join_msg_size); | 900 | req = GNUNET_malloc (sizeof (*req) + relay_size + join_msg_size); |
899 | req->header.size = htons (sizeof (*req) + relay_size + join_msg_size); | 901 | req->header.size = htons (sizeof (*req) + relay_size + join_msg_size); |
900 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN); | 902 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN); |
901 | req->channel_key = *channel_key; | 903 | req->channel_pub_key = *channel_pub_key; |
902 | req->slave_key = *slave_key; | 904 | req->slave_key = *slave_key; |
903 | req->origin = *origin; | 905 | req->origin = *origin; |
904 | req->relay_count = htonl (relay_count); | 906 | req->relay_count = htonl (relay_count); |
907 | req->flags = htonl (flags); | ||
905 | 908 | ||
906 | if (0 < relay_size) | 909 | if (0 < relay_size) |
907 | memcpy (&req[1], relays, relay_size); | 910 | memcpy (&req[1], relays, relay_size); |
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 1ce9074d5..f167e2697 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -843,7 +843,9 @@ slave_join (int t) | |||
843 | struct GNUNET_PSYC_Message * | 843 | struct GNUNET_PSYC_Message * |
844 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); | 844 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); |
845 | 845 | ||
846 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, &origin, 0, NULL, | 846 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, |
847 | GNUNET_PSYC_SLAVE_JOIN_NONE, | ||
848 | &origin, 0, NULL, | ||
847 | &slave_message_cb, &slave_message_part_cb, | 849 | &slave_message_cb, &slave_message_part_cb, |
848 | &slave_connect_cb, &join_decision_cb, NULL, | 850 | &slave_connect_cb, &join_decision_cb, NULL, |
849 | join_msg); | 851 | join_msg); |
diff --git a/src/psycstore/psyc_util_lib.c b/src/psycstore/psyc_util_lib.c index 9e6b1b770..e87d6106d 100644 --- a/src/psycstore/psyc_util_lib.c +++ b/src/psycstore/psyc_util_lib.c | |||
@@ -1264,12 +1264,15 @@ GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_MessageHeader *msg, | |||
1264 | 1264 | ||
1265 | struct GNUNET_PSYC_ReceiveHandle * | 1265 | struct GNUNET_PSYC_ReceiveHandle * |
1266 | recv = GNUNET_PSYC_receive_create (NULL, parse_message_part_cb, &cls); | 1266 | recv = GNUNET_PSYC_receive_create (NULL, parse_message_part_cb, &cls); |
1267 | GNUNET_PSYC_receive_message (recv, msg); | 1267 | int ret = GNUNET_PSYC_receive_message (recv, msg); |
1268 | GNUNET_PSYC_receive_destroy (recv); | 1268 | GNUNET_PSYC_receive_destroy (recv); |
1269 | 1269 | ||
1270 | if (GNUNET_OK != ret) | ||
1271 | return GNUNET_SYSERR; | ||
1272 | |||
1270 | return (GNUNET_PSYC_MESSAGE_STATE_END == cls.msg_state) | 1273 | return (GNUNET_PSYC_MESSAGE_STATE_END == cls.msg_state) |
1271 | ? GNUNET_OK | 1274 | ? GNUNET_OK |
1272 | : GNUNET_SYSERR; | 1275 | : GNUNET_NO; |
1273 | } | 1276 | } |
1274 | 1277 | ||
1275 | 1278 | ||
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); |