diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_tunnels.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnels.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnels.c b/src/cadet/gnunet-service-cadet_tunnels.c index f1f2ec81f..66e7d5b1e 100644 --- a/src/cadet/gnunet-service-cadet_tunnels.c +++ b/src/cadet/gnunet-service-cadet_tunnels.c | |||
@@ -464,8 +464,8 @@ struct CadetTunnel | |||
464 | * @param other the other peer | 464 | * @param other the other peer |
465 | * @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself | 465 | * @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself |
466 | */ | 466 | */ |
467 | static int | 467 | int |
468 | alice_or_betty (const struct GNUNET_PeerIdentity *other) | 468 | GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other) |
469 | { | 469 | { |
470 | if (0 > GNUNET_memcmp (&my_full_id, | 470 | if (0 > GNUNET_memcmp (&my_full_id, |
471 | other)) | 471 | other)) |
@@ -1345,7 +1345,7 @@ send_kx (struct CadetTunnel *t, | |||
1345 | struct GNUNET_CADET_TunnelKeyExchangeMessage *msg; | 1345 | struct GNUNET_CADET_TunnelKeyExchangeMessage *msg; |
1346 | enum GNUNET_CADET_KX_Flags flags; | 1346 | enum GNUNET_CADET_KX_Flags flags; |
1347 | 1347 | ||
1348 | if (GNUNET_YES != alice_or_betty (GCP_get_id (t->destination))) | 1348 | if (GNUNET_YES != GCT_alice_or_betty (GCP_get_id (t->destination))) |
1349 | return; /* only Alice may send KX */ | 1349 | return; /* only Alice may send KX */ |
1350 | if ((NULL == ct) || | 1350 | if ((NULL == ct) || |
1351 | (GNUNET_NO == ct->is_ready)) | 1351 | (GNUNET_NO == ct->is_ready)) |
@@ -1521,7 +1521,7 @@ update_ax_by_kx (struct CadetTunnelAxolotl *ax, | |||
1521 | const char salt[] = "CADET Axolotl salt"; | 1521 | const char salt[] = "CADET Axolotl salt"; |
1522 | int am_I_alice; | 1522 | int am_I_alice; |
1523 | 1523 | ||
1524 | if (GNUNET_SYSERR == (am_I_alice = alice_or_betty (pid))) | 1524 | if (GNUNET_SYSERR == (am_I_alice = GCT_alice_or_betty (pid))) |
1525 | { | 1525 | { |
1526 | GNUNET_break_op (0); | 1526 | GNUNET_break_op (0); |
1527 | return GNUNET_SYSERR; | 1527 | return GNUNET_SYSERR; |
@@ -1726,7 +1726,7 @@ GCT_handle_kx (struct CadetTConnection *ct, | |||
1726 | 1, | 1726 | 1, |
1727 | GNUNET_NO); | 1727 | GNUNET_NO); |
1728 | if (GNUNET_YES == | 1728 | if (GNUNET_YES == |
1729 | alice_or_betty (GCP_get_id (t->destination))) | 1729 | GCT_alice_or_betty (GCP_get_id (t->destination))) |
1730 | { | 1730 | { |
1731 | /* Betty/Bob is not allowed to send KX! */ | 1731 | /* Betty/Bob is not allowed to send KX! */ |
1732 | GNUNET_break_op (0); | 1732 | GNUNET_break_op (0); |
@@ -2123,9 +2123,10 @@ GCT_add_channel (struct CadetTunnel *t, | |||
2123 | ch, | 2123 | ch, |
2124 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 2124 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
2125 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2125 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2126 | "Adding %s to %s\n", | 2126 | "Adding %s to %s with state %d\n", |
2127 | GCCH_2s (ch), | 2127 | GCCH_2s (ch), |
2128 | GCT_2s (t)); | 2128 | GCT_2s (t), |
2129 | t->estate); | ||
2129 | switch (t->estate) | 2130 | switch (t->estate) |
2130 | { | 2131 | { |
2131 | case CADET_TUNNEL_KEY_UNINITIALIZED: | 2132 | case CADET_TUNNEL_KEY_UNINITIALIZED: |
@@ -2429,12 +2430,21 @@ connection_ready_cb (void *cls, | |||
2429 | switch (t->estate) | 2430 | switch (t->estate) |
2430 | { | 2431 | { |
2431 | case CADET_TUNNEL_KEY_UNINITIALIZED: | 2432 | case CADET_TUNNEL_KEY_UNINITIALIZED: |
2433 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2434 | "Do not begin KX for %s if WE have no channels waiting. Retrying after %d\n", | ||
2435 | GCT_2s (t), | ||
2436 | GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt).rel_value_us); | ||
2432 | /* Do not begin KX if WE have no channels waiting! */ | 2437 | /* Do not begin KX if WE have no channels waiting! */ |
2433 | if (0 != GNUNET_TIME_absolute_get_remaining ( | 2438 | if (0 != GNUNET_TIME_absolute_get_remaining ( |
2434 | t->next_kx_attempt).rel_value_us) | 2439 | t->next_kx_attempt).rel_value_us) |
2435 | return; /* wait for timeout before retrying */ | 2440 | return; /* wait for timeout before retrying */ |
2436 | /* We are uninitialized, just transmit immediately, | 2441 | /* We are uninitialized, just transmit immediately, |
2437 | without undue delay. */ | 2442 | without undue delay. */ |
2443 | |||
2444 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2445 | "Why for %s \n", | ||
2446 | GCT_2s (t)); | ||
2447 | |||
2438 | if (NULL != t->kx_task) | 2448 | if (NULL != t->kx_task) |
2439 | { | 2449 | { |
2440 | GNUNET_SCHEDULER_cancel (t->kx_task); | 2450 | GNUNET_SCHEDULER_cancel (t->kx_task); |
@@ -3028,7 +3038,8 @@ GCT_send_channel_destroy (struct CadetTunnel *t, | |||
3028 | GCT_send (t, | 3038 | GCT_send (t, |
3029 | &msg.header, | 3039 | &msg.header, |
3030 | NULL, | 3040 | NULL, |
3031 | NULL); | 3041 | NULL, |
3042 | &ctn); | ||
3032 | } | 3043 | } |
3033 | 3044 | ||
3034 | 3045 | ||
@@ -3445,18 +3456,32 @@ GCT_handle_encrypted (struct CadetTConnection *ct, | |||
3445 | * @param t Tunnel on which this message is transmitted. | 3456 | * @param t Tunnel on which this message is transmitted. |
3446 | * @param cont Continuation to call once message is really sent. | 3457 | * @param cont Continuation to call once message is really sent. |
3447 | * @param cont_cls Closure for @c cont. | 3458 | * @param cont_cls Closure for @c cont. |
3459 | * @param The ID of the channel we are using for sending. | ||
3448 | * @return Handle to cancel message | 3460 | * @return Handle to cancel message |
3449 | */ | 3461 | */ |
3450 | struct CadetTunnelQueueEntry * | 3462 | struct CadetTunnelQueueEntry * |
3451 | GCT_send (struct CadetTunnel *t, | 3463 | GCT_send (struct CadetTunnel *t, |
3452 | const struct GNUNET_MessageHeader *message, | 3464 | const struct GNUNET_MessageHeader *message, |
3453 | GCT_SendContinuation cont, | 3465 | GCT_SendContinuation cont, |
3454 | void *cont_cls) | 3466 | void *cont_cls, |
3467 | struct GNUNET_CADET_ChannelTunnelNumber *ctn) | ||
3455 | { | 3468 | { |
3456 | struct CadetTunnelQueueEntry *tq; | 3469 | struct CadetTunnelQueueEntry *tq; |
3457 | uint16_t payload_size; | 3470 | uint16_t payload_size; |
3458 | struct GNUNET_MQ_Envelope *env; | 3471 | struct GNUNET_MQ_Envelope *env; |
3459 | struct GNUNET_CADET_TunnelEncryptedMessage *ax_msg; | 3472 | struct GNUNET_CADET_TunnelEncryptedMessage *ax_msg; |
3473 | struct CadetChannel *ch; | ||
3474 | |||
3475 | if (NULL != ctn) | ||
3476 | { | ||
3477 | ch = lookup_channel (t, | ||
3478 | *ctn); | ||
3479 | if ((NULL != ch)&& GCCH_is_type_to_drop (ch, message)) | ||
3480 | { | ||
3481 | GNUNET_break (0); | ||
3482 | return NULL; | ||
3483 | } | ||
3484 | } | ||
3460 | 3485 | ||
3461 | if (CADET_TUNNEL_KEY_OK != t->estate) | 3486 | if (CADET_TUNNEL_KEY_OK != t->estate) |
3462 | { | 3487 | { |