aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-20 01:08:40 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-20 01:08:40 +0000
commit594640d015f63d56bfc6ce2613e7c1d026860378 (patch)
treece6a6524963b2edc3eb121651e8725599644e37f
parent96be70d5f2d5e4e0fe43d60b4addcfdf6e7b18e9 (diff)
downloadgnunet-594640d015f63d56bfc6ce2613e7c1d026860378.tar.gz
gnunet-594640d015f63d56bfc6ce2613e7c1d026860378.zip
-do not modify 'const' argument
-rw-r--r--src/multicast/gnunet-service-multicast.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c
index f4e37865f..faa754976 100644
--- a/src/multicast/gnunet-service-multicast.c
+++ b/src/multicast/gnunet-service-multicast.c
@@ -943,8 +943,7 @@ client_recv_multicast_message (void *cls, struct GNUNET_SERVER_Client *client,
943{ 943{
944 struct Group * 944 struct Group *
945 grp = GNUNET_SERVER_client_get_user_context (client, struct Group); 945 grp = GNUNET_SERVER_client_get_user_context (client, struct Group);
946 const struct GNUNET_MULTICAST_MessageHeader * 946 struct GNUNET_MULTICAST_MessageHeader *out;
947 msg = (const struct GNUNET_MULTICAST_MessageHeader *) m;
948 struct Origin *orig; 947 struct Origin *orig;
949 948
950 if (NULL == grp) 949 if (NULL == grp)
@@ -955,22 +954,25 @@ client_recv_multicast_message (void *cls, struct GNUNET_SERVER_Client *client,
955 } 954 }
956 GNUNET_assert (GNUNET_YES == grp->is_origin); 955 GNUNET_assert (GNUNET_YES == grp->is_origin);
957 orig = (struct Origin *) grp; 956 orig = (struct Origin *) grp;
958 957 /* FIXME: yucky, should use separate message structs for P2P and CS! */
959 msg->fragment_id = GNUNET_htonll (++orig->max_fragment_id); 958 out = (struct GNUNET_MULTICAST_MessageHeader *) GNUNET_copy_message (m);
960 msg->purpose.size = htonl (ntohs (msg->header.size) 959
961 - sizeof (msg->header) 960 out->fragment_id = GNUNET_htonll (++orig->max_fragment_id);
962 - sizeof (msg->hop_counter) 961 out->purpose.size = htonl (ntohs (out->header.size)
963 - sizeof (msg->signature)); 962 - sizeof (out->header)
964 msg->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE); 963 - sizeof (out->hop_counter)
965 964 - sizeof (out->signature));
966 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&orig->priv_key, &msg->purpose, 965 out->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE);
967 &msg->signature)) 966
967 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&orig->priv_key, &out->purpose,
968 &out->signature))
968 { 969 {
969 GNUNET_assert (0); 970 GNUNET_assert (0);
970 } 971 }
971 972
972 client_send_all (&grp->pub_key_hash, m); 973 client_send_all (&grp->pub_key_hash, &out->header);
973 cadet_send_members (&grp->pub_key_hash, m); 974 cadet_send_members (&grp->pub_key_hash, &out->header);
975 GNUNET_free (out);
974 976
975 GNUNET_SERVER_receive_done (client, GNUNET_OK); 977 GNUNET_SERVER_receive_done (client, GNUNET_OK);
976} 978}
@@ -985,8 +987,7 @@ client_recv_multicast_request (void *cls, struct GNUNET_SERVER_Client *client,
985{ 987{
986 struct Group *grp = GNUNET_SERVER_client_get_user_context (client, struct Group); 988 struct Group *grp = GNUNET_SERVER_client_get_user_context (client, struct Group);
987 struct Member *mem; 989 struct Member *mem;
988 const struct GNUNET_MULTICAST_RequestHeader * 990 struct GNUNET_MULTICAST_RequestHeader *out;
989 req = (const struct GNUNET_MULTICAST_RequestHeader *) m;
990 991
991 if (NULL == grp) 992 if (NULL == grp)
992 { 993 {
@@ -996,33 +997,37 @@ client_recv_multicast_request (void *cls, struct GNUNET_SERVER_Client *client,
996 } 997 }
997 GNUNET_assert (GNUNET_NO == grp->is_origin); 998 GNUNET_assert (GNUNET_NO == grp->is_origin);
998 mem = (struct Member *) grp; 999 mem = (struct Member *) grp;
999 1000 /* FIXME: yucky, should use separate message structs for P2P and CS! */
1000 req->fragment_id = GNUNET_ntohll (++mem->max_fragment_id); 1001 out = (struct GNUNET_MULTICAST_RequestHeader *) GNUNET_copy_message (m);
1001 req->purpose.size = htonl (ntohs (req->header.size) 1002
1002 - sizeof (req->header) 1003 out->fragment_id = GNUNET_ntohll (++mem->max_fragment_id);
1003 - sizeof (req->member_key) 1004 out->purpose.size = htonl (ntohs (out->header.size)
1004 - sizeof (req->signature)); 1005 - sizeof (out->header)
1005 req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); 1006 - sizeof (out->member_key)
1006 1007 - sizeof (out->signature));
1007 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose, 1008 out->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST);
1008 &req->signature)) 1009
1010 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &out->purpose,
1011 &out->signature))
1009 { 1012 {
1010 GNUNET_assert (0); 1013 GNUNET_assert (0);
1011 } 1014 }
1012 1015
1013 if (0 == client_send_origin (&grp->pub_key_hash, m)) 1016 if (0 == client_send_origin (&grp->pub_key_hash, &out->header))
1014 { /* No local origins, send to remote origin */ 1017 { /* No local origins, send to remote origin */
1015 if (NULL != mem->origin_channel) 1018 if (NULL != mem->origin_channel)
1016 { 1019 {
1017 cadet_send_msg (mem->origin_channel, m); 1020 cadet_send_msg (mem->origin_channel, &out->header);
1018 } 1021 }
1019 else 1022 else
1020 { 1023 {
1021 /* FIXME: not yet connected to origin */ 1024 /* FIXME: not yet connected to origin */
1022 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1025 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1026 GNUNET_free (out);
1023 return; 1027 return;
1024 } 1028 }
1025 } 1029 }
1030 GNUNET_free (out);
1026 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1031 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1027} 1032}
1028 1033