*/
struct CadetClient
{
- /**
- * Linked list next
- */
+ /**
+ * Linked list next
+ */
struct CadetClient *next;
- /**
- * Linked list prev
- */
+ /**
+ * Linked list prev
+ */
struct CadetClient *prev;
- /**
- * Tunnels that belong to this client, indexed by local id
- */
+ /**
+ * Tunnels that belong to this client, indexed by local id
+ */
struct GNUNET_CONTAINER_MultiHashMap32 *own_channels;
-
- /**
- * Tunnels this client has accepted, indexed by incoming local id
- */
+
+ /**
+ * Tunnels this client has accepted, indexed by incoming local id
+ */
struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels;
- /**
- * Channel ID for the next incoming channel.
- */
+ /**
+ * Channel ID for the next incoming channel.
+ */
CADET_ChannelNumber next_chid;
- /**
- * Handle to communicate with the client
- */
+ /**
+ * Handle to communicate with the client
+ */
struct GNUNET_SERVER_Client *handle;
- /**
- * Ports that this client has declared interest in.
- * Indexed by port, contains *Client.
- */
+ /**
+ * Ports that this client has declared interest in.
+ * Indexed by port, contains *Client.
+ */
struct GNUNET_CONTAINER_MultiHashMap *ports;
- /**
- * Whether the client is active or shutting down (don't send confirmations
- * to a client that is shutting down.
- */
+ /**
+ * Whether the client is active or shutting down (don't send confirmations
+ * to a client that is shutting down.
+ */
int shutting_down;
- /**
- * ID of the client, mainly for debug messages
- */
+ /**
+ * ID of the client, mainly for debug messages
+ */
unsigned int id;
};
* @param key Port.
* @param value Client structure.
*
- * @return GNUNET_OK, keep iterating.
+ * @return #GNUNET_OK, keep iterating.
*/
static int
client_release_ports (void *cls,
* @param key The local channel id (used to access the hashmap).
* @param value The value stored at the key (channel to destroy).
*
- * @return GNUNET_OK, keep iterating.
+ * @return #GNUNET_OK, keep iterating.
*/
static int
channel_destroy_iterator (void *cls,
GNUNET_free (c);
}
+
/**
* Create a client record, register data and initialize memory.
*
handle_port_close (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
+ 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);
}
struct CadetPeer *p = value;
struct CadetTunnel *t;
- GCP_debug (p, GNUNET_ERROR_TYPE_ERROR);
-
t = GCP_get_tunnel (p);
if (NULL != t)
GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);