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/psyc | |
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/psyc')
-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 |
4 files changed, 37 insertions, 14 deletions
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); |