aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-10 18:23:48 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-10 18:23:48 +0000
commit990ca23b4da56d67f093d0ad967731998d9851fb (patch)
tree745f206b33c9566964259192d63185141c415b81 /src/mesh/gnunet-service-mesh_local.c
parent0b2836dbc4f3da21c9321caefbaa229500c75adf (diff)
downloadgnunet-990ca23b4da56d67f093d0ad967731998d9851fb.tar.gz
gnunet-990ca23b4da56d67f093d0ad967731998d9851fb.zip
- fixes in local
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r--src/mesh/gnunet-service-mesh_local.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index a1ff2b12c..2d6214d3e 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -913,10 +913,10 @@ GML_channel_remove (struct MeshClient *client,
913 uint32_t chid, 913 uint32_t chid,
914 struct MeshChannel *ch) 914 struct MeshChannel *ch)
915{ 915{
916 if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) 916 if (GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= chid)
917 GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, chid, ch); 917 GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels, chid, ch);
918 else if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_CLI) 918 else if (GNUNET_MESH_LOCAL_CHANNEL_ID_CLI <= chid)
919 GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, chid, ch); 919 GNUNET_CONTAINER_multihashmap32_remove (client->own_channels, chid, ch);
920 else 920 else
921 GNUNET_break (0); 921 GNUNET_break (0);
922} 922}
@@ -978,25 +978,32 @@ GML_client_get_by_port (uint32_t port)
978 * 978 *
979 * @param c Client whose tunnel to delete. 979 * @param c Client whose tunnel to delete.
980 * @param ch Channel which should be deleted. 980 * @param ch Channel which should be deleted.
981 * @param id Channel ID.
981 */ 982 */
982void 983void
983GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch) 984GML_client_delete_channel (struct MeshClient *c,
985 struct MeshChannel *ch,
986 MESH_ChannelNumber id)
984{ 987{
985 int res; 988 int res;
986 989
987 if (c == ch->root) 990 if (GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= id)
988 { 991 {
989 res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, 992 res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels,
990 ch->lid_root, ch); 993 id, ch);
991 if (GNUNET_YES != res) 994 if (GNUNET_YES != res)
992 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel owner KO\n"); 995 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel dest KO\n");
993 } 996 }
994 if (c == ch->dest) 997 else if (GNUNET_MESH_LOCAL_CHANNEL_ID_CLI <= id)
995 { 998 {
996 res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, 999 res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels,
997 ch->lid_dest, ch); 1000 id, ch);
998 if (GNUNET_YES != res) 1001 if (GNUNET_YES != res)
999 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel client KO\n"); 1002 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel root KO\n");
1003 }
1004 else
1005 {
1006 GNUNET_break (0);
1000 } 1007 }
1001} 1008}
1002 1009
@@ -1005,39 +1012,21 @@ GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch)
1005 * 1012 *
1006 * If the client was already allowed to send data, do nothing. 1013 * If the client was already allowed to send data, do nothing.
1007 * 1014 *
1008 * @param ch Channel on which to send the ACK.
1009 * @param c Client to whom send the ACK. 1015 * @param c Client to whom send the ACK.
1010 * @param fwd Set to GNUNET_YES for FWD ACK (dest->root) 1016 * @param id Channel ID to use
1011 */ 1017 */
1012void 1018void
1013GML_send_ack (struct MeshChannel *ch, int fwd) 1019GML_send_ack (struct MeshClient *c, MESH_ChannelNumber id)
1014{ 1020{
1015 struct GNUNET_MESH_LocalAck msg; 1021 struct GNUNET_MESH_LocalAck msg;
1016 struct MeshChannelReliability *rel;
1017 struct MeshClient *c;
1018
1019 c = fwd ? ch->root : ch->dest;
1020 rel = fwd ? ch->root_rel : ch->dest_rel;
1021
1022 if (GNUNET_YES == rel->client_ready)
1023 return; /* don't send double ACKs to client */
1024
1025 rel->client_ready = GNUNET_YES;
1026 1022
1027 LOG (GNUNET_ERROR_TYPE_DEBUG, 1023 LOG (GNUNET_ERROR_TYPE_DEBUG,
1028 "send local %s ack on %s:%X towards %p\n", 1024 "send local %s ack on %X towards %p\n",
1029 fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid, c); 1025 id < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV ? "FWD" : "BCK", id, c);
1030 1026
1031 if (NULL == c
1032 || ( fwd && (0 == ch->lid_root || c != ch->root))
1033 || (!fwd && (0 == ch->lid_dest || c != ch->dest)) )
1034 {
1035 GNUNET_break (0);
1036 return;
1037 }
1038 msg.header.size = htons (sizeof (msg)); 1027 msg.header.size = htons (sizeof (msg));
1039 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK); 1028 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK);
1040 msg.channel_id = htonl (fwd ? ch->lid_root : ch->lid_dest); 1029 msg.channel_id = htonl (id);
1041 GNUNET_SERVER_notification_context_unicast (nc, 1030 GNUNET_SERVER_notification_context_unicast (nc,
1042 c->handle, 1031 c->handle,
1043 &msg.header, 1032 &msg.header,