*/
void
GCCH_hash_port (struct GNUNET_HashCode *h_port,
- const struct GNUNET_HashCode *port,
- const struct GNUNET_PeerIdentity *listener);
- /**
- * Check if type of message is the one to drop.
- * @param ch CadetChannel to assign type to drop.
- * @param message GNUNET_CADET_RequestDropCadetMessage to get the type from.
- */
- void
- GCCH_assign_type_to_drop(struct CadetChannel *ch, const struct GNUNET_CADET_RequestDropCadetMessage *message);
+ const struct GNUNET_HashCode *port,
+ const struct GNUNET_PeerIdentity *listener);
+/**
+ * Check if type of message is the one to drop.
+ * @param ch CadetChannel to check for message type to drop.
+ * @param message GNUNET_MessageHeader to compare the type with.
+ */
+int
+GCCH_is_type_to_drop(struct CadetChannel *ch, const struct GNUNET_MessageHeader *message);
/**
* Get the static string for identification of the channel.
GCC_2s (cc),
GCT_2s (cc->ct->t));
GNUNET_STATISTICS_update (stats, "# keepalives sent", 1, GNUNET_NO);
- msg.size = htons (sizeof (msg));
+ msg.size = htons (sizeof(msg));
msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE);
- cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc);
+ cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc, NULL);
}
GNUNET_assert (GNUNET_YES == cc->mqm_ready);
env =
GNUNET_MQ_msg_extra (create_msg,
- (2 + cc->off) * sizeof (struct GNUNET_PeerIdentity),
+ (2 + cc->off) * sizeof(struct GNUNET_PeerIdentity),
GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE);
- //TODO This will be removed in a major release, because this will be a protocol breaking change. We set the deprecated 'reliable' bit here that was removed.
+ // TODO This will be removed in a major release, because this will be a protocol breaking change. We set the deprecated 'reliable' bit here that was removed.
create_msg->options = 2;
create_msg->cid = cc->cid;
+
+ // check for tunnel state and define tunnel_up (xrs,t3ss)
+ t = GCP_get_tunnel (cc->destination, GNUNET_YES);
+ create_msg->tunnel_up = (t->estate == CADET_TUNNEL_KEY_UNINITIALIZED)? GNUNET_NO : GNUNET_YES;
+
pids = (struct GNUNET_PeerIdentity *) &create_msg[1];
pids[0] = my_full_id;
for (unsigned int i = 0; i <= cc->off; i++)
const struct GNUNET_PeerIdentity *pids =
(const struct GNUNET_PeerIdentity *) &msg[1];
struct CadetRoute *route;
- uint16_t size = ntohs (msg->header.size) - sizeof (*msg);
+ uint16_t size = ntohs (msg->header.size) - sizeof(*msg);
unsigned int path_length;
unsigned int off;
+ struct CadetTunnel *t;
- path_length = size / sizeof (struct GNUNET_PeerIdentity);
+ path_length = size / sizeof(struct GNUNET_PeerIdentity);
if (0 == path_length)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
* @param other the other peer
* @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself
*/
-static int
-alice_or_betty (const struct GNUNET_PeerIdentity *other)
+int
+GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other)
{
-
if (0 > GNUNET_memcmp (&my_full_id,
- other))
+ other))
return GNUNET_YES;
else if (0 < GNUNET_memcmp (&my_full_id,
- other))
+ other))
return GNUNET_NO;
else
{
struct GNUNET_CADET_TunnelKeyExchangeMessage *msg;
enum GNUNET_CADET_KX_Flags flags;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Will we ever send a KX message?\n");
-
- if (GNUNET_YES != alice_or_betty (GCP_get_id (t->destination)))
+ if (GNUNET_YES != GCT_alice_or_betty (GCP_get_id (t->destination)))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Only Alice may send KX to %s!\n",
- GCT_2s (t));
return; /* only Alice may send KX */
- }
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "It is Alice!\n");
-
- if ( (NULL == ct) ||
- (GNUNET_NO == ct->is_ready) )
+ if ((NULL == ct) ||
+ (GNUNET_NO == ct->is_ready))
ct = get_ready_connection (t);
if (NULL == ct)
{
switch (t->estate)
{
case CADET_TUNNEL_KEY_UNINITIALIZED:
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Do not begin KX for %s if WE have no channels waiting. Retrying after %d\n",
+ GCT_2s (t),
+ GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt).rel_value_us);
/* Do not begin KX if WE have no channels waiting! */
- if (0 != GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt).rel_value_us)
- return; /* wait for timeout before retrying */
+ if (0 != GNUNET_TIME_absolute_get_remaining (
+ t->next_kx_attempt).rel_value_us)
+ return; /* wait for timeout before retrying */
/* We are uninitialized, just transmit immediately,
without undue delay. */
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Why for %s \n",
+ GCT_2s (t));
+
if (NULL != t->kx_task)
{
GNUNET_SCHEDULER_cancel (t->kx_task);
* Handshake completed: session key available.
*/
CADET_TUNNEL_KEY_OK
-
};
+/**
+ * Am I Alice or Betty (some call her Bob), or talking to myself?
+ *
+ * @param other the other peer
+ * @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself
+ */
+int
+GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other);
/**
* Get the static string for the peer this tunnel is directed.
*/
static void
disconnect_handler (void *cls,
- const struct GNUNET_CADET_Channel *channel);
+ const struct GNUNET_CADET_Channel *channel);
+static struct GNUNET_PeerIdentity *
+get_from_p_ids()
+{
+ if (0 < GNUNET_memcmp (p_id[0], p_id[1]))
+ {
+ return p_id[1];
+ }else
+ {
+ return p_id[0];
+ }
+}
+
+static struct GNUNET_CADET_Handle *
+get_from_cadets()
+{
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "1\n");
+ if (0 < GNUNET_memcmp (p_id[0], p_id[1]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "standard peer\n");
+ return cadets_running[0];
+ }else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "the other peer\n");
+ return cadets_running[peers_running - 1];
+ }
+
+}
/**
* Task to reconnect to other peer.