From: t3sserakt Date: Fri, 3 Jan 2020 19:27:29 +0000 (+0100) Subject: merged master into branch X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3b99011d3a4453df8ad0d33821ac3be399209399;p=oweals%2Fgnunet.git merged master into branch --- 3b99011d3a4453df8ad0d33821ac3be399209399 diff --cc src/cadet/gnunet-service-cadet_channel.h index 80fc43477,0a6c97329..06e1f21ef --- a/src/cadet/gnunet-service-cadet_channel.h +++ b/src/cadet/gnunet-service-cadet_channel.h @@@ -54,23 -54,9 +54,16 @@@ struct CadetChannel */ 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. diff --cc src/cadet/gnunet-service-cadet_connection.c index 4d9a40927,c07339ebc..3eb5eb8f8 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@@ -406,10 -389,10 +404,10 @@@ send_keepalive (void *cls 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); } @@@ -615,16 -598,11 +613,16 @@@ send_create (void *cls 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++) diff --cc src/cadet/gnunet-service-cadet_core.c index c90c97fca,d54022896..5359370e6 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c @@@ -724,12 -721,11 +721,12 @@@ handle_connection_create 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, diff --cc src/cadet/gnunet-service-cadet_tunnels.c index 8999b26da,a1098d757..639b4956f --- a/src/cadet/gnunet-service-cadet_tunnels.c +++ b/src/cadet/gnunet-service-cadet_tunnels.c @@@ -463,15 -464,14 +464,14 @@@ struct CadetTunne * @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 { @@@ -1343,22 -1353,10 +1353,10 @@@ send_kx (struct CadetTunnel *t 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) { @@@ -2432,20 -2437,12 +2438,21 @@@ connection_ready_cb (void *cls 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); diff --cc src/cadet/gnunet-service-cadet_tunnels.h index 9da81881c,ef07badea..20cdabc80 --- a/src/cadet/gnunet-service-cadet_tunnels.h +++ b/src/cadet/gnunet-service-cadet_tunnels.h @@@ -79,17 -78,8 +78,16 @@@ enum CadetTunnelEStat * 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. diff --cc src/cadet/test_cadet.c index 1500af813,25713709c..4b7c16ec5 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c @@@ -518,36 -514,8 +520,36 @@@ handle_data (void *cls */ 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.