aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_tunnels.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_tunnels.c')
-rw-r--r--src/cadet/gnunet-service-cadet_tunnels.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnels.c b/src/cadet/gnunet-service-cadet_tunnels.c
index dbd84a818..1e7a8e086 100644
--- a/src/cadet/gnunet-service-cadet_tunnels.c
+++ b/src/cadet/gnunet-service-cadet_tunnels.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013, 2017, 2018 GNUnet e.V. 3 Copyright (C) 2013, 2017, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file cadet/gnunet-service-cadet_tunnels.c 19 * @file cadet/gnunet-service-cadet_tunnels.c
@@ -459,13 +457,13 @@ struct CadetTunnel
459 457
460 458
461/** 459/**
462 * Am I Alice or Bob, or talking to myself? 460 * Am I Alice or Betty (some call her Bob), or talking to myself?
463 * 461 *
464 * @param other the other peer 462 * @param other the other peer
465 * @return #GNUNET_YES for Alice, #GNUNET_NO for Bob, #GNUNET_SYSERR if talking to myself 463 * @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself
466 */ 464 */
467static int 465static int
468alice_or_bob (const struct GNUNET_PeerIdentity *other) 466alice_or_betty (const struct GNUNET_PeerIdentity *other)
469{ 467{
470 if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, 468 if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id,
471 other)) 469 other))
@@ -1347,7 +1345,7 @@ send_kx (struct CadetTunnel *t,
1347 struct GNUNET_CADET_TunnelKeyExchangeMessage *msg; 1345 struct GNUNET_CADET_TunnelKeyExchangeMessage *msg;
1348 enum GNUNET_CADET_KX_Flags flags; 1346 enum GNUNET_CADET_KX_Flags flags;
1349 1347
1350 if (GNUNET_YES != alice_or_bob (GCP_get_id (t->destination))) 1348 if (GNUNET_YES != alice_or_betty (GCP_get_id (t->destination)))
1351 return; /* only Alice may send KX */ 1349 return; /* only Alice may send KX */
1352 if ( (NULL == ct) || 1350 if ( (NULL == ct) ||
1353 (GNUNET_NO == ct->is_ready) ) 1351 (GNUNET_NO == ct->is_ready) )
@@ -1523,7 +1521,7 @@ update_ax_by_kx (struct CadetTunnelAxolotl *ax,
1523 const char salt[] = "CADET Axolotl salt"; 1521 const char salt[] = "CADET Axolotl salt";
1524 int am_I_alice; 1522 int am_I_alice;
1525 1523
1526 if (GNUNET_SYSERR == (am_I_alice = alice_or_bob (pid))) 1524 if (GNUNET_SYSERR == (am_I_alice = alice_or_betty (pid)))
1527 { 1525 {
1528 GNUNET_break_op (0); 1526 GNUNET_break_op (0);
1529 return GNUNET_SYSERR; 1527 return GNUNET_SYSERR;
@@ -1726,9 +1724,9 @@ GCT_handle_kx (struct CadetTConnection *ct,
1726 1, 1724 1,
1727 GNUNET_NO); 1725 GNUNET_NO);
1728 if (GNUNET_YES == 1726 if (GNUNET_YES ==
1729 alice_or_bob (GCP_get_id (t->destination))) 1727 alice_or_betty (GCP_get_id (t->destination)))
1730 { 1728 {
1731 /* Bob is not allowed to send KX! */ 1729 /* Betty/Bob is not allowed to send KX! */
1732 GNUNET_break_op (0); 1730 GNUNET_break_op (0);
1733 return; 1731 return;
1734 } 1732 }
@@ -2048,6 +2046,13 @@ GCT_handle_kx_auth (struct CadetTConnection *ct,
2048 Nothing to do here. */ 2046 Nothing to do here. */
2049 break; 2047 break;
2050 } 2048 }
2049 if (0 != (GNUNET_CADET_KX_FLAG_FORCE_REPLY & ntohl (msg->kx.flags)))
2050 {
2051 send_kx_auth (t,
2052 NULL,
2053 &t->ax,
2054 GNUNET_NO);
2055 }
2051} 2056}
2052 2057
2053 2058
@@ -2422,8 +2427,6 @@ connection_ready_cb (void *cls,
2422 { 2427 {
2423 case CADET_TUNNEL_KEY_UNINITIALIZED: 2428 case CADET_TUNNEL_KEY_UNINITIALIZED:
2424 /* Do not begin KX if WE have no channels waiting! */ 2429 /* Do not begin KX if WE have no channels waiting! */
2425 if (0 == GCT_count_channels (t))
2426 return;
2427 if (0 != GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt).rel_value_us) 2430 if (0 != GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt).rel_value_us)
2428 return; /* wait for timeout before retrying */ 2431 return; /* wait for timeout before retrying */
2429 /* We are uninitialized, just transmit immediately, 2432 /* We are uninitialized, just transmit immediately,
@@ -2436,6 +2439,15 @@ connection_ready_cb (void *cls,
2436 send_kx (t, 2439 send_kx (t,
2437 ct, 2440 ct,
2438 &t->ax); 2441 &t->ax);
2442 if ( (0 ==
2443 GCT_count_channels (t)) &&
2444 (NULL == t->destroy_task) )
2445 {
2446 t->destroy_task
2447 = GNUNET_SCHEDULER_add_delayed (IDLE_DESTROY_DELAY,
2448 &destroy_tunnel,
2449 t);
2450 }
2439 break; 2451 break;
2440 case CADET_TUNNEL_KEY_AX_RECV: 2452 case CADET_TUNNEL_KEY_AX_RECV:
2441 case CADET_TUNNEL_KEY_AX_SENT: 2453 case CADET_TUNNEL_KEY_AX_SENT: