aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-08-17 23:21:47 +0000
committerGabor X Toth <*@tg-x.net>2016-08-17 23:21:47 +0000
commit94a717fab18ed25e6bec4b349526212045f6ca70 (patch)
treec441a241d009a141bf63212afd6630aaa042af40 /src
parentd226c5f08990628851ac0b61894727e3817f8ad7 (diff)
downloadgnunet-94a717fab18ed25e6bec4b349526212045f6ca70.tar.gz
gnunet-94a717fab18ed25e6bec4b349526212045f6ca70.zip
multicast: use CADET port hash derived from group key
Diffstat (limited to 'src')
-rw-r--r--src/multicast/gnunet-service-multicast.c113
1 files changed, 68 insertions, 45 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c
index 7aeda1421..780e8ceee 100644
--- a/src/multicast/gnunet-service-multicast.c
+++ b/src/multicast/gnunet-service-multicast.c
@@ -222,6 +222,11 @@ struct Group
222 struct GNUNET_HashCode pub_key_hash; 222 struct GNUNET_HashCode pub_key_hash;
223 223
224 /** 224 /**
225 * CADET port hash.
226 */
227 struct GNUNET_HashCode cadet_port_hash;
228
229 /**
225 * Is this an origin (#GNUNET_YES), or member (#GNUNET_NO)? 230 * Is this an origin (#GNUNET_YES), or member (#GNUNET_NO)?
226 */ 231 */
227 uint8_t is_origin; 232 uint8_t is_origin;
@@ -789,7 +794,7 @@ cadet_channel_create (struct Group *grp, struct GNUNET_PeerIdentity *peer)
789 chn->direction = DIR_OUTGOING; 794 chn->direction = DIR_OUTGOING;
790 chn->join_status = JOIN_WAITING; 795 chn->join_status = JOIN_WAITING;
791 chn->channel = GNUNET_CADET_channel_create (cadet, chn, &chn->peer, 796 chn->channel = GNUNET_CADET_channel_create (cadet, chn, &chn->peer,
792 GC_u2h (GNUNET_APPLICATION_TYPE_MULTICAST), 797 &grp->cadet_port_hash,
793 GNUNET_CADET_OPTION_RELIABLE); 798 GNUNET_CADET_OPTION_RELIABLE);
794 GNUNET_CONTAINER_multihashmap_put (channels_out, &chn->group_pub_hash, chn, 799 GNUNET_CONTAINER_multihashmap_put (channels_out, &chn->group_pub_hash, chn,
795 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 800 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -895,6 +900,63 @@ cadet_send_parents (struct GNUNET_HashCode *pub_key_hash,
895 900
896 901
897/** 902/**
903 * New incoming CADET channel.
904 */
905static void *
906cadet_notify_channel_new (void *cls,
907 struct GNUNET_CADET_Channel *channel,
908 const struct GNUNET_PeerIdentity *initiator,
909 const struct GNUNET_HashCode *port,
910 enum GNUNET_CADET_ChannelOption options)
911{
912 return NULL;
913}
914
915
916/**
917 * CADET channel is being destroyed.
918 */
919static void
920cadet_notify_channel_end (void *cls,
921 const struct GNUNET_CADET_Channel *channel,
922 void *ctx)
923{
924 if (NULL == ctx)
925 return;
926
927 struct Channel *chn = ctx;
928 if (NULL != chn->grp)
929 {
930 if (GNUNET_NO == chn->grp->is_origin)
931 {
932 struct Member *mem = (struct Member *) chn->grp;
933 if (chn == mem->origin_channel)
934 mem->origin_channel = NULL;
935 }
936 }
937
938 while (GNUNET_YES == replay_req_remove_cadet (chn));
939
940 GNUNET_free (chn);
941}
942
943
944static void
945group_set_cadet_port_hash (struct Group *grp)
946{
947 struct CadetPort {
948 struct GNUNET_CRYPTO_EddsaPublicKey pub_key;
949 uint32_t app_type;
950 } port = {
951 grp->pub_key,
952 GNUNET_APPLICATION_TYPE_MULTICAST,
953 };
954
955 GNUNET_CRYPTO_hash (&port, sizeof (port), &grp->cadet_port_hash);
956}
957
958
959/**
898 * Handle a connecting client starting an origin. 960 * Handle a connecting client starting an origin.
899 */ 961 */
900static void 962static void
@@ -926,6 +988,10 @@ client_recv_origin_start (void *cls, struct GNUNET_SERVER_Client *client,
926 988
927 GNUNET_CONTAINER_multihashmap_put (origins, &grp->pub_key_hash, orig, 989 GNUNET_CONTAINER_multihashmap_put (origins, &grp->pub_key_hash, orig,
928 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 990 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
991 group_set_cadet_port_hash (grp);
992 GNUNET_CADET_open_port (cadet, &grp->cadet_port_hash,
993 cadet_notify_channel_new, NULL);
994
929 } 995 }
930 else 996 else
931 { 997 {
@@ -984,6 +1050,7 @@ client_recv_member_join (void *cls, struct GNUNET_SERVER_Client *client,
984 grp->is_origin = GNUNET_NO; 1050 grp->is_origin = GNUNET_NO;
985 grp->pub_key = msg->group_pub_key; 1051 grp->pub_key = msg->group_pub_key;
986 grp->pub_key_hash = pub_key_hash; 1052 grp->pub_key_hash = pub_key_hash;
1053 group_set_cadet_port_hash (grp);
987 1054
988 if (NULL == grp_mem) 1055 if (NULL == grp_mem)
989 { 1056 {
@@ -1480,48 +1547,6 @@ static const struct GNUNET_SERVER_MessageHandler server_handlers[] = {
1480 1547
1481 1548
1482/** 1549/**
1483 * New incoming CADET channel.
1484 */
1485static void *
1486cadet_notify_channel_new (void *cls,
1487 struct GNUNET_CADET_Channel *channel,
1488 const struct GNUNET_PeerIdentity *initiator,
1489 const struct GNUNET_HashCode *port,
1490 enum GNUNET_CADET_ChannelOption options)
1491{
1492 return NULL;
1493}
1494
1495
1496/**
1497 * CADET channel is being destroyed.
1498 */
1499static void
1500cadet_notify_channel_end (void *cls,
1501 const struct GNUNET_CADET_Channel *channel,
1502 void *ctx)
1503{
1504 if (NULL == ctx)
1505 return;
1506
1507 struct Channel *chn = ctx;
1508 if (NULL != chn->grp)
1509 {
1510 if (GNUNET_NO == chn->grp->is_origin)
1511 {
1512 struct Member *mem = (struct Member *) chn->grp;
1513 if (chn == mem->origin_channel)
1514 mem->origin_channel = NULL;
1515 }
1516 }
1517
1518 while (GNUNET_YES == replay_req_remove_cadet (chn));
1519
1520 GNUNET_free (chn);
1521}
1522
1523
1524/**
1525 * Incoming join request message from CADET. 1550 * Incoming join request message from CADET.
1526 */ 1551 */
1527int 1552int
@@ -1832,8 +1857,6 @@ core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity)
1832 &cadet_notify_channel_end, 1857 &cadet_notify_channel_end,
1833 cadet_handlers); 1858 cadet_handlers);
1834 GNUNET_assert (NULL != cadet); 1859 GNUNET_assert (NULL != cadet);
1835 GNUNET_CADET_open_port (cadet, GC_u2h (GNUNET_APPLICATION_TYPE_MULTICAST),
1836 &cadet_notify_channel_new, NULL);
1837 1860
1838 nc = GNUNET_SERVER_notification_context_create (server, 1); 1861 nc = GNUNET_SERVER_notification_context_create (server, 1);
1839 GNUNET_SERVER_add_handlers (server, server_handlers); 1862 GNUNET_SERVER_add_handlers (server, server_handlers);