[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30582 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30582 - gnunet/src/mesh |
Date: |
Wed, 6 Nov 2013 23:34:36 +0100 |
Author: bartpolot
Date: 2013-11-06 23:34:36 +0100 (Wed, 06 Nov 2013)
New Revision: 30582
Modified:
gnunet/src/mesh/gnunet-service-mesh_channel.c
gnunet/src/mesh/gnunet-service-mesh_channel.h
gnunet/src/mesh/gnunet-service-mesh_connection.c
gnunet/src/mesh/gnunet-service-mesh_connection.h
gnunet/src/mesh/gnunet-service-mesh_local.c
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/gnunet-service-mesh_peer.h
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
gnunet/src/mesh/gnunet-service-mesh_tunnel.h
gnunet/src/mesh/mesh_protocol_enc.h
Log:
- refactoring
- fixes
- doxygen
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -1014,7 +1014,7 @@
* @param ch Channel.
* @param fwd Is query about FWD traffic? (Request root status).
*
- * @return GNUNET_YES if client is allowed to send us data.
+ * @return #GNUNET_YES if client is allowed to send us data.
*/
int
GMCH_get_allowed (struct MeshChannel *ch, int fwd)
@@ -1033,7 +1033,7 @@
* @param ch Channel.
* @param fwd Is this for fwd traffic?
*
- * @return GNUNET_YES in case it is.
+ * @return #GNUNET_YES in case it is.
*/
int
GMCH_is_origin (struct MeshChannel *ch, int fwd)
@@ -1051,7 +1051,7 @@
* @param ch Channel.
* @param fwd Is this for fwd traffic?
*
- * @return GNUNET_YES in case it is.
+ * @return #GNUNET_YES in case it is.
*/
int
GMCH_is_terminal (struct MeshChannel *ch, int fwd)
@@ -1449,7 +1449,7 @@
*
* @param ch Channel for the message.
* @param msg Unencryted data message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_data (struct MeshChannel *ch,
@@ -1604,7 +1604,7 @@
*
* @param t Tunnel this channel will be in.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
struct MeshChannel *
GMCH_handle_create (struct MeshTunnel3 *t,
@@ -1661,7 +1661,7 @@
*
* @param ch Channel.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_ack (struct MeshChannel *ch,
@@ -1677,7 +1677,7 @@
*
* @param ch Channel to be destroyed of.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_destroy (struct MeshChannel *ch,
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -91,7 +91,7 @@
* @param ch Channel.
* @param fwd Is query about FWD traffic? (Request root status).
*
- * @return GNUNET_YES if client is allowed to send us data.
+ * @return #GNUNET_YES if client is allowed to send us data.
*/
int
GMCH_get_allowed (struct MeshChannel *ch, int fwd);
@@ -103,7 +103,7 @@
* @param ch Channel.
* @param fwd Is this for fwd traffic?
*
- * @return GNUNET_YES in case it is.
+ * @return #GNUNET_YES in case it is.
*/
int
GMCH_is_origin (struct MeshChannel *ch, int fwd);
@@ -114,7 +114,7 @@
* @param ch Channel.
* @param fwd Is this for fwd traffic?
*
- * @return GNUNET_YES in case it is.
+ * @return #GNUNET_YES in case it is.
*/
int
GMCH_is_terminal (struct MeshChannel *ch, int fwd);
@@ -240,7 +240,7 @@
*
* @param ch Channel for the message.
* @param msg Unencryted data message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_data (struct MeshChannel *ch,
@@ -264,7 +264,7 @@
*
* @param t Tunnel this channel will be in.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
struct MeshChannel *
GMCH_handle_create (struct MeshTunnel3 *t,
@@ -276,7 +276,7 @@
*
* @param ch Channel this channel is to be created in.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_ack (struct MeshChannel *ch,
@@ -288,7 +288,7 @@
*
* @param ch Channel this channel is to be destroyed of.
* @param msg Message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
+ * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
*/
void
GMCH_handle_destroy (struct MeshChannel *ch,
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -561,8 +561,10 @@
* @param c Connection to check.
* @param sender Peer identity of neighbor.
*
- * @return GNUNET_YES in case the sender is the 'prev' hop and therefore
- * the traffic is 'FWD'. GNUNET_NO for BCK. GNUNET_SYSERR for errors.
+ * @return #GNUNET_YES in case the sender is the 'prev' hop and therefore
+ * the traffic is 'FWD'.
+ * #GNUNET_NO for BCK.
+ * #GNUNET_SYSERR for errors.
*/
static int
is_fwd (const struct MeshConnection *c,
@@ -669,7 +671,7 @@
* Send CONNECTION_{CREATE/ACK} packets for a connection.
*
* @param c Connection for which to send the message.
- * @param fwd If GNUNET_YES, send CREATE, otherwise send ACK.
+ * @param fwd If #GNUNET_YES, send CREATE, otherwise send ACK.
*/
static void
connection_recreate (struct MeshConnection *c, int fwd)
@@ -2143,7 +2145,7 @@
* @param c Connection.
* @param fwd Is this about fwd traffic?
*
- * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
+ * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal.
*/
int
GMC_is_origin (struct MeshConnection *c, int fwd)
@@ -2163,7 +2165,7 @@
* @param fwd Is this about fwd traffic?
* Note that the ROOT is the terminal for BCK traffic!
*
- * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
+ * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin.
*/
int
GMC_is_terminal (struct MeshConnection *c, int fwd)
@@ -2178,7 +2180,7 @@
* @param c Connection.
* @param fwd Is this about fwd traffic?
*
- * @return GNUNET_YES in case it's OK.
+ * @return #GNUNET_YES in case it's OK to send.
*/
int
GMC_is_sendable (struct MeshConnection *c, int fwd)
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -379,7 +379,7 @@
* @param c Connection.
* @param fwd Is this about fwd traffic?
*
- * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
+ * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal.
*/
int
GMC_is_origin (struct MeshConnection *c, int fwd);
@@ -391,7 +391,7 @@
* @param fwd Is this about fwd traffic?
* Note that the ROOT is the terminal for BCK traffic!
*
- * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
+ * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin.
*/
int
GMC_is_terminal (struct MeshConnection *c, int fwd);
@@ -402,7 +402,7 @@
* @param c Connection.
* @param fwd Is this about fwd traffic?
*
- * @return GNUNET_YES in case it's OK.
+ * @return #GNUNET_YES in case it's OK to send.
*/
int
GMC_is_sendable (struct MeshConnection *c, int fwd);
Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2013-11-06 22:33:59 UTC (rev
30581)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2013-11-06 22:34:36 UTC (rev
30582)
@@ -573,7 +573,7 @@
* @param key Key (hashed tunnel ID, unused).
* @param value Tunnel info.
*
- * @return GNUNET_YES, to keep iterating.
+ * @return #GNUNET_YES, to keep iterating.
*/
// static int
// monitor_all_tunnels_iterator (void *cls,
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-11-06 22:33:59 UTC (rev
30581)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-11-06 22:34:36 UTC (rev
30582)
@@ -215,8 +215,7 @@
* @param key Current key code (peer id).
* @param value Value in the hash map (connection).
*
- * @return GNUNET_YES if we should continue to iterate,
- * GNUNET_NO if not.
+ * @return #GNUNET_YES to continue to iterate.
*/
static int
notify_broken (void *cls,
@@ -546,11 +545,11 @@
/**
- * Returns if peer is used (has a tunnel, is neighbor).
+ * Returns if peer is used (has a tunnel or is neighbor).
*
* @param peer Peer to check.
*
- * @return GNUNET_YES if peer is in use.
+ * @return #GNUNET_YES if peer is in use.
*/
static int
peer_is_used (struct MeshPeer *peer)
@@ -1371,7 +1370,7 @@
*
* @param peer Peer to check.
*
- * @return GNUNET_YES if there is a direct connection.
+ * @return #GNUNET_YES if there is a direct connection.
*/
int
GMP_is_neighbor (const struct MeshPeer *peer)
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-11-06 22:33:59 UTC (rev
30581)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-11-06 22:34:36 UTC (rev
30582)
@@ -159,7 +159,7 @@
*
* @param peer Peer to check.
*
- * @return GNUNET_YES if there is a direct connection.
+ * @return #GNUNET_YES if there is a direct connection.
*/
int
GMP_is_neighbor (const struct MeshPeer *peer);
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -592,7 +592,7 @@
t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
- if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
+ if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
return;
t->kx_ctx = GNUNET_new (struct MeshTunnelKXCtx);
@@ -600,7 +600,20 @@
UINT32_MAX);
t->kx_ctx->d_key_old = t->d_key;
send_ephemeral (t);
- send_ping (t);
+ if (MESH_TUNNEL3_READY == t->state)
+ {
+ send_ping (t);
+ t->state = MESH_TUNNEL3_REKEY;
+ }
+ else if (MESH_TUNNEL3_WAITING == t->state)
+ {
+ t->state = MESH_TUNNEL3_KEY_SENT;
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Unexpected state %u\n", t->state);
+ }
+
t->rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_WAIT, &rekey_tunnel, t);
}
@@ -624,6 +637,9 @@
long n = (long) cls;
uint32_t r;
+ if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task)
+ return GNUNET_YES;
+
r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t) n *
100);
delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, r);
t->rekey_task = GNUNET_SCHEDULER_add_delayed (delay, &rekey_tunnel, t);
@@ -856,6 +872,11 @@
derive_key_material (&km, &msg->ephemeral_key);
derive_symmertic (&t->e_key, &my_full_id, GMP_get_id (t->peer), &km);
derive_symmertic (&t->d_key, GMP_get_id (t->peer), &my_full_id, &km);
+ if (MESH_TUNNEL3_KEY_SENT == t->state)
+ {
+ send_ping (t);
+ t->state = MESH_TUNNEL3_PING_SENT;
+ }
}
@@ -898,17 +919,30 @@
handle_pong (struct MeshTunnel3 *t,
const struct GNUNET_MESH_KX_Pong *msg)
{
- if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task)
+ uint32_t challenge;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "PONG received\n");
+ if (GNUNET_SCHEDULER_NO_TASK == t->rekey_task)
{
- GNUNET_SCHEDULER_cancel (t->rekey_task);
- t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_free (t->kx_ctx);
- t->kx_ctx = NULL;
+ GNUNET_break_op (0);
+ return;
}
- else
+ t_decrypt (t, &challenge, &msg->nonce, sizeof (uint32_t), msg->iv);
+
+ if (challenge != t->kx_ctx->challenge)
{
- GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Wrong PONG challenge: %u. Expected: %u.\n",
+ challenge, t->kx_ctx->challenge);
+ GNUNET_break_op (0);
+ return;
}
+ GNUNET_SCHEDULER_cancel (t->rekey_task);
+ t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_free (t->kx_ctx);
+ t->kx_ctx = NULL;
+ send_queued_data (t, GNUNET_YES);
+ send_queued_data (t, GNUNET_NO);
}
@@ -1137,10 +1171,9 @@
"Tunnel %s state is now %s\n",
GMP_2s (t->peer),
GMT_state2s (state));
- if (MESH_TUNNEL3_WAITING == t->state)
+ if (MESH_TUNNEL3_WAITING == t->state && MESH_TUNNEL3_READY == state)
{
- send_queued_data (t, GNUNET_YES);
- send_queued_data (t, GNUNET_NO);
+ rekey_tunnel (t, NULL);
}
t->state = state;
if (MESH_TUNNEL3_READY == state && 3 <= GMT_count_connections (t))
@@ -1731,7 +1764,7 @@
*
* @param t Tunnel.
*
- * @return GNUNET_YES if it is loopback.
+ * @return #GNUNET_YES if it is loopback.
*/
int
GMT_is_loopback (const struct MeshTunnel3 *t)
@@ -1746,7 +1779,7 @@
* @param t Tunnel.
* @param p Path.
*
- * @return GNUNET_YES a connection uses this path.
+ * @return #GNUNET_YES a connection uses this path.
*/
int
GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p)
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2013-11-06 22:33:59 UTC
(rev 30581)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2013-11-06 22:34:36 UTC
(rev 30582)
@@ -353,7 +353,7 @@
*
* @param t Tunnel.
*
- * @return GNUNET_YES if it is loopback.
+ * @return #GNUNET_YES if it is loopback.
*/
int
GMT_is_loopback (const struct MeshTunnel3 *t);
@@ -364,7 +364,7 @@
* @param t Tunnel.
* @param p Path.
*
- * @return GNUNET_YES a connection uses this path.
+ * @return #GNUNET_YES a connection uses this path.
*/
int
GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p);
Modified: gnunet/src/mesh/mesh_protocol_enc.h
===================================================================
--- gnunet/src/mesh/mesh_protocol_enc.h 2013-11-06 22:33:59 UTC (rev 30581)
+++ gnunet/src/mesh/mesh_protocol_enc.h 2013-11-06 22:34:36 UTC (rev 30582)
@@ -220,12 +220,6 @@
uint32_t iv GNUNET_PACKED;
/**
- * Intended target of the PING, used primarily to check
- * that decryption actually worked.
- */
- struct GNUNET_PeerIdentity target;
-
- /**
* Same nonce as in the reve.
*/
uint32_t nonce GNUNET_PACKED;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30582 - gnunet/src/mesh,
gnunet <=