* @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)
* @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)
* @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)
*
* @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,
*
* @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,
*
* @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,
*
* @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,
* @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);
* @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);
* @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);
*
* @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,
*
* @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,
*
* @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,
*
* @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,
* @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,
* 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)
* @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)
* @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)
* @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)
* @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);
* @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);
* @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);
* @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,
* @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,
/**
- * 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)
*
* @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)
*
* @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);
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);
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);
}
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);
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;
+ }
}
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);
}
"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))
*
* @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)
* @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)
*
* @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);
* @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);
*/
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.
*/