diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_connection.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index c07339ebc..1dac9eb1e 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -26,6 +26,7 @@ | |||
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | */ | 27 | */ |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_signatures.h" | ||
29 | #include "gnunet-service-cadet_connection.h" | 30 | #include "gnunet-service-cadet_connection.h" |
30 | #include "gnunet-service-cadet_channel.h" | 31 | #include "gnunet-service-cadet_channel.h" |
31 | #include "gnunet-service-cadet_paths.h" | 32 | #include "gnunet-service-cadet_paths.h" |
@@ -78,7 +79,6 @@ enum CadetConnectionState | |||
78 | CADET_CONNECTION_READY | 79 | CADET_CONNECTION_READY |
79 | }; | 80 | }; |
80 | 81 | ||
81 | |||
82 | /** | 82 | /** |
83 | * Low-level connection to a destination. | 83 | * Low-level connection to a destination. |
84 | */ | 84 | */ |
@@ -206,6 +206,14 @@ update_state (struct CadetConnection *cc, | |||
206 | int old_ready; | 206 | int old_ready; |
207 | int new_ready; | 207 | int new_ready; |
208 | 208 | ||
209 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
210 | "Trying to update connection state for %s having old state %d to new %d and mqm_ready old %d to mqm_ready new %d\n", | ||
211 | GCT_2s (cc->ct->t), | ||
212 | cc->state, | ||
213 | new_state, | ||
214 | cc->mqm_ready, | ||
215 | new_mqm_ready); | ||
216 | |||
209 | if ((new_state == cc->state) && (new_mqm_ready == cc->mqm_ready)) | 217 | if ((new_state == cc->state) && (new_mqm_ready == cc->mqm_ready)) |
210 | return; /* no change, nothing to do */ | 218 | return; /* no change, nothing to do */ |
211 | old_ready = | 219 | old_ready = |
@@ -214,6 +222,13 @@ update_state (struct CadetConnection *cc, | |||
214 | ((CADET_CONNECTION_READY == new_state) && (GNUNET_YES == new_mqm_ready)); | 222 | ((CADET_CONNECTION_READY == new_state) && (GNUNET_YES == new_mqm_ready)); |
215 | cc->state = new_state; | 223 | cc->state = new_state; |
216 | cc->mqm_ready = new_mqm_ready; | 224 | cc->mqm_ready = new_mqm_ready; |
225 | |||
226 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
227 | "Updating connection state for %s having old_ready %d and new_rady %d\n", | ||
228 | GCT_2s (cc->ct->t), | ||
229 | old_ready, | ||
230 | new_ready); | ||
231 | |||
217 | if (old_ready != new_ready) | 232 | if (old_ready != new_ready) |
218 | cc->ready_cb (cc->ready_cb_cls, new_ready); | 233 | cc->ready_cb (cc->ready_cb_cls, new_ready); |
219 | } | 234 | } |
@@ -392,7 +407,7 @@ send_keepalive (void *cls) | |||
392 | msg.size = htons (sizeof(msg)); | 407 | msg.size = htons (sizeof(msg)); |
393 | msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE); | 408 | msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE); |
394 | 409 | ||
395 | cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc); | 410 | cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc, NULL); |
396 | } | 411 | } |
397 | 412 | ||
398 | 413 | ||
@@ -580,6 +595,20 @@ GCC_handle_encrypted (struct CadetConnection *cc, | |||
580 | } | 595 | } |
581 | 596 | ||
582 | 597 | ||
598 | void | ||
599 | set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage *msg) | ||
600 | { | ||
601 | |||
602 | struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl ( | ||
603 | GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR), | ||
604 | .purpose.size = htonl (sizeof(cp)), | ||
605 | .monotonic_time = msg->monotime}; | ||
606 | |||
607 | GNUNET_CRYPTO_eddsa_sign (my_private_key, &cp, | ||
608 | &msg->monotime_sig); | ||
609 | |||
610 | } | ||
611 | |||
583 | /** | 612 | /** |
584 | * Send a #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE message to the | 613 | * Send a #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE message to the |
585 | * first hop. | 614 | * first hop. |
@@ -593,6 +622,7 @@ send_create (void *cls) | |||
593 | struct GNUNET_CADET_ConnectionCreateMessage *create_msg; | 622 | struct GNUNET_CADET_ConnectionCreateMessage *create_msg; |
594 | struct GNUNET_PeerIdentity *pids; | 623 | struct GNUNET_PeerIdentity *pids; |
595 | struct GNUNET_MQ_Envelope *env; | 624 | struct GNUNET_MQ_Envelope *env; |
625 | struct CadetTunnel *t; | ||
596 | 626 | ||
597 | cc->task = NULL; | 627 | cc->task = NULL; |
598 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 628 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
@@ -603,6 +633,18 @@ send_create (void *cls) | |||
603 | // 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. | 633 | // 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. |
604 | create_msg->options = 2; | 634 | create_msg->options = 2; |
605 | create_msg->cid = cc->cid; | 635 | create_msg->cid = cc->cid; |
636 | |||
637 | // check for tunnel state and set signed monotime (xrs,t3ss) | ||
638 | t = GCP_get_tunnel (cc->destination, GNUNET_YES); | ||
639 | if ((NULL != t)&& (GCT_get_estate (t) == CADET_TUNNEL_KEY_UNINITIALIZED) && | ||
640 | (GCT_alice_or_betty (GCP_get_id (cc->destination)) == GNUNET_NO)) | ||
641 | { | ||
642 | create_msg->has_monotime = GNUNET_YES; | ||
643 | create_msg->monotime = GNUNET_TIME_absolute_hton ( | ||
644 | GNUNET_TIME_absolute_get_monotonic (cfg)); | ||
645 | set_monotime_sig (create_msg); | ||
646 | } | ||
647 | |||
606 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; | 648 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; |
607 | pids[0] = my_full_id; | 649 | pids[0] = my_full_id; |
608 | for (unsigned int i = 0; i <= cc->off; i++) | 650 | for (unsigned int i = 0; i <= cc->off; i++) |
@@ -792,6 +834,7 @@ connection_create (struct CadetPeer *destination, | |||
792 | cc = GNUNET_new (struct CadetConnection); | 834 | cc = GNUNET_new (struct CadetConnection); |
793 | cc->state = init_state; | 835 | cc->state = init_state; |
794 | cc->ct = ct; | 836 | cc->ct = ct; |
837 | cc->destination = destination; /* xrs,t3ss,lurchi*/ | ||
795 | cc->cid = *cid; | 838 | cc->cid = *cid; |
796 | cc->retry_delay = | 839 | cc->retry_delay = |
797 | GNUNET_TIME_relative_multiply (INITIAL_CONNECTION_CREATE_RETRY_DELAY, off); | 840 | GNUNET_TIME_relative_multiply (INITIAL_CONNECTION_CREATE_RETRY_DELAY, off); |