diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-21 19:45:41 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-21 19:45:41 +0100 |
commit | 742aa628e2045b947a9e55b60b0e976ea6658c9a (patch) | |
tree | eade56d7ee1a30281f94e1af8cec2da57e35e5db /src/cadet | |
parent | 308518cb6fbc4b635fccd87a770f66cc2e2816f3 (diff) | |
download | gnunet-742aa628e2045b947a9e55b60b0e976ea6658c9a.tar.gz gnunet-742aa628e2045b947a9e55b60b0e976ea6658c9a.zip |
more logging, minor bugfixes / renames
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_protocol.h | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 42 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.h | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.c | 65 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.h | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_core.c | 6 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.c | 297 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.h | 8 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 6 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.h | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 4 |
11 files changed, 295 insertions, 143 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index 3a70758d9..24145a008 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h | |||
@@ -87,7 +87,7 @@ struct GNUNET_CADET_ConnectionCreateMessage | |||
87 | /** | 87 | /** |
88 | * Message for ack'ing a connection | 88 | * Message for ack'ing a connection |
89 | */ | 89 | */ |
90 | struct GNUNET_CADET_ConnectionCreateMessageAckMessage | 90 | struct GNUNET_CADET_ConnectionCreateAckMessage |
91 | { | 91 | { |
92 | /** | 92 | /** |
93 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK | 93 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index e64e66dfa..a3ab07c3c 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include "gnunet-service-cadet-new_peer.h" | 44 | #include "gnunet-service-cadet-new_peer.h" |
45 | #include "gnunet-service-cadet-new_paths.h" | 45 | #include "gnunet-service-cadet-new_paths.h" |
46 | 46 | ||
47 | #define LOG(level,...) GNUNET_log_from (level,"cadet-channel",__VA_ARGS__) | 47 | #define LOG(level,...) GNUNET_log_from (level,"cadet-chn",__VA_ARGS__) |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * How long do we initially wait before retransmitting? | 50 | * How long do we initially wait before retransmitting? |
@@ -405,7 +405,7 @@ channel_destroy (struct CadetChannel *ch) | |||
405 | * @param cls Channel for which to send. | 405 | * @param cls Channel for which to send. |
406 | */ | 406 | */ |
407 | static void | 407 | static void |
408 | send_create (void *cls); | 408 | send_channel_open (void *cls); |
409 | 409 | ||
410 | 410 | ||
411 | /** | 411 | /** |
@@ -415,25 +415,25 @@ send_create (void *cls); | |||
415 | * @param cls our `struct CadetChannel`. | 415 | * @param cls our `struct CadetChannel`. |
416 | */ | 416 | */ |
417 | static void | 417 | static void |
418 | create_sent_cb (void *cls) | 418 | channel_open_sent_cb (void *cls) |
419 | { | 419 | { |
420 | struct CadetChannel *ch = cls; | 420 | struct CadetChannel *ch = cls; |
421 | 421 | ||
422 | ch->last_control_qe = NULL; | 422 | ch->last_control_qe = NULL; |
423 | ch->retry_time = GNUNET_TIME_STD_BACKOFF (ch->retry_time); | 423 | ch->retry_time = GNUNET_TIME_STD_BACKOFF (ch->retry_time); |
424 | ch->retry_task = GNUNET_SCHEDULER_add_delayed (ch->retry_time, | 424 | ch->retry_task = GNUNET_SCHEDULER_add_delayed (ch->retry_time, |
425 | &send_create, | 425 | &send_channel_open, |
426 | ch); | 426 | ch); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | /** | 430 | /** |
431 | * Send a channel create message. | 431 | * Send a channel open message. |
432 | * | 432 | * |
433 | * @param cls Channel for which to send. | 433 | * @param cls Channel for which to send. |
434 | */ | 434 | */ |
435 | static void | 435 | static void |
436 | send_create (void *cls) | 436 | send_channel_open (void *cls) |
437 | { | 437 | { |
438 | struct CadetChannel *ch = cls; | 438 | struct CadetChannel *ch = cls; |
439 | struct GNUNET_CADET_ChannelOpenMessage msgcc; | 439 | struct GNUNET_CADET_ChannelOpenMessage msgcc; |
@@ -454,8 +454,11 @@ send_create (void *cls) | |||
454 | ch->state = CADET_CHANNEL_CREATE_SENT; | 454 | ch->state = CADET_CHANNEL_CREATE_SENT; |
455 | ch->last_control_qe = GCT_send (ch->t, | 455 | ch->last_control_qe = GCT_send (ch->t, |
456 | &msgcc.header, | 456 | &msgcc.header, |
457 | &create_sent_cb, | 457 | &channel_open_sent_cb, |
458 | ch); | 458 | ch); |
459 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
460 | "Sending CHANNEL_OPEN message for channel %s\n", | ||
461 | GCCH_2s (ch)); | ||
459 | } | 462 | } |
460 | 463 | ||
461 | 464 | ||
@@ -491,7 +494,7 @@ GCCH_channel_local_new (struct CadetClient *owner, | |||
491 | ch->ctn = GCT_add_channel (ch->t, | 494 | ch->ctn = GCT_add_channel (ch->t, |
492 | ch); | 495 | ch); |
493 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; | 496 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; |
494 | ch->retry_task = GNUNET_SCHEDULER_add_now (&send_create, | 497 | ch->retry_task = GNUNET_SCHEDULER_add_now (&send_channel_open, |
495 | ch); | 498 | ch); |
496 | GNUNET_STATISTICS_update (stats, | 499 | GNUNET_STATISTICS_update (stats, |
497 | "# channels", | 500 | "# channels", |
@@ -611,7 +614,7 @@ send_ack_cb (void *cls) | |||
611 | * @param ch channel to send the ACK for | 614 | * @param ch channel to send the ACK for |
612 | */ | 615 | */ |
613 | static void | 616 | static void |
614 | send_channel_ack (struct CadetChannel *ch) | 617 | send_channel_data_ack (struct CadetChannel *ch) |
615 | { | 618 | { |
616 | struct GNUNET_CADET_ChannelDataAckMessage msg; | 619 | struct GNUNET_CADET_ChannelDataAckMessage msg; |
617 | 620 | ||
@@ -641,7 +644,7 @@ send_connect_ack (void *cls) | |||
641 | struct CadetChannel *ch = cls; | 644 | struct CadetChannel *ch = cls; |
642 | 645 | ||
643 | ch->retry_task = NULL; | 646 | ch->retry_task = NULL; |
644 | send_channel_ack (ch); | 647 | send_channel_data_ack (ch); |
645 | } | 648 | } |
646 | 649 | ||
647 | 650 | ||
@@ -792,7 +795,7 @@ GCCH_channel_incoming_destroy (struct CadetChannel *ch) | |||
792 | * @param ch channel to destroy | 795 | * @param ch channel to destroy |
793 | */ | 796 | */ |
794 | void | 797 | void |
795 | GCCH_handle_channel_create_ack (struct CadetChannel *ch) | 798 | GCCH_handle_channel_open_ack (struct CadetChannel *ch) |
796 | { | 799 | { |
797 | switch (ch->state) | 800 | switch (ch->state) |
798 | { | 801 | { |
@@ -807,6 +810,9 @@ GCCH_handle_channel_create_ack (struct CadetChannel *ch) | |||
807 | GNUNET_break_op (0); | 810 | GNUNET_break_op (0); |
808 | return; | 811 | return; |
809 | } | 812 | } |
813 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
814 | "Received channel OPEN_ACK for waiting channel %s, entering READY state\n", | ||
815 | GCCH_2s (ch)); | ||
810 | ch->state = CADET_CHANNEL_READY; | 816 | ch->state = CADET_CHANNEL_READY; |
811 | /* On first connect, send client as many ACKs as we allow messages | 817 | /* On first connect, send client as many ACKs as we allow messages |
812 | to be buffered! */ | 818 | to be buffered! */ |
@@ -816,6 +822,9 @@ GCCH_handle_channel_create_ack (struct CadetChannel *ch) | |||
816 | break; | 822 | break; |
817 | case CADET_CHANNEL_READY: | 823 | case CADET_CHANNEL_READY: |
818 | /* duplicate ACK, maybe we retried the CREATE. Ignore. */ | 824 | /* duplicate ACK, maybe we retried the CREATE. Ignore. */ |
825 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
826 | "Received duplicate channel OPEN_ACK for channel %s\n", | ||
827 | GCCH_2s (ch)); | ||
819 | GNUNET_STATISTICS_update (stats, | 828 | GNUNET_STATISTICS_update (stats, |
820 | "# duplicate CREATE_ACKs", | 829 | "# duplicate CREATE_ACKs", |
821 | 1, | 830 | 1, |
@@ -876,6 +885,10 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
876 | size_t payload_size; | 885 | size_t payload_size; |
877 | 886 | ||
878 | payload_size = ntohs (msg->header.size) - sizeof (*msg); | 887 | payload_size = ntohs (msg->header.size) - sizeof (*msg); |
888 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
889 | "Receicved %u bytes of application data on channel %s\n", | ||
890 | (unsigned int) payload_size, | ||
891 | GCCH_2s (ch)); | ||
879 | env = GNUNET_MQ_msg_extra (ld, | 892 | env = GNUNET_MQ_msg_extra (ld, |
880 | payload_size, | 893 | payload_size, |
881 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); | 894 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); |
@@ -966,7 +979,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
966 | /* ACK for message we already dropped, might have been a | 979 | /* ACK for message we already dropped, might have been a |
967 | duplicate ACK? Ignore. */ | 980 | duplicate ACK? Ignore. */ |
968 | GNUNET_STATISTICS_update (stats, | 981 | GNUNET_STATISTICS_update (stats, |
969 | "# duplicate CHANNEL_DATA_ACKs", | 982 | "# duplicate DATA_ACKs", |
970 | 1, | 983 | 1, |
971 | GNUNET_NO); | 984 | GNUNET_NO); |
972 | return; | 985 | return; |
@@ -995,6 +1008,9 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch) | |||
995 | struct GNUNET_MQ_Envelope *env; | 1008 | struct GNUNET_MQ_Envelope *env; |
996 | struct GNUNET_CADET_LocalChannelDestroyMessage *tdm; | 1009 | struct GNUNET_CADET_LocalChannelDestroyMessage *tdm; |
997 | 1010 | ||
1011 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1012 | "Received remote channel DESTROY for channel %s\n", | ||
1013 | GCCH_2s (ch)); | ||
998 | ch->destroy = GNUNET_YES; | 1014 | ch->destroy = GNUNET_YES; |
999 | env = GNUNET_MQ_msg (tdm, | 1015 | env = GNUNET_MQ_msg (tdm, |
1000 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY); | 1016 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY); |
@@ -1255,7 +1271,7 @@ send_client_buffered_data (struct CadetChannel *ch) | |||
1255 | "Sender on channel %s likely blocked on flow-control, sending ACK now.\n", | 1271 | "Sender on channel %s likely blocked on flow-control, sending ACK now.\n", |
1256 | GCCH_2s (ch)); | 1272 | GCCH_2s (ch)); |
1257 | if (GNUNET_YES == ch->reliable) | 1273 | if (GNUNET_YES == ch->reliable) |
1258 | send_channel_ack (ch); | 1274 | send_channel_data_ack (ch); |
1259 | } | 1275 | } |
1260 | 1276 | ||
1261 | if (NULL != ch->head_recv) | 1277 | if (NULL != ch->head_recv) |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.h b/src/cadet/gnunet-service-cadet-new_channel.h index 2e1eb4115..a479145aa 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.h +++ b/src/cadet/gnunet-service-cadet-new_channel.h | |||
@@ -174,7 +174,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
174 | * @param ch channel to destroy | 174 | * @param ch channel to destroy |
175 | */ | 175 | */ |
176 | void | 176 | void |
177 | GCCH_handle_channel_create_ack (struct CadetChannel *ch); | 177 | GCCH_handle_channel_open_ack (struct CadetChannel *ch); |
178 | 178 | ||
179 | 179 | ||
180 | /** | 180 | /** |
diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 5eb6335a2..55b33e224 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c | |||
@@ -40,6 +40,9 @@ | |||
40 | #include "cadet_protocol.h" | 40 | #include "cadet_protocol.h" |
41 | 41 | ||
42 | 42 | ||
43 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-con",__VA_ARGS__) | ||
44 | |||
45 | |||
43 | /** | 46 | /** |
44 | * All the states a connection can be in. | 47 | * All the states a connection can be in. |
45 | */ | 48 | */ |
@@ -158,6 +161,9 @@ GCC_destroy (struct CadetConnection *cc) | |||
158 | { | 161 | { |
159 | struct GNUNET_MQ_Envelope *env = NULL; | 162 | struct GNUNET_MQ_Envelope *env = NULL; |
160 | 163 | ||
164 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
165 | "Destroying connection %s\n", | ||
166 | GCC_2s (cc)); | ||
161 | if (CADET_CONNECTION_SENDING_CREATE != cc->state) | 167 | if (CADET_CONNECTION_SENDING_CREATE != cc->state) |
162 | { | 168 | { |
163 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; | 169 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; |
@@ -201,8 +207,12 @@ GCC_get_ct (struct CadetConnection *cc) | |||
201 | * @param cc the connection that got the ACK. | 207 | * @param cc the connection that got the ACK. |
202 | */ | 208 | */ |
203 | void | 209 | void |
204 | GCC_handle_connection_ack (struct CadetConnection *cc) | 210 | GCC_handle_connection_create_ack (struct CadetConnection *cc) |
205 | { | 211 | { |
212 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
213 | "Received CREATE_ACK for connection %s in state %d\n", | ||
214 | GCC_2s (cc), | ||
215 | cc->state); | ||
206 | if (NULL != cc->task) | 216 | if (NULL != cc->task) |
207 | { | 217 | { |
208 | GNUNET_SCHEDULER_cancel (cc->task); | 218 | GNUNET_SCHEDULER_cancel (cc->task); |
@@ -234,7 +244,10 @@ GCC_handle_kx (struct CadetConnection *cc, | |||
234 | { | 244 | { |
235 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, | 245 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, |
236 | clearly something is working, so pretend we got an ACK. */ | 246 | clearly something is working, so pretend we got an ACK. */ |
237 | GCC_handle_connection_ack (cc); | 247 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
248 | "Faking connection ACK for connection %s due to KX\n", | ||
249 | GCC_2s (cc)); | ||
250 | GCC_handle_connection_create_ack (cc); | ||
238 | } | 251 | } |
239 | GCT_handle_kx (cc->ct, | 252 | GCT_handle_kx (cc->ct, |
240 | msg); | 253 | msg); |
@@ -255,7 +268,10 @@ GCC_handle_encrypted (struct CadetConnection *cc, | |||
255 | { | 268 | { |
256 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, | 269 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, |
257 | clearly something is working, so pretend we got an ACK. */ | 270 | clearly something is working, so pretend we got an ACK. */ |
258 | GCC_handle_connection_ack (cc); | 271 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
272 | "Faking connection ACK for connection %s due to ENCRYPTED payload\n", | ||
273 | GCC_2s (cc)); | ||
274 | GCC_handle_connection_create_ack (cc); | ||
259 | } | 275 | } |
260 | GCT_handle_encrypted (cc->ct, | 276 | GCT_handle_encrypted (cc->ct, |
261 | msg); | 277 | msg); |
@@ -287,6 +303,9 @@ send_create (void *cls) | |||
287 | for (unsigned int i=0;i<path_length;i++) | 303 | for (unsigned int i=0;i<path_length;i++) |
288 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, | 304 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, |
289 | i)); | 305 | i)); |
306 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
307 | "Sending CONNECTION_CREATE message for connection %s\n", | ||
308 | GCC_2s (cc)); | ||
290 | cc->env = env; | 309 | cc->env = env; |
291 | cc->mqm_ready = GNUNET_NO; | 310 | cc->mqm_ready = GNUNET_NO; |
292 | cc->state = CADET_CONNECTION_SENT; | 311 | cc->state = CADET_CONNECTION_SENT; |
@@ -304,22 +323,17 @@ static void | |||
304 | send_create_ack (void *cls) | 323 | send_create_ack (void *cls) |
305 | { | 324 | { |
306 | struct CadetConnection *cc = cls; | 325 | struct CadetConnection *cc = cls; |
307 | struct GNUNET_CADET_ConnectionCreateMessage *create_msg; | 326 | struct GNUNET_CADET_ConnectionCreateAckMessage *ack_msg; |
308 | struct GNUNET_PeerIdentity *pids; | ||
309 | struct GNUNET_MQ_Envelope *env; | 327 | struct GNUNET_MQ_Envelope *env; |
310 | unsigned int path_length; | ||
311 | 328 | ||
312 | cc->task = NULL; | 329 | cc->task = NULL; |
330 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
331 | "Sending CONNECTION_CREATE_ACK message for connection %s\n", | ||
332 | GCC_2s (cc)); | ||
313 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 333 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
314 | path_length = GCPP_get_length (cc->path); | 334 | env = GNUNET_MQ_msg (ack_msg, |
315 | env = GNUNET_MQ_msg_extra (create_msg, | 335 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK); |
316 | path_length * sizeof (struct GNUNET_PeerIdentity), | 336 | ack_msg->cid = cc->cid; |
317 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); | ||
318 | create_msg->cid = cc->cid; | ||
319 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; | ||
320 | for (unsigned int i=0;i<path_length;i++) | ||
321 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, | ||
322 | i)); | ||
323 | cc->env = env; | 337 | cc->env = env; |
324 | cc->mqm_ready = GNUNET_NO; | 338 | cc->mqm_ready = GNUNET_NO; |
325 | cc->state = CADET_CONNECTION_READY; | 339 | cc->state = CADET_CONNECTION_READY; |
@@ -340,11 +354,13 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
340 | { | 354 | { |
341 | if (GNUNET_YES == cc->mqm_ready) | 355 | if (GNUNET_YES == cc->mqm_ready) |
342 | { | 356 | { |
357 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
358 | "Got duplicate CREATE for connection %s, scheduling another ACK\n", | ||
359 | GCC_2s (cc)); | ||
343 | /* Tell tunnel that we are not ready for transmission anymore | 360 | /* Tell tunnel that we are not ready for transmission anymore |
344 | (until CREATE_ACK is done) */ | 361 | (until CREATE_ACK is done) */ |
345 | cc->ready_cb (cc->ready_cb_cls, | 362 | cc->ready_cb (cc->ready_cb_cls, |
346 | GNUNET_NO); | 363 | GNUNET_NO); |
347 | |||
348 | /* Revert back to the state of having only received the 'CREATE', | 364 | /* Revert back to the state of having only received the 'CREATE', |
349 | and immediately proceed to send the CREATE_ACK. */ | 365 | and immediately proceed to send the CREATE_ACK. */ |
350 | cc->state = CADET_CONNECTION_CREATE_RECEIVED; | 366 | cc->state = CADET_CONNECTION_CREATE_RECEIVED; |
@@ -356,6 +372,9 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
356 | /* We are currently sending something else back, which | 372 | /* We are currently sending something else back, which |
357 | can only be an ACK or payload, either of which would | 373 | can only be an ACK or payload, either of which would |
358 | do. So actually no need to do anything. */ | 374 | do. So actually no need to do anything. */ |
375 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
376 | "Got duplicate CREATE for connection %s. MQ is busy, not queueing another ACK\n", | ||
377 | GCC_2s (cc)); | ||
359 | } | 378 | } |
360 | } | 379 | } |
361 | 380 | ||
@@ -379,6 +398,9 @@ manage_first_hop_mq (void *cls, | |||
379 | if (GNUNET_YES != available) | 398 | if (GNUNET_YES != available) |
380 | { | 399 | { |
381 | /* Connection is down, for now... */ | 400 | /* Connection is down, for now... */ |
401 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
402 | "Core MQ for connection %s went down\n", | ||
403 | GCC_2s (cc)); | ||
382 | cc->mqm_ready = GNUNET_NO; | 404 | cc->mqm_ready = GNUNET_NO; |
383 | cc->state = CADET_CONNECTION_NEW; | 405 | cc->state = CADET_CONNECTION_NEW; |
384 | cc->retry_delay = GNUNET_TIME_UNIT_ZERO; | 406 | cc->retry_delay = GNUNET_TIME_UNIT_ZERO; |
@@ -393,6 +415,10 @@ manage_first_hop_mq (void *cls, | |||
393 | } | 415 | } |
394 | 416 | ||
395 | cc->mqm_ready = GNUNET_YES; | 417 | cc->mqm_ready = GNUNET_YES; |
418 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
419 | "Core MQ for connection %s became available in state %d\n", | ||
420 | GCC_2s (cc), | ||
421 | cc->state); | ||
396 | switch (cc->state) | 422 | switch (cc->state) |
397 | { | 423 | { |
398 | case CADET_CONNECTION_NEW: | 424 | case CADET_CONNECTION_NEW: |
@@ -479,6 +505,10 @@ connection_create (struct CadetPeer *destination, | |||
479 | cc->mq_man = GCP_request_mq (first_hop, | 505 | cc->mq_man = GCP_request_mq (first_hop, |
480 | &manage_first_hop_mq, | 506 | &manage_first_hop_mq, |
481 | cc); | 507 | cc); |
508 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
509 | "Created connection %s using path %s\n", | ||
510 | GCC_2s (cc), | ||
511 | GCPP_2s (path)); | ||
482 | return cc; | 512 | return cc; |
483 | } | 513 | } |
484 | 514 | ||
@@ -560,6 +590,9 @@ void | |||
560 | GCC_transmit (struct CadetConnection *cc, | 590 | GCC_transmit (struct CadetConnection *cc, |
561 | struct GNUNET_MQ_Envelope *env) | 591 | struct GNUNET_MQ_Envelope *env) |
562 | { | 592 | { |
593 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
594 | "Scheduling message for transmission on %s\n", | ||
595 | GCC_2s (cc)); | ||
563 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 596 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
564 | GNUNET_assert (CADET_CONNECTION_READY == cc->state); | 597 | GNUNET_assert (CADET_CONNECTION_READY == cc->state); |
565 | cc->mqm_ready = GNUNET_NO; | 598 | cc->mqm_ready = GNUNET_NO; |
diff --git a/src/cadet/gnunet-service-cadet-new_connection.h b/src/cadet/gnunet-service-cadet-new_connection.h index 31a2e80bb..efdf9929a 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.h +++ b/src/cadet/gnunet-service-cadet-new_connection.h | |||
@@ -113,12 +113,12 @@ GCC_transmit (struct CadetConnection *cc, | |||
113 | 113 | ||
114 | 114 | ||
115 | /** | 115 | /** |
116 | * An ACK was received for this connection, process it. | 116 | * A CREATE_ACK was received for this connection, process it. |
117 | * | 117 | * |
118 | * @param cc the connection that got the ACK. | 118 | * @param cc the connection that got the ACK. |
119 | */ | 119 | */ |
120 | void | 120 | void |
121 | GCC_handle_connection_ack (struct CadetConnection *cc); | 121 | GCC_handle_connection_create_ack (struct CadetConnection *cc); |
122 | 122 | ||
123 | 123 | ||
124 | /** | 124 | /** |
diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index a5d114b34..39a6a9296 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c | |||
@@ -477,7 +477,7 @@ handle_connection_create (void *cls, | |||
477 | */ | 477 | */ |
478 | static void | 478 | static void |
479 | handle_connection_create_ack (void *cls, | 479 | handle_connection_create_ack (void *cls, |
480 | const struct GNUNET_CADET_ConnectionCreateMessageAckMessage *msg) | 480 | const struct GNUNET_CADET_ConnectionCreateAckMessage *msg) |
481 | { | 481 | { |
482 | struct CadetPeer *peer = cls; | 482 | struct CadetPeer *peer = cls; |
483 | struct CadetConnection *cc; | 483 | struct CadetConnection *cc; |
@@ -498,7 +498,7 @@ handle_connection_create_ack (void *cls, | |||
498 | GNUNET_break_op (0); | 498 | GNUNET_break_op (0); |
499 | return; | 499 | return; |
500 | } | 500 | } |
501 | GCC_handle_connection_ack (cc); | 501 | GCC_handle_connection_create_ack (cc); |
502 | return; | 502 | return; |
503 | } | 503 | } |
504 | 504 | ||
@@ -778,7 +778,7 @@ GCO_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
778 | NULL), | 778 | NULL), |
779 | GNUNET_MQ_hd_fixed_size (connection_create_ack, | 779 | GNUNET_MQ_hd_fixed_size (connection_create_ack, |
780 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, | 780 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, |
781 | struct GNUNET_CADET_ConnectionCreateMessageAckMessage, | 781 | struct GNUNET_CADET_ConnectionCreateAckMessage, |
782 | NULL), | 782 | NULL), |
783 | GNUNET_MQ_hd_fixed_size (connection_broken, | 783 | GNUNET_MQ_hd_fixed_size (connection_broken, |
784 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, | 784 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, |
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index cfdc4270a..535bd66a8 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c | |||
@@ -417,6 +417,37 @@ GCT_2s (const struct CadetTunnel *t) | |||
417 | 417 | ||
418 | 418 | ||
419 | /** | 419 | /** |
420 | * Get string description for tunnel encryption state. | ||
421 | * | ||
422 | * @param es Tunnel state. | ||
423 | * | ||
424 | * @return String representation. | ||
425 | */ | ||
426 | static const char * | ||
427 | estate2s (enum CadetTunnelEState es) | ||
428 | { | ||
429 | static char buf[32]; | ||
430 | |||
431 | switch (es) | ||
432 | { | ||
433 | case CADET_TUNNEL_KEY_UNINITIALIZED: | ||
434 | return "CADET_TUNNEL_KEY_UNINITIALIZED"; | ||
435 | case CADET_TUNNEL_KEY_SENT: | ||
436 | return "CADET_TUNNEL_KEY_SENT"; | ||
437 | case CADET_TUNNEL_KEY_PING: | ||
438 | return "CADET_TUNNEL_KEY_PING"; | ||
439 | case CADET_TUNNEL_KEY_OK: | ||
440 | return "CADET_TUNNEL_KEY_OK"; | ||
441 | case CADET_TUNNEL_KEY_REKEY: | ||
442 | return "CADET_TUNNEL_KEY_REKEY"; | ||
443 | default: | ||
444 | SPRINTF (buf, "%u (UNKNOWN STATE)", es); | ||
445 | return buf; | ||
446 | } | ||
447 | } | ||
448 | |||
449 | |||
450 | /** | ||
420 | * Return the peer to which this tunnel goes. | 451 | * Return the peer to which this tunnel goes. |
421 | * | 452 | * |
422 | * @param t a tunnel | 453 | * @param t a tunnel |
@@ -1196,8 +1227,17 @@ send_kx (struct CadetTunnel *t, | |||
1196 | 1227 | ||
1197 | ct = get_ready_connection (t); | 1228 | ct = get_ready_connection (t); |
1198 | if (NULL == ct) | 1229 | if (NULL == ct) |
1230 | { | ||
1231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1232 | "Wanted to send KX on tunnel %s, but no connection is ready, deferring\n", | ||
1233 | GCT_2s (t)); | ||
1199 | return; | 1234 | return; |
1235 | } | ||
1200 | cc = ct->cc; | 1236 | cc = ct->cc; |
1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1238 | "Sending KX on tunnel %s using connection %s\n", | ||
1239 | GCT_2s (t), | ||
1240 | GCC_2s (ct->cc)); | ||
1201 | 1241 | ||
1202 | // GNUNET_assert (GNUNET_NO == GCT_is_loopback (t)); | 1242 | // GNUNET_assert (GNUNET_NO == GCT_is_loopback (t)); |
1203 | env = GNUNET_MQ_msg (msg, | 1243 | env = GNUNET_MQ_msg (msg, |
@@ -1327,6 +1367,10 @@ GCT_handle_kx (struct CadetTConnection *ct, | |||
1327 | " known handshake key, exit\n"); | 1367 | " known handshake key, exit\n"); |
1328 | return; | 1368 | return; |
1329 | } | 1369 | } |
1370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1371 | "Handling KX message for tunnel %s\n", | ||
1372 | GCT_2s (t)); | ||
1373 | |||
1330 | ax->RK = keys[0]; | 1374 | ax->RK = keys[0]; |
1331 | if (GNUNET_YES == am_I_alice) | 1375 | if (GNUNET_YES == am_I_alice) |
1332 | { | 1376 | { |
@@ -1428,6 +1472,10 @@ GCT_add_channel (struct CadetTunnel *t, | |||
1428 | ntohl (ctn.cn), | 1472 | ntohl (ctn.cn), |
1429 | ch, | 1473 | ch, |
1430 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1474 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1475 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1476 | "Adding channel %s to tunnel %s\n", | ||
1477 | GCCH_2s (ch), | ||
1478 | GCT_2s (t)); | ||
1431 | return ctn; | 1479 | return ctn; |
1432 | } | 1480 | } |
1433 | 1481 | ||
@@ -1445,6 +1493,9 @@ destroy_tunnel (void *cls) | |||
1445 | struct CadetTunnelQueueEntry *tqe; | 1493 | struct CadetTunnelQueueEntry *tqe; |
1446 | 1494 | ||
1447 | t->destroy_task = NULL; | 1495 | t->destroy_task = NULL; |
1496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1497 | "Destroying idle tunnel %s\n", | ||
1498 | GCT_2s (t)); | ||
1448 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (t->channels)); | 1499 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (t->channels)); |
1449 | while (NULL != (ct = t->connection_head)) | 1500 | while (NULL != (ct = t->connection_head)) |
1450 | { | 1501 | { |
@@ -1478,6 +1529,36 @@ destroy_tunnel (void *cls) | |||
1478 | 1529 | ||
1479 | 1530 | ||
1480 | /** | 1531 | /** |
1532 | * Remove a channel from a tunnel. | ||
1533 | * | ||
1534 | * @param t Tunnel. | ||
1535 | * @param ch Channel | ||
1536 | * @param ctn unique number identifying @a ch within @a t | ||
1537 | */ | ||
1538 | void | ||
1539 | GCT_remove_channel (struct CadetTunnel *t, | ||
1540 | struct CadetChannel *ch, | ||
1541 | struct GNUNET_CADET_ChannelTunnelNumber ctn) | ||
1542 | { | ||
1543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1544 | "Removing channel %s from tunnel %s\n", | ||
1545 | GCCH_2s (ch), | ||
1546 | GCT_2s (t)); | ||
1547 | GNUNET_assert (GNUNET_YES == | ||
1548 | GNUNET_CONTAINER_multihashmap32_remove (t->channels, | ||
1549 | ntohl (ctn.cn), | ||
1550 | ch)); | ||
1551 | if (0 == | ||
1552 | GNUNET_CONTAINER_multihashmap32_size (t->channels)) | ||
1553 | { | ||
1554 | t->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_DESTROY_DELAY, | ||
1555 | &destroy_tunnel, | ||
1556 | t); | ||
1557 | } | ||
1558 | } | ||
1559 | |||
1560 | |||
1561 | /** | ||
1481 | * It's been a while, we should try to redo the KX, if we can. | 1562 | * It's been a while, we should try to redo the KX, if we can. |
1482 | * | 1563 | * |
1483 | * @param cls the `struct CadetTunnel` to do KX for. | 1564 | * @param cls the `struct CadetTunnel` to do KX for. |
@@ -1497,6 +1578,50 @@ retry_kx (void *cls) | |||
1497 | 1578 | ||
1498 | 1579 | ||
1499 | /** | 1580 | /** |
1581 | * Send normal payload from queue in @a t via connection @a ct. | ||
1582 | * Does nothing if our payload queue is empty. | ||
1583 | * | ||
1584 | * @param t tunnel to send data from | ||
1585 | * @param ct connection to use for transmission (is ready) | ||
1586 | */ | ||
1587 | static void | ||
1588 | try_send_normal_payload (struct CadetTunnel *t, | ||
1589 | struct CadetTConnection *ct) | ||
1590 | { | ||
1591 | struct CadetTunnelQueueEntry *tq; | ||
1592 | |||
1593 | GNUNET_assert (GNUNET_YES == ct->is_ready); | ||
1594 | tq = t->tq_head; | ||
1595 | if (NULL == tq) | ||
1596 | { | ||
1597 | /* no messages pending right now */ | ||
1598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1599 | "Not sending payload of tunnel %s on ready connection %s (nothing pending)\n", | ||
1600 | GCT_2s (t), | ||
1601 | GCC_2s (ct->cc)); | ||
1602 | return; | ||
1603 | } | ||
1604 | /* ready to send message 'tq' on tunnel 'ct' */ | ||
1605 | GNUNET_assert (t == tq->t); | ||
1606 | GNUNET_CONTAINER_DLL_remove (t->tq_head, | ||
1607 | t->tq_tail, | ||
1608 | tq); | ||
1609 | if (NULL != tq->cid) | ||
1610 | *tq->cid = *GCC_get_id (ct->cc); | ||
1611 | ct->is_ready = GNUNET_NO; | ||
1612 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1613 | "Sending payload of tunnel %s on connection %s\n", | ||
1614 | GCT_2s (t), | ||
1615 | GCC_2s (ct->cc)); | ||
1616 | GCC_transmit (ct->cc, | ||
1617 | tq->env); | ||
1618 | if (NULL != tq->cont) | ||
1619 | tq->cont (tq->cont_cls); | ||
1620 | GNUNET_free (tq); | ||
1621 | } | ||
1622 | |||
1623 | |||
1624 | /** | ||
1500 | * A connection is @a is_ready for transmission. Looks at our message | 1625 | * A connection is @a is_ready for transmission. Looks at our message |
1501 | * queue and if there is a message, sends it out via the connection. | 1626 | * queue and if there is a message, sends it out via the connection. |
1502 | * | 1627 | * |
@@ -1510,14 +1635,22 @@ connection_ready_cb (void *cls, | |||
1510 | { | 1635 | { |
1511 | struct CadetTConnection *ct = cls; | 1636 | struct CadetTConnection *ct = cls; |
1512 | struct CadetTunnel *t = ct->t; | 1637 | struct CadetTunnel *t = ct->t; |
1513 | struct CadetTunnelQueueEntry *tq = t->tq_head; | ||
1514 | 1638 | ||
1515 | if (GNUNET_NO == ct->is_ready) | 1639 | if (GNUNET_NO == is_ready) |
1516 | { | 1640 | { |
1641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1642 | "Connection %s no longer ready for tunnel %s\n", | ||
1643 | GCC_2s (ct->cc), | ||
1644 | GCT_2s (t)); | ||
1517 | ct->is_ready = GNUNET_NO; | 1645 | ct->is_ready = GNUNET_NO; |
1518 | return; | 1646 | return; |
1519 | } | 1647 | } |
1520 | ct->is_ready = GNUNET_YES; | 1648 | ct->is_ready = GNUNET_YES; |
1649 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1650 | "Connection %s now ready for tunnel %s in state %s\n", | ||
1651 | GCC_2s (ct->cc), | ||
1652 | GCT_2s (t), | ||
1653 | estate2s (t->estate)); | ||
1521 | switch (t->estate) | 1654 | switch (t->estate) |
1522 | { | 1655 | { |
1523 | case CADET_TUNNEL_KEY_UNINITIALIZED: | 1656 | case CADET_TUNNEL_KEY_UNINITIALIZED: |
@@ -1536,22 +1669,8 @@ connection_ready_cb (void *cls, | |||
1536 | } | 1669 | } |
1537 | break; | 1670 | break; |
1538 | case CADET_TUNNEL_KEY_OK: | 1671 | case CADET_TUNNEL_KEY_OK: |
1539 | /* send normal payload */ | 1672 | try_send_normal_payload (t, |
1540 | if (NULL == tq) | 1673 | ct); |
1541 | return; /* no messages pending right now */ | ||
1542 | /* ready to send message 'tq' on tunnel 'ct' */ | ||
1543 | GNUNET_assert (t == tq->t); | ||
1544 | GNUNET_CONTAINER_DLL_remove (t->tq_head, | ||
1545 | t->tq_tail, | ||
1546 | tq); | ||
1547 | if (NULL != tq->cid) | ||
1548 | *tq->cid = *GCC_get_id (ct->cc); | ||
1549 | ct->is_ready = GNUNET_NO; | ||
1550 | GCC_transmit (ct->cc, | ||
1551 | tq->env); | ||
1552 | if (NULL != tq->cont) | ||
1553 | tq->cont (tq->cont_cls); | ||
1554 | GNUNET_free (tq); | ||
1555 | break; | 1674 | break; |
1556 | case CADET_TUNNEL_KEY_REKEY: | 1675 | case CADET_TUNNEL_KEY_REKEY: |
1557 | send_kx (t, | 1676 | send_kx (t, |
@@ -1580,10 +1699,8 @@ trigger_transmissions (struct CadetTunnel *t) | |||
1580 | ct = get_ready_connection (t); | 1699 | ct = get_ready_connection (t); |
1581 | if (NULL == ct) | 1700 | if (NULL == ct) |
1582 | return; /* no connections ready */ | 1701 | return; /* no connections ready */ |
1583 | 1702 | try_send_normal_payload (t, | |
1584 | /* FIXME: a bit hackish to do it like this... */ | 1703 | ct); |
1585 | connection_ready_cb (ct, | ||
1586 | GNUNET_YES); | ||
1587 | } | 1704 | } |
1588 | 1705 | ||
1589 | 1706 | ||
@@ -1690,6 +1807,11 @@ consider_path_cb (void *cls, | |||
1690 | t->connection_tail, | 1807 | t->connection_tail, |
1691 | ct); | 1808 | ct); |
1692 | t->num_connections++; | 1809 | t->num_connections++; |
1810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1811 | "Found interesting path %s for tunnel %s, created connection %s\n", | ||
1812 | GCPP_2s (path), | ||
1813 | GCT_2s (t), | ||
1814 | GCC_2s (ct->cc)); | ||
1693 | return GNUNET_YES; | 1815 | return GNUNET_YES; |
1694 | } | 1816 | } |
1695 | 1817 | ||
@@ -1714,7 +1836,7 @@ GCT_consider_path (struct CadetTunnel *t, | |||
1714 | 1836 | ||
1715 | 1837 | ||
1716 | /** | 1838 | /** |
1717 | * | 1839 | * NOT IMPLEMENTED. |
1718 | * | 1840 | * |
1719 | * @param cls the `struct CadetTunnel` for which we decrypted the message | 1841 | * @param cls the `struct CadetTunnel` for which we decrypted the message |
1720 | * @param msg the message we received on the tunnel | 1842 | * @param msg the message we received on the tunnel |
@@ -1764,6 +1886,10 @@ handle_plaintext_data (void *cls, | |||
1764 | { | 1886 | { |
1765 | /* We don't know about such a channel, might have been destroyed on our | 1887 | /* We don't know about such a channel, might have been destroyed on our |
1766 | end in the meantime, or never existed. Send back a DESTROY. */ | 1888 | end in the meantime, or never existed. Send back a DESTROY. */ |
1889 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1890 | "Receicved %u bytes of application data for unknown channel %u, sending DESTROY\n", | ||
1891 | (unsigned int) (ntohs (msg->header.size) - sizeof (*msg)), | ||
1892 | ntohl (msg->ctn.cn)); | ||
1767 | GCT_send_channel_destroy (t, | 1893 | GCT_send_channel_destroy (t, |
1768 | msg->ctn); | 1894 | msg->ctn); |
1769 | return; | 1895 | return; |
@@ -1794,6 +1920,9 @@ handle_plaintext_data_ack (void *cls, | |||
1794 | { | 1920 | { |
1795 | /* We don't know about such a channel, might have been destroyed on our | 1921 | /* We don't know about such a channel, might have been destroyed on our |
1796 | end in the meantime, or never existed. Send back a DESTROY. */ | 1922 | end in the meantime, or never existed. Send back a DESTROY. */ |
1923 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1924 | "Receicved DATA_ACK for unknown channel %u, sending DESTROY\n", | ||
1925 | ntohl (ack->ctn.cn)); | ||
1797 | GCT_send_channel_destroy (t, | 1926 | GCT_send_channel_destroy (t, |
1798 | ack->ctn); | 1927 | ack->ctn); |
1799 | return; | 1928 | return; |
@@ -1811,13 +1940,17 @@ handle_plaintext_data_ack (void *cls, | |||
1811 | * @param cc the message we received on the tunnel | 1940 | * @param cc the message we received on the tunnel |
1812 | */ | 1941 | */ |
1813 | static void | 1942 | static void |
1814 | handle_plaintext_channel_create (void *cls, | 1943 | handle_plaintext_channel_open (void *cls, |
1815 | const struct GNUNET_CADET_ChannelOpenMessage *cc) | 1944 | const struct GNUNET_CADET_ChannelOpenMessage *cc) |
1816 | { | 1945 | { |
1817 | struct CadetTunnel *t = cls; | 1946 | struct CadetTunnel *t = cls; |
1818 | struct CadetChannel *ch; | 1947 | struct CadetChannel *ch; |
1819 | struct GNUNET_CADET_ChannelTunnelNumber ctn; | 1948 | struct GNUNET_CADET_ChannelTunnelNumber ctn; |
1820 | 1949 | ||
1950 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1951 | "Receicved channel OPEN on port %s from peer %s\n", | ||
1952 | GNUNET_h2s (&cc->port), | ||
1953 | GCP_2s (GCT_get_destination (t))); | ||
1821 | ctn = get_next_free_ctn (t); | 1954 | ctn = get_next_free_ctn (t); |
1822 | ch = GCCH_channel_incoming_new (t, | 1955 | ch = GCCH_channel_incoming_new (t, |
1823 | ctn, | 1956 | ctn, |
@@ -1843,6 +1976,9 @@ GCT_send_channel_destroy (struct CadetTunnel *t, | |||
1843 | { | 1976 | { |
1844 | struct GNUNET_CADET_ChannelManageMessage msg; | 1977 | struct GNUNET_CADET_ChannelManageMessage msg; |
1845 | 1978 | ||
1979 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1980 | "Sending DESTORY message for channel ID %u\n", | ||
1981 | ntohl (ctn.cn)); | ||
1846 | msg.header.size = htons (sizeof (msg)); | 1982 | msg.header.size = htons (sizeof (msg)); |
1847 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); | 1983 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); |
1848 | msg.reserved = htonl (0); | 1984 | msg.reserved = htonl (0); |
@@ -1863,8 +1999,8 @@ GCT_send_channel_destroy (struct CadetTunnel *t, | |||
1863 | * @param cm the message we received on the tunnel | 1999 | * @param cm the message we received on the tunnel |
1864 | */ | 2000 | */ |
1865 | static void | 2001 | static void |
1866 | handle_plaintext_channel_ack (void *cls, | 2002 | handle_plaintext_channel_open_ack (void *cls, |
1867 | const struct GNUNET_CADET_ChannelManageMessage *cm) | 2003 | const struct GNUNET_CADET_ChannelManageMessage *cm) |
1868 | { | 2004 | { |
1869 | struct CadetTunnel *t = cls; | 2005 | struct CadetTunnel *t = cls; |
1870 | struct CadetChannel *ch; | 2006 | struct CadetChannel *ch; |
@@ -1875,11 +2011,14 @@ handle_plaintext_channel_ack (void *cls, | |||
1875 | { | 2011 | { |
1876 | /* We don't know about such a channel, might have been destroyed on our | 2012 | /* We don't know about such a channel, might have been destroyed on our |
1877 | end in the meantime, or never existed. Send back a DESTROY. */ | 2013 | end in the meantime, or never existed. Send back a DESTROY. */ |
2014 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2015 | "Received channel OPEN_ACK for unknown channel, sending DESTROY\n", | ||
2016 | GCCH_2s (ch)); | ||
1878 | GCT_send_channel_destroy (t, | 2017 | GCT_send_channel_destroy (t, |
1879 | cm->ctn); | 2018 | cm->ctn); |
1880 | return; | 2019 | return; |
1881 | } | 2020 | } |
1882 | GCCH_handle_channel_create_ack (ch); | 2021 | GCCH_handle_channel_open_ack (ch); |
1883 | } | 2022 | } |
1884 | 2023 | ||
1885 | 2024 | ||
@@ -1895,10 +2034,20 @@ handle_plaintext_channel_destroy (void *cls, | |||
1895 | const struct GNUNET_CADET_ChannelManageMessage *cm) | 2034 | const struct GNUNET_CADET_ChannelManageMessage *cm) |
1896 | { | 2035 | { |
1897 | struct CadetTunnel *t = cls; | 2036 | struct CadetTunnel *t = cls; |
1898 | struct CadetChannel *cc = lookup_channel (t, | 2037 | struct CadetChannel *ch; |
1899 | cm->ctn); | ||
1900 | 2038 | ||
1901 | GCCH_handle_remote_destroy (cc); | 2039 | ch = lookup_channel (t, |
2040 | cm->ctn); | ||
2041 | if (NULL == ch) | ||
2042 | { | ||
2043 | /* We don't know about such a channel, might have been destroyed on our | ||
2044 | end in the meantime, or never existed. */ | ||
2045 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2046 | "Received channel DESTORY for unknown channel. Ignoring.\n", | ||
2047 | GCCH_2s (ch)); | ||
2048 | return; | ||
2049 | } | ||
2050 | GCCH_handle_remote_destroy (ch); | ||
1902 | } | 2051 | } |
1903 | 2052 | ||
1904 | 2053 | ||
@@ -1960,11 +2109,11 @@ GCT_create_tunnel (struct CadetPeer *destination) | |||
1960 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK, | 2109 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK, |
1961 | struct GNUNET_CADET_ChannelDataAckMessage, | 2110 | struct GNUNET_CADET_ChannelDataAckMessage, |
1962 | NULL), | 2111 | NULL), |
1963 | GNUNET_MQ_hd_fixed_size (plaintext_channel_create, | 2112 | GNUNET_MQ_hd_fixed_size (plaintext_channel_open, |
1964 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN, | 2113 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN, |
1965 | struct GNUNET_CADET_ChannelOpenMessage, | 2114 | struct GNUNET_CADET_ChannelOpenMessage, |
1966 | NULL), | 2115 | NULL), |
1967 | GNUNET_MQ_hd_fixed_size (plaintext_channel_ack, | 2116 | GNUNET_MQ_hd_fixed_size (plaintext_channel_open_ack, |
1968 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK, | 2117 | GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK, |
1969 | struct GNUNET_CADET_ChannelManageMessage, | 2118 | struct GNUNET_CADET_ChannelManageMessage, |
1970 | NULL), | 2119 | NULL), |
@@ -1999,32 +2148,6 @@ GCT_create_tunnel (struct CadetPeer *destination) | |||
1999 | 2148 | ||
2000 | 2149 | ||
2001 | /** | 2150 | /** |
2002 | * Remove a channel from a tunnel. | ||
2003 | * | ||
2004 | * @param t Tunnel. | ||
2005 | * @param ch Channel | ||
2006 | * @param gid unique number identifying @a ch within @a t | ||
2007 | */ | ||
2008 | void | ||
2009 | GCT_remove_channel (struct CadetTunnel *t, | ||
2010 | struct CadetChannel *ch, | ||
2011 | struct GNUNET_CADET_ChannelTunnelNumber gid) | ||
2012 | { | ||
2013 | GNUNET_assert (GNUNET_YES == | ||
2014 | GNUNET_CONTAINER_multihashmap32_remove (t->channels, | ||
2015 | ntohl (gid.cn), | ||
2016 | ch)); | ||
2017 | if (0 == | ||
2018 | GNUNET_CONTAINER_multihashmap32_size (t->channels)) | ||
2019 | { | ||
2020 | t->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_DESTROY_DELAY, | ||
2021 | &destroy_tunnel, | ||
2022 | t); | ||
2023 | } | ||
2024 | } | ||
2025 | |||
2026 | |||
2027 | /** | ||
2028 | * Add a @a connection to the @a tunnel. | 2151 | * Add a @a connection to the @a tunnel. |
2029 | * | 2152 | * |
2030 | * @param t a tunnel | 2153 | * @param t a tunnel |
@@ -2055,6 +2178,10 @@ GCT_add_inbound_connection (struct CadetTunnel *t, | |||
2055 | t->connection_tail, | 2178 | t->connection_tail, |
2056 | ct); | 2179 | ct); |
2057 | t->num_connections++; | 2180 | t->num_connections++; |
2181 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2182 | "Tunnel %s has new connection %s\n", | ||
2183 | GCT_2s (t), | ||
2184 | GCC_2s (ct->cc)); | ||
2058 | } | 2185 | } |
2059 | 2186 | ||
2060 | 2187 | ||
@@ -2073,6 +2200,12 @@ GCT_handle_encrypted (struct CadetTConnection *ct, | |||
2073 | char cbuf [size] GNUNET_ALIGN; | 2200 | char cbuf [size] GNUNET_ALIGN; |
2074 | ssize_t decrypted_size; | 2201 | ssize_t decrypted_size; |
2075 | 2202 | ||
2203 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2204 | "Tunnel %s received %u bytes of encrypted data in state %d\n", | ||
2205 | GCT_2s (t), | ||
2206 | (unsigned int) size, | ||
2207 | t->estate); | ||
2208 | |||
2076 | switch (t->estate) | 2209 | switch (t->estate) |
2077 | { | 2210 | { |
2078 | case CADET_TUNNEL_KEY_UNINITIALIZED: | 2211 | case CADET_TUNNEL_KEY_UNINITIALIZED: |
@@ -2110,17 +2243,14 @@ GCT_handle_encrypted (struct CadetTConnection *ct, | |||
2110 | 2243 | ||
2111 | if (-1 == decrypted_size) | 2244 | if (-1 == decrypted_size) |
2112 | { | 2245 | { |
2246 | GNUNET_break_op (0); | ||
2247 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2248 | "Tunnel %s failed to decrypt and validate encrypted data\n", | ||
2249 | GCT_2s (t)); | ||
2113 | GNUNET_STATISTICS_update (stats, | 2250 | GNUNET_STATISTICS_update (stats, |
2114 | "# unable to decrypt", | 2251 | "# unable to decrypt", |
2115 | 1, | 2252 | 1, |
2116 | GNUNET_NO); | 2253 | GNUNET_NO); |
2117 | if (CADET_TUNNEL_KEY_PING <= t->estate) | ||
2118 | { | ||
2119 | GNUNET_break_op (0); | ||
2120 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2121 | "Failed to decrypt message on tunnel %s\n", | ||
2122 | GCT_2s (t)); | ||
2123 | } | ||
2124 | return; | 2254 | return; |
2125 | } | 2255 | } |
2126 | if (CADET_TUNNEL_KEY_PING == t->estate) | 2256 | if (CADET_TUNNEL_KEY_PING == t->estate) |
@@ -2161,6 +2291,10 @@ GCT_send (struct CadetTunnel *t, | |||
2161 | struct GNUNET_CADET_TunnelEncryptedMessage *ax_msg; | 2291 | struct GNUNET_CADET_TunnelEncryptedMessage *ax_msg; |
2162 | 2292 | ||
2163 | payload_size = ntohs (message->size); | 2293 | payload_size = ntohs (message->size); |
2294 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2295 | "Encrypting %u bytes of for tunnel %s\n", | ||
2296 | (unsigned int) payload_size, | ||
2297 | GCT_2s (t)); | ||
2164 | env = GNUNET_MQ_msg_extra (ax_msg, | 2298 | env = GNUNET_MQ_msg_extra (ax_msg, |
2165 | payload_size, | 2299 | payload_size, |
2166 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED); | 2300 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED); |
@@ -2318,37 +2452,6 @@ debug_channel (void *cls, | |||
2318 | } | 2452 | } |
2319 | 2453 | ||
2320 | 2454 | ||
2321 | /** | ||
2322 | * Get string description for tunnel encryption state. | ||
2323 | * | ||
2324 | * @param es Tunnel state. | ||
2325 | * | ||
2326 | * @return String representation. | ||
2327 | */ | ||
2328 | static const char * | ||
2329 | estate2s (enum CadetTunnelEState es) | ||
2330 | { | ||
2331 | static char buf[32]; | ||
2332 | |||
2333 | switch (es) | ||
2334 | { | ||
2335 | case CADET_TUNNEL_KEY_UNINITIALIZED: | ||
2336 | return "CADET_TUNNEL_KEY_UNINITIALIZED"; | ||
2337 | case CADET_TUNNEL_KEY_SENT: | ||
2338 | return "CADET_TUNNEL_KEY_SENT"; | ||
2339 | case CADET_TUNNEL_KEY_PING: | ||
2340 | return "CADET_TUNNEL_KEY_PING"; | ||
2341 | case CADET_TUNNEL_KEY_OK: | ||
2342 | return "CADET_TUNNEL_KEY_OK"; | ||
2343 | case CADET_TUNNEL_KEY_REKEY: | ||
2344 | return "CADET_TUNNEL_KEY_REKEY"; | ||
2345 | default: | ||
2346 | SPRINTF (buf, "%u (UNKNOWN STATE)", es); | ||
2347 | return buf; | ||
2348 | } | ||
2349 | } | ||
2350 | |||
2351 | |||
2352 | #define LOG2(level, ...) GNUNET_log_from_nocheck(level,"cadet-tun",__VA_ARGS__) | 2455 | #define LOG2(level, ...) GNUNET_log_from_nocheck(level,"cadet-tun",__VA_ARGS__) |
2353 | 2456 | ||
2354 | 2457 | ||
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.h b/src/cadet/gnunet-service-cadet-new_tunnels.h index 78c3cb6bb..3c88ae5f0 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.h +++ b/src/cadet/gnunet-service-cadet-new_tunnels.h | |||
@@ -152,23 +152,23 @@ GCT_add_channel (struct CadetTunnel *t, | |||
152 | * | 152 | * |
153 | * @param t Tunnel. | 153 | * @param t Tunnel. |
154 | * @param ch Channel | 154 | * @param ch Channel |
155 | * @param gid unique number identifying @a ch within @a t | 155 | * @param ctn unique number identifying @a ch within @a t |
156 | */ | 156 | */ |
157 | void | 157 | void |
158 | GCT_remove_channel (struct CadetTunnel *t, | 158 | GCT_remove_channel (struct CadetTunnel *t, |
159 | struct CadetChannel *ch, | 159 | struct CadetChannel *ch, |
160 | struct GNUNET_CADET_ChannelTunnelNumber gid); | 160 | struct GNUNET_CADET_ChannelTunnelNumber ctn); |
161 | 161 | ||
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Send a DESTROY message via the tunnel. | 164 | * Send a DESTROY message via the tunnel. |
165 | * | 165 | * |
166 | * @param t the tunnel to transmit over | 166 | * @param t the tunnel to transmit over |
167 | * @param chid ID of the channel to destroy | 167 | * @param ctn ID of the channel to destroy |
168 | */ | 168 | */ |
169 | void | 169 | void |
170 | GCT_send_channel_destroy (struct CadetTunnel *t, | 170 | GCT_send_channel_destroy (struct CadetTunnel *t, |
171 | struct GNUNET_CADET_ChannelTunnelNumber chid); | 171 | struct GNUNET_CADET_ChannelTunnelNumber ctn); |
172 | 172 | ||
173 | 173 | ||
174 | /** | 174 | /** |
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index c4802abde..af27647b3 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -1054,9 +1054,9 @@ static void | |||
1054 | send_connection_ack (struct CadetConnection *c, int fwd) | 1054 | send_connection_ack (struct CadetConnection *c, int fwd) |
1055 | { | 1055 | { |
1056 | static struct CadetEncryptedMessageIdentifier zero; | 1056 | static struct CadetEncryptedMessageIdentifier zero; |
1057 | struct GNUNET_CADET_ConnectionCreateMessageAckMessage msg; | 1057 | struct GNUNET_CADET_ConnectionCreateAckMessage msg; |
1058 | struct CadetTunnel *t; | 1058 | struct CadetTunnel *t; |
1059 | const uint16_t size = sizeof (struct GNUNET_CADET_ConnectionCreateMessageAckMessage); | 1059 | const uint16_t size = sizeof (struct GNUNET_CADET_ConnectionCreateAckMessage); |
1060 | const uint16_t type = GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK; | 1060 | const uint16_t type = GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK; |
1061 | 1061 | ||
1062 | GCC_check_connections (); | 1062 | GCC_check_connections (); |
@@ -2067,7 +2067,7 @@ GCC_handle_create (struct CadetPeer *peer, | |||
2067 | */ | 2067 | */ |
2068 | void | 2068 | void |
2069 | GCC_handle_confirm (struct CadetPeer *peer, | 2069 | GCC_handle_confirm (struct CadetPeer *peer, |
2070 | const struct GNUNET_CADET_ConnectionCreateMessageAckMessage *msg) | 2070 | const struct GNUNET_CADET_ConnectionCreateAckMessage *msg) |
2071 | { | 2071 | { |
2072 | static struct CadetEncryptedMessageIdentifier zero; | 2072 | static struct CadetEncryptedMessageIdentifier zero; |
2073 | struct CadetConnection *c; | 2073 | struct CadetConnection *c; |
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index 1c3160dfd..307cb42c2 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h | |||
@@ -136,7 +136,7 @@ GCC_handle_create (struct CadetPeer *peer, | |||
136 | */ | 136 | */ |
137 | void | 137 | void |
138 | GCC_handle_confirm (struct CadetPeer *peer, | 138 | GCC_handle_confirm (struct CadetPeer *peer, |
139 | const struct GNUNET_CADET_ConnectionCreateMessageAckMessage *msg); | 139 | const struct GNUNET_CADET_ConnectionCreateAckMessage *msg); |
140 | 140 | ||
141 | 141 | ||
142 | /** | 142 | /** |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 3f8b7bbb8..fa3f2be80 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -490,7 +490,7 @@ handle_create (void *cls, const struct GNUNET_CADET_ConnectionCreateMessage *msg | |||
490 | * @param msg Message itself. | 490 | * @param msg Message itself. |
491 | */ | 491 | */ |
492 | static void | 492 | static void |
493 | handle_confirm (void *cls, const struct GNUNET_CADET_ConnectionCreateMessageAckMessage *msg) | 493 | handle_confirm (void *cls, const struct GNUNET_CADET_ConnectionCreateAckMessage *msg) |
494 | { | 494 | { |
495 | struct CadetPeer *peer = cls; | 495 | struct CadetPeer *peer = cls; |
496 | GCC_handle_confirm (peer, msg); | 496 | GCC_handle_confirm (peer, msg); |
@@ -628,7 +628,7 @@ connect_to_core (const struct GNUNET_CONFIGURATION_Handle *c) | |||
628 | NULL), | 628 | NULL), |
629 | GNUNET_MQ_hd_fixed_size (confirm, | 629 | GNUNET_MQ_hd_fixed_size (confirm, |
630 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, | 630 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, |
631 | struct GNUNET_CADET_ConnectionCreateMessageAckMessage, | 631 | struct GNUNET_CADET_ConnectionCreateAckMessage, |
632 | NULL), | 632 | NULL), |
633 | GNUNET_MQ_hd_fixed_size (broken, | 633 | GNUNET_MQ_hd_fixed_size (broken, |
634 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, | 634 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, |