From ef3a1ee88ce00bde339214774813f01464fd0b77 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 10 Aug 2016 18:04:52 +0000 Subject: [PATCH] - missing implementation --- src/cadet/gnunet-service-cadet_local.c | 31 +++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c index c6e2fe30d..4213ad278 100644 --- a/src/cadet/gnunet-service-cadet_local.c +++ b/src/cadet/gnunet-service-cadet_local.c @@ -379,7 +379,36 @@ static void handle_port_close (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { - // FIXME + struct CadetClient *c; + struct GNUNET_CADET_PortMessage *pmsg; + int removed; + + LOG (GNUNET_ERROR_TYPE_DEBUG, "close port requested\n"); + + /* Sanity check for client registration */ + if (NULL == (c = GML_client_get (client))) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + LOG (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); + + /* Message size sanity check */ + if (sizeof (struct GNUNET_CADET_PortMessage) != ntohs (message->size)) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + + pmsg = (struct GNUNET_CADET_PortMessage *) message; + removed = GNUNET_CONTAINER_multihashmap_remove (c->ports, &pmsg->port, c); + GNUNET_break_op (GNUNET_YES == removed); + removed = GNUNET_CONTAINER_multihashmap_remove (ports, &pmsg->port, c); + GNUNET_break_op (GNUNET_YES == removed); + + GNUNET_SERVER_receive_done (client, GNUNET_OK); } -- 2.25.1