[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35652 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35652 - gnunet/src/cadet |
Date: |
Mon, 27 Apr 2015 21:15:58 +0200 |
Author: bartpolot
Date: 2015-04-27 21:15:58 +0200 (Mon, 27 Apr 2015)
New Revision: 35652
Modified:
gnunet/src/cadet/cadet_protocol.h
gnunet/src/cadet/gnunet-service-cadet_tunnel.c
gnunet/src/cadet/gnunet-service-cadet_tunnel.h
gnunet/src/cadet/test_cadet.c
Log:
- resend ax kx when lost
Modified: gnunet/src/cadet/cadet_protocol.h
===================================================================
--- gnunet/src/cadet/cadet_protocol.h 2015-04-27 19:15:57 UTC (rev 35651)
+++ gnunet/src/cadet/cadet_protocol.h 2015-04-27 19:15:58 UTC (rev 35652)
@@ -122,6 +122,11 @@
struct GNUNET_MessageHeader header;
/**
+ * Should the peer reply with its KX details?
+ */
+ uint32_t force_reply;
+
+ /**
* An EdDSA signature of the permanent ECDH key with the Peer's ID key.
*/
struct GNUNET_CRYPTO_EddsaSignature signature;
Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c 2015-04-27 19:15:57 UTC
(rev 35651)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c 2015-04-27 19:15:58 UTC
(rev 35652)
@@ -2008,6 +2008,29 @@
/**
+ * @brief Resend the AX KX until we complete the handshake.
+ *
+ * @param cls Closure (tunnel).
+ * @param tc Task context.
+ */
+static void
+ax_kx_resend (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct CadetTunnel *t = cls;
+
+ t->rekey_task = NULL;
+
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+
+ if (CADET_TUNNEL_KEY_OK == t->estate)
+ return;
+
+ GCT_send_ax_kx (t, GNUNET_YES);
+}
+
+
+/**
* Callback called when a queued message is sent.
*
* @param cls Closure.
@@ -2018,15 +2041,31 @@
*/
static void
ephm_sent (void *cls,
- struct CadetConnection *c,
- struct CadetConnectionQueue *q,
- uint16_t type, int fwd, size_t size)
+ struct CadetConnection *c,
+ struct CadetConnectionQueue *q,
+ uint16_t type, int fwd, size_t size)
{
struct CadetTunnel *t = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG, "ephemeral sent %s\n", GC_m2s (type));
+
t->ephm_h = NULL;
+
+ if (CADET_TUNNEL_KEY_OK == t->estate)
+ return;
+
+ if (CADET_Axolotl == t->enc_type && CADET_TUNNEL_KEY_OK != t->estate)
+ {
+ if (NULL != t->rekey_task)
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (t->rekey_task);
+ }
+ t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &ax_kx_resend, t);
+ }
}
+
/**
* Callback called when a queued message is sent.
*
@@ -2048,6 +2087,7 @@
t->pong_h = NULL;
}
+
/**
* Sends key exchange message on a tunnel, choosing the best connection.
* Should not be called on loopback tunnels.
@@ -2663,6 +2703,17 @@
GNUNET_free (t->ax);
t->ax = NULL;
+
+ if (NULL != t->rekey_task)
+ {
+ GNUNET_SCHEDULER_cancel (t->rekey_task);
+ t->rekey_task = NULL;
+ }
+ if (NULL != t->ephm_h)
+ {
+ GCC_cancel (t->ephm_h);
+ t->ephm_h = NULL;
+ }
}
@@ -2846,6 +2897,12 @@
return;
}
+ if (GNUNET_YES == ntohl (msg->force_reply))
+ GCT_send_ax_kx (t, GNUNET_NO);
+
+ if (CADET_TUNNEL_KEY_OK == t->estate)
+ return;
+
LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
ax = t->ax;
@@ -3228,7 +3285,7 @@
else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered kx\n");
- GCT_send_ax_kx (t);
+ GCT_send_ax_kx (t, GNUNET_NO);
}
else
{
@@ -4126,9 +4183,10 @@
* Send an Axolotl KX message.
*
* @param t Tunnel on which to send it.
+ * @param force_reply Force the other peer to reply with a KX message.
*/
void
-GCT_send_ax_kx (struct CadetTunnel *t)
+GCT_send_ax_kx (struct CadetTunnel *t, int force_reply)
{
struct GNUNET_CADET_AX_KX msg;
@@ -4141,6 +4199,7 @@
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX);
+ msg.force_reply = htonl (force_reply);
msg.permanent_key = ax_identity.permanent_key;
msg.purpose = ax_identity.purpose;
msg.signature = ax_identity.signature;
Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.h 2015-04-27 19:15:57 UTC
(rev 35651)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.h 2015-04-27 19:15:58 UTC
(rev 35652)
@@ -446,9 +446,10 @@
* Send an Axolotl KX message.
*
* @param t Tunnel on which to send it.
+ * @param force_reply Force the other peer to reply with a KX message.
*/
void
-GCT_send_ax_kx (struct CadetTunnel *t);
+GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
/**
* Sends an already built and encrypted message on a tunnel, choosing the best
Modified: gnunet/src/cadet/test_cadet.c
===================================================================
--- gnunet/src/cadet/test_cadet.c 2015-04-27 19:15:57 UTC (rev 35651)
+++ gnunet/src/cadet/test_cadet.c 2015-04-27 19:15:58 UTC (rev 35652)
@@ -33,7 +33,7 @@
/**
* How many messages to send
*/
-#define TOTAL_PACKETS 50
+#define TOTAL_PACKETS 500
/**
* How long until we give up on connecting the peers?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35652 - gnunet/src/cadet,
gnunet <=