/**
* ID of a channel controlled by this client.
*/
- struct GNUNET_CADET_ClientChannelNumber channel_id;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
/**
* Channel's peer
/**
* ID of a channel controlled by this client.
*/
- struct GNUNET_CADET_ClientChannelNumber channel_id;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
};
/**
* ID of the channel
*/
- struct GNUNET_CADET_ClientChannelNumber channel_id;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
/**
* Payload follows
/**
* ID of the channel allowed to send more data.
*/
- struct GNUNET_CADET_ClientChannelNumber channel_id;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
};
/**
* Message to inform the client about channels in the service.
+ *
+ * TODO: split into two messages!
*/
struct GNUNET_CADET_LocalInfo
{
/**
* ID of the channel allowed to send more data.
*/
- struct GNUNET_CADET_ClientChannelNumber channel_id;
-
- /**
- * ID of the owner of the channel (can be local peer).
- */
-// struct GNUNET_PeerIdentity owner;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
/**
* ID of the destination of the channel (can be local peer).
/**
* Message to inform the client about one of the peers in the service.
+ *
+ * TODO: split into two messages!
*/
struct GNUNET_CADET_LocalInfoPeer
{
/**
* Message to inform the client about one of the tunnels in the service.
+ *
+ * TODO: split into two messages!
*/
struct GNUNET_CADET_LocalInfoTunnel
{
/**
* child of the next channel to create (to avoid reusing IDs often)
*/
- struct GNUNET_CADET_ClientChannelNumber next_chid;
+ struct GNUNET_CADET_ClientChannelNumber next_ccn;
/**
* Configuration given by the client, in case of reconnection
/**
* Local ID of the channel
*/
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
/**
* Channel's port, if any.
* Get the channel handler for the channel specified by id from the given handle
*
* @param h Cadet handle
- * @param chid ID of the wanted channel
+ * @param ccn ID of the wanted channel
* @return handle to the required channel or NULL if not found
*/
static struct GNUNET_CADET_Channel *
retrieve_channel (struct GNUNET_CADET_Handle *h,
- struct GNUNET_CADET_ClientChannelNumber chid)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_Channel *ch;
for (ch = h->channels_head; NULL != ch; ch = ch->next)
- if (ch->chid.channel_of_client == chid.channel_of_client)
+ if (ch->ccn.channel_of_client == ccn.channel_of_client)
return ch;
return NULL;
}
* Create a new channel and insert it in the channel list of the cadet handle
*
* @param h Cadet handle
- * @param chid Desired chid of the channel, 0 to assign one automatically.
+ * @param ccn Desired ccn of the channel, 0 to assign one automatically.
*
* @return Handle to the created channel.
*/
static struct GNUNET_CADET_Channel *
create_channel (struct GNUNET_CADET_Handle *h,
- struct GNUNET_CADET_ClientChannelNumber chid)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_Channel *ch;
h->channels_tail,
ch);
ch->cadet = h;
- if (0 == chid.channel_of_client)
+ if (0 == ccn.channel_of_client)
{
- ch->chid = h->next_chid;
+ ch->ccn = h->next_ccn;
while (NULL != retrieve_channel (h,
- h->next_chid))
+ h->next_ccn))
{
- h->next_chid.channel_of_client
- = htonl (1 + ntohl (h->next_chid.channel_of_client));
- if (0 == ntohl (h->next_chid.channel_of_client))
- h->next_chid.channel_of_client
+ h->next_ccn.channel_of_client
+ = htonl (1 + ntohl (h->next_ccn.channel_of_client));
+ if (0 == ntohl (h->next_ccn.channel_of_client))
+ h->next_ccn.channel_of_client
= htonl (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
}
}
else
{
- ch->chid = chid;
+ ch->ccn = ccn;
}
ch->allow_send = GNUNET_NO;
return ch;
struct GNUNET_CADET_TransmitHandle *th;
struct GNUNET_CADET_TransmitHandle *next;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " destroy_channel %X\n", ch->chid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " destroy_channel %X\n", ch->ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending ACK on channel %X\n",
- ch->chid.channel_of_client);
- msg->channel_id = ch->chid;
+ ch->ccn.channel_of_client);
+ msg->ccn = ch->ccn;
GNUNET_MQ_send (ch->cadet->mq,
env);
}
env = GNUNET_MQ_msg_extra (msg,
th->size,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
- msg->channel_id = th->channel->chid;
+ msg->ccn = th->channel->ccn;
osize = th->notify (th->notify_cls,
th->size,
&msg[1]);
struct GNUNET_CADET_Channel *ch;
struct GNUNET_CADET_Port *port;
const struct GNUNET_HashCode *port_number;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
- chid = msg->channel_id;
+ ccn = msg->ccn;
port_number = &msg->port;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Creating incoming channel %X [%s]\n",
- ntohl (chid.channel_of_client),
+ ntohl (ccn.channel_of_client),
GNUNET_h2s (port_number));
- if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
{
GNUNET_break (0);
return;
{
void *ctx;
- ch = create_channel (h, chid);
+ ch = create_channel (h, ccn);
ch->allow_send = GNUNET_NO;
ch->peer = GNUNET_PEER_intern (&msg->peer);
ch->cadet = h;
- ch->chid = chid;
+ ch->ccn = ccn;
ch->port = port;
ch->options = ntohl (msg->opt);
LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming channels\n");
env = GNUNET_MQ_msg (d_msg,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
- d_msg->channel_id = msg->channel_id;
+ d_msg->ccn = msg->ccn;
GNUNET_MQ_send (h->mq, env);
}
return;
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Channel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
- chid = msg->channel_id;
+ ccn = msg->ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Channel %X Destroy from service\n",
- ntohl (chid.channel_of_client));
+ ntohl (ccn.channel_of_client));
ch = retrieve_channel (h,
- chid);
+ ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"channel %X unknown\n",
- ntohl (chid.channel_of_client));
+ ntohl (ccn.channel_of_client));
return;
}
destroy_channel (ch,
}
ch = retrieve_channel (h,
- message->channel_id);
+ message->ccn);
if (NULL == ch)
{
GNUNET_break_op (0);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got a data message!\n");
- ch = retrieve_channel (h, message->channel_id);
+ ch = retrieve_channel (h,
+ message->ccn);
GNUNET_assert (NULL != ch);
payload = (struct GNUNET_MessageHeader *) &message[1];
LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n",
- GC_f2s (ntohl (ch->chid.channel_of_client) >=
+ GC_f2s (ntohl (ch->ccn.channel_of_client) >=
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI),
GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)),
- ntohl (message->channel_id.channel_of_client));
+ ntohl (message->ccn.channel_of_client));
type = ntohs (payload->type);
LOG (GNUNET_ERROR_TYPE_DEBUG, " payload type %s\n", GC_m2s (type));
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Channel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK!\n");
- chid = message->channel_id;
- ch = retrieve_channel (h, chid);
+ ccn = message->ccn;
+ ch = retrieve_channel (h, ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"ACK on unknown channel %X\n",
- ntohl (chid.channel_of_client));
+ ntohl (ccn.channel_of_client));
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
" on channel %X!\n",
- ntohl (ch->chid.channel_of_client));
+ ntohl (ch->ccn.channel_of_client));
ch->allow_send = GNUNET_YES;
if (0 < ch->packet_size)
{
}
h->cls = cls;
h->message_handlers = handlers;
- h->next_chid.channel_of_client = htonl (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
+ h->next_ccn.channel_of_client = htonl (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS;
h->reconnect_task = NULL;
while (NULL != ch)
{
aux = ch->next;
- if (ntohl (ch->chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (ch->ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
{
GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"channel %X not destroyed\n",
- ntohl (ch->chid.channel_of_client));
+ ntohl (ch->ccn.channel_of_client));
}
destroy_channel (ch,
GNUNET_YES);
* @param peer peer identity the channel should go to
* @param port Port hash (port number).
* @param options CadetOption flag field, with all desired option bits set to 1.
- *
* @return handle to the channel
*/
struct GNUNET_CADET_Channel *
struct GNUNET_CADET_LocalChannelCreateMessage *msg;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_CADET_Channel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Creating new channel to %s:%u\n",
GNUNET_i2s (peer), port);
- chid.channel_of_client = htonl (0);
- ch = create_channel (h, chid);
+ ccn.channel_of_client = htonl (0);
+ ch = create_channel (h, ccn);
LOG (GNUNET_ERROR_TYPE_DEBUG, " at %p\n", ch);
LOG (GNUNET_ERROR_TYPE_DEBUG, " number %X\n",
- ntohl (ch->chid.channel_of_client));
+ ntohl (ch->ccn.channel_of_client));
ch->ctx = channel_ctx;
ch->peer = GNUNET_PEER_intern (peer);
env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
- msg->channel_id = ch->chid;
+ msg->ccn = ch->ccn;
msg->port = *port;
msg->peer = *peer;
msg->opt = htonl (options);
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
- msg->channel_id = channel->chid;
- GNUNET_MQ_send (h->mq, env);
+ msg->ccn = channel->ccn;
+ GNUNET_MQ_send (h->mq,
+ env);
destroy_channel (channel, GNUNET_YES);
}
GNUNET_assert (NULL != channel);
GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size);
LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY\n");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->chid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->ccn);
LOG (GNUNET_ERROR_TYPE_DEBUG, " allow_send %d\n", channel->allow_send);
- if (ntohl (channel->chid.channel_of_client) >=
+ if (ntohl (channel->ccn.channel_of_client) >=
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
LOG (GNUNET_ERROR_TYPE_DEBUG, " to origin\n");
else
env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL);
msg->peer = *initiator;
- msg->channel_id.channel_of_client = htonl (channel_number);
+ msg->ccn.channel_of_client = htonl (channel_number);
GNUNET_MQ_send (h->mq, env);
h->info_cb.channel_cb = callback;
/**
* ID of the channel within the tunnel.
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
};
/**
* ID of the channel
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
};
/**
* ID of the channel
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
/**
* Payload follows
/**
* ID of the channel
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
/**
* Bitfield of already-received newer messages
/**
* ID of the channel
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
/**
* Payload follows
/**
* ID of the channel
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
/**
* Bitfield of already-received messages past @e mid.
struct CadetClient *prev;
/**
- * Tunnels that belong to this client, indexed by local id
+ * Tunnels that belong to this client, indexed by local id,
+ * value is a `struct CadetChannel`.
*/
- struct GNUNET_CONTAINER_MultiHashMap32 *own_channels;
-
- /**
- * Tunnels this client has accepted, indexed by incoming local id
- */
- struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels;
-
- /**
- * Channel ID for the next incoming channel.
- */
- struct GNUNET_CADET_ClientChannelNumber next_chid;
+ struct GNUNET_CONTAINER_MultiHashMap32 *channels;
/**
* Handle to communicate with the 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).
+ * Channel ID to use for the next incoming channel for this client.
+ * Wraps around (in theory).
*/
- int shutting_down;
+ struct GNUNET_CADET_ClientChannelNumber next_ccn;
/**
- * ID of the client, mainly for debug messages
+ * ID of the client, mainly for debug messages. Purely internal to this file.
*/
unsigned int id;
};
struct GNUNET_TIME_Relative ratchet_time;
-
/**
* Send a message to a client.
*
{
static char buf[32];
- if (NULL == c)
- return "Client(NULL)";
GNUNET_snprintf (buf,
sizeof (buf),
"Client(%u)",
}
+/**
+ * Lookup channel of client @a c by @a ccn.
+ *
+ * @param c client to look in
+ * @param ccn channel ID to look up
+ * @return NULL if no such channel exists
+ */
+static struct CadetChannel *
+lookup_channel (struct CadetClient *c,
+ struct GNUNET_CADET_ClientChannelNumber ccn)
+{
+ return GNUNET_CONTAINER_multihashmap32_get (c->channels,
+ ntohl (ccn.channel_of_client));
+}
+
+
/**
* Obtain the next LID to use for incoming connections to
* the given client.
* @param c client handle
*/
static struct GNUNET_CADET_ClientChannelNumber
-client_get_next_lid (struct CadetClient *c)
+client_get_next_ccn (struct CadetClient *c)
{
- struct GNUNET_CADET_ClientChannelNumber ccn = c->next_chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn = c->next_ccn;
/* increment until we have a free one... */
while (NULL !=
- GNUNET_CONTAINER_multihashmap32_get (c->incoming_channels,
- ntohl (ccn.channel_of_client)))
+ lookup_channel (c,
+ ccn))
{
ccn.channel_of_client
= htonl (1 + (ntohl (ccn.channel_of_client)));
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
ccn.channel_of_client = htonl (0);
}
- c->next_chid.channel_of_client
+ c->next_ccn.channel_of_client
= htonl (1 + (ntohl (ccn.channel_of_client)));
return ccn;
}
/**
- * Bind incoming channel to this client, and notify client
- * about incoming connection.
+ * Bind incoming channel to this client, and notify client about
+ * incoming connection. Caller is responsible for notifying the other
+ * peer about our acceptance of the channel.
*
* @param c client to bind to
* @param ch channel to be bound
{
struct GNUNET_MQ_Envelope *env;
struct GNUNET_CADET_LocalChannelCreateMessage *msg;
- struct GNUNET_CADET_ClientChannelNumber lid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
- lid = client_get_next_lid (c);
+ ccn = client_get_next_ccn (c);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_put (c->incoming_channels,
- ntohl (lid.channel_of_client),
+ GNUNET_CONTAINER_multihashmap32_put (c->channels,
+ ntohl (ccn.channel_of_client),
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Accepting incoming channel %s from %s on open port %s (%u)\n",
+ GCCH_2s (ch),
+ GCP_2s (dest),
+ GNUNET_h2s (port),
+ ntohl (options));
/* notify local client about incoming connection! */
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
- msg->channel_id = lid;
+ msg->ccn = ccn;
msg->port = *port;
msg->opt = htonl (options);
msg->peer = *GCP_get_id (dest);
GSC_send_to_client (c,
env);
- return lid;
+ return ccn;
}
-/******************************************************************************/
-/************************ MAIN FUNCTIONS ****************************/
-/******************************************************************************/
-
/**
* Task run during shutdown.
*
shutdown_task (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "shutting down\n");
+ "Shutting down\n");
shutting_down = GNUNET_YES;
GCO_shutdown ();
if (NULL != stats)
/**
- * Handler for port open requests.
+ * Handle port open request. Creates a mapping from the
+ * port to the respective client and checks whether we have
+ * loose channels trying to bind to the port. If so, those
+ * are bound.
*
* @param cls Identification of the client.
* @param pmsg The actual message.
struct CadetClient *c = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Open port %s requested by client %u\n",
+ "Open port %s requested by client %s\n",
GNUNET_h2s (&pmsg->port),
- c->id);
+ GSC_2s (c));
if (NULL == c->ports)
c->ports = GNUNET_CONTAINER_multihashmap_create (4,
GNUNET_NO);
GNUNET_SERVICE_client_drop (c->client);
return;
}
- /* store in global hashmap */
- /* FIXME only allow one client to have the port open,
- * have a backup hashmap with waiting clients */
- GNUNET_CONTAINER_multihashmap_put (open_ports,
- &pmsg->port,
- c,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multihashmap_put (open_ports,
+ &pmsg->port,
+ c,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_CONTAINER_multihashmap_get_multiple (loose_channels,
&pmsg->port,
&bind_loose_channel,
/**
- * Handler for port close requests.
+ * Handler for port close requests. Marks this port as closed
+ * (unless of course we have another client with the same port
+ * open). Note that existing channels accepted on the port are
+ * not affected.
*
* @param cls Identification of the client.
* @param pmsg The actual message.
struct CadetClient *c = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Open port %s requested by client %u\n",
+ "Closing port %s as requested by client %s\n",
GNUNET_h2s (&pmsg->port),
- c->id);
+ GSC_2s (c));
if (GNUNET_YES !=
GNUNET_CONTAINER_multihashmap_remove (c->ports,
&pmsg->port,
GNUNET_CONTAINER_multihashmap_remove (open_ports,
&pmsg->port,
c));
-
GNUNET_SERVICE_client_continue (c->client);
}
/**
- * Handler for requests of new channels.
+ * Handler for requests for us creating a new channel to another peer and port.
*
* @param cls Identification of the client.
* @param tcm The actual message.
*/
static void
-handle_tunnel_create (void *cls,
- const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
+handle_channel_create (void *cls,
+ const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
{
struct CadetClient *c = cls;
struct CadetChannel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
- struct CadetPeer *dst;
- chid = tcm->channel_id;
- if (ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (tcm->ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
{
/* Channel ID not in allowed range. */
GNUNET_break (0);
GNUNET_SERVICE_client_drop (c->client);
return;
}
- ch = GNUNET_CONTAINER_multihashmap32_get (c->own_channels,
- ntohl (chid.channel_of_client));
+ ch = lookup_channel (c,
+ tcm->ccn);
if (NULL != ch)
{
/* Channel ID already in use. Not allowed. */
return;
}
- dst = GCP_get (&tcm->peer,
- GNUNET_YES);
-
/* Create channel */
ch = GCCH_channel_local_new (c,
- chid,
- dst,
+ tcm->ccn,
+ GCP_get (&tcm->peer,
+ GNUNET_YES),
&tcm->port,
ntohl (tcm->opt));
if (NULL == ch)
return;
}
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_put (c->own_channels,
- ntohl (chid.channel_of_client),
+ GNUNET_CONTAINER_multihashmap32_put (c->channels,
+ ntohl (tcm->ccn.channel_of_client),
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "New channel %s to %s at port %s requested by client %u\n",
+ "New channel %s to %s at port %s requested by client %s\n",
GCCH_2s (ch),
GNUNET_i2s (&tcm->peer),
GNUNET_h2s (&tcm->port),
- c->id);
+ GSC_2s (c));
GNUNET_SERVICE_client_continue (c->client);
}
/**
- * Return the map which we use for client @a c for a channel ID of @a chid
- *
- * @param c client to find map for
- * @param chid chid to find map for
- * @return applicable map we use
- */
-static struct GNUNET_CONTAINER_MultiHashMap32 *
-get_map_by_chid (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber chid)
-{
- return (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
- ? c->own_channels
- : c->incoming_channels;
-}
-
-
-/**
- * Handler for requests of deleting tunnels
+ * Handler for requests of destroying an existing channel.
*
* @param cls client identification of the client
* @param msg the actual message
*/
static void
-handle_tunnel_destroy (void *cls,
- const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
+handle_channel_destroy (void *cls,
+ const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
{
struct CadetClient *c = cls;
- struct GNUNET_CADET_ClientChannelNumber chid;
- struct GNUNET_CONTAINER_MultiHashMap32 *map;
struct CadetChannel *ch;
- /* Retrieve tunnel */
- chid = msg->channel_id;
- map = get_map_by_chid (c,
- chid);
- ch = GNUNET_CONTAINER_multihashmap32_get (map,
- ntohl (chid.channel_of_client));
+ ch = lookup_channel (c,
+ msg->ccn);
if (NULL == ch)
{
/* Client attempted to destroy unknown channel */
return;
}
LOG (GNUNET_ERROR_TYPE_INFO,
- "Client %u is destroying channel %s\n",
- c->id,
+ "Client %s is destroying channel %s\n",
+ GSC_2s(c),
GCCH_2s (ch));
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_remove (map,
- ntohl (chid.channel_of_client),
+ GNUNET_CONTAINER_multihashmap32_remove (c->channels,
+ ntohl (msg->ccn.channel_of_client),
ch));
GCCH_channel_local_destroy (ch);
GNUNET_SERVICE_client_continue (c->client);
/**
- * Check for client traffic data message is well-formed
+ * Check for client traffic data message is well-formed.
*
* @param cls identification of the client
* @param msg the actual message
/**
- * Handler for client traffic
+ * Handler for client payload traffic to be send on a channel to
+ * another peer.
*
* @param cls identification of the client
* @param msg the actual message
const struct GNUNET_CADET_LocalData *msg)
{
struct CadetClient *c = cls;
- struct GNUNET_CONTAINER_MultiHashMap32 *map;
- struct GNUNET_CADET_ClientChannelNumber chid;
struct CadetChannel *ch;
const struct GNUNET_MessageHeader *payload;
- chid = msg->channel_id;
- map = get_map_by_chid (c,
- chid);
- ch = GNUNET_CONTAINER_multihashmap32_get (map,
- ntohl (chid.channel_of_client));
+ ch = lookup_channel (c,
+ msg->ccn);
if (NULL == ch)
{
/* Channel does not exist! */
payload = (const struct GNUNET_MessageHeader *) &msg[1];
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received %u bytes payload from client %u for channel %s\n",
+ "Received %u bytes payload from client %s for channel %s\n",
ntohs (payload->size),
- c->id,
+ GSC_2s (c),
GCCH_2s (ch));
if (GNUNET_OK !=
GCCH_handle_local_data (ch,
const struct GNUNET_CADET_LocalAck *msg)
{
struct CadetClient *c = cls;
- struct GNUNET_CONTAINER_MultiHashMap32 *map;
- struct GNUNET_CADET_ClientChannelNumber chid;
struct CadetChannel *ch;
- chid = msg->channel_id;
- map = get_map_by_chid (c,
- chid);
- ch = GNUNET_CONTAINER_multihashmap32_get (map,
- ntohl (chid.channel_of_client));
+ ch = lookup_channel (c,
+ msg->ccn);
if (NULL == ch)
{
/* Channel does not exist! */
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Got a local ACK from client %u for channel %s\n",
- c->id,
+ "Got a local ACK from client %s for channel %s\n",
+ GSC_2s(c),
GCCH_2s (ch));
GCCH_handle_local_ack (ch);
GNUNET_SERVICE_client_continue (c->client);
/**
- * Handler for client's INFO TUNNELS request.
+ * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS request.
*
* @param cls client Identification of the client.
* @param message The actual message.
*/
static void
-handle_get_tunnels (void *cls,
- const struct GNUNET_MessageHeader *message)
+handle_info_tunnels (void *cls,
+ const struct GNUNET_MessageHeader *message)
{
struct CadetClient *c = cls;
struct GNUNET_MQ_Envelope *env;
/**
- * FIXME.
+ * Update the message with information about the connection.
+ *
+ * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update
+ * @param c a connection about which we should store information in @a cls
*/
static void
iter_connection (void *cls,
/**
- * FIXME.
+ * Update the message with information about the channel.
+ *
+ * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update
+ * @param ch a channel about which we should store information in @a cls
*/
static void
iter_channel (void *cls,
/**
- * Handler for client's SHOW_TUNNEL request.
+ * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL request.
*
* @param cls Identification of the client.
* @param msg The actual message.
*/
static void
-handle_show_tunnel (void *cls,
+handle_info_tunnel (void *cls,
const struct GNUNET_CADET_LocalInfo *msg)
{
struct CadetClient *c = cls;
LOG (GNUNET_ERROR_TYPE_ERROR,
"*************************** DUMP START ***************************\n");
- for (struct CadetClient *ci = clients_head; NULL != ci; ci = ci->next)
+ for (struct CadetClient *ci = clients_head;
+ NULL != ci;
+ ci = ci->next)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Client %u (%p), handle: %p, ports: %u, own channels: %u, incoming channels: %u\n",
+ "Client %u (%p), handle: %p, ports: %u, channels: %u\n",
ci->id,
ci,
ci->client,
(NULL != c->ports)
? GNUNET_CONTAINER_multihashmap_size (ci->ports)
: 0,
- GNUNET_CONTAINER_multihashmap32_size (ci->own_channels),
- GNUNET_CONTAINER_multihashmap32_size (ci->incoming_channels));
+ GNUNET_CONTAINER_multihashmap32_size (ci->channels));
}
LOG (GNUNET_ERROR_TYPE_ERROR, "***************************\n");
GCP_iterate_all (&show_peer_iterator,
c->client = client;
c->mq = mq;
c->id = next_client_id++; /* overflow not important: just for debug */
- c->own_channels
- = GNUNET_CONTAINER_multihashmap32_create (32);
- c->incoming_channels
+ c->channels
= GNUNET_CONTAINER_multihashmap32_create (32);
GNUNET_CONTAINER_DLL_insert (clients_head,
clients_tail,
"# clients",
+1,
GNUNET_NO);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %s connected\n",
+ GSC_2s (c));
return c;
}
* Iterator for deleting each channel whose client endpoint disconnected.
*
* @param cls Closure (client that has disconnected).
- * @param key The local channel id (used to access the hashmap).
+ * @param key The local channel id in host byte order
* @param value The value stored at the key (channel to destroy).
* @return #GNUNET_OK, keep iterating.
*/
static int
-own_channel_destroy_iterator (void *cls,
- uint32_t key,
- void *value)
+channel_destroy_iterator (void *cls,
+ uint32_t key,
+ void *value)
{
struct CadetClient *c = cls;
struct CadetChannel *ch = value;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_remove (c->own_channels,
- key,
- ch));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Destroying own channel %s, due to client %u shutdown.\n",
- GCCH_2s (ch),
- c->id);
- GCCH_channel_local_destroy (ch);
- return GNUNET_OK;
-}
-
-
-/**
- * Iterator for deleting each channel whose client endpoint disconnected.
- *
- * @param cls Closure (client that has disconnected).
- * @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.
- */
-static int
-incoming_channel_destroy_iterator (void *cls,
- uint32_t key,
- void *value)
-{
- struct CadetChannel *ch = value;
- struct CadetClient *c = cls;
-
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels,
+ GNUNET_CONTAINER_multihashmap32_remove (c->channels,
key,
ch));
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Destroying incoming channel %s due to client %u shutdown.\n",
+ "Destroying channel %s, due to client %s disconnecting.\n",
GCCH_2s (ch),
- c->id);
- GCCH_channel_incoming_destroy (ch);
+ GSC_2s (c));
+ if (key < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ GCCH_channel_local_destroy (ch);
+ else
+ GCCH_channel_incoming_destroy (ch);
return GNUNET_OK;
}
* Remove client's ports from the global hashmap on disconnect.
*
* @param cls Closure (unused).
- * @param key Port.
+ * @param key the port.
* @param value the `struct CadetClient` to remove
* @return #GNUNET_OK, keep iterating.
*/
{
struct CadetClient *c = value;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Closing port %s due to client %s disconnect.\n",
+ GNUNET_h2s (key),
+ GSC_2s (c));
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (open_ports,
key,
struct CadetClient *c = internal_cls;
GNUNET_assert (c->client == client);
- c->shutting_down = GNUNET_YES;
- if (NULL != c->own_channels)
- {
- GNUNET_CONTAINER_multihashmap32_iterate (c->own_channels,
- &own_channel_destroy_iterator,
- c);
- GNUNET_CONTAINER_multihashmap32_destroy (c->own_channels);
- }
- if (NULL != c->incoming_channels)
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %s is disconnecting.\n",
+ GSC_2s (c));
+ if (NULL != c->channels)
{
- GNUNET_CONTAINER_multihashmap32_iterate (c->incoming_channels,
- &incoming_channel_destroy_iterator,
+ GNUNET_CONTAINER_multihashmap32_iterate (c->channels,
+ &channel_destroy_iterator,
c);
- GNUNET_CONTAINER_multihashmap32_destroy (c->incoming_channels);
+ GNUNET_CONTAINER_multihashmap32_destroy (c->channels);
}
if (NULL != c->ports)
{
GCD_init (c);
GCO_init (c);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "CADET starting at peer %s\n",
+ "CADET started for peer %s\n",
GNUNET_i2s (&my_full_id));
}
GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE,
struct GNUNET_CADET_PortMessage,
NULL),
- GNUNET_MQ_hd_fixed_size (tunnel_create,
+ GNUNET_MQ_hd_fixed_size (channel_create,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE,
struct GNUNET_CADET_LocalChannelCreateMessage,
NULL),
- GNUNET_MQ_hd_fixed_size (tunnel_destroy,
+ GNUNET_MQ_hd_fixed_size (channel_destroy,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY,
struct GNUNET_CADET_LocalChannelDestroyMessage,
NULL),
GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER,
struct GNUNET_CADET_LocalInfo,
NULL),
- GNUNET_MQ_hd_fixed_size (get_tunnels,
+ GNUNET_MQ_hd_fixed_size (info_tunnels,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
struct GNUNET_MessageHeader,
NULL),
- GNUNET_MQ_hd_fixed_size (show_tunnel,
+ GNUNET_MQ_hd_fixed_size (info_tunnel,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
struct GNUNET_CADET_LocalInfo,
NULL),
#include "gnunet-service-cadet-new_peer.h"
#include "gnunet-service-cadet-new_paths.h"
-#define LOG(level, ...) GNUNET_log (level,__VA_ARGS__)
+#define LOG(level,...) GNUNET_log_from (level,"cadet-channel",__VA_ARGS__)
/**
* How long do we initially wait before retransmitting?
/**
* Number identifying this channel in its tunnel.
*/
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
/**
* Local tunnel number for local client owning the channel.
* ( >= #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI or 0 )
*/
- struct GNUNET_CADET_ClientChannelNumber lid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
/**
* Channel state.
return "(NULL Channel)";
GNUNET_snprintf (buf,
sizeof (buf),
- "%s:%s chid:%X (%X)",
+ "%s:%s ctn:%X (%X)",
GCT_2s (ch->t),
GNUNET_h2s (&ch->port),
- ch->chid,
- ntohl (ch->lid.channel_of_client));
+ ch->ctn,
+ ntohl (ch->ccn.channel_of_client));
return buf;
}
struct GNUNET_CADET_ChannelTunnelNumber
GCCH_get_id (const struct CadetChannel *ch)
{
- return ch->chid;
+ return ch->ctn;
}
}
GCT_remove_channel (ch->t,
ch,
- ch->chid);
+ ch->ctn);
GNUNET_free (ch);
}
msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN);
msgcc.opt = htonl (options);
msgcc.port = ch->port;
- msgcc.chid = ch->chid;
+ msgcc.ctn = ch->ctn;
ch->state = CADET_CHANNEL_CREATE_SENT;
ch->last_control_qe = GCT_send (ch->t,
&msgcc.header,
* Create a new channel.
*
* @param owner local client owning the channel
- * @param owner_id local chid of this channel at the @a owner
+ * @param ccn local number of this channel at the @a owner
* @param destination peer to which we should build the channel
* @param port desired port at @a destination
* @param options options for the channel
*/
struct CadetChannel *
GCCH_channel_local_new (struct CadetClient *owner,
- struct GNUNET_CADET_ClientChannelNumber owner_id,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
struct CadetPeer *destination,
const struct GNUNET_HashCode *port,
uint32_t options)
ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER));
ch->max_pending_messages = (ch->nobuffer) ? 1 : 32; /* FIXME: 32!? Do not hardcode! */
ch->owner = owner;
- ch->lid = owner_id;
+ ch->ccn = ccn;
ch->port = *port;
ch->t = GCP_get_tunnel (destination,
GNUNET_YES);
- ch->chid = GCT_add_channel (ch->t,
+ ch->ctn = GCT_add_channel (ch->t,
ch);
ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME;
ch->retry_task = GNUNET_SCHEDULER_add_now (&send_create,
"# channels",
1,
GNUNET_NO);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Created channel to port %s at peer %s for client %s using tunnel %s\n",
+ GNUNET_h2s (port),
+ GCP_2s (destination),
+ GSC_2s (owner),
+ GCT_2s (ch->t));
return ch;
}
struct CadetChannel *ch = cls;
ch->retry_task = NULL;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Closing incoming channel to port %s from peer %s due to timeout\n",
+ GNUNET_h2s (&ch->port),
+ GCP_2s (GCT_get_destination (ch->t)));
channel_destroy (ch);
}
* Create a new channel based on a request coming in over the network.
*
* @param t tunnel to the remote peer
- * @param chid identifier of this channel in the tunnel
+ * @param ctn identifier of this channel in the tunnel
* @param port desired local port
* @param options options for the channel
* @return handle to the new channel
*/
struct CadetChannel *
GCCH_channel_incoming_new (struct CadetTunnel *t,
- struct GNUNET_CADET_ChannelTunnelNumber chid,
+ struct GNUNET_CADET_ChannelTunnelNumber ctn,
const struct GNUNET_HashCode *port,
uint32_t options)
{
ch = GNUNET_new (struct CadetChannel);
ch->port = *port;
ch->t = t;
- ch->chid = chid;
+ ch->ctn = ctn;
ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME;
ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER));
ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE));
ch->retry_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_CLOSED_PORT,
&timeout_closed_cb,
ch);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Created loose incoming channel to port %s from peer %s\n",
+ GNUNET_h2s (&ch->port),
+ GCP_2s (GCT_get_destination (ch->t)));
}
else
{
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK);
msg.header.size = htons (sizeof (msg));
- msg.chid = ch->chid;
+ msg.ctn = ch->ctn;
msg.mid.mid = htonl (ntohl (ch->mid_recv.mid) - 1);
msg.futures = GNUNET_htonll (ch->mid_futures);
if (NULL != ch->last_control_qe)
env = GNUNET_MQ_msg (ack,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
- ack->channel_id = ch->lid;
+ ack->ccn = ch->ccn;
GSC_send_to_client (c,
env);
}
struct GNUNET_CADET_LocalChannelCreateMessage *tcm;
uint32_t options;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Binding channel %s from tunnel %s to port %s of client %s\n",
+ GCCH_2s (ch),
+ GCT_2s (ch->t),
+ GNUNET_h2s (&ch->port),
+ GSC_2s (c));
if (NULL != ch->retry_task)
{
/* there might be a timeout task here */
if (ch->out_of_order)
options |= GNUNET_CADET_OPTION_OUT_OF_ORDER;
ch->dest = c;
- ch->lid = GSC_bind (c,
+ ch->ccn = GSC_bind (c,
ch,
GCT_get_destination (ch->t),
&ch->port,
/* give client it's initial supply of ACKs */
env = GNUNET_MQ_msg (tcm,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
- tcm->channel_id = ch->lid;
+ tcm->ccn = ch->ccn;
tcm->peer = *GCP_get_id (GCT_get_destination (ch->t));
tcm->port = ch->port;
tcm->opt = htonl (options);
}
/* Nothing left to do, just finish destruction */
GCT_send_channel_destroy (ch->t,
- ch->chid);
+ ch->ctn);
channel_destroy (ch);
}
}
/* Nothing left to do, just finish destruction */
GCT_send_channel_destroy (ch->t,
- ch->chid);
+ ch->ctn);
channel_destroy (ch);
}
env = GNUNET_MQ_msg_extra (ld,
payload_size,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
- ld->channel_id = ch->lid;
+ ld->ccn = ch->ccn;
GNUNET_memcpy (&ld[1],
&msg[1],
payload_size);
ch->destroy = GNUNET_YES;
env = GNUNET_MQ_msg (tdm,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
- tdm->channel_id = ch->lid;
+ tdm->ccn = ch->ccn;
GSC_send_to_client ((NULL != ch->owner) ? ch->owner : ch->dest,
env);
channel_destroy (ch);
GCCH_2s (ch));
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
- msg->channel_id = ch->lid;
+ msg->ccn = ch->ccn;
GSC_send_to_client (ch->owner ? ch->owner : ch->dest,
env);
}
crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1);
crm->data_message.mid = ch->mid_send;
- crm->data_message.chid = ch->chid;
+ crm->data_message.ctn = ch->ctn;
GNUNET_memcpy (&crm[1],
message,
payload_size);
if (GNUNET_NO == ch->destroy)
return;
GCT_send_channel_destroy (ch->t,
- ch->chid);
+ ch->ctn);
channel_destroy (ch);
}
LOG2 (level,
"CHN Channel %s:%X (%p)\n",
GCT_2s (ch->t),
- ch->chid,
+ ch->ctn,
ch);
if (NULL != ch->owner)
{
"CHN origin %s ready %s local-id: %u\n",
GSC_2s (ch->owner),
ch->client_ready ? "YES" : "NO",
- ntohl (ch->lid.channel_of_client));
+ ntohl (ch->ccn.channel_of_client));
}
if (NULL != ch->dest)
{
"CHN destination %s ready %s local-id: %u\n",
GSC_2s (ch->dest),
ch->client_ready ? "YES" : "NO",
- ntohl (ch->lid.channel_of_client));
+ ntohl (ch->ccn.channel_of_client));
}
LOG2 (level,
"CHN Message IDs recv: %d (%LLX), send: %d\n",
/**
* Channel ID for the next created channel in this tunnel.
*/
- struct GNUNET_CADET_ChannelTunnelNumber next_chid;
+ struct GNUNET_CADET_ChannelTunnelNumber next_ctn;
/**
* Queued messages, to transmit once tunnel gets connected.
/**
- * Lookup a channel by its @a chid.
+ * Lookup a channel by its @a ctn.
*
* @param t tunnel to look in
- * @param chid number of channel to find
+ * @param ctn number of channel to find
* @return NULL if channel does not exist
*/
struct CadetChannel *
lookup_channel (struct CadetTunnel *t,
- struct GNUNET_CADET_ChannelTunnelNumber chid)
+ struct GNUNET_CADET_ChannelTunnelNumber ctn)
{
return GNUNET_CONTAINER_multihashmap32_get (t->channels,
- ntohl (chid.cn));
+ ntohl (ctn.cn));
}
* @return unused number that can uniquely identify a channel in the tunnel
*/
static struct GNUNET_CADET_ChannelTunnelNumber
-get_next_free_chid (struct CadetTunnel *t)
+get_next_free_ctn (struct CadetTunnel *t)
{
struct GNUNET_CADET_ChannelTunnelNumber ret;
- uint32_t chid;
+ uint32_t ctn;
/* FIXME: this logic does NOT prevent both ends of the
- channel from picking the same CHID!
- Need to reserve one bit of the CHID for the
+ channel from picking the same CTN!
+ Need to reserve one bit of the CTN for the
direction, i.e. which side established the connection! */
- chid = ntohl (t->next_chid.cn);
+ ctn = ntohl (t->next_ctn.cn);
while (NULL !=
GNUNET_CONTAINER_multihashmap32_get (t->channels,
- chid))
- chid++;
- t->next_chid.cn = htonl (chid + 1);
- ret.cn = ntohl (chid);
+ ctn))
+ ctn++;
+ t->next_ctn.cn = htonl (ctn + 1);
+ ret.cn = ntohl (ctn);
return ret;
}
GCT_add_channel (struct CadetTunnel *t,
struct CadetChannel *ch)
{
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
- chid = get_next_free_chid (t);
+ ctn = get_next_free_ctn (t);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap32_put (t->channels,
- ntohl (chid.cn),
+ ntohl (ctn.cn),
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- return chid;
+ return ctn;
}
struct CadetChannel *ch;
ch = lookup_channel (t,
- msg->chid);
+ msg->ctn);
if (NULL == ch)
{
/* We don't know about such a channel, might have been destroyed on our
end in the meantime, or never existed. Send back a DESTROY. */
GCT_send_channel_destroy (t,
- msg->chid);
+ msg->ctn);
return;
}
GCCH_handle_channel_plaintext_data (ch,
struct CadetChannel *ch;
ch = lookup_channel (t,
- ack->chid);
+ ack->ctn);
if (NULL == ch)
{
/* We don't know about such a channel, might have been destroyed on our
end in the meantime, or never existed. Send back a DESTROY. */
GCT_send_channel_destroy (t,
- ack->chid);
+ ack->ctn);
return;
}
GCCH_handle_channel_plaintext_data_ack (ch,
{
struct CadetTunnel *t = cls;
struct CadetChannel *ch;
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
- chid = get_next_free_chid (t);
+ ctn = get_next_free_ctn (t);
ch = GCCH_channel_incoming_new (t,
- chid,
+ ctn,
&cc->port,
ntohl (cc->opt));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap32_put (t->channels,
- ntohl (chid.cn),
+ ntohl (ctn.cn),
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
* Send a DESTROY message via the tunnel.
*
* @param t the tunnel to transmit over
- * @param chid ID of the channel to destroy
+ * @param ctn ID of the channel to destroy
*/
void
GCT_send_channel_destroy (struct CadetTunnel *t,
- struct GNUNET_CADET_ChannelTunnelNumber chid)
+ struct GNUNET_CADET_ChannelTunnelNumber ctn)
{
struct GNUNET_CADET_ChannelManageMessage msg;
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
msg.reserved = htonl (0);
- msg.chid = chid;
+ msg.ctn = ctn;
GCT_send (t,
&msg.header,
NULL,
struct CadetChannel *ch;
ch = lookup_channel (t,
- cm->chid);
+ cm->ctn);
if (NULL == ch)
{
/* We don't know about such a channel, might have been destroyed on our
end in the meantime, or never existed. Send back a DESTROY. */
GCT_send_channel_destroy (t,
- cm->chid);
+ cm->ctn);
return;
}
GCCH_handle_channel_create_ack (ch);
{
struct CadetTunnel *t = cls;
struct CadetChannel *cc = lookup_channel (t,
- cm->chid);
+ cm->ctn);
GCCH_handle_remote_destroy (cc);
}
}
/* Assign local id as destination */
- ch->lid_dest = GML_get_next_chid (c);
+ ch->lid_dest = GML_get_next_ccn (c);
/* Store in client's hashmap */
GML_channel_add (c, ch->lid_dest, ch);
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
msg.header.size = htons (sizeof (msg));
- msg.chid = ch->gid;
+ msg.ctn = ch->gid;
/* If root is not NULL, notify.
* If it's NULL, check lid_root. When a local destroy comes in, root
msgcc.header.size = htons (sizeof (msgcc));
msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN);
- msgcc.chid = ch->gid;
+ msgcc.ctn = ch->gid;
msgcc.port = ch->port;
msgcc.opt = htonl (channel_get_options (ch));
" sending channel %s ack for channel %s\n",
GC_f2s (fwd), GCCH_2s (ch));
- msg.chid =ch->gid;
+ msg.ctn =ch->gid;
GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL);
}
" sending channel NACK for channel %s\n",
GCCH_2s (ch));
- msg.chid = ch->gid;
+ msg.ctn = ch->gid;
GCCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, NULL);
}
if (NULL != owner)
{
- ch->gid = GCT_get_next_chid (t);
+ ch->gid = GCT_get_next_ctn (t);
GML_channel_add (owner, lid_root, ch);
}
GCT_add_channel (t, ch);
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK);
msg.header.size = htons (sizeof (msg));
- msg.chid = ch->gid;
+ msg.ctn = ch->gid;
msg.mid = htonl (ack);
msg.futures = 0LL;
GNUNET_memcpy (&payload[1], message, size);
payload->header.size = htons (p2p_size);
payload->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
- payload->chid = ch->gid;
+ payload->ctn = ch->gid;
LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n");
GCCH_send_prebuilt_message (&payload->header, ch, fwd, NULL);
struct CadetChannel *ch;
struct CadetTunnel *t;
struct CadetPeer *peer;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
GNUNET_i2s (&msg->peer), GNUNET_h2s (&msg->port));
- chid = msg->channel_id;
+ ccn = msg->ccn;
/* Sanity check for duplicate channel IDs */
- if (NULL != GML_channel_get (c, chid))
+ if (NULL != GML_channel_get (c, ccn))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
/* Create channel */
- ch = channel_new (t, c, chid);
+ ch = channel_new (t, c, ccn);
if (NULL == ch)
{
GNUNET_break (0);
GCCH_handle_create (struct CadetTunnel *t,
const struct GNUNET_CADET_ChannelOpenMessage *msg)
{
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
struct GNUNET_CADET_ChannelTunnelNumber gid;
struct CadetChannel *ch;
struct CadetClient *c;
int new_channel;
const struct GNUNET_HashCode *port;
- gid = msg->chid;
+ gid = msg->ctn;
ch = GCT_get_channel (t, gid);
if (NULL == ch)
{
/* Create channel */
- chid.channel_of_client = htonl (0);
- ch = channel_new (t, NULL, chid);
+ ccn.channel_of_client = htonl (0);
+ ch = channel_new (t, NULL, ccn);
ch->gid = gid;
channel_set_options (ch, ntohl (msg->opt));
new_channel = GNUNET_YES;
LOG (GNUNET_ERROR_TYPE_INFO,
"<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
- GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN), chid, port,
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN), ccn, port,
GCCH_2s (ch), ch, GC_f2s (GNUNET_YES), ntohs (msg->header.size));
if (GNUNET_YES == new_channel || GCT_is_loopback (t))
{
struct GNUNET_CADET_ChannelOpenMessage *cc_msg;
cc_msg = (struct GNUNET_CADET_ChannelOpenMessage *) message;
- SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid.cn));
+ SPRINTF (info, " 0x%08X", ntohl (cc_msg->ctn.cn));
break;
}
case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK:
{
struct GNUNET_CADET_ChannelManageMessage *m_msg;
m_msg = (struct GNUNET_CADET_ChannelManageMessage *) message;
- SPRINTF (info, " 0x%08X", ntohl (m_msg->chid.cn));
+ SPRINTF (info, " 0x%08X", ntohl (m_msg->ctn.cn));
break;
}
default:
/**
* Channel ID for the next incoming channel.
*/
- struct GNUNET_CADET_ClientChannelNumber next_chid;
+ struct GNUNET_CADET_ClientChannelNumber next_ccn;
/**
* Handle to communicate with the client
const struct GNUNET_CADET_LocalChannelDestroyMessage *msg;
struct CadetClient *c;
struct CadetChannel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Got a DESTROY CHANNEL from client!\n");
msg = (const struct GNUNET_CADET_LocalChannelDestroyMessage *) message;
/* Retrieve tunnel */
- chid = msg->channel_id;
- ch = GML_channel_get (c, chid);
+ ccn = msg->ccn;
+ ch = GML_channel_get (c, ccn);
LOG (GNUNET_ERROR_TYPE_INFO, "Client %u is destroying channel %X\n",
- c->id, chid);
+ c->id, ccn);
if (NULL == ch)
{
- LOG (GNUNET_ERROR_TYPE_WARNING, " channel %X not found\n", chid);
+ LOG (GNUNET_ERROR_TYPE_WARNING, " channel %X not found\n", ccn);
GNUNET_STATISTICS_update (stats,
"# client destroy messages on unknown channel",
1, GNUNET_NO);
GCCH_handle_local_destroy (ch,
c,
- ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
+ ntohl (ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
struct GNUNET_CADET_LocalData *msg;
struct CadetClient *c;
struct CadetChannel *ch;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
size_t message_size;
size_t payload_size;
size_t payload_claimed_size;
return;
}
- chid = msg->channel_id;
+ ccn = msg->ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG, " %u bytes (%u payload) by client %u\n",
payload_size, payload_claimed_size, c->id);
/* Channel exists? */
- fwd = ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
- ch = GML_channel_get (c, chid);
+ fwd = ntohl (ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
+ ch = GML_channel_get (c, ccn);
if (NULL == ch)
{
GNUNET_STATISTICS_update (stats,
struct GNUNET_CADET_LocalAck *msg;
struct CadetChannel *ch;
struct CadetClient *c;
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
int fwd;
LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
msg = (struct GNUNET_CADET_LocalAck *) message;
/* Channel exists? */
- chid = msg->channel_id;
+ ccn = msg->ccn;
LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n",
- ntohl (chid.channel_of_client));
- ch = GML_channel_get (c, chid);
+ ntohl (ccn.channel_of_client));
+ ch = GML_channel_get (c, ccn);
LOG (GNUNET_ERROR_TYPE_DEBUG, " -- ch %p\n", ch);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Channel %X unknown.\n",
- ntohl (chid.channel_of_client));
+ ntohl (ccn.channel_of_client));
LOG (GNUNET_ERROR_TYPE_DEBUG, " for client %u.\n", c->id);
GNUNET_STATISTICS_update (stats,
"# client ack messages on unknown channel",
/* If client is root, the ACK is going FWD, therefore this is "BCK ACK". */
/* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */
- fwd = ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
+ fwd = ntohl (ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
GCCH_handle_local_ack (ch, fwd);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
* Get a channel from a client.
*
* @param c Client to check.
- * @param chid Channel ID, must be local (> 0x800...).
+ * @param ccn Channel ID, must be local (> 0x800...).
*
* @return non-NULL if channel exists in the clients lists
*/
struct CadetChannel *
GML_channel_get (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber chid)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CONTAINER_MultiHashMap32 *map;
- if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
map = c->own_channels;
else
map = c->incoming_channels;
{
GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Client %s does no t have a valid map for CHID %X\n",
- GML_2s (c), chid);
+ "Client %s does no t have a valid map for CCN %X\n",
+ GML_2s (c), ccn);
return NULL;
}
return GNUNET_CONTAINER_multihashmap32_get (map,
- chid.channel_of_client);
+ ccn.channel_of_client);
}
* Add a channel to a client
*
* @param client Client.
- * @param chid Channel ID.
+ * @param ccn Channel ID.
* @param ch Channel.
*/
void
GML_channel_add (struct CadetClient *client,
- struct GNUNET_CADET_ClientChannelNumber chid,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
struct CadetChannel *ch)
{
- if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
GNUNET_CONTAINER_multihashmap32_put (client->own_channels,
- chid.channel_of_client,
+ ccn.channel_of_client,
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
else
GNUNET_CONTAINER_multihashmap32_put (client->incoming_channels,
- chid.channel_of_client,
+ ccn.channel_of_client,
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
* Remove a channel from a client.
*
* @param client Client.
- * @param chid Channel ID.
+ * @param ccn Channel ID.
* @param ch Channel.
*/
void
GML_channel_remove (struct CadetClient *client,
- struct GNUNET_CADET_ClientChannelNumber chid,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
struct CadetChannel *ch)
{
- if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ if (ntohl (ccn.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
GNUNET_CONTAINER_multihashmap32_remove (client->own_channels,
- chid.channel_of_client,
+ ccn.channel_of_client,
ch);
else
GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels,
- chid.channel_of_client,
+ ccn.channel_of_client,
ch);
}
* @return LID of a channel free to use.
*/
struct GNUNET_CADET_ClientChannelNumber
-GML_get_next_chid (struct CadetClient *c)
+GML_get_next_ccn (struct CadetClient *c)
{
- struct GNUNET_CADET_ClientChannelNumber chid;
+ struct GNUNET_CADET_ClientChannelNumber ccn;
while (NULL != GML_channel_get (c,
- c->next_chid))
+ c->next_ccn))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Channel %u exists...\n",
- c->next_chid);
- c->next_chid.channel_of_client
- = htonl (1 + (ntohl (c->next_chid.channel_of_client)));
- if (ntohl (c->next_chid.channel_of_client) >=
+ c->next_ccn);
+ c->next_ccn.channel_of_client
+ = htonl (1 + (ntohl (c->next_ccn.channel_of_client)));
+ if (ntohl (c->next_ccn.channel_of_client) >=
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
- c->next_chid.channel_of_client = htonl (0);
+ c->next_ccn.channel_of_client = htonl (0);
}
- chid = c->next_chid;
- c->next_chid.channel_of_client
- = htonl (1 + (ntohl (c->next_chid.channel_of_client)));
+ ccn = c->next_ccn;
+ c->next_ccn.channel_of_client
+ = htonl (1 + (ntohl (c->next_ccn.channel_of_client)));
- return chid;
+ return ccn;
}
* If the client was already allowed to send data, do nothing.
*
* @param c Client to whom send the ACK.
- * @param id Channel ID to use
+ * @param ccn Channel ID to use
*/
void
GML_send_ack (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber id)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_LocalAck msg;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"send local %s ack on %X towards %p\n",
- ntohl (id.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
+ ntohl (ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
? "FWD" : "BCK",
- ntohl (id.channel_of_client),
+ ntohl (ccn.channel_of_client),
c);
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
- msg.channel_id = id;
+ msg.ccn = ccn;
GNUNET_SERVER_notification_context_unicast (nc,
c->handle,
&msg.header,
* Notify the client that a new incoming channel was created.
*
* @param c Client to notify.
- * @param id Channel ID.
+ * @param ccn Channel ID.
* @param port Channel's destination port.
* @param opt Options (bit array).
* @param peer Origin peer.
*/
void
GML_send_channel_create (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber id,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
const struct GNUNET_HashCode *port,
uint32_t opt,
const struct GNUNET_PeerIdentity *peer)
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
- msg.channel_id = id;
+ msg.ccn = ccn;
msg.port = *port;
msg.opt = htonl (opt);
msg.peer = *peer;
* Build a local channel NACK message and send it to a local client.
*
* @param c Client to whom send the NACK.
- * @param id Channel ID to use
+ * @param ccn Channel ID to use
*/
void
GML_send_channel_nack (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber id)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_LocalAck msg;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"send local nack on %X towards %p\n",
- ntohl (id.channel_of_client),
+ ntohl (ccn.channel_of_client),
c);
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_NACK_DEPRECATED);
- msg.channel_id = id;
+ msg.ccn = ccn;
GNUNET_SERVER_notification_context_unicast (nc,
c->handle,
&msg.header,
* Notify a client that a channel is no longer valid.
*
* @param c Client.
- * @param id ID of the channel that is destroyed.
+ * @param ccn ID of the channel that is destroyed.
*/
void
GML_send_channel_destroy (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber id)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_LocalChannelDestroyMessage msg;
return;
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
- msg.channel_id = id;
+ msg.ccn = ccn;
GNUNET_SERVER_notification_context_unicast (nc, c->handle,
&msg.header, GNUNET_NO);
}
*
* @param c Client to send to.
* @param msg Message to modify and send.
- * @param id Channel ID to use (c can be both owner and client).
+ * @param ccn Channel ID to use (c can be both owner and client).
*/
void
GML_send_data (struct CadetClient *c,
const struct GNUNET_CADET_ChannelAppDataMessage *msg,
- struct GNUNET_CADET_ClientChannelNumber id)
+ struct GNUNET_CADET_ClientChannelNumber ccn)
{
struct GNUNET_CADET_LocalData *copy;
uint16_t size = ntohs (msg->header.size) - sizeof (struct GNUNET_CADET_ChannelAppDataMessage);
GNUNET_memcpy (©[1], &msg[1], size);
copy->header.size = htons (sizeof (struct GNUNET_CADET_LocalData) + size);
copy->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
- copy->channel_id = id;
+ copy->ccn = ccn;
GNUNET_SERVER_notification_context_unicast (nc, c->handle,
©->header, GNUNET_NO);
}
* Get a channel from a client.
*
* @param c Client to check.
- * @param chid Channel ID, must be local (> 0x800...).
+ * @param ccn Channel ID, must be local (> 0x800...).
*
* @return non-NULL if channel exists in the clients lists
*/
struct CadetChannel *
GML_channel_get (struct CadetClient *c,
- struct GNUNET_CADET_ClientChannelNumber chid);
+ struct GNUNET_CADET_ClientChannelNumber ccn);
/**
* Add a channel to a client
*
* @param client Client.
- * @param chid Channel ID.
+ * @param ccn Channel ID.
* @param ch Channel.
*/
void
GML_channel_add (struct CadetClient *client,
- struct GNUNET_CADET_ClientChannelNumber chid,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
struct CadetChannel *ch);
/**
* Remove a channel from a client
*
* @param client Client.
- * @param chid Channel ID.
+ * @param ccn Channel ID.
* @param ch Channel.
*/
void
GML_channel_remove (struct CadetClient *client,
- struct GNUNET_CADET_ClientChannelNumber chid,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
struct CadetChannel *ch);
/**
* @return LID of a channel free to use.
*/
struct GNUNET_CADET_ClientChannelNumber
-GML_get_next_chid (struct CadetClient *c);
+GML_get_next_ccn (struct CadetClient *c);
/**
* Check if client has registered with the service and has not disconnected
/**
* Channel ID for the next created channel.
*/
- struct GNUNET_CADET_ChannelTunnelNumber next_chid;
+ struct GNUNET_CADET_ChannelTunnelNumber next_ctn;
/**
* Destroy flag: if true, destroy on last message.
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
msg.header.size = htons (sizeof (msg));
- msg.chid = gid;
+ msg.ctn = gid;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"WARNING destroying unknown channel %u on tunnel %s\n",
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL == ch)
{
GNUNET_STATISTICS_update (stats,
GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"channel 0x%X unknown\n",
- ntohl (msg->chid.cn));
- send_channel_destroy (t, msg->chid);
+ ntohl (msg->ctn.cn));
+ send_channel_destroy (t, msg->ctn);
return;
}
}
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL == ch)
{
GNUNET_STATISTICS_update (stats, "# data ack on unknown channel",
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING channel %u unknown\n",
- ntohl (msg->chid.cn));
+ ntohl (msg->ctn.cn));
return;
}
}
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL != ch && ! GCT_is_loopback (t))
{
/* Probably a retransmission, safe to ignore */
}
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL == ch)
{
GNUNET_STATISTICS_update (stats, "# channel NACK on unknown channel",
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"WARNING channel %u unknown\n",
- ntohl (msg->chid.cn));
+ ntohl (msg->ctn.cn));
return;
}
}
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL == ch)
{
GNUNET_STATISTICS_update (stats,
GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"WARNING channel %u unknown\n",
- ntohl (msg->chid.cn));
+ ntohl (msg->ctn.cn));
return;
}
}
/* Check channel */
- ch = GCT_get_channel (t, msg->chid);
+ ch = GCT_get_channel (t, msg->ctn);
if (NULL == ch)
{
/* Probably a retransmission, safe to ignore */
struct CadetTunnel *t;
t = GNUNET_new (struct CadetTunnel);
- t->next_chid.cn = 0;
+ t->next_ctn.cn = 0;
t->peer = destination;
if (GNUNET_OK !=
* Search for a channel by global ID.
*
* @param t Tunnel containing the channel.
- * @param chid Public channel number.
+ * @param ctn Public channel number.
*
* @return channel handler, NULL if doesn't exist
*/
struct CadetChannel *
GCT_get_channel (struct CadetTunnel *t,
- struct GNUNET_CADET_ChannelTunnelNumber chid)
+ struct GNUNET_CADET_ChannelTunnelNumber ctn)
{
struct CadetTChannel *iter;
for (iter = t->channel_head; NULL != iter; iter = iter->next)
{
- if (GCCH_get_id (iter->ch).cn == chid.cn)
+ if (GCCH_get_id (iter->ch).cn == ctn.cn)
break;
}
* @return GID of a channel free to use.
*/
struct GNUNET_CADET_ChannelTunnelNumber
-GCT_get_next_chid (struct CadetTunnel *t)
+GCT_get_next_ctn (struct CadetTunnel *t)
{
- struct GNUNET_CADET_ChannelTunnelNumber chid;
+ struct GNUNET_CADET_ChannelTunnelNumber ctn;
struct GNUNET_CADET_ChannelTunnelNumber mask;
int result;
mask.cn = htonl (0x40000000);
else
mask.cn = 0x0;
- t->next_chid.cn |= mask.cn;
+ t->next_ctn.cn |= mask.cn;
- while (NULL != GCT_get_channel (t, t->next_chid))
+ while (NULL != GCT_get_channel (t, t->next_ctn))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Channel %u exists...\n",
- t->next_chid.cn);
- t->next_chid.cn = htonl ((ntohl (t->next_chid.cn) + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
- t->next_chid.cn |= mask.cn;
+ t->next_ctn.cn);
+ t->next_ctn.cn = htonl ((ntohl (t->next_ctn.cn) + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
+ t->next_ctn.cn |= mask.cn;
}
- chid = t->next_chid;
- t->next_chid.cn = (t->next_chid.cn + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
- t->next_chid.cn |= mask.cn;
+ ctn = t->next_ctn;
+ t->next_ctn.cn = (t->next_ctn.cn + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
+ t->next_ctn.cn |= mask.cn;
- return chid;
+ return ctn;
}
* Search for a channel by global ID.
*
* @param t Tunnel containing the channel.
- * @param chid Public channel number.
+ * @param ctn Public channel number.
*
* @return channel handler, NULL if doesn't exist
*/
struct CadetChannel *
-GCT_get_channel (struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber chid);
+GCT_get_channel (struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn);
/**
* @return ID of a channel free to use.
*/
struct GNUNET_CADET_ChannelTunnelNumber
-GCT_get_next_chid (struct CadetTunnel *t);
+GCT_get_next_ctn (struct CadetTunnel *t);
/**