From b11588dadd5e7412d48f7fd05eac9f225dad1405 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 5 Dec 2013 01:38:16 +0000 Subject: [PATCH] - improve dealing with duplicate channel create (in case of replay attack / missed channel ACK) --- src/mesh/gnunet-service-mesh_channel.c | 55 +++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index ed3ebdd07..a708ef039 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -1997,41 +1997,42 @@ GMCH_handle_create (struct MeshTunnel3 *t, /* Create channel */ ch = channel_new (t, NULL, 0); ch->gid = chid; - } - channel_set_options (ch, ntohl (msg->opt)); + channel_set_options (ch, ntohl (msg->opt)); - /* Find a destination client */ - ch->port = ntohl (msg->port); - LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); - c = GML_client_get_by_port (ch->port); - if (NULL == c) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n"); - if (is_loopback (ch)) + /* Find a destination client */ + ch->port = ntohl (msg->port); + LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); + c = GML_client_get_by_port (ch->port); + if (NULL == c) { - LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback: destroy on handler\n"); - send_nack (ch); + LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n"); + if (is_loopback (ch)) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback: destroy on handler\n"); + send_nack (ch); + } + else + { + LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n"); + send_nack (ch); + GMCH_destroy (ch); + } + return NULL; } else { - LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n"); - send_nack (ch); - GMCH_destroy (ch); + LOG (GNUNET_ERROR_TYPE_DEBUG, " client %p has port registered\n", c); } - return NULL; - } - else - { - LOG (GNUNET_ERROR_TYPE_DEBUG, " client %p has port registered\n", c); - } - add_destination (ch, c); - if (GNUNET_YES == ch->reliable) - LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); - else - LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Not Reliable\n"); + add_destination (ch, c); + if (GNUNET_YES == ch->reliable) + LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); + else + LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Not Reliable\n"); + + send_client_create (ch); + } - send_client_create (ch); send_ack (ch, GNUNET_YES); return ch; -- 2.25.1