/*
This file is part of GNUnet.
- Copyright (C) 2013 GNUnet e.V.
+ Copyright (C) 2013, 2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
+/**
+ * @file cadet/gnunet-service-cadet_tunnel.c
+ * @brief logical links between CADET clients
+ * @author Bartlomiej Polot
+ */
#include "platform.h"
#include "gnunet_util_lib.h"
-
#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
-
#include "cadet_protocol.h"
#include "cadet_path.h"
-
#include "gnunet-service-cadet_tunnel.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_channel.h"
/**
* 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.
{
case CADET_TUNNEL_KEY_UNINITIALIZED:
return "CADET_TUNNEL_KEY_UNINITIALIZED";
- case CADET_TUNNEL_KEY_SENT:
- return "CADET_TUNNEL_KEY_SENT";
- case CADET_TUNNEL_KEY_PING:
- return "CADET_TUNNEL_KEY_PING";
+ case CADET_TUNNEL_KEY_AX_SENT:
+ return "CADET_TUNNEL_KEY_AX_SENT";
+ case CADET_TUNNEL_KEY_AX_AUTH_SENT:
+ return "CADET_TUNNEL_KEY_AX_AUTH_SENT";
case CADET_TUNNEL_KEY_OK:
return "CADET_TUNNEL_KEY_OK";
case CADET_TUNNEL_KEY_REKEY:
conn_ok = CADET_TUNNEL_READY == t->cstate;
enc_ok = CADET_TUNNEL_KEY_OK == t->estate
|| CADET_TUNNEL_KEY_REKEY == t->estate
- || CADET_TUNNEL_KEY_PING == t->estate;
+ || CADET_TUNNEL_KEY_AX_AUTH_SENT == t->estate;
ready = conn_ok && enc_ok;
ready = ready || GCT_is_loopback (t);
return ready;
return;
}
- GCT_send_kx (t, CADET_TUNNEL_KEY_SENT >= t->estate);
+ GCT_send_kx (t, CADET_TUNNEL_KEY_AX_SENT >= t->estate);
}
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 */
if (-1 == decrypted_size)
{
GNUNET_STATISTICS_update (stats, "# unable to decrypt", 1, GNUNET_NO);
- if (CADET_TUNNEL_KEY_PING <= t->estate)
+ if (CADET_TUNNEL_KEY_AX_AUTH_SENT <= t->estate)
{
GNUNET_break_op (0);
LOG (GNUNET_ERROR_TYPE_WARNING, "Wrong crypto, tunnel %s\n", GCT_2s (t));
ax->Nr = 0;
ax->Ns = 0;
- GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
+ GCT_change_estate (t, CADET_TUNNEL_KEY_AX_AUTH_SENT);
send_queued_data (t);
CADET_TIMING_END;
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;
}
GCC_is_origin (c, GNUNET_YES),
GNUNET_YES, &ephm_sent, t);
if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
- GCT_change_estate (t, CADET_TUNNEL_KEY_SENT);
+ GCT_change_estate (t, CADET_TUNNEL_KEY_AX_SENT);
}