static struct CadetTConnection *
get_ready_connection (struct CadetTunnel *t)
{
- return t->connection_ready_head;
+ struct CadetTConnection *hd = t->connection_ready_head;
+
+ GNUNET_assert ( (NULL == hd) ||
+ (GNUNET_YES == hd->is_ready) );
+ return hd;
}
struct GNUNET_CADET_TunnelKeyExchangeMessage *msg;
enum GNUNET_CADET_KX_Flags flags;
- if (NULL == ct)
+ if ( (NULL == ct) ||
+ (GNUNET_NO == ct->is_ready) )
ct = get_ready_connection (t);
if (NULL == ct)
{
{
/* This KX_AUTH is not using the latest KX/KX_AUTH data
we transmitted to the sender, refuse it, try KX again. */
- GNUNET_break_op (0);
+ GNUNET_STATISTICS_update (stats,
+ "# KX_AUTH not using our last KX received (auth failure)",
+ 1,
+ GNUNET_NO);
send_kx (t,
- NULL,
+ ct,
&t->ax);
return;
}
struct CadetTunnel *t = ct->t;
if (GNUNET_YES == ct->is_ready)
+ {
GNUNET_CONTAINER_DLL_remove (t->connection_ready_head,
t->connection_ready_tail,
ct);
+ t->num_ready_connections--;
+ }
else
+ {
GNUNET_CONTAINER_DLL_remove (t->connection_busy_head,
t->connection_busy_tail,
ct);
+ t->num_busy_connections--;
+ }
GNUNET_free (ct);
}
struct CadetPeerPath *p,
unsigned int off)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Considering %s for %s\n",
+ GCPP_2s (p),
+ GCT_2s (t));
(void) consider_path_cb (t,
p,
off);
case CADET_TUNNEL_KEY_UNINITIALIZED:
case CADET_TUNNEL_KEY_AX_RECV:
/* We did not even SEND our KX, how can the other peer
- send us encrypted data? */
- GNUNET_break_op (0);
+ send us encrypted data? Must have been that we went
+ down and the other peer still things we are up.
+ Let's send it KX back. */
+ GNUNET_STATISTICS_update (stats,
+ "# received encrypted without any KX",
+ 1,
+ GNUNET_NO);
+ if (NULL != t->kx_task)
+ {
+ GNUNET_SCHEDULER_cancel (t->kx_task);
+ t->kx_task = NULL;
+ }
+ send_kx (t,
+ ct,
+ &t->ax);
return;
case CADET_TUNNEL_KEY_AX_SENT_AND_RECV:
/* We send KX, and other peer send KX to us at the same time.
break;
}
- GNUNET_STATISTICS_update (stats,
- "# received encrypted",
- 1,
- GNUNET_NO);
decrypted_size = -1;
if (CADET_TUNNEL_KEY_OK == t->estate)
{
if (-1 == decrypted_size)
{
/* Decryption failed for good, complain. */
- GNUNET_break_op (0);
LOG (GNUNET_ERROR_TYPE_WARNING,
- "%s failed to decrypt and validate encrypted data\n",
+ "%s failed to decrypt and validate encrypted data, retrying KX\n",
GCT_2s (t));
GNUNET_STATISTICS_update (stats,
"# unable to decrypt",
1,
GNUNET_NO);
+ if (NULL != t->kx_task)
+ {
+ GNUNET_SCHEDULER_cancel (t->kx_task);
+ t->kx_task = NULL;
+ }
+ send_kx (t,
+ ct,
+ &t->ax);
return;
}
+ GNUNET_STATISTICS_update (stats,
+ "# decrypted bytes",
+ decrypted_size,
+ GNUNET_NO);
/* The MST will ultimately call #handle_decrypted() on each message. */
t->current_ct = ct;
&ax_msg[1],
message,
payload_size);
+ GNUNET_STATISTICS_update (stats,
+ "# encrypted bytes",
+ payload_size,
+ GNUNET_NO);
ax_msg->ax_header.Ns = htonl (t->ax.Ns++);
ax_msg->ax_header.PNs = htonl (t->ax.PNs);
/* FIXME: we should do this once, not once per message;