diff options
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_api.c | 25 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet-profiler.c | 7 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet.c | 3 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 574 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 282 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.h | 5 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_core.c | 513 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnels.c | 3 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnels.h | 2 | ||||
-rw-r--r-- | src/cadet/test_cadet.c | 7 | ||||
-rw-r--r-- | src/cadet/test_cadet_local_mq.c | 1 |
11 files changed, 518 insertions, 904 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index e141787a0..ff6f15543 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -11,7 +11,7 @@ | |||
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 | Affero 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 Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -134,11 +134,6 @@ struct GNUNET_CADET_Channel | |||
134 | struct GNUNET_CADET_ClientChannelNumber ccn; | 134 | struct GNUNET_CADET_ClientChannelNumber ccn; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Channel options: reliability, etc. | ||
138 | */ | ||
139 | enum GNUNET_CADET_ChannelOption options; | ||
140 | |||
141 | /** | ||
142 | * How many messages are we allowed to send to the service right now? | 137 | * How many messages are we allowed to send to the service right now? |
143 | */ | 138 | */ |
144 | unsigned int allow_send; | 139 | unsigned int allow_send; |
@@ -578,7 +573,6 @@ handle_channel_created ( | |||
578 | ch = create_channel (h, &ccn); | 573 | ch = create_channel (h, &ccn); |
579 | ch->peer = msg->peer; | 574 | ch->peer = msg->peer; |
580 | ch->incoming_port = port; | 575 | ch->incoming_port = port; |
581 | ch->options = ntohl (msg->opt); | ||
582 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 576 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
583 | "Creating incoming channel %X [%s] %p\n", | 577 | "Creating incoming channel %X [%s] %p\n", |
584 | ntohl (ccn.channel_of_client), | 578 | ntohl (ccn.channel_of_client), |
@@ -938,25 +932,13 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel) | |||
938 | */ | 932 | */ |
939 | const union GNUNET_CADET_ChannelInfo * | 933 | const union GNUNET_CADET_ChannelInfo * |
940 | GNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel, | 934 | GNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel, |
941 | enum GNUNET_CADET_ChannelOption option, | 935 | enum GNUNET_CADET_ChannelInfoOption option, |
942 | ...) | 936 | ...) |
943 | { | 937 | { |
944 | static int bool_flag; | ||
945 | |||
946 | switch (option) | 938 | switch (option) |
947 | { | 939 | { |
948 | case GNUNET_CADET_OPTION_NOBUFFER: | ||
949 | case GNUNET_CADET_OPTION_RELIABLE: | ||
950 | case GNUNET_CADET_OPTION_OUT_OF_ORDER: | ||
951 | if (0 != (option & channel->options)) | ||
952 | bool_flag = GNUNET_YES; | ||
953 | else | ||
954 | bool_flag = GNUNET_NO; | ||
955 | return (const union GNUNET_CADET_ChannelInfo *) &bool_flag; | ||
956 | break; | ||
957 | case GNUNET_CADET_OPTION_PEER: | 940 | case GNUNET_CADET_OPTION_PEER: |
958 | return (const union GNUNET_CADET_ChannelInfo *) &channel->peer; | 941 | return (const union GNUNET_CADET_ChannelInfo *) &channel->peer; |
959 | break; | ||
960 | default: | 942 | default: |
961 | GNUNET_break (0); | 943 | GNUNET_break (0); |
962 | return NULL; | 944 | return NULL; |
@@ -1089,7 +1071,6 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, | |||
1089 | void *channel_cls, | 1071 | void *channel_cls, |
1090 | const struct GNUNET_PeerIdentity *destination, | 1072 | const struct GNUNET_PeerIdentity *destination, |
1091 | const struct GNUNET_HashCode *port, | 1073 | const struct GNUNET_HashCode *port, |
1092 | enum GNUNET_CADET_ChannelOption options, | ||
1093 | GNUNET_CADET_WindowSizeEventHandler window_changes, | 1074 | GNUNET_CADET_WindowSizeEventHandler window_changes, |
1094 | GNUNET_CADET_DisconnectEventHandler disconnects, | 1075 | GNUNET_CADET_DisconnectEventHandler disconnects, |
1095 | const struct GNUNET_MQ_MessageHandler *handlers) | 1076 | const struct GNUNET_MQ_MessageHandler *handlers) |
@@ -1106,7 +1087,6 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, | |||
1106 | ch = create_channel (h, NULL); | 1087 | ch = create_channel (h, NULL); |
1107 | ch->ctx = channel_cls; | 1088 | ch->ctx = channel_cls; |
1108 | ch->peer = *destination; | 1089 | ch->peer = *destination; |
1109 | ch->options = options; | ||
1110 | ch->window_changes = window_changes; | 1090 | ch->window_changes = window_changes; |
1111 | ch->disconnects = disconnects; | 1091 | ch->disconnects = disconnects; |
1112 | 1092 | ||
@@ -1125,7 +1105,6 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, | |||
1125 | msg->ccn = ch->ccn; | 1105 | msg->ccn = ch->ccn; |
1126 | msg->port = *port; | 1106 | msg->port = *port; |
1127 | msg->peer = *destination; | 1107 | msg->peer = *destination; |
1128 | msg->opt = htonl (options); | ||
1129 | GNUNET_MQ_send (h->mq, env); | 1108 | GNUNET_MQ_send (h->mq, env); |
1130 | return ch; | 1109 | return ch; |
1131 | } | 1110 | } |
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c index 920d8d830..2de17dc9e 100644 --- a/src/cadet/gnunet-cadet-profiler.c +++ b/src/cadet/gnunet-cadet-profiler.c | |||
@@ -912,19 +912,18 @@ select_random_peer (struct CadetPeer *peer) | |||
912 | static void | 912 | static void |
913 | start_test (void *cls) | 913 | start_test (void *cls) |
914 | { | 914 | { |
915 | enum GNUNET_CADET_ChannelOption flags; | ||
916 | unsigned long i; | 915 | unsigned long i; |
917 | 916 | ||
918 | test_task = NULL; | 917 | test_task = NULL; |
919 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); | 918 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); |
920 | 919 | ||
921 | flags = GNUNET_CADET_OPTION_DEFAULT; | 920 | |
922 | for (i = 0; i < peers_pinging; i++) | 921 | for (i = 0; i < peers_pinging; i++) |
923 | { | 922 | { |
924 | peers[i].dest = select_random_peer (&peers[i]); | 923 | peers[i].dest = select_random_peer (&peers[i]); |
925 | peers[i].ch = GNUNET_CADET_channel_create (peers[i].cadet, NULL, | 924 | peers[i].ch = GNUNET_CADET_channel_create (peers[i].cadet, NULL, |
926 | &peers[i].dest->id, | 925 | &peers[i].dest->id, |
927 | GC_u2h (1), flags); | 926 | GC_u2h (1)); |
928 | if (NULL == peers[i].ch) | 927 | if (NULL == peers[i].ch) |
929 | { | 928 | { |
930 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i); | 929 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i); |
@@ -969,7 +968,7 @@ warmup (void) | |||
969 | i, get_index (peer)); | 968 | i, get_index (peer)); |
970 | peers[i].warmup_ch = | 969 | peers[i].warmup_ch = |
971 | GNUNET_CADET_channel_create (peers[i].cadet, NULL, &peer->id, | 970 | GNUNET_CADET_channel_create (peers[i].cadet, NULL, &peer->id, |
972 | GC_u2h (1), GNUNET_CADET_OPTION_DEFAULT); | 971 | GC_u2h (1)); |
973 | if (NULL == peers[i].warmup_ch) | 972 | if (NULL == peers[i].warmup_ch) |
974 | { | 973 | { |
975 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Warmup %u failed\n", i); | 974 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Warmup %u failed\n", i); |
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index 932d069a1..262cdf64d 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -784,7 +784,6 @@ run (void *cls, | |||
784 | if (NULL != target_id) | 784 | if (NULL != target_id) |
785 | { | 785 | { |
786 | struct GNUNET_PeerIdentity pid; | 786 | struct GNUNET_PeerIdentity pid; |
787 | enum GNUNET_CADET_ChannelOption opt; | ||
788 | 787 | ||
789 | if (GNUNET_OK != | 788 | if (GNUNET_OK != |
790 | GNUNET_CRYPTO_eddsa_public_key_from_string (target_id, | 789 | GNUNET_CRYPTO_eddsa_public_key_from_string (target_id, |
@@ -801,7 +800,6 @@ run (void *cls, | |||
801 | "Connecting to `%s:%s'\n", | 800 | "Connecting to `%s:%s'\n", |
802 | target_id, | 801 | target_id, |
803 | target_port); | 802 | target_port); |
804 | opt = GNUNET_CADET_OPTION_DEFAULT | GNUNET_CADET_OPTION_RELIABLE; | ||
805 | GNUNET_CRYPTO_hash (target_port, | 803 | GNUNET_CRYPTO_hash (target_port, |
806 | strlen(target_port), | 804 | strlen(target_port), |
807 | &porthash); | 805 | &porthash); |
@@ -809,7 +807,6 @@ run (void *cls, | |||
809 | NULL, | 807 | NULL, |
810 | &pid, | 808 | &pid, |
811 | &porthash, | 809 | &porthash, |
812 | opt, | ||
813 | NULL /* window changes */, | 810 | NULL /* window changes */, |
814 | &channel_ended, | 811 | &channel_ended, |
815 | handlers); | 812 | handlers); |
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index a1f6e37c2..664b8a7c1 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -41,23 +41,26 @@ | |||
41 | #include "gnunet-service-cadet_tunnels.h" | 41 | #include "gnunet-service-cadet_tunnels.h" |
42 | #include "gnunet-service-cadet_paths.h" | 42 | #include "gnunet-service-cadet_paths.h" |
43 | 43 | ||
44 | #define LOG(level,...) GNUNET_log_from (level,"cadet-chn",__VA_ARGS__) | 44 | #define LOG(level, ...) GNUNET_log_from (level, "cadet-chn", __VA_ARGS__) |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * How long do we initially wait before retransmitting? | 47 | * How long do we initially wait before retransmitting? |
48 | */ | 48 | */ |
49 | #define CADET_INITIAL_RETRANSMIT_TIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250) | 49 | #define CADET_INITIAL_RETRANSMIT_TIME \ |
50 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * How long do we wait before dropping state about incoming | 53 | * How long do we wait before dropping state about incoming |
53 | * connection to closed port? | 54 | * connection to closed port? |
54 | */ | 55 | */ |
55 | #define TIMEOUT_CLOSED_PORT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) | 56 | #define TIMEOUT_CLOSED_PORT \ |
57 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | ||
56 | 58 | ||
57 | /** | 59 | /** |
58 | * How long do we wait at least before retransmitting ever? | 60 | * How long do we wait at least before retransmitting ever? |
59 | */ | 61 | */ |
60 | #define MIN_RTT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 75) | 62 | #define MIN_RTT_DELAY \ |
63 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 75) | ||
61 | 64 | ||
62 | /** | 65 | /** |
63 | * Maximum message ID into the future we accept for out-of-order messages. | 66 | * Maximum message ID into the future we accept for out-of-order messages. |
@@ -164,7 +167,6 @@ struct CadetReliableMessage | |||
164 | * yet transmitted ever, otherwise the number of (re) transmissions. | 167 | * yet transmitted ever, otherwise the number of (re) transmissions. |
165 | */ | 168 | */ |
166 | int num_transmissions; | 169 | int num_transmissions; |
167 | |||
168 | }; | 170 | }; |
169 | 171 | ||
170 | 172 | ||
@@ -193,7 +195,6 @@ struct CadetOutOfOrderMessage | |||
193 | * The envelope with the payload of the out-of-order message | 195 | * The envelope with the payload of the out-of-order message |
194 | */ | 196 | */ |
195 | struct GNUNET_MQ_Envelope *env; | 197 | struct GNUNET_MQ_Envelope *env; |
196 | |||
197 | }; | 198 | }; |
198 | 199 | ||
199 | 200 | ||
@@ -238,7 +239,6 @@ struct CadetChannelClient | |||
238 | * Can we send data to the client? | 239 | * Can we send data to the client? |
239 | */ | 240 | */ |
240 | int client_ready; | 241 | int client_ready; |
241 | |||
242 | }; | 242 | }; |
243 | 243 | ||
244 | 244 | ||
@@ -380,7 +380,6 @@ struct CadetChannel | |||
380 | * empty. | 380 | * empty. |
381 | */ | 381 | */ |
382 | int destroy; | 382 | int destroy; |
383 | |||
384 | }; | 383 | }; |
385 | 384 | ||
386 | 385 | ||
@@ -400,12 +399,16 @@ GCCH_2s (const struct CadetChannel *ch) | |||
400 | sizeof (buf), | 399 | sizeof (buf), |
401 | "Channel %s:%s ctn:%X(%X/%X)", | 400 | "Channel %s:%s ctn:%X(%X/%X)", |
402 | (GNUNET_YES == ch->is_loopback) | 401 | (GNUNET_YES == ch->is_loopback) |
403 | ? "loopback" | 402 | ? "loopback" |
404 | : GNUNET_i2s (GCP_get_id (GCT_get_destination (ch->t))), | 403 | : GNUNET_i2s (GCP_get_id (GCT_get_destination (ch->t))), |
405 | GNUNET_h2s (&ch->port), | 404 | GNUNET_h2s (&ch->port), |
406 | ch->ctn, | 405 | ch->ctn, |
407 | (NULL == ch->owner) ? 0 : ntohl (ch->owner->ccn.channel_of_client), | 406 | (NULL == ch->owner) |
408 | (NULL == ch->dest) ? 0 : ntohl (ch->dest->ccn.channel_of_client)); | 407 | ? 0 |
408 | : ntohl (ch->owner->ccn.channel_of_client), | ||
409 | (NULL == ch->dest) | ||
410 | ? 0 | ||
411 | : ntohl (ch->dest->ccn.channel_of_client)); | ||
409 | return buf; | 412 | return buf; |
410 | } | 413 | } |
411 | 414 | ||
@@ -421,20 +424,15 @@ GCCH_2s (const struct CadetChannel *ch) | |||
421 | */ | 424 | */ |
422 | void | 425 | void |
423 | GCCH_hash_port (struct GNUNET_HashCode *h_port, | 426 | GCCH_hash_port (struct GNUNET_HashCode *h_port, |
424 | const struct GNUNET_HashCode *port, | 427 | const struct GNUNET_HashCode *port, |
425 | const struct GNUNET_PeerIdentity *listener) | 428 | const struct GNUNET_PeerIdentity *listener) |
426 | { | 429 | { |
427 | struct GNUNET_HashContext *hc; | 430 | struct GNUNET_HashContext *hc; |
428 | 431 | ||
429 | hc = GNUNET_CRYPTO_hash_context_start (); | 432 | hc = GNUNET_CRYPTO_hash_context_start (); |
430 | GNUNET_CRYPTO_hash_context_read (hc, | 433 | GNUNET_CRYPTO_hash_context_read (hc, port, sizeof (*port)); |
431 | port, | 434 | GNUNET_CRYPTO_hash_context_read (hc, listener, sizeof (*listener)); |
432 | sizeof (*port)); | 435 | GNUNET_CRYPTO_hash_context_finish (hc, h_port); |
433 | GNUNET_CRYPTO_hash_context_read (hc, | ||
434 | listener, | ||
435 | sizeof (*listener)); | ||
436 | GNUNET_CRYPTO_hash_context_finish (hc, | ||
437 | h_port); | ||
438 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 436 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
439 | "Calculated port hash %s\n", | 437 | "Calculated port hash %s\n", |
440 | GNUNET_h2s (h_port)); | 438 | GNUNET_h2s (h_port)); |
@@ -467,9 +465,7 @@ free_channel_client (struct CadetChannelClient *ccc) | |||
467 | 465 | ||
468 | while (NULL != (com = ccc->head_recv)) | 466 | while (NULL != (com = ccc->head_recv)) |
469 | { | 467 | { |
470 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | 468 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, com); |
471 | ccc->tail_recv, | ||
472 | com); | ||
473 | ccc->num_recv--; | 469 | ccc->num_recv--; |
474 | GNUNET_MQ_discard (com->env); | 470 | GNUNET_MQ_discard (com->env); |
475 | GNUNET_free (com); | 471 | GNUNET_free (com); |
@@ -496,16 +492,13 @@ channel_destroy (struct CadetChannel *ch) | |||
496 | GCT_send_cancel (crm->qe); | 492 | GCT_send_cancel (crm->qe); |
497 | crm->qe = NULL; | 493 | crm->qe = NULL; |
498 | } | 494 | } |
499 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, | 495 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, ch->tail_sent, crm); |
500 | ch->tail_sent, | ||
501 | crm); | ||
502 | GNUNET_free (crm->data_message); | 496 | GNUNET_free (crm->data_message); |
503 | GNUNET_free (crm); | 497 | GNUNET_free (crm); |
504 | } | 498 | } |
505 | if (CADET_CHANNEL_LOOSE == ch->state) | 499 | if (CADET_CHANNEL_LOOSE == ch->state) |
506 | { | 500 | { |
507 | GSC_drop_loose_channel (&ch->h_port, | 501 | GSC_drop_loose_channel (&ch->h_port, ch); |
508 | ch); | ||
509 | } | 502 | } |
510 | if (NULL != ch->owner) | 503 | if (NULL != ch->owner) |
511 | { | 504 | { |
@@ -534,9 +527,7 @@ channel_destroy (struct CadetChannel *ch) | |||
534 | } | 527 | } |
535 | if (GNUNET_NO == ch->is_loopback) | 528 | if (GNUNET_NO == ch->is_loopback) |
536 | { | 529 | { |
537 | GCT_remove_channel (ch->t, | 530 | GCT_remove_channel (ch->t, ch, ch->ctn); |
538 | ch, | ||
539 | ch->ctn); | ||
540 | ch->t = NULL; | 531 | ch->t = NULL; |
541 | } | 532 | } |
542 | GNUNET_free (ch); | 533 | GNUNET_free (ch); |
@@ -572,12 +563,9 @@ channel_open_sent_cb (void *cls, | |||
572 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 563 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
573 | "Sent CADET_CHANNEL_OPEN on %s, retrying in %s\n", | 564 | "Sent CADET_CHANNEL_OPEN on %s, retrying in %s\n", |
574 | GCCH_2s (ch), | 565 | GCCH_2s (ch), |
575 | GNUNET_STRINGS_relative_time_to_string (ch->retry_time, | 566 | GNUNET_STRINGS_relative_time_to_string (ch->retry_time, GNUNET_YES)); |
576 | GNUNET_YES)); | 567 | ch->retry_control_task = |
577 | ch->retry_control_task | 568 | GNUNET_SCHEDULER_add_delayed (ch->retry_time, &send_channel_open, ch); |
578 | = GNUNET_SCHEDULER_add_delayed (ch->retry_time, | ||
579 | &send_channel_open, | ||
580 | ch); | ||
581 | } | 569 | } |
582 | 570 | ||
583 | 571 | ||
@@ -591,31 +579,22 @@ send_channel_open (void *cls) | |||
591 | { | 579 | { |
592 | struct CadetChannel *ch = cls; | 580 | struct CadetChannel *ch = cls; |
593 | struct GNUNET_CADET_ChannelOpenMessage msgcc; | 581 | struct GNUNET_CADET_ChannelOpenMessage msgcc; |
594 | uint32_t options; | ||
595 | 582 | ||
596 | ch->retry_control_task = NULL; | 583 | ch->retry_control_task = NULL; |
597 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 584 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
598 | "Sending CHANNEL_OPEN message for %s\n", | 585 | "Sending CHANNEL_OPEN message for %s\n", |
599 | GCCH_2s (ch)); | 586 | GCCH_2s (ch)); |
600 | options = 0; | ||
601 | if (ch->nobuffer) | ||
602 | options |= GNUNET_CADET_OPTION_NOBUFFER; | ||
603 | if (ch->reliable) | ||
604 | options |= GNUNET_CADET_OPTION_RELIABLE; | ||
605 | if (ch->out_of_order) | ||
606 | options |= GNUNET_CADET_OPTION_OUT_OF_ORDER; | ||
607 | msgcc.header.size = htons (sizeof (msgcc)); | 587 | msgcc.header.size = htons (sizeof (msgcc)); |
608 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN); | 588 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN); |
609 | msgcc.opt = htonl (options); | 589 | //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. |
590 | msgcc.opt = 2; | ||
610 | msgcc.h_port = ch->h_port; | 591 | msgcc.h_port = ch->h_port; |
611 | msgcc.ctn = ch->ctn; | 592 | msgcc.ctn = ch->ctn; |
612 | ch->state = CADET_CHANNEL_OPEN_SENT; | 593 | ch->state = CADET_CHANNEL_OPEN_SENT; |
613 | if (NULL != ch->last_control_qe) | 594 | if (NULL != ch->last_control_qe) |
614 | GCT_send_cancel (ch->last_control_qe); | 595 | GCT_send_cancel (ch->last_control_qe); |
615 | ch->last_control_qe = GCT_send (ch->t, | 596 | ch->last_control_qe = |
616 | &msgcc.header, | 597 | GCT_send (ch->t, &msgcc.header, &channel_open_sent_cb, ch); |
617 | &channel_open_sent_cb, | ||
618 | ch); | ||
619 | GNUNET_assert (NULL == ch->retry_control_task); | 598 | GNUNET_assert (NULL == ch->retry_control_task); |
620 | } | 599 | } |
621 | 600 | ||
@@ -637,9 +616,7 @@ GCCH_tunnel_up (struct CadetChannel *ch) | |||
637 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 616 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
638 | "Tunnel up, sending CHANNEL_OPEN on %s now\n", | 617 | "Tunnel up, sending CHANNEL_OPEN on %s now\n", |
639 | GCCH_2s (ch)); | 618 | GCCH_2s (ch)); |
640 | ch->retry_control_task | 619 | ch->retry_control_task = GNUNET_SCHEDULER_add_now (&send_channel_open, ch); |
641 | = GNUNET_SCHEDULER_add_now (&send_channel_open, | ||
642 | ch); | ||
643 | } | 620 | } |
644 | 621 | ||
645 | 622 | ||
@@ -670,54 +647,45 @@ GCCH_channel_local_new (struct CadetClient *owner, | |||
670 | 647 | ||
671 | ch = GNUNET_new (struct CadetChannel); | 648 | ch = GNUNET_new (struct CadetChannel); |
672 | ch->mid_recv.mid = htonl (1); /* The OPEN_ACK counts as message 0! */ | 649 | ch->mid_recv.mid = htonl (1); /* The OPEN_ACK counts as message 0! */ |
673 | ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER)); | 650 | ch->nobuffer = GNUNET_NO; |
674 | ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE)); | 651 | ch->reliable = GNUNET_YES; |
675 | ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER)); | 652 | ch->out_of_order = GNUNET_NO; |
676 | ch->max_pending_messages = (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not hardcode! */ | 653 | ch->max_pending_messages = |
654 | (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not hardcode! */ | ||
677 | ch->owner = ccco; | 655 | ch->owner = ccco; |
678 | ch->port = *port; | 656 | ch->port = *port; |
679 | GCCH_hash_port (&ch->h_port, | 657 | GCCH_hash_port (&ch->h_port, port, GCP_get_id (destination)); |
680 | port, | 658 | if (0 == GNUNET_memcmp (&my_full_id, GCP_get_id (destination))) |
681 | GCP_get_id (destination)); | ||
682 | if (0 == GNUNET_memcmp (&my_full_id, | ||
683 | GCP_get_id (destination))) | ||
684 | { | 659 | { |
685 | struct OpenPort *op; | 660 | struct OpenPort *op; |
686 | 661 | ||
687 | ch->is_loopback = GNUNET_YES; | 662 | ch->is_loopback = GNUNET_YES; |
688 | op = GNUNET_CONTAINER_multihashmap_get (open_ports, | 663 | op = GNUNET_CONTAINER_multihashmap_get (open_ports, &ch->h_port); |
689 | &ch->h_port); | ||
690 | if (NULL == op) | 664 | if (NULL == op) |
691 | { | 665 | { |
692 | /* port closed, wait for it to possibly open */ | 666 | /* port closed, wait for it to possibly open */ |
693 | ch->state = CADET_CHANNEL_LOOSE; | 667 | ch->state = CADET_CHANNEL_LOOSE; |
694 | (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, | 668 | (void) GNUNET_CONTAINER_multihashmap_put ( |
695 | &ch->h_port, | 669 | loose_channels, |
696 | ch, | 670 | &ch->h_port, |
697 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 671 | ch, |
672 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
698 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 673 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
699 | "Created loose incoming loopback channel to port %s\n", | 674 | "Created loose incoming loopback channel to port %s\n", |
700 | GNUNET_h2s (&ch->port)); | 675 | GNUNET_h2s (&ch->port)); |
701 | } | 676 | } |
702 | else | 677 | else |
703 | { | 678 | { |
704 | GCCH_bind (ch, | 679 | GCCH_bind (ch, op->c, &op->port); |
705 | op->c, | ||
706 | &op->port); | ||
707 | } | 680 | } |
708 | } | 681 | } |
709 | else | 682 | else |
710 | { | 683 | { |
711 | ch->t = GCP_get_tunnel (destination, | 684 | ch->t = GCP_get_tunnel (destination, GNUNET_YES); |
712 | GNUNET_YES); | ||
713 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; | 685 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; |
714 | ch->ctn = GCT_add_channel (ch->t, | 686 | ch->ctn = GCT_add_channel (ch->t, ch); |
715 | ch); | ||
716 | } | 687 | } |
717 | GNUNET_STATISTICS_update (stats, | 688 | GNUNET_STATISTICS_update (stats, "# channels", 1, GNUNET_NO); |
718 | "# channels", | ||
719 | 1, | ||
720 | GNUNET_NO); | ||
721 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 689 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
722 | "Created channel to port %s at peer %s for %s using %s\n", | 690 | "Created channel to port %s at peer %s for %s using %s\n", |
723 | GNUNET_h2s (port), | 691 | GNUNET_h2s (port), |
@@ -771,30 +739,27 @@ GCCH_channel_incoming_new (struct CadetTunnel *t, | |||
771 | ch->t = t; | 739 | ch->t = t; |
772 | ch->ctn = ctn; | 740 | ch->ctn = ctn; |
773 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; | 741 | ch->retry_time = CADET_INITIAL_RETRANSMIT_TIME; |
774 | ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER)); | 742 | ch->nobuffer = GNUNET_NO; |
775 | ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE)); | 743 | ch->reliable = GNUNET_YES; |
776 | ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER)); | 744 | ch->out_of_order = GNUNET_NO; |
777 | ch->max_pending_messages = (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not hardcode! */ | 745 | ch->max_pending_messages = |
778 | GNUNET_STATISTICS_update (stats, | 746 | (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not hardcode! */ |
779 | "# channels", | 747 | GNUNET_STATISTICS_update (stats, "# channels", 1, GNUNET_NO); |
780 | 1, | 748 | |
781 | GNUNET_NO); | 749 | op = GNUNET_CONTAINER_multihashmap_get (open_ports, h_port); |
782 | |||
783 | op = GNUNET_CONTAINER_multihashmap_get (open_ports, | ||
784 | h_port); | ||
785 | if (NULL == op) | 750 | if (NULL == op) |
786 | { | 751 | { |
787 | /* port closed, wait for it to possibly open */ | 752 | /* port closed, wait for it to possibly open */ |
788 | ch->state = CADET_CHANNEL_LOOSE; | 753 | ch->state = CADET_CHANNEL_LOOSE; |
789 | (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, | 754 | (void) GNUNET_CONTAINER_multihashmap_put ( |
790 | &ch->h_port, | 755 | loose_channels, |
791 | ch, | 756 | &ch->h_port, |
792 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 757 | ch, |
758 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
793 | GNUNET_assert (NULL == ch->retry_control_task); | 759 | GNUNET_assert (NULL == ch->retry_control_task); |
794 | ch->retry_control_task | 760 | ch->retry_control_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_CLOSED_PORT, |
795 | = GNUNET_SCHEDULER_add_delayed (TIMEOUT_CLOSED_PORT, | 761 | &timeout_closed_cb, |
796 | &timeout_closed_cb, | 762 | ch); |
797 | ch); | ||
798 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 763 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
799 | "Created loose incoming channel to port %s from peer %s\n", | 764 | "Created loose incoming channel to port %s from peer %s\n", |
800 | GNUNET_h2s (&ch->port), | 765 | GNUNET_h2s (&ch->port), |
@@ -802,14 +767,9 @@ GCCH_channel_incoming_new (struct CadetTunnel *t, | |||
802 | } | 767 | } |
803 | else | 768 | else |
804 | { | 769 | { |
805 | GCCH_bind (ch, | 770 | GCCH_bind (ch, op->c, &op->port); |
806 | op->c, | ||
807 | &op->port); | ||
808 | } | 771 | } |
809 | GNUNET_STATISTICS_update (stats, | 772 | GNUNET_STATISTICS_update (stats, "# channels", 1, GNUNET_NO); |
810 | "# channels", | ||
811 | 1, | ||
812 | GNUNET_NO); | ||
813 | return ch; | 773 | return ch; |
814 | } | 774 | } |
815 | 775 | ||
@@ -858,10 +818,7 @@ send_channel_data_ack (struct CadetChannel *ch) | |||
858 | GCCH_2s (ch)); | 818 | GCCH_2s (ch)); |
859 | if (NULL != ch->last_control_qe) | 819 | if (NULL != ch->last_control_qe) |
860 | GCT_send_cancel (ch->last_control_qe); | 820 | GCT_send_cancel (ch->last_control_qe); |
861 | ch->last_control_qe = GCT_send (ch->t, | 821 | ch->last_control_qe = GCT_send (ch->t, &msg.header, &send_ack_cb, ch); |
862 | &msg.header, | ||
863 | &send_ack_cb, | ||
864 | ch); | ||
865 | } | 822 | } |
866 | 823 | ||
867 | 824 | ||
@@ -888,10 +845,7 @@ send_open_ack (void *cls) | |||
888 | msg.port = ch->port; | 845 | msg.port = ch->port; |
889 | if (NULL != ch->last_control_qe) | 846 | if (NULL != ch->last_control_qe) |
890 | GCT_send_cancel (ch->last_control_qe); | 847 | GCT_send_cancel (ch->last_control_qe); |
891 | ch->last_control_qe = GCT_send (ch->t, | 848 | ch->last_control_qe = GCT_send (ch->t, &msg.header, &send_ack_cb, ch); |
892 | &msg.header, | ||
893 | &send_ack_cb, | ||
894 | ch); | ||
895 | } | 849 | } |
896 | 850 | ||
897 | 851 | ||
@@ -904,8 +858,9 @@ send_open_ack (void *cls) | |||
904 | * @param cti identifier of the connection that delivered the message | 858 | * @param cti identifier of the connection that delivered the message |
905 | */ | 859 | */ |
906 | void | 860 | void |
907 | GCCH_handle_duplicate_open (struct CadetChannel *ch, | 861 | GCCH_handle_duplicate_open ( |
908 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) | 862 | struct CadetChannel *ch, |
863 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) | ||
909 | { | 864 | { |
910 | if (NULL == ch->dest) | 865 | if (NULL == ch->dest) |
911 | { | 866 | { |
@@ -924,9 +879,7 @@ GCCH_handle_duplicate_open (struct CadetChannel *ch, | |||
924 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 879 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
925 | "Retransmitting CHANNEL_OPEN_ACK on %s\n", | 880 | "Retransmitting CHANNEL_OPEN_ACK on %s\n", |
926 | GCCH_2s (ch)); | 881 | GCCH_2s (ch)); |
927 | ch->retry_control_task | 882 | ch->retry_control_task = GNUNET_SCHEDULER_add_now (&send_open_ack, ch); |
928 | = GNUNET_SCHEDULER_add_now (&send_open_ack, | ||
929 | ch); | ||
930 | } | 883 | } |
931 | 884 | ||
932 | 885 | ||
@@ -938,8 +891,7 @@ GCCH_handle_duplicate_open (struct CadetChannel *ch, | |||
938 | * #GNUNET_NO to send to dest | 891 | * #GNUNET_NO to send to dest |
939 | */ | 892 | */ |
940 | static void | 893 | static void |
941 | send_ack_to_client (struct CadetChannel *ch, | 894 | send_ack_to_client (struct CadetChannel *ch, int to_owner) |
942 | int to_owner) | ||
943 | { | 895 | { |
944 | struct GNUNET_MQ_Envelope *env; | 896 | struct GNUNET_MQ_Envelope *env; |
945 | struct GNUNET_CADET_LocalAck *ack; | 897 | struct GNUNET_CADET_LocalAck *ack; |
@@ -953,8 +905,7 @@ send_ack_to_client (struct CadetChannel *ch, | |||
953 | GNUNET_assert (GNUNET_YES == ch->destroy); | 905 | GNUNET_assert (GNUNET_YES == ch->destroy); |
954 | return; | 906 | return; |
955 | } | 907 | } |
956 | env = GNUNET_MQ_msg (ack, | 908 | env = GNUNET_MQ_msg (ack, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK); |
957 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK); | ||
958 | ack->ccn = ccc->ccn; | 909 | ack->ccn = ccc->ccn; |
959 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 910 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
960 | "Sending CADET_LOCAL_ACK to %s (%s) at ccn %X (%u/%u pending)\n", | 911 | "Sending CADET_LOCAL_ACK to %s (%s) at ccn %X (%u/%u pending)\n", |
@@ -963,8 +914,7 @@ send_ack_to_client (struct CadetChannel *ch, | |||
963 | ntohl (ack->ccn.channel_of_client), | 914 | ntohl (ack->ccn.channel_of_client), |
964 | ch->pending_messages, | 915 | ch->pending_messages, |
965 | ch->max_pending_messages); | 916 | ch->max_pending_messages); |
966 | GSC_send_to_client (ccc->c, | 917 | GSC_send_to_client (ccc->c, env); |
967 | env); | ||
968 | } | 918 | } |
969 | 919 | ||
970 | 920 | ||
@@ -980,7 +930,7 @@ send_ack_to_client (struct CadetChannel *ch, | |||
980 | void | 930 | void |
981 | GCCH_bind (struct CadetChannel *ch, | 931 | GCCH_bind (struct CadetChannel *ch, |
982 | struct CadetClient *c, | 932 | struct CadetClient *c, |
983 | const struct GNUNET_HashCode *port) | 933 | const struct GNUNET_HashCode *port) |
984 | { | 934 | { |
985 | uint32_t options; | 935 | uint32_t options; |
986 | struct CadetChannelClient *cccd; | 936 | struct CadetChannelClient *cccd; |
@@ -998,12 +948,6 @@ GCCH_bind (struct CadetChannel *ch, | |||
998 | ch->retry_control_task = NULL; | 948 | ch->retry_control_task = NULL; |
999 | } | 949 | } |
1000 | options = 0; | 950 | options = 0; |
1001 | if (ch->nobuffer) | ||
1002 | options |= GNUNET_CADET_OPTION_NOBUFFER; | ||
1003 | if (ch->reliable) | ||
1004 | options |= GNUNET_CADET_OPTION_RELIABLE; | ||
1005 | if (ch->out_of_order) | ||
1006 | options |= GNUNET_CADET_OPTION_OUT_OF_ORDER; | ||
1007 | cccd = GNUNET_new (struct CadetChannelClient); | 951 | cccd = GNUNET_new (struct CadetChannelClient); |
1008 | GNUNET_assert (NULL == ch->dest); | 952 | GNUNET_assert (NULL == ch->dest); |
1009 | ch->dest = cccd; | 953 | ch->dest = cccd; |
@@ -1013,9 +957,8 @@ GCCH_bind (struct CadetChannel *ch, | |||
1013 | cccd->ccn = GSC_bind (c, | 957 | cccd->ccn = GSC_bind (c, |
1014 | ch, | 958 | ch, |
1015 | (GNUNET_YES == ch->is_loopback) | 959 | (GNUNET_YES == ch->is_loopback) |
1016 | ? GCP_get (&my_full_id, | 960 | ? GCP_get (&my_full_id, GNUNET_YES) |
1017 | GNUNET_YES) | 961 | : GCT_get_destination (ch->t), |
1018 | : GCT_get_destination (ch->t), | ||
1019 | port, | 962 | port, |
1020 | options); | 963 | options); |
1021 | GNUNET_assert (ntohl (cccd->ccn.channel_of_client) < | 964 | GNUNET_assert (ntohl (cccd->ccn.channel_of_client) < |
@@ -1024,24 +967,19 @@ GCCH_bind (struct CadetChannel *ch, | |||
1024 | if (GNUNET_YES == ch->is_loopback) | 967 | if (GNUNET_YES == ch->is_loopback) |
1025 | { | 968 | { |
1026 | ch->state = CADET_CHANNEL_OPEN_SENT; | 969 | ch->state = CADET_CHANNEL_OPEN_SENT; |
1027 | GCCH_handle_channel_open_ack (ch, | 970 | GCCH_handle_channel_open_ack (ch, NULL, port); |
1028 | NULL, | ||
1029 | port); | ||
1030 | } | 971 | } |
1031 | else | 972 | else |
1032 | { | 973 | { |
1033 | /* notify other peer that we accepted the connection */ | 974 | /* notify other peer that we accepted the connection */ |
1034 | ch->state = CADET_CHANNEL_READY; | 975 | ch->state = CADET_CHANNEL_READY; |
1035 | ch->retry_control_task | 976 | ch->retry_control_task = GNUNET_SCHEDULER_add_now (&send_open_ack, ch); |
1036 | = GNUNET_SCHEDULER_add_now (&send_open_ack, | ||
1037 | ch); | ||
1038 | } | 977 | } |
1039 | /* give client it's initial supply of ACKs */ | 978 | /* give client it's initial supply of ACKs */ |
1040 | GNUNET_assert (ntohl (cccd->ccn.channel_of_client) < | 979 | GNUNET_assert (ntohl (cccd->ccn.channel_of_client) < |
1041 | GNUNET_CADET_LOCAL_CHANNEL_ID_CLI); | 980 | GNUNET_CADET_LOCAL_CHANNEL_ID_CLI); |
1042 | for (unsigned int i=0;i<ch->max_pending_messages;i++) | 981 | for (unsigned int i = 0; i < ch->max_pending_messages; i++) |
1043 | send_ack_to_client (ch, | 982 | send_ack_to_client (ch, GNUNET_NO); |
1044 | GNUNET_NO); | ||
1045 | } | 983 | } |
1046 | 984 | ||
1047 | 985 | ||
@@ -1061,9 +999,7 @@ signal_remote_destroy_cb (void *cls) | |||
1061 | /* Find which end is left... */ | 999 | /* Find which end is left... */ |
1062 | ch->retry_control_task = NULL; | 1000 | ch->retry_control_task = NULL; |
1063 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | 1001 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; |
1064 | GSC_handle_remote_channel_destroy (ccc->c, | 1002 | GSC_handle_remote_channel_destroy (ccc->c, ccc->ccn, ch); |
1065 | ccc->ccn, | ||
1066 | ch); | ||
1067 | channel_destroy (ch); | 1003 | channel_destroy (ch); |
1068 | } | 1004 | } |
1069 | 1005 | ||
@@ -1086,16 +1022,14 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1086 | GSC_2s (c), | 1022 | GSC_2s (c), |
1087 | GCCH_2s (ch)); | 1023 | GCCH_2s (ch)); |
1088 | GNUNET_assert (NULL != c); | 1024 | GNUNET_assert (NULL != c); |
1089 | if ( (NULL != ch->owner) && | 1025 | if ((NULL != ch->owner) && (c == ch->owner->c) && |
1090 | (c == ch->owner->c) && | 1026 | (ccn.channel_of_client == ch->owner->ccn.channel_of_client)) |
1091 | (ccn.channel_of_client == ch->owner->ccn.channel_of_client) ) | ||
1092 | { | 1027 | { |
1093 | free_channel_client (ch->owner); | 1028 | free_channel_client (ch->owner); |
1094 | ch->owner = NULL; | 1029 | ch->owner = NULL; |
1095 | } | 1030 | } |
1096 | else if ( (NULL != ch->dest) && | 1031 | else if ((NULL != ch->dest) && (c == ch->dest->c) && |
1097 | (c == ch->dest->c) && | 1032 | (ccn.channel_of_client == ch->dest->ccn.channel_of_client)) |
1098 | (ccn.channel_of_client == ch->dest->ccn.channel_of_client) ) | ||
1099 | { | 1033 | { |
1100 | free_channel_client (ch->dest); | 1034 | free_channel_client (ch->dest); |
1101 | ch->dest = NULL; | 1035 | ch->dest = NULL; |
@@ -1112,24 +1046,20 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1112 | channel_destroy (ch); | 1046 | channel_destroy (ch); |
1113 | return; | 1047 | return; |
1114 | } | 1048 | } |
1115 | if ( (NULL != ch->head_sent) && | 1049 | if ((NULL != ch->head_sent) && ((NULL != ch->owner) || (NULL != ch->dest))) |
1116 | ( (NULL != ch->owner) || | ||
1117 | (NULL != ch->dest) ) ) | ||
1118 | { | 1050 | { |
1119 | /* Wait for other end to destroy us as well, | 1051 | /* Wait for other end to destroy us as well, |
1120 | and otherwise allow send queue to be transmitted first */ | 1052 | and otherwise allow send queue to be transmitted first */ |
1121 | ch->destroy = GNUNET_YES; | 1053 | ch->destroy = GNUNET_YES; |
1122 | return; | 1054 | return; |
1123 | } | 1055 | } |
1124 | if ( (GNUNET_YES == ch->is_loopback) && | 1056 | if ((GNUNET_YES == ch->is_loopback) && |
1125 | ( (NULL != ch->owner) || | 1057 | ((NULL != ch->owner) || (NULL != ch->dest))) |
1126 | (NULL != ch->dest) ) ) | ||
1127 | { | 1058 | { |
1128 | if (NULL != ch->retry_control_task) | 1059 | if (NULL != ch->retry_control_task) |
1129 | GNUNET_SCHEDULER_cancel (ch->retry_control_task); | 1060 | GNUNET_SCHEDULER_cancel (ch->retry_control_task); |
1130 | ch->retry_control_task | 1061 | ch->retry_control_task = |
1131 | = GNUNET_SCHEDULER_add_now (&signal_remote_destroy_cb, | 1062 | GNUNET_SCHEDULER_add_now (&signal_remote_destroy_cb, ch); |
1132 | ch); | ||
1133 | return; | 1063 | return; |
1134 | } | 1064 | } |
1135 | if (GNUNET_NO == ch->is_loopback) | 1065 | if (GNUNET_NO == ch->is_loopback) |
@@ -1144,8 +1074,7 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1144 | case CADET_CHANNEL_LOOSE: | 1074 | case CADET_CHANNEL_LOOSE: |
1145 | break; | 1075 | break; |
1146 | default: | 1076 | default: |
1147 | GCT_send_channel_destroy (ch->t, | 1077 | GCT_send_channel_destroy (ch->t, ch->ctn); |
1148 | ch->ctn); | ||
1149 | } | 1078 | } |
1150 | } | 1079 | } |
1151 | /* Nothing left to do, just finish destruction */ | 1080 | /* Nothing left to do, just finish destruction */ |
@@ -1163,9 +1092,10 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1163 | * @param port port number (needed to verify receiver knows the port) | 1092 | * @param port port number (needed to verify receiver knows the port) |
1164 | */ | 1093 | */ |
1165 | void | 1094 | void |
1166 | GCCH_handle_channel_open_ack (struct CadetChannel *ch, | 1095 | GCCH_handle_channel_open_ack ( |
1167 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, | 1096 | struct CadetChannel *ch, |
1168 | const struct GNUNET_HashCode *port) | 1097 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, |
1098 | const struct GNUNET_HashCode *port) | ||
1169 | { | 1099 | { |
1170 | switch (ch->state) | 1100 | switch (ch->state) |
1171 | { | 1101 | { |
@@ -1184,8 +1114,7 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch, | |||
1184 | GNUNET_break_op (0); | 1114 | GNUNET_break_op (0); |
1185 | return; | 1115 | return; |
1186 | } | 1116 | } |
1187 | if (0 != GNUNET_memcmp (&ch->port, | 1117 | if (0 != GNUNET_memcmp (&ch->port, port)) |
1188 | port)) | ||
1189 | { | 1118 | { |
1190 | /* Other peer failed to provide the right port, | 1119 | /* Other peer failed to provide the right port, |
1191 | refuse connection. */ | 1120 | refuse connection. */ |
@@ -1203,19 +1132,15 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch, | |||
1203 | ch->state = CADET_CHANNEL_READY; | 1132 | ch->state = CADET_CHANNEL_READY; |
1204 | /* On first connect, send client as many ACKs as we allow messages | 1133 | /* On first connect, send client as many ACKs as we allow messages |
1205 | to be buffered! */ | 1134 | to be buffered! */ |
1206 | for (unsigned int i=0;i<ch->max_pending_messages;i++) | 1135 | for (unsigned int i = 0; i < ch->max_pending_messages; i++) |
1207 | send_ack_to_client (ch, | 1136 | send_ack_to_client (ch, GNUNET_YES); |
1208 | GNUNET_YES); | ||
1209 | break; | 1137 | break; |
1210 | case CADET_CHANNEL_READY: | 1138 | case CADET_CHANNEL_READY: |
1211 | /* duplicate ACK, maybe we retried the CREATE. Ignore. */ | 1139 | /* duplicate ACK, maybe we retried the CREATE. Ignore. */ |
1212 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1140 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1213 | "Received duplicate channel OPEN_ACK for %s\n", | 1141 | "Received duplicate channel OPEN_ACK for %s\n", |
1214 | GCCH_2s (ch)); | 1142 | GCCH_2s (ch)); |
1215 | GNUNET_STATISTICS_update (stats, | 1143 | GNUNET_STATISTICS_update (stats, "# duplicate CREATE_ACKs", 1, GNUNET_NO); |
1216 | "# duplicate CREATE_ACKs", | ||
1217 | 1, | ||
1218 | GNUNET_NO); | ||
1219 | break; | 1144 | break; |
1220 | } | 1145 | } |
1221 | } | 1146 | } |
@@ -1264,9 +1189,10 @@ is_before (void *cls, | |||
1264 | * @param msg message that was received | 1189 | * @param msg message that was received |
1265 | */ | 1190 | */ |
1266 | void | 1191 | void |
1267 | GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | 1192 | GCCH_handle_channel_plaintext_data ( |
1268 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, | 1193 | struct CadetChannel *ch, |
1269 | const struct GNUNET_CADET_ChannelAppDataMessage *msg) | 1194 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, |
1195 | const struct GNUNET_CADET_ChannelAppDataMessage *msg) | ||
1270 | { | 1196 | { |
1271 | struct GNUNET_MQ_Envelope *env; | 1197 | struct GNUNET_MQ_Envelope *env; |
1272 | struct GNUNET_CADET_LocalData *ld; | 1198 | struct GNUNET_CADET_LocalData *ld; |
@@ -1280,8 +1206,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1280 | uint32_t delta; | 1206 | uint32_t delta; |
1281 | 1207 | ||
1282 | GNUNET_assert (GNUNET_NO == ch->is_loopback); | 1208 | GNUNET_assert (GNUNET_NO == ch->is_loopback); |
1283 | if ( (NULL == ch->owner) && | 1209 | if ((NULL == ch->owner) && (NULL == ch->dest)) |
1284 | (NULL == ch->dest) ) | ||
1285 | { | 1210 | { |
1286 | /* This client is gone, but we still have messages to send to | 1211 | /* This client is gone, but we still have messages to send to |
1287 | the other end (which is why @a ch is not yet dead). However, | 1212 | the other end (which is why @a ch is not yet dead). However, |
@@ -1291,8 +1216,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1291 | GCCH_2s (ch)); | 1216 | GCCH_2s (ch)); |
1292 | /* send back DESTROY notification to stop further retransmissions! */ | 1217 | /* send back DESTROY notification to stop further retransmissions! */ |
1293 | if (GNUNET_YES == ch->destroy) | 1218 | if (GNUNET_YES == ch->destroy) |
1294 | GCT_send_channel_destroy (ch->t, | 1219 | GCT_send_channel_destroy (ch->t, ch->ctn); |
1295 | ch->ctn); | ||
1296 | return; | 1220 | return; |
1297 | } | 1221 | } |
1298 | payload_size = ntohs (msg->header.size) - sizeof (*msg); | 1222 | payload_size = ntohs (msg->header.size) - sizeof (*msg); |
@@ -1300,9 +1224,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1300 | payload_size, | 1224 | payload_size, |
1301 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); | 1225 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); |
1302 | ld->ccn = (NULL == ch->dest) ? ch->owner->ccn : ch->dest->ccn; | 1226 | ld->ccn = (NULL == ch->dest) ? ch->owner->ccn : ch->dest->ccn; |
1303 | GNUNET_memcpy (&ld[1], | 1227 | GNUNET_memcpy (&ld[1], &msg[1], payload_size); |
1304 | &msg[1], | ||
1305 | payload_size); | ||
1306 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | 1228 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; |
1307 | if (GNUNET_YES == ccc->client_ready) | 1229 | if (GNUNET_YES == ccc->client_ready) |
1308 | { | 1230 | { |
@@ -1312,13 +1234,12 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1312 | * - The channel is reliable and MID matches next expected MID | 1234 | * - The channel is reliable and MID matches next expected MID |
1313 | * - The channel is unreliable and MID is before lowest seen MID | 1235 | * - The channel is unreliable and MID is before lowest seen MID |
1314 | */ | 1236 | */ |
1315 | if ( (GNUNET_YES == ch->out_of_order) || | 1237 | if ((GNUNET_YES == ch->out_of_order) || |
1316 | ((msg->mid.mid == ch->mid_recv.mid) && | 1238 | ((msg->mid.mid == ch->mid_recv.mid) && (GNUNET_YES == ch->reliable)) || |
1317 | (GNUNET_YES == ch->reliable)) || | 1239 | ((GNUNET_NO == ch->reliable) && |
1318 | ((GNUNET_NO == ch->reliable) && | 1240 | (ntohl (msg->mid.mid) >= ntohl (ch->mid_recv.mid)) && |
1319 | (ntohl (msg->mid.mid) >= ntohl (ch->mid_recv.mid)) && | 1241 | ((NULL == ccc->head_recv) || |
1320 | ((NULL == ccc->head_recv) || | 1242 | (ntohl (msg->mid.mid) < ntohl (ccc->head_recv->mid.mid))))) |
1321 | (ntohl (msg->mid.mid) < ntohl (ccc->head_recv->mid.mid)))) ) | ||
1322 | { | 1243 | { |
1323 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1244 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1324 | "Giving %u bytes of payload with MID %u from %s to client %s\n", | 1245 | "Giving %u bytes of payload with MID %u from %s to client %s\n", |
@@ -1327,24 +1248,22 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1327 | GCCH_2s (ch), | 1248 | GCCH_2s (ch), |
1328 | GSC_2s (ccc->c)); | 1249 | GSC_2s (ccc->c)); |
1329 | ccc->client_ready = GNUNET_NO; | 1250 | ccc->client_ready = GNUNET_NO; |
1330 | GSC_send_to_client (ccc->c, | 1251 | GSC_send_to_client (ccc->c, env); |
1331 | env); | ||
1332 | if (GNUNET_NO == ch->out_of_order) | 1252 | if (GNUNET_NO == ch->out_of_order) |
1333 | ch->mid_recv.mid = htonl (1 + ntohl (msg->mid.mid)); | 1253 | ch->mid_recv.mid = htonl (1 + ntohl (msg->mid.mid)); |
1334 | else | 1254 | else |
1335 | ch->mid_recv.mid = htonl (1 + ntohl (ch->mid_recv.mid)); | 1255 | ch->mid_recv.mid = htonl (1 + ntohl (ch->mid_recv.mid)); |
1336 | ch->mid_futures >>= 1; | 1256 | ch->mid_futures >>= 1; |
1337 | if ( (GNUNET_YES == ch->out_of_order) && | 1257 | if ((GNUNET_YES == ch->out_of_order) && (GNUNET_NO == ch->reliable)) |
1338 | (GNUNET_NO == ch->reliable) ) | ||
1339 | { | 1258 | { |
1340 | /* possibly shift by more if we skipped messages */ | 1259 | /* possibly shift by more if we skipped messages */ |
1341 | uint64_t delta = htonl (msg->mid.mid) - 1 - ntohl (ch->mid_recv.mid); | 1260 | uint64_t delta = htonl (msg->mid.mid) - 1 - ntohl (ch->mid_recv.mid); |
1342 | 1261 | ||
1343 | if (delta > 63) | 1262 | if (delta > 63) |
1344 | ch->mid_futures = 0; | 1263 | ch->mid_futures = 0; |
1345 | else | 1264 | else |
1346 | ch->mid_futures >>= delta; | 1265 | ch->mid_futures >>= delta; |
1347 | ch->mid_recv.mid = htonl (1 + ntohl (msg->mid.mid)); | 1266 | ch->mid_recv.mid = htonl (1 + ntohl (msg->mid.mid)); |
1348 | } | 1267 | } |
1349 | send_channel_data_ack (ch); | 1268 | send_channel_data_ack (ch); |
1350 | return; | 1269 | return; |
@@ -1357,8 +1276,8 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1357 | mid_min = ntohl (ch->mid_recv.mid); | 1276 | mid_min = ntohl (ch->mid_recv.mid); |
1358 | mid_max = mid_min + ch->max_pending_messages; | 1277 | mid_max = mid_min + ch->max_pending_messages; |
1359 | mid_msg = ntohl (msg->mid.mid); | 1278 | mid_msg = ntohl (msg->mid.mid); |
1360 | if ( ( (uint32_t) (mid_msg - mid_min) > ch->max_pending_messages) || | 1279 | if (((uint32_t) (mid_msg - mid_min) > ch->max_pending_messages) || |
1361 | ( (uint32_t) (mid_max - mid_msg) > ch->max_pending_messages) ) | 1280 | ((uint32_t) (mid_max - mid_msg) > ch->max_pending_messages)) |
1362 | { | 1281 | { |
1363 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1282 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1364 | "%s at %u drops ancient or far-future message %u\n", | 1283 | "%s at %u drops ancient or far-future message %u\n", |
@@ -1386,10 +1305,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1386 | (unsigned int) payload_size, | 1305 | (unsigned int) payload_size, |
1387 | GCCH_2s (ch), | 1306 | GCCH_2s (ch), |
1388 | ntohl (msg->mid.mid)); | 1307 | ntohl (msg->mid.mid)); |
1389 | GNUNET_STATISTICS_update (stats, | 1308 | GNUNET_STATISTICS_update (stats, "# duplicate DATA", 1, GNUNET_NO); |
1390 | "# duplicate DATA", | ||
1391 | 1, | ||
1392 | GNUNET_NO); | ||
1393 | GNUNET_MQ_discard (env); | 1309 | GNUNET_MQ_discard (env); |
1394 | send_channel_data_ack (ch); | 1310 | send_channel_data_ack (ch); |
1395 | return; | 1311 | return; |
@@ -1411,8 +1327,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1411 | * We always send if possible in this case. | 1327 | * We always send if possible in this case. |
1412 | * It is guaranteed that the queued MID < received MID | 1328 | * It is guaranteed that the queued MID < received MID |
1413 | **/ | 1329 | **/ |
1414 | if ((NULL != ccc->head_recv) && | 1330 | if ((NULL != ccc->head_recv) && (GNUNET_YES == ccc->client_ready)) |
1415 | (GNUNET_YES == ccc->client_ready)) | ||
1416 | { | 1331 | { |
1417 | next_msg = ccc->head_recv; | 1332 | next_msg = ccc->head_recv; |
1418 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1333 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1421,14 +1336,11 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1421 | GCCH_2s (ch), | 1336 | GCCH_2s (ch), |
1422 | GSC_2s (ccc->c)); | 1337 | GSC_2s (ccc->c)); |
1423 | ccc->client_ready = GNUNET_NO; | 1338 | ccc->client_ready = GNUNET_NO; |
1424 | GSC_send_to_client (ccc->c, | 1339 | GSC_send_to_client (ccc->c, next_msg->env); |
1425 | next_msg->env); | ||
1426 | ch->mid_recv.mid = htonl (1 + ntohl (next_msg->mid.mid)); | 1340 | ch->mid_recv.mid = htonl (1 + ntohl (next_msg->mid.mid)); |
1427 | ch->mid_futures >>= 1; | 1341 | ch->mid_futures >>= 1; |
1428 | send_channel_data_ack (ch); | 1342 | send_channel_data_ack (ch); |
1429 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | 1343 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, next_msg); |
1430 | ccc->tail_recv, | ||
1431 | next_msg); | ||
1432 | ccc->num_recv--; | 1344 | ccc->num_recv--; |
1433 | /* Do not process duplicate MID */ | 1345 | /* Do not process duplicate MID */ |
1434 | if (msg->mid.mid == next_msg->mid.mid) /* Duplicate */ | 1346 | if (msg->mid.mid == next_msg->mid.mid) /* Duplicate */ |
@@ -1473,9 +1385,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1473 | GNUNET_NO); | 1385 | GNUNET_NO); |
1474 | drop = ccc->head_recv; | 1386 | drop = ccc->head_recv; |
1475 | GNUNET_assert (NULL != drop); | 1387 | GNUNET_assert (NULL != drop); |
1476 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | 1388 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, drop); |
1477 | ccc->tail_recv, | ||
1478 | drop); | ||
1479 | ccc->num_recv--; | 1389 | ccc->num_recv--; |
1480 | GNUNET_MQ_discard (drop->env); | 1390 | GNUNET_MQ_discard (drop->env); |
1481 | GNUNET_free (drop); | 1391 | GNUNET_free (drop); |
@@ -1506,13 +1416,8 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1506 | (unsigned int) payload_size, | 1416 | (unsigned int) payload_size, |
1507 | GCCH_2s (ch), | 1417 | GCCH_2s (ch), |
1508 | ntohl (msg->mid.mid)); | 1418 | ntohl (msg->mid.mid)); |
1509 | GNUNET_STATISTICS_update (stats, | 1419 | GNUNET_STATISTICS_update (stats, "# duplicate DATA", 1, GNUNET_NO); |
1510 | "# duplicate DATA", | 1420 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, com); |
1511 | 1, | ||
1512 | GNUNET_NO); | ||
1513 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | ||
1514 | ccc->tail_recv, | ||
1515 | com); | ||
1516 | ccc->num_recv--; | 1421 | ccc->num_recv--; |
1517 | GNUNET_MQ_discard (com->env); | 1422 | GNUNET_MQ_discard (com->env); |
1518 | GNUNET_free (com); | 1423 | GNUNET_free (com); |
@@ -1521,9 +1426,7 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | |||
1521 | } | 1426 | } |
1522 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1427 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1523 | "Queued %s payload of %u bytes on %s-%X(%p) (mid %u, need %u first)\n", | 1428 | "Queued %s payload of %u bytes on %s-%X(%p) (mid %u, need %u first)\n", |
1524 | (GNUNET_YES == ccc->client_ready) | 1429 | (GNUNET_YES == ccc->client_ready) ? "out-of-order" : "client-not-ready", |
1525 | ? "out-of-order" | ||
1526 | : "client-not-ready", | ||
1527 | (unsigned int) payload_size, | 1430 | (unsigned int) payload_size, |
1528 | GCCH_2s (ch), | 1431 | GCCH_2s (ch), |
1529 | ntohl (ccc->ccn.channel_of_client), | 1432 | ntohl (ccc->ccn.channel_of_client), |
@@ -1571,10 +1474,7 @@ retry_transmission (void *cls) | |||
1571 | "Retrying transmission on %s of message %u\n", | 1474 | "Retrying transmission on %s of message %u\n", |
1572 | GCCH_2s (ch), | 1475 | GCCH_2s (ch), |
1573 | (unsigned int) ntohl (crm->data_message->mid.mid)); | 1476 | (unsigned int) ntohl (crm->data_message->mid.mid)); |
1574 | crm->qe = GCT_send (ch->t, | 1477 | crm->qe = GCT_send (ch->t, &crm->data_message->header, &data_sent_cb, crm); |
1575 | &crm->data_message->header, | ||
1576 | &data_sent_cb, | ||
1577 | crm); | ||
1578 | GNUNET_assert (NULL == ch->retry_data_task); | 1478 | GNUNET_assert (NULL == ch->retry_data_task); |
1579 | } | 1479 | } |
1580 | 1480 | ||
@@ -1592,9 +1492,7 @@ handle_matching_ack (struct CadetChannel *ch, | |||
1592 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, | 1492 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, |
1593 | struct CadetReliableMessage *crm) | 1493 | struct CadetReliableMessage *crm) |
1594 | { | 1494 | { |
1595 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, | 1495 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, ch->tail_sent, crm); |
1596 | ch->tail_sent, | ||
1597 | crm); | ||
1598 | ch->pending_messages--; | 1496 | ch->pending_messages--; |
1599 | GNUNET_assert (ch->pending_messages < ch->max_pending_messages); | 1497 | GNUNET_assert (ch->pending_messages < ch->max_pending_messages); |
1600 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1498 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1607,23 +1505,19 @@ handle_matching_ack (struct CadetChannel *ch, | |||
1607 | GCT_send_cancel (crm->qe); | 1505 | GCT_send_cancel (crm->qe); |
1608 | crm->qe = NULL; | 1506 | crm->qe = NULL; |
1609 | } | 1507 | } |
1610 | if ( (1 == crm->num_transmissions) && | 1508 | if ((1 == crm->num_transmissions) && (NULL != cti)) |
1611 | (NULL != cti) ) | ||
1612 | { | 1509 | { |
1613 | GCC_ack_observed (cti); | 1510 | GCC_ack_observed (cti); |
1614 | if (0 == GNUNET_memcmp (cti, | 1511 | if (0 == GNUNET_memcmp (cti, &crm->connection_taken)) |
1615 | &crm->connection_taken)) | ||
1616 | { | 1512 | { |
1617 | GCC_latency_observed (cti, | 1513 | GCC_latency_observed (cti, |
1618 | GNUNET_TIME_absolute_get_duration (crm->first_transmission_time)); | 1514 | GNUNET_TIME_absolute_get_duration ( |
1515 | crm->first_transmission_time)); | ||
1619 | } | 1516 | } |
1620 | } | 1517 | } |
1621 | GNUNET_free (crm->data_message); | 1518 | GNUNET_free (crm->data_message); |
1622 | GNUNET_free (crm); | 1519 | GNUNET_free (crm); |
1623 | send_ack_to_client (ch, | 1520 | send_ack_to_client (ch, (NULL == ch->owner) ? GNUNET_NO : GNUNET_YES); |
1624 | (NULL == ch->owner) | ||
1625 | ? GNUNET_NO | ||
1626 | : GNUNET_YES); | ||
1627 | } | 1521 | } |
1628 | 1522 | ||
1629 | 1523 | ||
@@ -1636,9 +1530,10 @@ handle_matching_ack (struct CadetChannel *ch, | |||
1636 | * @param ack details about what was received | 1530 | * @param ack details about what was received |
1637 | */ | 1531 | */ |
1638 | void | 1532 | void |
1639 | GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | 1533 | GCCH_handle_channel_plaintext_data_ack ( |
1640 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, | 1534 | struct CadetChannel *ch, |
1641 | const struct GNUNET_CADET_ChannelDataAckMessage *ack) | 1535 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, |
1536 | const struct GNUNET_CADET_ChannelDataAckMessage *ack) | ||
1642 | { | 1537 | { |
1643 | struct CadetReliableMessage *crm; | 1538 | struct CadetReliableMessage *crm; |
1644 | struct CadetReliableMessage *crmn; | 1539 | struct CadetReliableMessage *crmn; |
@@ -1660,9 +1555,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1660 | mid_base = ntohl (ack->mid.mid); | 1555 | mid_base = ntohl (ack->mid.mid); |
1661 | mid_mask = GNUNET_htonll (ack->futures); | 1556 | mid_mask = GNUNET_htonll (ack->futures); |
1662 | found = GNUNET_NO; | 1557 | found = GNUNET_NO; |
1663 | for (crm = ch->head_sent; | 1558 | for (crm = ch->head_sent; NULL != crm; crm = crmn) |
1664 | NULL != crm; | ||
1665 | crm = crmn) | ||
1666 | { | 1559 | { |
1667 | crmn = crm->next; | 1560 | crmn = crm->next; |
1668 | delta = (unsigned int) (ntohl (crm->data_message->mid.mid) - mid_base); | 1561 | delta = (unsigned int) (ntohl (crm->data_message->mid.mid) - mid_base); |
@@ -1674,9 +1567,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1674 | (unsigned int) mid_base, | 1567 | (unsigned int) mid_base, |
1675 | ntohl (crm->data_message->mid.mid), | 1568 | ntohl (crm->data_message->mid.mid), |
1676 | GCCH_2s (ch)); | 1569 | GCCH_2s (ch)); |
1677 | handle_matching_ack (ch, | 1570 | handle_matching_ack (ch, cti, crm); |
1678 | cti, | ||
1679 | crm); | ||
1680 | found = GNUNET_YES; | 1571 | found = GNUNET_YES; |
1681 | continue; | 1572 | continue; |
1682 | } | 1573 | } |
@@ -1694,9 +1585,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1694 | "Got DATA_ACK with mask for %u on %s\n", | 1585 | "Got DATA_ACK with mask for %u on %s\n", |
1695 | ntohl (crm->data_message->mid.mid), | 1586 | ntohl (crm->data_message->mid.mid), |
1696 | GCCH_2s (ch)); | 1587 | GCCH_2s (ch)); |
1697 | handle_matching_ack (ch, | 1588 | handle_matching_ack (ch, cti, crm); |
1698 | cti, | ||
1699 | crm); | ||
1700 | found = GNUNET_YES; | 1589 | found = GNUNET_YES; |
1701 | } | 1590 | } |
1702 | } | 1591 | } |
@@ -1707,10 +1596,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1707 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1596 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1708 | "Duplicate DATA_ACK on %s, ignoring\n", | 1597 | "Duplicate DATA_ACK on %s, ignoring\n", |
1709 | GCCH_2s (ch)); | 1598 | GCCH_2s (ch)); |
1710 | GNUNET_STATISTICS_update (stats, | 1599 | GNUNET_STATISTICS_update (stats, "# duplicate DATA_ACKs", 1, GNUNET_NO); |
1711 | "# duplicate DATA_ACKs", | ||
1712 | 1, | ||
1713 | GNUNET_NO); | ||
1714 | return; | 1600 | return; |
1715 | } | 1601 | } |
1716 | if (NULL != ch->retry_data_task) | 1602 | if (NULL != ch->retry_data_task) |
@@ -1718,12 +1604,10 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1718 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); | 1604 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); |
1719 | ch->retry_data_task = NULL; | 1605 | ch->retry_data_task = NULL; |
1720 | } | 1606 | } |
1721 | if ( (NULL != ch->head_sent) && | 1607 | if ((NULL != ch->head_sent) && (NULL == ch->head_sent->qe)) |
1722 | (NULL == ch->head_sent->qe) ) | 1608 | ch->retry_data_task = GNUNET_SCHEDULER_add_at (ch->head_sent->next_retry, |
1723 | ch->retry_data_task | 1609 | &retry_transmission, |
1724 | = GNUNET_SCHEDULER_add_at (ch->head_sent->next_retry, | 1610 | ch); |
1725 | &retry_transmission, | ||
1726 | ch); | ||
1727 | } | 1611 | } |
1728 | 1612 | ||
1729 | 1613 | ||
@@ -1737,8 +1621,9 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1737 | * NULL if we are simulating receiving a destroy due to shutdown | 1621 | * NULL if we are simulating receiving a destroy due to shutdown |
1738 | */ | 1622 | */ |
1739 | void | 1623 | void |
1740 | GCCH_handle_remote_destroy (struct CadetChannel *ch, | 1624 | GCCH_handle_remote_destroy ( |
1741 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) | 1625 | struct CadetChannel *ch, |
1626 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) | ||
1742 | { | 1627 | { |
1743 | struct CadetChannelClient *ccc; | 1628 | struct CadetChannelClient *ccc; |
1744 | 1629 | ||
@@ -1753,8 +1638,7 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch, | |||
1753 | return; | 1638 | return; |
1754 | } | 1639 | } |
1755 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | 1640 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; |
1756 | if ( (NULL != ccc) && | 1641 | if ((NULL != ccc) && (NULL != ccc->head_recv)) |
1757 | (NULL != ccc->head_recv) ) | ||
1758 | { | 1642 | { |
1759 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1643 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1760 | "Lost end of transmission due to remote shutdown on %s\n", | 1644 | "Lost end of transmission due to remote shutdown on %s\n", |
@@ -1763,9 +1647,7 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch, | |||
1763 | } | 1647 | } |
1764 | ch->destroy = GNUNET_YES; | 1648 | ch->destroy = GNUNET_YES; |
1765 | if (NULL != ccc) | 1649 | if (NULL != ccc) |
1766 | GSC_handle_remote_channel_destroy (ccc->c, | 1650 | GSC_handle_remote_channel_destroy (ccc->c, ccc->ccn, ch); |
1767 | ccc->ccn, | ||
1768 | ch); | ||
1769 | channel_destroy (ch); | 1651 | channel_destroy (ch); |
1770 | } | 1652 | } |
1771 | 1653 | ||
@@ -1783,8 +1665,7 @@ cmp_crm_by_next_retry (void *cls, | |||
1783 | struct CadetReliableMessage *crm1, | 1665 | struct CadetReliableMessage *crm1, |
1784 | struct CadetReliableMessage *crm2) | 1666 | struct CadetReliableMessage *crm2) |
1785 | { | 1667 | { |
1786 | if (crm1->next_retry.abs_value_us < | 1668 | if (crm1->next_retry.abs_value_us < crm2->next_retry.abs_value_us) |
1787 | crm2->next_retry.abs_value_us) | ||
1788 | return GNUNET_YES; | 1669 | return GNUNET_YES; |
1789 | return GNUNET_NO; | 1670 | return GNUNET_NO; |
1790 | } | 1671 | } |
@@ -1810,18 +1691,13 @@ data_sent_cb (void *cls, | |||
1810 | GNUNET_assert (GNUNET_NO == ch->is_loopback); | 1691 | GNUNET_assert (GNUNET_NO == ch->is_loopback); |
1811 | GNUNET_assert (NULL != crm->qe); | 1692 | GNUNET_assert (NULL != crm->qe); |
1812 | crm->qe = NULL; | 1693 | crm->qe = NULL; |
1813 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, | 1694 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, ch->tail_sent, crm); |
1814 | ch->tail_sent, | ||
1815 | crm); | ||
1816 | if (GNUNET_NO == ch->reliable) | 1695 | if (GNUNET_NO == ch->reliable) |
1817 | { | 1696 | { |
1818 | GNUNET_free (crm->data_message); | 1697 | GNUNET_free (crm->data_message); |
1819 | GNUNET_free (crm); | 1698 | GNUNET_free (crm); |
1820 | ch->pending_messages--; | 1699 | ch->pending_messages--; |
1821 | send_ack_to_client (ch, | 1700 | send_ack_to_client (ch, (NULL == ch->owner) ? GNUNET_NO : GNUNET_YES); |
1822 | (NULL == ch->owner) | ||
1823 | ? GNUNET_NO | ||
1824 | : GNUNET_YES); | ||
1825 | return; | 1701 | return; |
1826 | } | 1702 | } |
1827 | if (NULL == cid) | 1703 | if (NULL == cid) |
@@ -1841,8 +1717,7 @@ data_sent_cb (void *cls, | |||
1841 | GCC_ack_expected (cid); | 1717 | GCC_ack_expected (cid); |
1842 | } | 1718 | } |
1843 | } | 1719 | } |
1844 | if ( (0 == crm->retry_delay.rel_value_us) && | 1720 | if ((0 == crm->retry_delay.rel_value_us) && (NULL != cid)) |
1845 | (NULL != cid) ) | ||
1846 | { | 1721 | { |
1847 | struct CadetConnection *cc = GCC_lookup (cid); | 1722 | struct CadetConnection *cc = GCC_lookup (cid); |
1848 | 1723 | ||
@@ -1852,8 +1727,7 @@ data_sent_cb (void *cls, | |||
1852 | crm->retry_delay = ch->retry_time; | 1727 | crm->retry_delay = ch->retry_time; |
1853 | } | 1728 | } |
1854 | crm->retry_delay = GNUNET_TIME_STD_BACKOFF (crm->retry_delay); | 1729 | crm->retry_delay = GNUNET_TIME_STD_BACKOFF (crm->retry_delay); |
1855 | crm->retry_delay = GNUNET_TIME_relative_max (crm->retry_delay, | 1730 | crm->retry_delay = GNUNET_TIME_relative_max (crm->retry_delay, MIN_RTT_DELAY); |
1856 | MIN_RTT_DELAY); | ||
1857 | crm->next_retry = GNUNET_TIME_relative_to_absolute (crm->retry_delay); | 1731 | crm->next_retry = GNUNET_TIME_relative_to_absolute (crm->retry_delay); |
1858 | 1732 | ||
1859 | GNUNET_CONTAINER_DLL_insert_sorted (struct CadetReliableMessage, | 1733 | GNUNET_CONTAINER_DLL_insert_sorted (struct CadetReliableMessage, |
@@ -1866,16 +1740,16 @@ data_sent_cb (void *cls, | |||
1866 | "Message %u sent, next transmission on %s in %s\n", | 1740 | "Message %u sent, next transmission on %s in %s\n", |
1867 | (unsigned int) ntohl (crm->data_message->mid.mid), | 1741 | (unsigned int) ntohl (crm->data_message->mid.mid), |
1868 | GCCH_2s (ch), | 1742 | GCCH_2s (ch), |
1869 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (ch->head_sent->next_retry), | 1743 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining ( |
1744 | ch->head_sent->next_retry), | ||
1870 | GNUNET_YES)); | 1745 | GNUNET_YES)); |
1871 | if (NULL == ch->head_sent->qe) | 1746 | if (NULL == ch->head_sent->qe) |
1872 | { | 1747 | { |
1873 | if (NULL != ch->retry_data_task) | 1748 | if (NULL != ch->retry_data_task) |
1874 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); | 1749 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); |
1875 | ch->retry_data_task | 1750 | ch->retry_data_task = GNUNET_SCHEDULER_add_at (ch->head_sent->next_retry, |
1876 | = GNUNET_SCHEDULER_add_at (ch->head_sent->next_retry, | 1751 | &retry_transmission, |
1877 | &retry_transmission, | 1752 | ch); |
1878 | ch); | ||
1879 | } | 1753 | } |
1880 | } | 1754 | } |
1881 | 1755 | ||
@@ -1921,19 +1795,16 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1921 | struct GNUNET_CADET_LocalData *ld; | 1795 | struct GNUNET_CADET_LocalData *ld; |
1922 | int ack_to_owner; | 1796 | int ack_to_owner; |
1923 | 1797 | ||
1924 | env = GNUNET_MQ_msg_extra (ld, | 1798 | env = |
1925 | buf_len, | 1799 | GNUNET_MQ_msg_extra (ld, buf_len, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); |
1926 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); | 1800 | if ((NULL != ch->owner) && |
1927 | if ( (NULL != ch->owner) && | 1801 | (sender_ccn.channel_of_client == ch->owner->ccn.channel_of_client)) |
1928 | (sender_ccn.channel_of_client == | ||
1929 | ch->owner->ccn.channel_of_client) ) | ||
1930 | { | 1802 | { |
1931 | receiver = ch->dest; | 1803 | receiver = ch->dest; |
1932 | ack_to_owner = GNUNET_YES; | 1804 | ack_to_owner = GNUNET_YES; |
1933 | } | 1805 | } |
1934 | else if ( (NULL != ch->dest) && | 1806 | else if ((NULL != ch->dest) && |
1935 | (sender_ccn.channel_of_client == | 1807 | (sender_ccn.channel_of_client == ch->dest->ccn.channel_of_client)) |
1936 | ch->dest->ccn.channel_of_client) ) | ||
1937 | { | 1808 | { |
1938 | receiver = ch->owner; | 1809 | receiver = ch->owner; |
1939 | ack_to_owner = GNUNET_NO; | 1810 | ack_to_owner = GNUNET_NO; |
@@ -1945,16 +1816,12 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1945 | } | 1816 | } |
1946 | GNUNET_assert (NULL != receiver); | 1817 | GNUNET_assert (NULL != receiver); |
1947 | ld->ccn = receiver->ccn; | 1818 | ld->ccn = receiver->ccn; |
1948 | GNUNET_memcpy (&ld[1], | 1819 | GNUNET_memcpy (&ld[1], buf, buf_len); |
1949 | buf, | ||
1950 | buf_len); | ||
1951 | if (GNUNET_YES == receiver->client_ready) | 1820 | if (GNUNET_YES == receiver->client_ready) |
1952 | { | 1821 | { |
1953 | ch->pending_messages--; | 1822 | ch->pending_messages--; |
1954 | GSC_send_to_client (receiver->c, | 1823 | GSC_send_to_client (receiver->c, env); |
1955 | env); | 1824 | send_ack_to_client (ch, ack_to_owner); |
1956 | send_ack_to_client (ch, | ||
1957 | ack_to_owner); | ||
1958 | } | 1825 | } |
1959 | else | 1826 | else |
1960 | { | 1827 | { |
@@ -1973,19 +1840,17 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1973 | /* Everything is correct, send the message. */ | 1840 | /* Everything is correct, send the message. */ |
1974 | crm = GNUNET_malloc (sizeof (*crm)); | 1841 | crm = GNUNET_malloc (sizeof (*crm)); |
1975 | crm->ch = ch; | 1842 | crm->ch = ch; |
1976 | crm->data_message = GNUNET_malloc (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) | 1843 | crm->data_message = GNUNET_malloc ( |
1977 | + buf_len); | 1844 | sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); |
1978 | crm->data_message->header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); | 1845 | crm->data_message->header.size = |
1979 | crm->data_message->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | 1846 | htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); |
1847 | crm->data_message->header.type = | ||
1848 | htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | ||
1980 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); | 1849 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); |
1981 | crm->data_message->mid = ch->mid_send; | 1850 | crm->data_message->mid = ch->mid_send; |
1982 | crm->data_message->ctn = ch->ctn; | 1851 | crm->data_message->ctn = ch->ctn; |
1983 | GNUNET_memcpy (&crm->data_message[1], | 1852 | GNUNET_memcpy (&crm->data_message[1], buf, buf_len); |
1984 | buf, | 1853 | GNUNET_CONTAINER_DLL_insert_tail (ch->head_sent, ch->tail_sent, crm); |
1985 | buf_len); | ||
1986 | GNUNET_CONTAINER_DLL_insert_tail (ch->head_sent, | ||
1987 | ch->tail_sent, | ||
1988 | crm); | ||
1989 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1854 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1990 | "Sending message %u from local client to %s with %u bytes\n", | 1855 | "Sending message %u from local client to %s with %u bytes\n", |
1991 | ntohl (crm->data_message->mid.mid), | 1856 | ntohl (crm->data_message->mid.mid), |
@@ -1996,10 +1861,7 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1996 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); | 1861 | GNUNET_SCHEDULER_cancel (ch->retry_data_task); |
1997 | ch->retry_data_task = NULL; | 1862 | ch->retry_data_task = NULL; |
1998 | } | 1863 | } |
1999 | crm->qe = GCT_send (ch->t, | 1864 | crm->qe = GCT_send (ch->t, &crm->data_message->header, &data_sent_cb, crm); |
2000 | &crm->data_message->header, | ||
2001 | &data_sent_cb, | ||
2002 | crm); | ||
2003 | GNUNET_assert (NULL == ch->retry_data_task); | 1865 | GNUNET_assert (NULL == ch->retry_data_task); |
2004 | return GNUNET_OK; | 1866 | return GNUNET_OK; |
2005 | } | 1867 | } |
@@ -2019,11 +1881,11 @@ GCCH_handle_local_ack (struct CadetChannel *ch, | |||
2019 | struct CadetChannelClient *ccc; | 1881 | struct CadetChannelClient *ccc; |
2020 | struct CadetOutOfOrderMessage *com; | 1882 | struct CadetOutOfOrderMessage *com; |
2021 | 1883 | ||
2022 | if ( (NULL != ch->owner) && | 1884 | if ((NULL != ch->owner) && |
2023 | (ch->owner->ccn.channel_of_client == client_ccn.channel_of_client) ) | 1885 | (ch->owner->ccn.channel_of_client == client_ccn.channel_of_client)) |
2024 | ccc = ch->owner; | 1886 | ccc = ch->owner; |
2025 | else if ( (NULL != ch->dest) && | 1887 | else if ((NULL != ch->dest) && |
2026 | (ch->dest->ccn.channel_of_client == client_ccn.channel_of_client) ) | 1888 | (ch->dest->ccn.channel_of_client == client_ccn.channel_of_client)) |
2027 | ccc = ch->dest; | 1889 | ccc = ch->dest; |
2028 | else | 1890 | else |
2029 | GNUNET_assert (0); | 1891 | GNUNET_assert (0); |
@@ -2045,35 +1907,28 @@ GCCH_handle_local_ack (struct CadetChannel *ch, | |||
2045 | int to_owner; | 1907 | int to_owner; |
2046 | 1908 | ||
2047 | /* Messages are always in-order, just send */ | 1909 | /* Messages are always in-order, just send */ |
2048 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | 1910 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, com); |
2049 | ccc->tail_recv, | ||
2050 | com); | ||
2051 | ccc->num_recv--; | 1911 | ccc->num_recv--; |
2052 | GSC_send_to_client (ccc->c, | 1912 | GSC_send_to_client (ccc->c, com->env); |
2053 | com->env); | ||
2054 | /* Notify sender that we can receive more */ | 1913 | /* Notify sender that we can receive more */ |
2055 | if ( (NULL != ch->owner) && | 1914 | if ((NULL != ch->owner) && |
2056 | (ccc->ccn.channel_of_client == | 1915 | (ccc->ccn.channel_of_client == ch->owner->ccn.channel_of_client)) |
2057 | ch->owner->ccn.channel_of_client) ) | ||
2058 | { | 1916 | { |
2059 | to_owner = GNUNET_NO; | 1917 | to_owner = GNUNET_NO; |
2060 | } | 1918 | } |
2061 | else | 1919 | else |
2062 | { | 1920 | { |
2063 | GNUNET_assert ( (NULL != ch->dest) && | 1921 | GNUNET_assert ((NULL != ch->dest) && (ccc->ccn.channel_of_client == |
2064 | (ccc->ccn.channel_of_client == | 1922 | ch->dest->ccn.channel_of_client)); |
2065 | ch->dest->ccn.channel_of_client) ); | ||
2066 | to_owner = GNUNET_YES; | 1923 | to_owner = GNUNET_YES; |
2067 | } | 1924 | } |
2068 | send_ack_to_client (ch, | 1925 | send_ack_to_client (ch, to_owner); |
2069 | to_owner); | ||
2070 | GNUNET_free (com); | 1926 | GNUNET_free (com); |
2071 | return; | 1927 | return; |
2072 | } | 1928 | } |
2073 | 1929 | ||
2074 | if ( (com->mid.mid != ch->mid_recv.mid) && | 1930 | if ((com->mid.mid != ch->mid_recv.mid) && (GNUNET_NO == ch->out_of_order) && |
2075 | (GNUNET_NO == ch->out_of_order) && | 1931 | (GNUNET_YES == ch->reliable)) |
2076 | (GNUNET_YES == ch->reliable) ) | ||
2077 | { | 1932 | { |
2078 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1933 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2079 | "Got LOCAL_ACK, %s-%X ready to receive more data (but next one is out-of-order %u vs. %u)!\n", | 1934 | "Got LOCAL_ACK, %s-%X ready to receive more data (but next one is out-of-order %u vs. %u)!\n", |
@@ -2092,9 +1947,7 @@ GCCH_handle_local_ack (struct CadetChannel *ch, | |||
2092 | GCCH_2s (ch)); | 1947 | GCCH_2s (ch)); |
2093 | 1948 | ||
2094 | /* all good, pass next message to client */ | 1949 | /* all good, pass next message to client */ |
2095 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, | 1950 | GNUNET_CONTAINER_DLL_remove (ccc->head_recv, ccc->tail_recv, com); |
2096 | ccc->tail_recv, | ||
2097 | com); | ||
2098 | ccc->num_recv--; | 1951 | ccc->num_recv--; |
2099 | /* FIXME: if unreliable, this is not aggressive | 1952 | /* FIXME: if unreliable, this is not aggressive |
2100 | enough, as it would be OK to have lost some! */ | 1953 | enough, as it would be OK to have lost some! */ |
@@ -2102,21 +1955,20 @@ GCCH_handle_local_ack (struct CadetChannel *ch, | |||
2102 | ch->mid_recv.mid = htonl (1 + ntohl (com->mid.mid)); | 1955 | ch->mid_recv.mid = htonl (1 + ntohl (com->mid.mid)); |
2103 | ch->mid_futures >>= 1; /* equivalent to division by 2 */ | 1956 | ch->mid_futures >>= 1; /* equivalent to division by 2 */ |
2104 | ccc->client_ready = GNUNET_NO; | 1957 | ccc->client_ready = GNUNET_NO; |
2105 | GSC_send_to_client (ccc->c, | 1958 | GSC_send_to_client (ccc->c, com->env); |
2106 | com->env); | ||
2107 | GNUNET_free (com); | 1959 | GNUNET_free (com); |
2108 | send_channel_data_ack (ch); | 1960 | send_channel_data_ack (ch); |
2109 | if (NULL != ccc->head_recv) | 1961 | if (NULL != ccc->head_recv) |
2110 | return; | 1962 | return; |
2111 | if (GNUNET_NO == ch->destroy) | 1963 | if (GNUNET_NO == ch->destroy) |
2112 | return; | 1964 | return; |
2113 | GCT_send_channel_destroy (ch->t, | 1965 | GCT_send_channel_destroy (ch->t, ch->ctn); |
2114 | ch->ctn); | ||
2115 | channel_destroy (ch); | 1966 | channel_destroy (ch); |
2116 | } | 1967 | } |
2117 | 1968 | ||
2118 | 1969 | ||
2119 | #define LOG2(level, ...) GNUNET_log_from_nocheck(level,"cadet-chn",__VA_ARGS__) | 1970 | #define LOG2(level, ...) \ |
1971 | GNUNET_log_from_nocheck (level, "cadet-chn", __VA_ARGS__) | ||
2120 | 1972 | ||
2121 | 1973 | ||
2122 | /** | 1974 | /** |
@@ -2126,15 +1978,16 @@ GCCH_handle_local_ack (struct CadetChannel *ch, | |||
2126 | * @param level Debug level to use. | 1978 | * @param level Debug level to use. |
2127 | */ | 1979 | */ |
2128 | void | 1980 | void |
2129 | GCCH_debug (struct CadetChannel *ch, | 1981 | GCCH_debug (struct CadetChannel *ch, enum GNUNET_ErrorType level) |
2130 | enum GNUNET_ErrorType level) | ||
2131 | { | 1982 | { |
2132 | #if !defined(GNUNET_CULL_LOGGING) | 1983 | #if ! defined(GNUNET_CULL_LOGGING) |
2133 | int do_log; | 1984 | int do_log; |
2134 | 1985 | ||
2135 | do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK), | 1986 | do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK), |
2136 | "cadet-chn", | 1987 | "cadet-chn", |
2137 | __FILE__, __FUNCTION__, __LINE__); | 1988 | __FILE__, |
1989 | __FUNCTION__, | ||
1990 | __LINE__); | ||
2138 | if (0 == do_log) | 1991 | if (0 == do_log) |
2139 | return; | 1992 | return; |
2140 | 1993 | ||
@@ -2143,11 +1996,7 @@ GCCH_debug (struct CadetChannel *ch, | |||
2143 | LOG2 (level, "CHN *** DEBUG NULL CHANNEL ***\n"); | 1996 | LOG2 (level, "CHN *** DEBUG NULL CHANNEL ***\n"); |
2144 | return; | 1997 | return; |
2145 | } | 1998 | } |
2146 | LOG2 (level, | 1999 | LOG2 (level, "CHN %s:%X (%p)\n", GCT_2s (ch->t), ch->ctn, ch); |
2147 | "CHN %s:%X (%p)\n", | ||
2148 | GCT_2s (ch->t), | ||
2149 | ch->ctn, | ||
2150 | ch); | ||
2151 | if (NULL != ch->owner) | 2000 | if (NULL != ch->owner) |
2152 | { | 2001 | { |
2153 | LOG2 (level, | 2002 | LOG2 (level, |
@@ -2173,5 +2022,4 @@ GCCH_debug (struct CadetChannel *ch, | |||
2173 | } | 2022 | } |
2174 | 2023 | ||
2175 | 2024 | ||
2176 | |||
2177 | /* end of gnunet-service-cadet-new_channel.c */ | 2025 | /* end of gnunet-service-cadet-new_channel.c */ |
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 1f7e86d60..8849e563f 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -11,7 +11,7 @@ | |||
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 | Affero 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 Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -35,14 +35,15 @@ | |||
35 | #include "cadet_protocol.h" | 35 | #include "cadet_protocol.h" |
36 | 36 | ||
37 | 37 | ||
38 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-con",__VA_ARGS__) | 38 | #define LOG(level, ...) GNUNET_log_from (level, "cadet-con", __VA_ARGS__) |
39 | 39 | ||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * How long do we wait initially before retransmitting the KX? | 42 | * How long do we wait initially before retransmitting the KX? |
43 | * TODO: replace by 2 RTT if/once we have connection-level RTT data! | 43 | * TODO: replace by 2 RTT if/once we have connection-level RTT data! |
44 | */ | 44 | */ |
45 | #define INITIAL_CONNECTION_CREATE_RETRY_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200) | 45 | #define INITIAL_CONNECTION_CREATE_RETRY_DELAY \ |
46 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200) | ||
46 | 47 | ||
47 | 48 | ||
48 | /** | 49 | /** |
@@ -161,11 +162,6 @@ struct CadetConnection | |||
161 | enum CadetConnectionState state; | 162 | enum CadetConnectionState state; |
162 | 163 | ||
163 | /** | 164 | /** |
164 | * Options for the route, control buffering. | ||
165 | */ | ||
166 | enum GNUNET_CADET_ChannelOption options; | ||
167 | |||
168 | /** | ||
169 | * How many latency observations did we make for this connection? | 165 | * How many latency observations did we make for this connection? |
170 | */ | 166 | */ |
171 | unsigned int latency_datapoints; | 167 | unsigned int latency_datapoints; |
@@ -179,7 +175,6 @@ struct CadetConnection | |||
179 | * Are we ready to transmit via @e mq_man right now? | 175 | * Are we ready to transmit via @e mq_man right now? |
180 | */ | 176 | */ |
181 | int mqm_ready; | 177 | int mqm_ready; |
182 | |||
183 | }; | 178 | }; |
184 | 179 | ||
185 | 180 | ||
@@ -213,18 +208,16 @@ update_state (struct CadetConnection *cc, | |||
213 | int old_ready; | 208 | int old_ready; |
214 | int new_ready; | 209 | int new_ready; |
215 | 210 | ||
216 | if ( (new_state == cc->state) && | 211 | if ((new_state == cc->state) && (new_mqm_ready == cc->mqm_ready)) |
217 | (new_mqm_ready == cc->mqm_ready) ) | ||
218 | return; /* no change, nothing to do */ | 212 | return; /* no change, nothing to do */ |
219 | old_ready = ( (CADET_CONNECTION_READY == cc->state) && | 213 | old_ready = |
220 | (GNUNET_YES == cc->mqm_ready) ); | 214 | ((CADET_CONNECTION_READY == cc->state) && (GNUNET_YES == cc->mqm_ready)); |
221 | new_ready = ( (CADET_CONNECTION_READY == new_state) && | 215 | new_ready = |
222 | (GNUNET_YES == new_mqm_ready) ); | 216 | ((CADET_CONNECTION_READY == new_state) && (GNUNET_YES == new_mqm_ready)); |
223 | cc->state = new_state; | 217 | cc->state = new_state; |
224 | cc->mqm_ready = new_mqm_ready; | 218 | cc->mqm_ready = new_mqm_ready; |
225 | if (old_ready != new_ready) | 219 | if (old_ready != new_ready) |
226 | cc->ready_cb (cc->ready_cb_cls, | 220 | cc->ready_cb (cc->ready_cb_cls, new_ready); |
227 | new_ready); | ||
228 | } | 221 | } |
229 | 222 | ||
230 | 223 | ||
@@ -237,13 +230,10 @@ update_state (struct CadetConnection *cc, | |||
237 | static void | 230 | static void |
238 | GCC_destroy (struct CadetConnection *cc) | 231 | GCC_destroy (struct CadetConnection *cc) |
239 | { | 232 | { |
240 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 233 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying %s\n", GCC_2s (cc)); |
241 | "Destroying %s\n", | ||
242 | GCC_2s (cc)); | ||
243 | if (NULL != cc->mq_man) | 234 | if (NULL != cc->mq_man) |
244 | { | 235 | { |
245 | GCP_request_mq_cancel (cc->mq_man, | 236 | GCP_request_mq_cancel (cc->mq_man, NULL); |
246 | NULL); | ||
247 | cc->mq_man = NULL; | 237 | cc->mq_man = NULL; |
248 | } | 238 | } |
249 | if (NULL != cc->task) | 239 | if (NULL != cc->task) |
@@ -256,22 +246,19 @@ GCC_destroy (struct CadetConnection *cc) | |||
256 | GCT_send_cancel (cc->keepalive_qe); | 246 | GCT_send_cancel (cc->keepalive_qe); |
257 | cc->keepalive_qe = NULL; | 247 | cc->keepalive_qe = NULL; |
258 | } | 248 | } |
259 | GCPP_del_connection (cc->path, | 249 | GCPP_del_connection (cc->path, cc->off, cc); |
260 | cc->off, | 250 | for (unsigned int i = 0; i < cc->off; i++) |
261 | cc); | 251 | GCP_remove_connection (GCPP_get_peer_at_offset (cc->path, i), cc); |
262 | for (unsigned int i=0;i<cc->off;i++) | 252 | GNUNET_assert ( |
263 | GCP_remove_connection (GCPP_get_peer_at_offset (cc->path, | 253 | GNUNET_YES == |
264 | i), | 254 | GNUNET_CONTAINER_multishortmap_remove (connections, |
265 | cc); | 255 | &GCC_get_id (cc) |
266 | GNUNET_assert (GNUNET_YES == | 256 | ->connection_of_tunnel, |
267 | GNUNET_CONTAINER_multishortmap_remove (connections, | 257 | cc)); |
268 | &GCC_get_id (cc)->connection_of_tunnel, | ||
269 | cc)); | ||
270 | GNUNET_free (cc); | 258 | GNUNET_free (cc); |
271 | } | 259 | } |
272 | 260 | ||
273 | 261 | ||
274 | |||
275 | /** | 262 | /** |
276 | * Destroy a connection, called when the CORE layer is already done | 263 | * Destroy a connection, called when the CORE layer is already done |
277 | * (i.e. has received a BROKEN message), but if we still have to | 264 | * (i.e. has received a BROKEN message), but if we still have to |
@@ -303,18 +290,16 @@ void | |||
303 | GCC_destroy_without_tunnel (struct CadetConnection *cc) | 290 | GCC_destroy_without_tunnel (struct CadetConnection *cc) |
304 | { | 291 | { |
305 | cc->ct = NULL; | 292 | cc->ct = NULL; |
306 | if ( (CADET_CONNECTION_SENDING_CREATE != cc->state) && | 293 | if ((CADET_CONNECTION_SENDING_CREATE != cc->state) && (NULL != cc->mq_man)) |
307 | (NULL != cc->mq_man) ) | ||
308 | { | 294 | { |
309 | struct GNUNET_MQ_Envelope *env; | 295 | struct GNUNET_MQ_Envelope *env; |
310 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; | 296 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; |
311 | 297 | ||
312 | /* Need to notify next hop that we are down. */ | 298 | /* Need to notify next hop that we are down. */ |
313 | env = GNUNET_MQ_msg (destroy_msg, | 299 | env = |
314 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY); | 300 | GNUNET_MQ_msg (destroy_msg, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY); |
315 | destroy_msg->cid = cc->cid; | 301 | destroy_msg->cid = cc->cid; |
316 | GCP_request_mq_cancel (cc->mq_man, | 302 | GCP_request_mq_cancel (cc->mq_man, env); |
317 | env); | ||
318 | cc->mq_man = NULL; | 303 | cc->mq_man = NULL; |
319 | } | 304 | } |
320 | GCC_destroy (cc); | 305 | GCC_destroy (cc); |
@@ -372,11 +357,9 @@ keepalive_done (void *cls, | |||
372 | struct CadetConnection *cc = cls; | 357 | struct CadetConnection *cc = cls; |
373 | 358 | ||
374 | cc->keepalive_qe = NULL; | 359 | cc->keepalive_qe = NULL; |
375 | if ( (GNUNET_YES == cc->mqm_ready) && | 360 | if ((GNUNET_YES == cc->mqm_ready) && (NULL == cc->task)) |
376 | (NULL == cc->task) ) | 361 | cc->task = |
377 | cc->task = GNUNET_SCHEDULER_add_delayed (keepalive_period, | 362 | GNUNET_SCHEDULER_add_delayed (keepalive_period, &send_keepalive, cc); |
378 | &send_keepalive, | ||
379 | cc); | ||
380 | } | 363 | } |
381 | 364 | ||
382 | 365 | ||
@@ -396,9 +379,8 @@ send_keepalive (void *cls) | |||
396 | if (CADET_TUNNEL_KEY_OK != GCT_get_estate (cc->ct->t)) | 379 | if (CADET_TUNNEL_KEY_OK != GCT_get_estate (cc->ct->t)) |
397 | { | 380 | { |
398 | /* Tunnel not yet ready, wait with keepalives... */ | 381 | /* Tunnel not yet ready, wait with keepalives... */ |
399 | cc->task = GNUNET_SCHEDULER_add_delayed (keepalive_period, | 382 | cc->task = |
400 | &send_keepalive, | 383 | GNUNET_SCHEDULER_add_delayed (keepalive_period, &send_keepalive, cc); |
401 | cc); | ||
402 | return; | 384 | return; |
403 | } | 385 | } |
404 | GNUNET_assert (NULL != cc->ct); | 386 | GNUNET_assert (NULL != cc->ct); |
@@ -408,18 +390,11 @@ send_keepalive (void *cls) | |||
408 | "Sending KEEPALIVE on behalf of %s via %s\n", | 390 | "Sending KEEPALIVE on behalf of %s via %s\n", |
409 | GCC_2s (cc), | 391 | GCC_2s (cc), |
410 | GCT_2s (cc->ct->t)); | 392 | GCT_2s (cc->ct->t)); |
411 | GNUNET_STATISTICS_update (stats, | 393 | GNUNET_STATISTICS_update (stats, "# keepalives sent", 1, GNUNET_NO); |
412 | "# keepalives sent", | ||
413 | 1, | ||
414 | GNUNET_NO); | ||
415 | msg.size = htons (sizeof (msg)); | 394 | msg.size = htons (sizeof (msg)); |
416 | msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE); | 395 | msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE); |
417 | 396 | ||
418 | cc->keepalive_qe | 397 | cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc); |
419 | = GCT_send (cc->ct->t, | ||
420 | &msg, | ||
421 | &keepalive_done, | ||
422 | cc); | ||
423 | } | 398 | } |
424 | 399 | ||
425 | 400 | ||
@@ -480,10 +455,7 @@ GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | |||
480 | cc = GCC_lookup (cid); | 455 | cc = GCC_lookup (cid); |
481 | if (NULL == cc) | 456 | if (NULL == cc) |
482 | return; /* whopise, connection alredy down? */ | 457 | return; /* whopise, connection alredy down? */ |
483 | GNUNET_STATISTICS_update (stats, | 458 | GNUNET_STATISTICS_update (stats, "# latencies observed", 1, GNUNET_NO); |
484 | "# latencies observed", | ||
485 | 1, | ||
486 | GNUNET_NO); | ||
487 | cc->latency_datapoints++; | 459 | cc->latency_datapoints++; |
488 | if (cc->latency_datapoints >= 7) | 460 | if (cc->latency_datapoints >= 7) |
489 | weight = 7.0; | 461 | weight = 7.0; |
@@ -492,7 +464,8 @@ GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | |||
492 | /* Compute weighted average, giving at MOST weight 7 to the | 464 | /* Compute weighted average, giving at MOST weight 7 to the |
493 | existing values, or less if that value is based on fewer than 7 | 465 | existing values, or less if that value is based on fewer than 7 |
494 | measurements. */ | 466 | measurements. */ |
495 | result = (weight * cc->metrics.aged_latency.rel_value_us) + 1.0 * latency.rel_value_us; | 467 | result = (weight * cc->metrics.aged_latency.rel_value_us) + |
468 | 1.0 * latency.rel_value_us; | ||
496 | result /= (weight + 1.0); | 469 | result /= (weight + 1.0); |
497 | cc->metrics.aged_latency.rel_value_us = (uint64_t) result; | 470 | cc->metrics.aged_latency.rel_value_us = (uint64_t) result; |
498 | } | 471 | } |
@@ -521,15 +494,11 @@ GCC_handle_connection_create_ack (struct CadetConnection *cc) | |||
521 | cc->task = NULL; | 494 | cc->task = NULL; |
522 | } | 495 | } |
523 | cc->metrics.age = GNUNET_TIME_absolute_get (); | 496 | cc->metrics.age = GNUNET_TIME_absolute_get (); |
524 | update_state (cc, | 497 | update_state (cc, CADET_CONNECTION_READY, cc->mqm_ready); |
525 | CADET_CONNECTION_READY, | 498 | if ((NULL == cc->keepalive_qe) && (GNUNET_YES == cc->mqm_ready) && |
526 | cc->mqm_ready); | 499 | (NULL == cc->task)) |
527 | if ( (NULL == cc->keepalive_qe) && | 500 | cc->task = |
528 | (GNUNET_YES == cc->mqm_ready) && | 501 | GNUNET_SCHEDULER_add_delayed (keepalive_period, &send_keepalive, cc); |
529 | (NULL == cc->task) ) | ||
530 | cc->task = GNUNET_SCHEDULER_add_delayed (keepalive_period, | ||
531 | &send_keepalive, | ||
532 | cc); | ||
533 | } | 502 | } |
534 | 503 | ||
535 | 504 | ||
@@ -557,8 +526,7 @@ GCC_handle_kx (struct CadetConnection *cc, | |||
557 | GCC_2s (cc)); | 526 | GCC_2s (cc)); |
558 | GCC_handle_connection_create_ack (cc); | 527 | GCC_handle_connection_create_ack (cc); |
559 | } | 528 | } |
560 | GCT_handle_kx (cc->ct, | 529 | GCT_handle_kx (cc->ct, msg); |
561 | msg); | ||
562 | } | 530 | } |
563 | 531 | ||
564 | 532 | ||
@@ -586,8 +554,7 @@ GCC_handle_kx_auth (struct CadetConnection *cc, | |||
586 | GCC_2s (cc)); | 554 | GCC_2s (cc)); |
587 | GCC_handle_connection_create_ack (cc); | 555 | GCC_handle_connection_create_ack (cc); |
588 | } | 556 | } |
589 | GCT_handle_kx_auth (cc->ct, | 557 | GCT_handle_kx_auth (cc->ct, msg); |
590 | msg); | ||
591 | } | 558 | } |
592 | 559 | ||
593 | 560 | ||
@@ -611,8 +578,7 @@ GCC_handle_encrypted (struct CadetConnection *cc, | |||
611 | GCC_handle_connection_create_ack (cc); | 578 | GCC_handle_connection_create_ack (cc); |
612 | } | 579 | } |
613 | cc->metrics.last_use = GNUNET_TIME_absolute_get (); | 580 | cc->metrics.last_use = GNUNET_TIME_absolute_get (); |
614 | GCT_handle_encrypted (cc->ct, | 581 | GCT_handle_encrypted (cc->ct, msg); |
615 | msg); | ||
616 | } | 582 | } |
617 | 583 | ||
618 | 584 | ||
@@ -632,16 +598,17 @@ send_create (void *cls) | |||
632 | 598 | ||
633 | cc->task = NULL; | 599 | cc->task = NULL; |
634 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 600 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
635 | env = GNUNET_MQ_msg_extra (create_msg, | 601 | env = |
636 | (2 + cc->off) * sizeof (struct GNUNET_PeerIdentity), | 602 | GNUNET_MQ_msg_extra (create_msg, |
637 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); | 603 | (2 + cc->off) * sizeof (struct GNUNET_PeerIdentity), |
638 | create_msg->options = htonl ((uint32_t) cc->options); | 604 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); |
605 | //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. | ||
606 | create_msg->options = 2; | ||
639 | create_msg->cid = cc->cid; | 607 | create_msg->cid = cc->cid; |
640 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; | 608 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; |
641 | pids[0] = my_full_id; | 609 | pids[0] = my_full_id; |
642 | for (unsigned int i=0;i<=cc->off;i++) | 610 | for (unsigned int i = 0; i <= cc->off; i++) |
643 | pids[i + 1] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, | 611 | pids[i + 1] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, i)); |
644 | i)); | ||
645 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 612 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
646 | "Sending CADET_CONNECTION_CREATE message for %s with %u hops\n", | 613 | "Sending CADET_CONNECTION_CREATE message for %s with %u hops\n", |
647 | GCC_2s (cc), | 614 | GCC_2s (cc), |
@@ -649,11 +616,8 @@ send_create (void *cls) | |||
649 | cc->env = env; | 616 | cc->env = env; |
650 | cc->retry_delay = GNUNET_TIME_STD_BACKOFF (cc->retry_delay); | 617 | cc->retry_delay = GNUNET_TIME_STD_BACKOFF (cc->retry_delay); |
651 | cc->create_at = GNUNET_TIME_relative_to_absolute (cc->retry_delay); | 618 | cc->create_at = GNUNET_TIME_relative_to_absolute (cc->retry_delay); |
652 | update_state (cc, | 619 | update_state (cc, CADET_CONNECTION_SENT, GNUNET_NO); |
653 | CADET_CONNECTION_SENT, | 620 | GCP_send (cc->mq_man, env); |
654 | GNUNET_NO); | ||
655 | GCP_send (cc->mq_man, | ||
656 | env); | ||
657 | } | 621 | } |
658 | 622 | ||
659 | 623 | ||
@@ -674,22 +638,18 @@ send_create_ack (void *cls) | |||
674 | "Sending CONNECTION_CREATE_ACK message for %s\n", | 638 | "Sending CONNECTION_CREATE_ACK message for %s\n", |
675 | GCC_2s (cc)); | 639 | GCC_2s (cc)); |
676 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 640 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
677 | env = GNUNET_MQ_msg (ack_msg, | 641 | env = |
678 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK); | 642 | GNUNET_MQ_msg (ack_msg, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK); |
679 | ack_msg->cid = cc->cid; | 643 | ack_msg->cid = cc->cid; |
680 | cc->env = env; | 644 | cc->env = env; |
681 | cc->retry_delay = GNUNET_TIME_STD_BACKOFF (cc->retry_delay); | 645 | cc->retry_delay = GNUNET_TIME_STD_BACKOFF (cc->retry_delay); |
682 | cc->create_ack_at = GNUNET_TIME_relative_to_absolute (cc->retry_delay); | 646 | cc->create_ack_at = GNUNET_TIME_relative_to_absolute (cc->retry_delay); |
683 | if (CADET_CONNECTION_CREATE_RECEIVED == cc->state) | 647 | if (CADET_CONNECTION_CREATE_RECEIVED == cc->state) |
684 | update_state (cc, | 648 | update_state (cc, CADET_CONNECTION_READY, GNUNET_NO); |
685 | CADET_CONNECTION_READY, | ||
686 | GNUNET_NO); | ||
687 | if (CADET_CONNECTION_READY == cc->state) | 649 | if (CADET_CONNECTION_READY == cc->state) |
688 | cc->task = GNUNET_SCHEDULER_add_delayed (keepalive_period, | 650 | cc->task = |
689 | &send_keepalive, | 651 | GNUNET_SCHEDULER_add_delayed (keepalive_period, &send_keepalive, cc); |
690 | cc); | 652 | GCP_send (cc->mq_man, env); |
691 | GCP_send (cc->mq_man, | ||
692 | env); | ||
693 | } | 653 | } |
694 | 654 | ||
695 | 655 | ||
@@ -711,14 +671,11 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
711 | (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy"); | 671 | (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy"); |
712 | /* Revert back to the state of having only received the 'CREATE', | 672 | /* Revert back to the state of having only received the 'CREATE', |
713 | and immediately proceed to send the CREATE_ACK. */ | 673 | and immediately proceed to send the CREATE_ACK. */ |
714 | update_state (cc, | 674 | update_state (cc, CADET_CONNECTION_CREATE_RECEIVED, cc->mqm_ready); |
715 | CADET_CONNECTION_CREATE_RECEIVED, | ||
716 | cc->mqm_ready); | ||
717 | if (NULL != cc->task) | 675 | if (NULL != cc->task) |
718 | GNUNET_SCHEDULER_cancel (cc->task); | 676 | GNUNET_SCHEDULER_cancel (cc->task); |
719 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_ack_at, | 677 | cc->task = |
720 | &send_create_ack, | 678 | GNUNET_SCHEDULER_add_at (cc->create_ack_at, &send_create_ack, cc); |
721 | cc); | ||
722 | } | 679 | } |
723 | else | 680 | else |
724 | { | 681 | { |
@@ -743,20 +700,15 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
743 | * and the last envelope was discarded | 700 | * and the last envelope was discarded |
744 | */ | 701 | */ |
745 | static void | 702 | static void |
746 | manage_first_hop_mq (void *cls, | 703 | manage_first_hop_mq (void *cls, int available) |
747 | int available) | ||
748 | { | 704 | { |
749 | struct CadetConnection *cc = cls; | 705 | struct CadetConnection *cc = cls; |
750 | 706 | ||
751 | if (GNUNET_YES != available) | 707 | if (GNUNET_YES != available) |
752 | { | 708 | { |
753 | /* Connection is down, for now... */ | 709 | /* Connection is down, for now... */ |
754 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 710 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Core MQ for %s went down\n", GCC_2s (cc)); |
755 | "Core MQ for %s went down\n", | 711 | update_state (cc, CADET_CONNECTION_NEW, GNUNET_NO); |
756 | GCC_2s (cc)); | ||
757 | update_state (cc, | ||
758 | CADET_CONNECTION_NEW, | ||
759 | GNUNET_NO); | ||
760 | cc->retry_delay = INITIAL_CONNECTION_CREATE_RETRY_DELAY; | 712 | cc->retry_delay = INITIAL_CONNECTION_CREATE_RETRY_DELAY; |
761 | if (NULL != cc->task) | 713 | if (NULL != cc->task) |
762 | { | 714 | { |
@@ -766,9 +718,7 @@ manage_first_hop_mq (void *cls, | |||
766 | return; | 718 | return; |
767 | } | 719 | } |
768 | 720 | ||
769 | update_state (cc, | 721 | update_state (cc, cc->state, GNUNET_YES); |
770 | cc->state, | ||
771 | GNUNET_YES); | ||
772 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 722 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
773 | "Core MQ for %s became available in state %d\n", | 723 | "Core MQ for %s became available in state %d\n", |
774 | GCC_2s (cc), | 724 | GCC_2s (cc), |
@@ -777,9 +727,7 @@ manage_first_hop_mq (void *cls, | |||
777 | { | 727 | { |
778 | case CADET_CONNECTION_NEW: | 728 | case CADET_CONNECTION_NEW: |
779 | /* Transmit immediately */ | 729 | /* Transmit immediately */ |
780 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_at, | 730 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_at, &send_create, cc); |
781 | &send_create, | ||
782 | cc); | ||
783 | break; | 731 | break; |
784 | case CADET_CONNECTION_SENDING_CREATE: | 732 | case CADET_CONNECTION_SENDING_CREATE: |
785 | /* Should not be possible to be called in this state. */ | 733 | /* Should not be possible to be called in this state. */ |
@@ -787,30 +735,25 @@ manage_first_hop_mq (void *cls, | |||
787 | break; | 735 | break; |
788 | case CADET_CONNECTION_SENT: | 736 | case CADET_CONNECTION_SENT: |
789 | /* Retry a bit later... */ | 737 | /* Retry a bit later... */ |
790 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_at, | 738 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_at, &send_create, cc); |
791 | &send_create, | ||
792 | cc); | ||
793 | break; | 739 | break; |
794 | case CADET_CONNECTION_CREATE_RECEIVED: | 740 | case CADET_CONNECTION_CREATE_RECEIVED: |
795 | /* We got the 'CREATE' (incoming connection), should send the CREATE_ACK */ | 741 | /* We got the 'CREATE' (incoming connection), should send the CREATE_ACK */ |
796 | cc->metrics.age = GNUNET_TIME_absolute_get (); | 742 | cc->metrics.age = GNUNET_TIME_absolute_get (); |
797 | cc->task = GNUNET_SCHEDULER_add_at (cc->create_ack_at, | 743 | cc->task = |
798 | &send_create_ack, | 744 | GNUNET_SCHEDULER_add_at (cc->create_ack_at, &send_create_ack, cc); |
799 | cc); | ||
800 | break; | 745 | break; |
801 | case CADET_CONNECTION_READY: | 746 | case CADET_CONNECTION_READY: |
802 | if ( (NULL == cc->keepalive_qe) && | 747 | if ((NULL == cc->keepalive_qe) && (GNUNET_YES == cc->mqm_ready) && |
803 | (GNUNET_YES == cc->mqm_ready) && | 748 | (NULL == cc->task)) |
804 | (NULL == cc->task) ) | ||
805 | { | 749 | { |
806 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 750 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
807 | "Scheduling keepalive for %s in %s\n", | 751 | "Scheduling keepalive for %s in %s\n", |
808 | GCC_2s (cc), | 752 | GCC_2s (cc), |
809 | GNUNET_STRINGS_relative_time_to_string (keepalive_period, | 753 | GNUNET_STRINGS_relative_time_to_string (keepalive_period, |
810 | GNUNET_YES)); | 754 | GNUNET_YES)); |
811 | cc->task = GNUNET_SCHEDULER_add_delayed (keepalive_period, | 755 | cc->task = |
812 | &send_keepalive, | 756 | GNUNET_SCHEDULER_add_delayed (keepalive_period, &send_keepalive, cc); |
813 | cc); | ||
814 | } | 757 | } |
815 | break; | 758 | break; |
816 | } | 759 | } |
@@ -825,7 +768,6 @@ manage_first_hop_mq (void *cls, | |||
825 | * @param destination where to go | 768 | * @param destination where to go |
826 | * @param path which path to take (may not be the full path) | 769 | * @param path which path to take (may not be the full path) |
827 | * @param off offset of @a destination on @a path | 770 | * @param off offset of @a destination on @a path |
828 | * @param options options for the connection | ||
829 | * @param ct which tunnel uses this connection | 771 | * @param ct which tunnel uses this connection |
830 | * @param init_state initial state for the connection | 772 | * @param init_state initial state for the connection |
831 | * @param ready_cb function to call when ready to transmit | 773 | * @param ready_cb function to call when ready to transmit |
@@ -836,7 +778,6 @@ static struct CadetConnection * | |||
836 | connection_create (struct CadetPeer *destination, | 778 | connection_create (struct CadetPeer *destination, |
837 | struct CadetPeerPath *path, | 779 | struct CadetPeerPath *path, |
838 | unsigned int off, | 780 | unsigned int off, |
839 | enum GNUNET_CADET_ChannelOption options, | ||
840 | struct CadetTConnection *ct, | 781 | struct CadetTConnection *ct, |
841 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 782 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
842 | enum CadetConnectionState init_state, | 783 | enum CadetConnectionState init_state, |
@@ -847,17 +788,17 @@ connection_create (struct CadetPeer *destination, | |||
847 | struct CadetPeer *first_hop; | 788 | struct CadetPeer *first_hop; |
848 | 789 | ||
849 | cc = GNUNET_new (struct CadetConnection); | 790 | cc = GNUNET_new (struct CadetConnection); |
850 | cc->options = options; | ||
851 | cc->state = init_state; | 791 | cc->state = init_state; |
852 | cc->ct = ct; | 792 | cc->ct = ct; |
853 | cc->cid = *cid; | 793 | cc->cid = *cid; |
854 | cc->retry_delay = GNUNET_TIME_relative_multiply (INITIAL_CONNECTION_CREATE_RETRY_DELAY, | 794 | cc->retry_delay = |
855 | off); | 795 | GNUNET_TIME_relative_multiply (INITIAL_CONNECTION_CREATE_RETRY_DELAY, off); |
856 | GNUNET_assert (GNUNET_OK == | 796 | GNUNET_assert (GNUNET_OK == |
857 | GNUNET_CONTAINER_multishortmap_put (connections, | 797 | GNUNET_CONTAINER_multishortmap_put ( |
858 | &GCC_get_id (cc)->connection_of_tunnel, | 798 | connections, |
859 | cc, | 799 | &GCC_get_id (cc)->connection_of_tunnel, |
860 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 800 | cc, |
801 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
861 | cc->ready_cb = ready_cb; | 802 | cc->ready_cb = ready_cb; |
862 | cc->ready_cb_cls = ready_cb_cls; | 803 | cc->ready_cb_cls = ready_cb_cls; |
863 | cc->path = path; | 804 | cc->path = path; |
@@ -867,18 +808,11 @@ connection_create (struct CadetPeer *destination, | |||
867 | GCC_2s (cc), | 808 | GCC_2s (cc), |
868 | GCPP_2s (path), | 809 | GCPP_2s (path), |
869 | off); | 810 | off); |
870 | GCPP_add_connection (path, | 811 | GCPP_add_connection (path, off, cc); |
871 | off, | 812 | for (unsigned int i = 0; i < off; i++) |
872 | cc); | 813 | GCP_add_connection (GCPP_get_peer_at_offset (path, i), cc); |
873 | for (unsigned int i=0;i<off;i++) | 814 | first_hop = GCPP_get_peer_at_offset (path, 0); |
874 | GCP_add_connection (GCPP_get_peer_at_offset (path, | 815 | cc->mq_man = GCP_request_mq (first_hop, &manage_first_hop_mq, cc); |
875 | i), | ||
876 | cc); | ||
877 | first_hop = GCPP_get_peer_at_offset (path, | ||
878 | 0); | ||
879 | cc->mq_man = GCP_request_mq (first_hop, | ||
880 | &manage_first_hop_mq, | ||
881 | cc); | ||
882 | return cc; | 816 | return cc; |
883 | } | 817 | } |
884 | 818 | ||
@@ -890,7 +824,6 @@ connection_create (struct CadetPeer *destination, | |||
890 | * | 824 | * |
891 | * @param destination where to go | 825 | * @param destination where to go |
892 | * @param path which path to take (may not be the full path) | 826 | * @param path which path to take (may not be the full path) |
893 | * @param options options for the connection | ||
894 | * @param ct which tunnel uses this connection | 827 | * @param ct which tunnel uses this connection |
895 | * @param ready_cb function to call when ready to transmit | 828 | * @param ready_cb function to call when ready to transmit |
896 | * @param ready_cb_cls closure for @a cb | 829 | * @param ready_cb_cls closure for @a cb |
@@ -900,7 +833,6 @@ connection_create (struct CadetPeer *destination, | |||
900 | struct CadetConnection * | 833 | struct CadetConnection * |
901 | GCC_create_inbound (struct CadetPeer *destination, | 834 | GCC_create_inbound (struct CadetPeer *destination, |
902 | struct CadetPeerPath *path, | 835 | struct CadetPeerPath *path, |
903 | enum GNUNET_CADET_ChannelOption options, | ||
904 | struct CadetTConnection *ct, | 836 | struct CadetTConnection *ct, |
905 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 837 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
906 | GCC_ReadyCallback ready_cb, | 838 | GCC_ReadyCallback ready_cb, |
@@ -909,18 +841,14 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
909 | struct CadetConnection *cc; | 841 | struct CadetConnection *cc; |
910 | unsigned int off; | 842 | unsigned int off; |
911 | 843 | ||
912 | off = GCPP_find_peer (path, | 844 | off = GCPP_find_peer (path, destination); |
913 | destination); | ||
914 | GNUNET_assert (UINT_MAX != off); | 845 | GNUNET_assert (UINT_MAX != off); |
915 | cc = GCPP_get_connection (path, | 846 | cc = GCPP_get_connection (path, destination, off); |
916 | destination, | ||
917 | off); | ||
918 | if (NULL != cc) | 847 | if (NULL != cc) |
919 | { | 848 | { |
920 | int cmp; | 849 | int cmp; |
921 | 850 | ||
922 | cmp = GNUNET_memcmp (cid, | 851 | cmp = GNUNET_memcmp (cid, &cc->cid); |
923 | &cc->cid); | ||
924 | if (0 == cmp) | 852 | if (0 == cmp) |
925 | { | 853 | { |
926 | /* Two peers picked the SAME random connection identifier at the | 854 | /* Two peers picked the SAME random connection identifier at the |
@@ -956,7 +884,6 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
956 | return connection_create (destination, | 884 | return connection_create (destination, |
957 | path, | 885 | path, |
958 | off, | 886 | off, |
959 | options, | ||
960 | ct, | 887 | ct, |
961 | cid, | 888 | cid, |
962 | CADET_CONNECTION_CREATE_RECEIVED, | 889 | CADET_CONNECTION_CREATE_RECEIVED, |
@@ -972,7 +899,6 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
972 | * @param destination where to go | 899 | * @param destination where to go |
973 | * @param path which path to take (may not be the full path) | 900 | * @param path which path to take (may not be the full path) |
974 | * @param off offset of @a destination on @a path | 901 | * @param off offset of @a destination on @a path |
975 | * @param options options for the connection | ||
976 | * @param ct tunnel that uses the connection | 902 | * @param ct tunnel that uses the connection |
977 | * @param ready_cb function to call when ready to transmit | 903 | * @param ready_cb function to call when ready to transmit |
978 | * @param ready_cb_cls closure for @a cb | 904 | * @param ready_cb_cls closure for @a cb |
@@ -982,20 +908,16 @@ struct CadetConnection * | |||
982 | GCC_create (struct CadetPeer *destination, | 908 | GCC_create (struct CadetPeer *destination, |
983 | struct CadetPeerPath *path, | 909 | struct CadetPeerPath *path, |
984 | unsigned int off, | 910 | unsigned int off, |
985 | enum GNUNET_CADET_ChannelOption options, | ||
986 | struct CadetTConnection *ct, | 911 | struct CadetTConnection *ct, |
987 | GCC_ReadyCallback ready_cb, | 912 | GCC_ReadyCallback ready_cb, |
988 | void *ready_cb_cls) | 913 | void *ready_cb_cls) |
989 | { | 914 | { |
990 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; | 915 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; |
991 | 916 | ||
992 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, | 917 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &cid, sizeof (cid)); |
993 | &cid, | ||
994 | sizeof (cid)); | ||
995 | return connection_create (destination, | 918 | return connection_create (destination, |
996 | path, | 919 | path, |
997 | off, | 920 | off, |
998 | options, | ||
999 | ct, | 921 | ct, |
1000 | &cid, | 922 | &cid, |
1001 | CADET_CONNECTION_NEW, | 923 | CADET_CONNECTION_NEW, |
@@ -1015,8 +937,7 @@ GCC_create (struct CadetPeer *destination, | |||
1015 | * yet have a #GNUNET_MQ_notify_sent() callback attached to it | 937 | * yet have a #GNUNET_MQ_notify_sent() callback attached to it |
1016 | */ | 938 | */ |
1017 | void | 939 | void |
1018 | GCC_transmit (struct CadetConnection *cc, | 940 | GCC_transmit (struct CadetConnection *cc, struct GNUNET_MQ_Envelope *env) |
1019 | struct GNUNET_MQ_Envelope *env) | ||
1020 | { | 941 | { |
1021 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 942 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1022 | "Scheduling message for transmission on %s\n", | 943 | "Scheduling message for transmission on %s\n", |
@@ -1030,8 +951,7 @@ GCC_transmit (struct CadetConnection *cc, | |||
1030 | GNUNET_SCHEDULER_cancel (cc->task); | 951 | GNUNET_SCHEDULER_cancel (cc->task); |
1031 | cc->task = NULL; | 952 | cc->task = NULL; |
1032 | } | 953 | } |
1033 | GCP_send (cc->mq_man, | 954 | GCP_send (cc->mq_man, env); |
1034 | env); | ||
1035 | } | 955 | } |
1036 | 956 | ||
1037 | 957 | ||
@@ -1043,8 +963,7 @@ GCC_transmit (struct CadetConnection *cc, | |||
1043 | * @return path to @a cc | 963 | * @return path to @a cc |
1044 | */ | 964 | */ |
1045 | struct CadetPeerPath * | 965 | struct CadetPeerPath * |
1046 | GCC_get_path (struct CadetConnection *cc, | 966 | GCC_get_path (struct CadetConnection *cc, unsigned int *off) |
1047 | unsigned int *off) | ||
1048 | { | 967 | { |
1049 | *off = cc->off; | 968 | *off = cc->off; |
1050 | return cc->path; | 969 | return cc->path; |
@@ -1094,7 +1013,8 @@ GCC_2s (const struct CadetConnection *cc) | |||
1094 | } | 1013 | } |
1095 | 1014 | ||
1096 | 1015 | ||
1097 | #define LOG2(level, ...) GNUNET_log_from_nocheck(level,"cadet-con",__VA_ARGS__) | 1016 | #define LOG2(level, ...) \ |
1017 | GNUNET_log_from_nocheck (level, "cadet-con", __VA_ARGS__) | ||
1098 | 1018 | ||
1099 | 1019 | ||
1100 | /** | 1020 | /** |
@@ -1104,21 +1024,21 @@ GCC_2s (const struct CadetConnection *cc) | |||
1104 | * @param level Debug level to use. | 1024 | * @param level Debug level to use. |
1105 | */ | 1025 | */ |
1106 | void | 1026 | void |
1107 | GCC_debug (struct CadetConnection *cc, | 1027 | GCC_debug (struct CadetConnection *cc, enum GNUNET_ErrorType level) |
1108 | enum GNUNET_ErrorType level) | ||
1109 | { | 1028 | { |
1110 | #if !defined(GNUNET_CULL_LOGGING) | 1029 | #if ! defined(GNUNET_CULL_LOGGING) |
1111 | int do_log; | 1030 | int do_log; |
1112 | 1031 | ||
1113 | do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK), | 1032 | do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK), |
1114 | "cadet-con", | 1033 | "cadet-con", |
1115 | __FILE__, __FUNCTION__, __LINE__); | 1034 | __FILE__, |
1035 | __FUNCTION__, | ||
1036 | __LINE__); | ||
1116 | if (0 == do_log) | 1037 | if (0 == do_log) |
1117 | return; | 1038 | return; |
1118 | if (NULL == cc) | 1039 | if (NULL == cc) |
1119 | { | 1040 | { |
1120 | LOG2 (level, | 1041 | LOG2 (level, "Connection (NULL)\n"); |
1121 | "Connection (NULL)\n"); | ||
1122 | return; | 1042 | return; |
1123 | } | 1043 | } |
1124 | LOG2 (level, | 1044 | LOG2 (level, |
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index 7cdbc9dee..d3de3347c 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
4 | Copyright (C) 2001-2017 GNUnet e.V. | 3 | Copyright (C) 2001-2017 GNUnet e.V. |
@@ -89,7 +88,6 @@ GCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid); | |||
89 | * @param destination where to go | 88 | * @param destination where to go |
90 | * @param path which path to take (may not be the full path) | 89 | * @param path which path to take (may not be the full path) |
91 | * @param off offset of @a destination on @a path | 90 | * @param off offset of @a destination on @a path |
92 | * @param options options for the connection | ||
93 | * @param ct which tunnel uses this connection | 91 | * @param ct which tunnel uses this connection |
94 | * @param ready_cb function to call when ready to transmit | 92 | * @param ready_cb function to call when ready to transmit |
95 | * @param ready_cb_cls closure for @a cb | 93 | * @param ready_cb_cls closure for @a cb |
@@ -99,7 +97,6 @@ struct CadetConnection * | |||
99 | GCC_create (struct CadetPeer *destination, | 97 | GCC_create (struct CadetPeer *destination, |
100 | struct CadetPeerPath *path, | 98 | struct CadetPeerPath *path, |
101 | unsigned int off, | 99 | unsigned int off, |
102 | enum GNUNET_CADET_ChannelOption options, | ||
103 | struct CadetTConnection *ct, | 100 | struct CadetTConnection *ct, |
104 | GCC_ReadyCallback ready_cb, | 101 | GCC_ReadyCallback ready_cb, |
105 | void *ready_cb_cls); | 102 | void *ready_cb_cls); |
@@ -112,7 +109,6 @@ GCC_create (struct CadetPeer *destination, | |||
112 | * | 109 | * |
113 | * @param destination where to go | 110 | * @param destination where to go |
114 | * @param path which path to take (may not be the full path) | 111 | * @param path which path to take (may not be the full path) |
115 | * @param options options for the connection | ||
116 | * @param ct which tunnel uses this connection | 112 | * @param ct which tunnel uses this connection |
117 | * @param ready_cb function to call when ready to transmit | 113 | * @param ready_cb function to call when ready to transmit |
118 | * @param ready_cb_cls closure for @a cb | 114 | * @param ready_cb_cls closure for @a cb |
@@ -122,7 +118,6 @@ GCC_create (struct CadetPeer *destination, | |||
122 | struct CadetConnection * | 118 | struct CadetConnection * |
123 | GCC_create_inbound (struct CadetPeer *destination, | 119 | GCC_create_inbound (struct CadetPeer *destination, |
124 | struct CadetPeerPath *path, | 120 | struct CadetPeerPath *path, |
125 | enum GNUNET_CADET_ChannelOption options, | ||
126 | struct CadetTConnection *ct, | 121 | struct CadetTConnection *ct, |
127 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 122 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
128 | GCC_ReadyCallback ready_cb, | 123 | GCC_ReadyCallback ready_cb, |
diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index 879230d29..ec70a968b 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c | |||
@@ -11,7 +11,7 @@ | |||
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 | Affero 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 Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -39,15 +39,13 @@ | |||
39 | #include "gnunet_statistics_service.h" | 39 | #include "gnunet_statistics_service.h" |
40 | #include "cadet_protocol.h" | 40 | #include "cadet_protocol.h" |
41 | 41 | ||
42 | 42 | #define LOG(level, ...) GNUNET_log_from (level, "cadet-cor", __VA_ARGS__) | |
43 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-cor",__VA_ARGS__) | ||
44 | 43 | ||
45 | /** | 44 | /** |
46 | * Information we keep per direction for a route. | 45 | * Information we keep per direction for a route. |
47 | */ | 46 | */ |
48 | struct RouteDirection; | 47 | struct RouteDirection; |
49 | 48 | ||
50 | |||
51 | /** | 49 | /** |
52 | * Set of CadetRoutes that have exactly the same number of messages | 50 | * Set of CadetRoutes that have exactly the same number of messages |
53 | * in their buffer. Used so we can efficiently find all of those | 51 | * in their buffer. Used so we can efficiently find all of those |
@@ -140,7 +138,6 @@ struct RouteDirection | |||
140 | * Is @e mqm currently ready for transmission? | 138 | * Is @e mqm currently ready for transmission? |
141 | */ | 139 | */ |
142 | int is_ready; | 140 | int is_ready; |
143 | |||
144 | }; | 141 | }; |
145 | 142 | ||
146 | 143 | ||
@@ -179,11 +176,6 @@ struct CadetRoute | |||
179 | * Position of this route in the #route_heap. | 176 | * Position of this route in the #route_heap. |
180 | */ | 177 | */ |
181 | struct GNUNET_CONTAINER_HeapNode *hn; | 178 | struct GNUNET_CONTAINER_HeapNode *hn; |
182 | |||
183 | /** | ||
184 | * Options for the route, control buffering. | ||
185 | */ | ||
186 | enum GNUNET_CADET_ChannelOption options; | ||
187 | }; | 179 | }; |
188 | 180 | ||
189 | 181 | ||
@@ -263,24 +255,17 @@ lower_rung (struct RouteDirection *dir) | |||
263 | struct Rung *rung = dir->rung; | 255 | struct Rung *rung = dir->rung; |
264 | struct Rung *prev; | 256 | struct Rung *prev; |
265 | 257 | ||
266 | GNUNET_CONTAINER_DLL_remove (rung->rd_head, | 258 | GNUNET_CONTAINER_DLL_remove (rung->rd_head, rung->rd_tail, dir); |
267 | rung->rd_tail, | ||
268 | dir); | ||
269 | prev = rung->prev; | 259 | prev = rung->prev; |
270 | GNUNET_assert (NULL != prev); | 260 | GNUNET_assert (NULL != prev); |
271 | if (prev->rung_off != rung->rung_off - 1) | 261 | if (prev->rung_off != rung->rung_off - 1) |
272 | { | 262 | { |
273 | prev = GNUNET_new (struct Rung); | 263 | prev = GNUNET_new (struct Rung); |
274 | prev->rung_off = rung->rung_off - 1; | 264 | prev->rung_off = rung->rung_off - 1; |
275 | GNUNET_CONTAINER_DLL_insert_after (rung_head, | 265 | GNUNET_CONTAINER_DLL_insert_after (rung_head, rung_tail, rung->prev, prev); |
276 | rung_tail, | ||
277 | rung->prev, | ||
278 | prev); | ||
279 | } | 266 | } |
280 | GNUNET_assert (NULL != prev); | 267 | GNUNET_assert (NULL != prev); |
281 | GNUNET_CONTAINER_DLL_insert (prev->rd_head, | 268 | GNUNET_CONTAINER_DLL_insert (prev->rd_head, prev->rd_tail, dir); |
282 | prev->rd_tail, | ||
283 | dir); | ||
284 | dir->rung = prev; | 269 | dir->rung = prev; |
285 | } | 270 | } |
286 | 271 | ||
@@ -293,19 +278,13 @@ lower_rung (struct RouteDirection *dir) | |||
293 | * @param env envelope to discard | 278 | * @param env envelope to discard |
294 | */ | 279 | */ |
295 | static void | 280 | static void |
296 | discard_buffer (struct RouteDirection *dir, | 281 | discard_buffer (struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env) |
297 | struct GNUNET_MQ_Envelope *env) | ||
298 | { | 282 | { |
299 | GNUNET_MQ_dll_remove (&dir->env_head, | 283 | GNUNET_MQ_dll_remove (&dir->env_head, &dir->env_tail, env); |
300 | &dir->env_tail, | ||
301 | env); | ||
302 | cur_buffers--; | 284 | cur_buffers--; |
303 | GNUNET_MQ_discard (env); | 285 | GNUNET_MQ_discard (env); |
304 | lower_rung (dir); | 286 | lower_rung (dir); |
305 | GNUNET_STATISTICS_set (stats, | 287 | GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO); |
306 | "# buffer use", | ||
307 | cur_buffers, | ||
308 | GNUNET_NO); | ||
309 | } | 288 | } |
310 | 289 | ||
311 | 290 | ||
@@ -327,12 +306,9 @@ discard_all_from_rung_tail () | |||
327 | "# messages dropped due to full buffer", | 306 | "# messages dropped due to full buffer", |
328 | 1, | 307 | 1, |
329 | GNUNET_NO); | 308 | GNUNET_NO); |
330 | discard_buffer (dir, | 309 | discard_buffer (dir, dir->env_head); |
331 | dir->env_head); | ||
332 | } | 310 | } |
333 | GNUNET_CONTAINER_DLL_remove (rung_head, | 311 | GNUNET_CONTAINER_DLL_remove (rung_head, rung_tail, tail); |
334 | rung_tail, | ||
335 | tail); | ||
336 | GNUNET_free (tail); | 312 | GNUNET_free (tail); |
337 | } | 313 | } |
338 | 314 | ||
@@ -349,7 +325,8 @@ discard_all_from_rung_tail () | |||
349 | static void | 325 | static void |
350 | route_message (struct CadetPeer *prev, | 326 | route_message (struct CadetPeer *prev, |
351 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 327 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
352 | const struct GNUNET_MessageHeader *msg) | 328 | const struct GNUNET_MessageHeader *msg, |
329 | const enum GNUNET_MQ_PriorityPreferences priority) | ||
353 | { | 330 | { |
354 | struct CadetRoute *route; | 331 | struct CadetRoute *route; |
355 | struct RouteDirection *dir; | 332 | struct RouteDirection *dir; |
@@ -375,17 +352,14 @@ route_message (struct CadetPeer *prev, | |||
375 | /* No need to respond to these! */ | 352 | /* No need to respond to these! */ |
376 | return; | 353 | return; |
377 | } | 354 | } |
378 | env = GNUNET_MQ_msg (bm, | 355 | env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); |
379 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | ||
380 | bm->cid = *cid; | 356 | bm->cid = *cid; |
381 | bm->peer1 = my_full_id; | 357 | bm->peer1 = my_full_id; |
382 | GCP_send_ooo (prev, | 358 | GCP_send_ooo (prev, env); |
383 | env); | ||
384 | return; | 359 | return; |
385 | } | 360 | } |
386 | route->last_use = GNUNET_TIME_absolute_get (); | 361 | route->last_use = GNUNET_TIME_absolute_get (); |
387 | GNUNET_CONTAINER_heap_update_cost (route->hn, | 362 | GNUNET_CONTAINER_heap_update_cost (route->hn, route->last_use.abs_value_us); |
388 | route->last_use.abs_value_us); | ||
389 | dir = (prev == route->prev.hop) ? &route->next : &route->prev; | 363 | dir = (prev == route->prev.hop) ? &route->next : &route->prev; |
390 | if (GNUNET_YES == dir->is_ready) | 364 | if (GNUNET_YES == dir->is_ready) |
391 | { | 365 | { |
@@ -396,27 +370,24 @@ route_message (struct CadetPeer *prev, | |||
396 | GNUNET_i2s (GCP_get_id (dir->hop)), | 370 | GNUNET_i2s (GCP_get_id (dir->hop)), |
397 | GNUNET_sh2s (&cid->connection_of_tunnel)); | 371 | GNUNET_sh2s (&cid->connection_of_tunnel)); |
398 | dir->is_ready = GNUNET_NO; | 372 | dir->is_ready = GNUNET_NO; |
399 | GCP_send (dir->mqm, | 373 | GCP_send (dir->mqm, GNUNET_MQ_msg_copy (msg)); |
400 | GNUNET_MQ_msg_copy (msg)); | ||
401 | return; | 374 | return; |
402 | } | 375 | } |
403 | /* Check if buffering is disallowed, and if so, make sure we only queue | 376 | /* Check if low latency is required and if the previous message was |
404 | one message per direction. */ | 377 | unreliable; if so, make sure we only queue one message per |
405 | if ( (0 != (route->options & GNUNET_CADET_OPTION_NOBUFFER)) && | 378 | direction (no buffering). */ |
406 | (NULL != dir->env_head) ) | 379 | if ((0 != (priority & GNUNET_MQ_PREF_LOW_LATENCY)) && |
407 | discard_buffer (dir, | 380 | (NULL != dir->env_head) && |
408 | dir->env_head); | 381 | (0 == |
382 | (GNUNET_MQ_env_get_options (dir->env_head) & GNUNET_MQ_PREF_UNRELIABLE))) | ||
383 | discard_buffer (dir, dir->env_head); | ||
409 | /* Check for duplicates */ | 384 | /* Check for duplicates */ |
410 | for (const struct GNUNET_MQ_Envelope *env = dir->env_head; | 385 | for (const struct GNUNET_MQ_Envelope *env = dir->env_head; NULL != env; |
411 | NULL != env; | ||
412 | env = GNUNET_MQ_env_next (env)) | 386 | env = GNUNET_MQ_env_next (env)) |
413 | { | 387 | { |
414 | const struct GNUNET_MessageHeader *hdr = GNUNET_MQ_env_get_msg (env); | 388 | const struct GNUNET_MessageHeader *hdr = GNUNET_MQ_env_get_msg (env); |
415 | 389 | ||
416 | if ( (hdr->size == msg->size) && | 390 | if ((hdr->size == msg->size) && (0 == memcmp (hdr, msg, ntohs (msg->size)))) |
417 | (0 == memcmp (hdr, | ||
418 | msg, | ||
419 | ntohs (msg->size))) ) | ||
420 | { | 391 | { |
421 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 392 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
422 | "Received duplicate of message already in buffer, dropping\n"); | 393 | "Received duplicate of message already in buffer, dropping\n"); |
@@ -447,31 +418,22 @@ route_message (struct CadetPeer *prev, | |||
447 | "# messages dropped due to full buffer", | 418 | "# messages dropped due to full buffer", |
448 | 1, | 419 | 1, |
449 | GNUNET_NO); | 420 | GNUNET_NO); |
450 | discard_buffer (dir, | 421 | discard_buffer (dir, dir->env_head); |
451 | dir->env_head); | ||
452 | rung = dir->rung; | 422 | rung = dir->rung; |
453 | } | 423 | } |
454 | } | 424 | } |
455 | /* remove 'dir' from current rung */ | 425 | /* remove 'dir' from current rung */ |
456 | GNUNET_CONTAINER_DLL_remove (rung->rd_head, | 426 | GNUNET_CONTAINER_DLL_remove (rung->rd_head, rung->rd_tail, dir); |
457 | rung->rd_tail, | ||
458 | dir); | ||
459 | /* make 'nxt' point to the next higher rung, create if necessary */ | 427 | /* make 'nxt' point to the next higher rung, create if necessary */ |
460 | nxt = rung->next; | 428 | nxt = rung->next; |
461 | if ( (NULL == nxt) || | 429 | if ((NULL == nxt) || (rung->rung_off + 1 != nxt->rung_off)) |
462 | (rung->rung_off + 1 != nxt->rung_off) ) | ||
463 | { | 430 | { |
464 | nxt = GNUNET_new (struct Rung); | 431 | nxt = GNUNET_new (struct Rung); |
465 | nxt->rung_off = rung->rung_off + 1; | 432 | nxt->rung_off = rung->rung_off + 1; |
466 | GNUNET_CONTAINER_DLL_insert_after (rung_head, | 433 | GNUNET_CONTAINER_DLL_insert_after (rung_head, rung_tail, rung, nxt); |
467 | rung_tail, | ||
468 | rung, | ||
469 | nxt); | ||
470 | } | 434 | } |
471 | /* insert 'dir' into next higher rung */ | 435 | /* insert 'dir' into next higher rung */ |
472 | GNUNET_CONTAINER_DLL_insert (nxt->rd_head, | 436 | GNUNET_CONTAINER_DLL_insert (nxt->rd_head, nxt->rd_tail, dir); |
473 | nxt->rd_tail, | ||
474 | dir); | ||
475 | dir->rung = nxt; | 437 | dir->rung = nxt; |
476 | 438 | ||
477 | /* add message into 'dir' buffer */ | 439 | /* add message into 'dir' buffer */ |
@@ -482,21 +444,21 @@ route_message (struct CadetPeer *prev, | |||
482 | GNUNET_i2s (GCP_get_id (dir->hop)), | 444 | GNUNET_i2s (GCP_get_id (dir->hop)), |
483 | GNUNET_sh2s (&cid->connection_of_tunnel)); | 445 | GNUNET_sh2s (&cid->connection_of_tunnel)); |
484 | env = GNUNET_MQ_msg_copy (msg); | 446 | env = GNUNET_MQ_msg_copy (msg); |
485 | GNUNET_MQ_dll_insert_tail (&dir->env_head, | 447 | GNUNET_MQ_env_set_options (env, priority); |
486 | &dir->env_tail, | 448 | if ((0 != (priority & GNUNET_MQ_PREF_LOW_LATENCY)) && |
487 | env); | 449 | (0 != (priority & GNUNET_MQ_PREF_OUT_OF_ORDER)) && |
450 | (NULL != dir->env_head) && | ||
451 | (0 == (GNUNET_MQ_env_get_options (dir->env_head) & | ||
452 | GNUNET_MQ_PREF_LOW_LATENCY))) | ||
453 | GNUNET_MQ_dll_insert_head (&dir->env_head, &dir->env_tail, env); | ||
454 | else | ||
455 | GNUNET_MQ_dll_insert_tail (&dir->env_head, &dir->env_tail, env); | ||
488 | cur_buffers++; | 456 | cur_buffers++; |
489 | GNUNET_STATISTICS_set (stats, | 457 | GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO); |
490 | "# buffer use", | ||
491 | cur_buffers, | ||
492 | GNUNET_NO); | ||
493 | /* Clean up 'rung' if now empty (and not head) */ | 458 | /* Clean up 'rung' if now empty (and not head) */ |
494 | if ( (NULL == rung->rd_head) && | 459 | if ((NULL == rung->rd_head) && (rung != rung_head)) |
495 | (rung != rung_head) ) | ||
496 | { | 460 | { |
497 | GNUNET_CONTAINER_DLL_remove (rung_head, | 461 | GNUNET_CONTAINER_DLL_remove (rung_head, rung_tail, rung); |
498 | rung_tail, | ||
499 | rung); | ||
500 | GNUNET_free (rung); | 462 | GNUNET_free (rung); |
501 | } | 463 | } |
502 | } | 464 | } |
@@ -541,18 +503,14 @@ destroy_direction (struct RouteDirection *dir) | |||
541 | "# messages dropped due to route destruction", | 503 | "# messages dropped due to route destruction", |
542 | 1, | 504 | 1, |
543 | GNUNET_NO); | 505 | GNUNET_NO); |
544 | discard_buffer (dir, | 506 | discard_buffer (dir, env); |
545 | env); | ||
546 | } | 507 | } |
547 | if (NULL != dir->mqm) | 508 | if (NULL != dir->mqm) |
548 | { | 509 | { |
549 | GCP_request_mq_cancel (dir->mqm, | 510 | GCP_request_mq_cancel (dir->mqm, NULL); |
550 | NULL); | ||
551 | dir->mqm = NULL; | 511 | dir->mqm = NULL; |
552 | } | 512 | } |
553 | GNUNET_CONTAINER_DLL_remove (rung_head->rd_head, | 513 | GNUNET_CONTAINER_DLL_remove (rung_head->rd_head, rung_head->rd_tail, dir); |
554 | rung_head->rd_tail, | ||
555 | dir); | ||
556 | } | 514 | } |
557 | 515 | ||
558 | 516 | ||
@@ -566,15 +524,15 @@ destroy_route (struct CadetRoute *route) | |||
566 | { | 524 | { |
567 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 525 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
568 | "Destroying route from %s to %s of connection %s\n", | 526 | "Destroying route from %s to %s of connection %s\n", |
569 | GNUNET_i2s (GCP_get_id (route->prev.hop)), | 527 | GNUNET_i2s (GCP_get_id (route->prev.hop)), |
570 | GNUNET_i2s2 (GCP_get_id (route->next.hop)), | 528 | GNUNET_i2s2 (GCP_get_id (route->next.hop)), |
571 | GNUNET_sh2s (&route->cid.connection_of_tunnel)); | 529 | GNUNET_sh2s (&route->cid.connection_of_tunnel)); |
572 | GNUNET_assert (route == | 530 | GNUNET_assert (route == GNUNET_CONTAINER_heap_remove_node (route->hn)); |
573 | GNUNET_CONTAINER_heap_remove_node (route->hn)); | 531 | GNUNET_assert ( |
574 | GNUNET_assert (GNUNET_YES == | 532 | GNUNET_YES == |
575 | GNUNET_CONTAINER_multishortmap_remove (routes, | 533 | GNUNET_CONTAINER_multishortmap_remove (routes, |
576 | &route->cid.connection_of_tunnel, | 534 | &route->cid.connection_of_tunnel, |
577 | route)); | 535 | route)); |
578 | GNUNET_STATISTICS_set (stats, | 536 | GNUNET_STATISTICS_set (stats, |
579 | "# routes", | 537 | "# routes", |
580 | GNUNET_CONTAINER_multishortmap_size (routes), | 538 | GNUNET_CONTAINER_multishortmap_size (routes), |
@@ -611,15 +569,13 @@ send_broken (struct RouteDirection *target, | |||
611 | GNUNET_i2s2 (peer2), | 569 | GNUNET_i2s2 (peer2), |
612 | GNUNET_sh2s (&cid->connection_of_tunnel)); | 570 | GNUNET_sh2s (&cid->connection_of_tunnel)); |
613 | 571 | ||
614 | env = GNUNET_MQ_msg (bm, | 572 | env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); |
615 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | ||
616 | bm->cid = *cid; | 573 | bm->cid = *cid; |
617 | if (NULL != peer1) | 574 | if (NULL != peer1) |
618 | bm->peer1 = *peer1; | 575 | bm->peer1 = *peer1; |
619 | if (NULL != peer2) | 576 | if (NULL != peer2) |
620 | bm->peer2 = *peer2; | 577 | bm->peer2 = *peer2; |
621 | GCP_request_mq_cancel (target->mqm, | 578 | GCP_request_mq_cancel (target->mqm, env); |
622 | env); | ||
623 | target->mqm = NULL; | 579 | target->mqm = NULL; |
624 | } | 580 | } |
625 | 581 | ||
@@ -639,33 +595,22 @@ timeout_cb (void *cls) | |||
639 | struct GNUNET_TIME_Absolute exp; | 595 | struct GNUNET_TIME_Absolute exp; |
640 | 596 | ||
641 | timeout_task = NULL; | 597 | timeout_task = NULL; |
642 | linger = GNUNET_TIME_relative_multiply (keepalive_period, | 598 | linger = GNUNET_TIME_relative_multiply (keepalive_period, 3); |
643 | 3); | ||
644 | while (NULL != (r = GNUNET_CONTAINER_heap_peek (route_heap))) | 599 | while (NULL != (r = GNUNET_CONTAINER_heap_peek (route_heap))) |
645 | { | 600 | { |
646 | exp = GNUNET_TIME_absolute_add (r->last_use, | 601 | exp = GNUNET_TIME_absolute_add (r->last_use, linger); |
647 | linger); | ||
648 | if (0 != GNUNET_TIME_absolute_get_remaining (exp).rel_value_us) | 602 | if (0 != GNUNET_TIME_absolute_get_remaining (exp).rel_value_us) |
649 | { | 603 | { |
650 | /* Route not yet timed out, wait until it does. */ | 604 | /* Route not yet timed out, wait until it does. */ |
651 | timeout_task = GNUNET_SCHEDULER_add_at (exp, | 605 | timeout_task = GNUNET_SCHEDULER_add_at (exp, &timeout_cb, NULL); |
652 | &timeout_cb, | ||
653 | NULL); | ||
654 | return; | 606 | return; |
655 | } | 607 | } |
656 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 608 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
657 | "Sending BROKEN due to timeout (%s was last use, %s linger)\n", | 609 | "Sending BROKEN due to timeout (%s was last use, %s linger)\n", |
658 | GNUNET_STRINGS_absolute_time_to_string (r->last_use), | 610 | GNUNET_STRINGS_absolute_time_to_string (r->last_use), |
659 | GNUNET_STRINGS_relative_time_to_string (linger, | 611 | GNUNET_STRINGS_relative_time_to_string (linger, GNUNET_YES)); |
660 | GNUNET_YES)); | 612 | send_broken (&r->prev, &r->cid, NULL, NULL); |
661 | send_broken (&r->prev, | 613 | send_broken (&r->next, &r->cid, NULL, NULL); |
662 | &r->cid, | ||
663 | NULL, | ||
664 | NULL); | ||
665 | send_broken (&r->next, | ||
666 | &r->cid, | ||
667 | NULL, | ||
668 | NULL); | ||
669 | destroy_route (r); | 614 | destroy_route (r); |
670 | } | 615 | } |
671 | /* No more routes left, so no need for a #timeout_task */ | 616 | /* No more routes left, so no need for a #timeout_task */ |
@@ -685,8 +630,7 @@ timeout_cb (void *cls) | |||
685 | * and the last envelope was discarded | 630 | * and the last envelope was discarded |
686 | */ | 631 | */ |
687 | static void | 632 | static void |
688 | dir_ready_cb (void *cls, | 633 | dir_ready_cb (void *cls, int ready) |
689 | int ready) | ||
690 | { | 634 | { |
691 | struct RouteDirection *dir = cls; | 635 | struct RouteDirection *dir = cls; |
692 | struct CadetRoute *route = dir->my_route; | 636 | struct CadetRoute *route = dir->my_route; |
@@ -699,28 +643,18 @@ dir_ready_cb (void *cls, | |||
699 | dir->is_ready = GNUNET_YES; | 643 | dir->is_ready = GNUNET_YES; |
700 | if (NULL != (env = dir->env_head)) | 644 | if (NULL != (env = dir->env_head)) |
701 | { | 645 | { |
702 | GNUNET_MQ_dll_remove (&dir->env_head, | 646 | GNUNET_MQ_dll_remove (&dir->env_head, &dir->env_tail, env); |
703 | &dir->env_tail, | ||
704 | env); | ||
705 | cur_buffers--; | 647 | cur_buffers--; |
706 | GNUNET_STATISTICS_set (stats, | 648 | GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO); |
707 | "# buffer use", | ||
708 | cur_buffers, | ||
709 | GNUNET_NO); | ||
710 | lower_rung (dir); | 649 | lower_rung (dir); |
711 | dir->is_ready = GNUNET_NO; | 650 | dir->is_ready = GNUNET_NO; |
712 | GCP_send (dir->mqm, | 651 | GCP_send (dir->mqm, env); |
713 | env); | ||
714 | } | 652 | } |
715 | return; | 653 | return; |
716 | } | 654 | } |
717 | odir = (dir == &route->next) ? &route->prev : &route->next; | 655 | odir = (dir == &route->next) ? &route->prev : &route->next; |
718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending BROKEN due to MQ going down\n"); |
719 | "Sending BROKEN due to MQ going down\n"); | 657 | send_broken (&route->next, &route->cid, GCP_get_id (odir->hop), &my_full_id); |
720 | send_broken (&route->next, | ||
721 | &route->cid, | ||
722 | GCP_get_id (odir->hop), | ||
723 | &my_full_id); | ||
724 | destroy_route (route); | 658 | destroy_route (route); |
725 | } | 659 | } |
726 | 660 | ||
@@ -739,12 +673,8 @@ dir_init (struct RouteDirection *dir, | |||
739 | { | 673 | { |
740 | dir->hop = hop; | 674 | dir->hop = hop; |
741 | dir->my_route = route; | 675 | dir->my_route = route; |
742 | dir->mqm = GCP_request_mq (hop, | 676 | dir->mqm = GCP_request_mq (hop, &dir_ready_cb, dir); |
743 | &dir_ready_cb, | 677 | GNUNET_CONTAINER_DLL_insert (rung_head->rd_head, rung_head->rd_tail, dir); |
744 | dir); | ||
745 | GNUNET_CONTAINER_DLL_insert (rung_head->rd_head, | ||
746 | rung_head->rd_tail, | ||
747 | dir); | ||
748 | dir->rung = rung_head; | 678 | dir->rung = rung_head; |
749 | GNUNET_assert (GNUNET_YES == dir->is_ready); | 679 | GNUNET_assert (GNUNET_YES == dir->is_ready); |
750 | } | 680 | } |
@@ -761,21 +691,20 @@ dir_init (struct RouteDirection *dir, | |||
761 | * or NULL. | 691 | * or NULL. |
762 | */ | 692 | */ |
763 | static void | 693 | static void |
764 | send_broken_without_mqm (struct CadetPeer *target, | 694 | send_broken_without_mqm ( |
765 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 695 | struct CadetPeer *target, |
766 | const struct GNUNET_PeerIdentity *failure_at) | 696 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
697 | const struct GNUNET_PeerIdentity *failure_at) | ||
767 | { | 698 | { |
768 | struct GNUNET_MQ_Envelope *env; | 699 | struct GNUNET_MQ_Envelope *env; |
769 | struct GNUNET_CADET_ConnectionBrokenMessage *bm; | 700 | struct GNUNET_CADET_ConnectionBrokenMessage *bm; |
770 | 701 | ||
771 | env = GNUNET_MQ_msg (bm, | 702 | env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); |
772 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | ||
773 | bm->cid = *cid; | 703 | bm->cid = *cid; |
774 | bm->peer1 = my_full_id; | 704 | bm->peer1 = my_full_id; |
775 | if (NULL != failure_at) | 705 | if (NULL != failure_at) |
776 | bm->peer2 = *failure_at; | 706 | bm->peer2 = *failure_at; |
777 | GCP_send_ooo (target, | 707 | GCP_send_ooo (target, env); |
778 | env); | ||
779 | } | 708 | } |
780 | 709 | ||
781 | 710 | ||
@@ -786,19 +715,19 @@ send_broken_without_mqm (struct CadetPeer *target, | |||
786 | * @param msg Message itself. | 715 | * @param msg Message itself. |
787 | */ | 716 | */ |
788 | static void | 717 | static void |
789 | handle_connection_create (void *cls, | 718 | handle_connection_create ( |
790 | const struct GNUNET_CADET_ConnectionCreateMessage *msg) | 719 | void *cls, |
720 | const struct GNUNET_CADET_ConnectionCreateMessage *msg) | ||
791 | { | 721 | { |
792 | struct CadetPeer *sender = cls; | 722 | struct CadetPeer *sender = cls; |
793 | struct CadetPeer *next; | 723 | struct CadetPeer *next; |
794 | const struct GNUNET_PeerIdentity *pids = (const struct GNUNET_PeerIdentity *) &msg[1]; | 724 | const struct GNUNET_PeerIdentity *pids = |
725 | (const struct GNUNET_PeerIdentity *) &msg[1]; | ||
795 | struct CadetRoute *route; | 726 | struct CadetRoute *route; |
796 | uint16_t size = ntohs (msg->header.size) - sizeof (*msg); | 727 | uint16_t size = ntohs (msg->header.size) - sizeof (*msg); |
797 | unsigned int path_length; | 728 | unsigned int path_length; |
798 | unsigned int off; | 729 | unsigned int off; |
799 | enum GNUNET_CADET_ChannelOption options; | ||
800 | 730 | ||
801 | options = (enum GNUNET_CADET_ChannelOption) ntohl (msg->options); | ||
802 | path_length = size / sizeof (struct GNUNET_PeerIdentity); | 731 | path_length = size / sizeof (struct GNUNET_PeerIdentity); |
803 | if (0 == path_length) | 732 | if (0 == path_length) |
804 | { | 733 | { |
@@ -816,20 +745,19 @@ handle_connection_create (void *cls, | |||
816 | { | 745 | { |
817 | struct GNUNET_CONTAINER_MultiPeerMap *map; | 746 | struct GNUNET_CONTAINER_MultiPeerMap *map; |
818 | 747 | ||
819 | map = GNUNET_CONTAINER_multipeermap_create (path_length * 2, | 748 | map = GNUNET_CONTAINER_multipeermap_create (path_length * 2, GNUNET_YES); |
820 | GNUNET_YES); | ||
821 | GNUNET_assert (NULL != map); | 749 | GNUNET_assert (NULL != map); |
822 | for (unsigned int i=0;i<path_length;i++) | 750 | for (unsigned int i = 0; i < path_length; i++) |
823 | { | 751 | { |
824 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 752 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
825 | "CADET_CONNECTION_CREATE has peer %s at offset %u\n", | 753 | "CADET_CONNECTION_CREATE has peer %s at offset %u\n", |
826 | GNUNET_i2s (&pids[i]), | 754 | GNUNET_i2s (&pids[i]), |
827 | i); | 755 | i); |
828 | if (GNUNET_SYSERR == | 756 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_put ( |
829 | GNUNET_CONTAINER_multipeermap_put (map, | 757 | map, |
830 | &pids[i], | 758 | &pids[i], |
831 | NULL, | 759 | NULL, |
832 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 760 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
833 | { | 761 | { |
834 | /* bogus request */ | 762 | /* bogus request */ |
835 | GNUNET_CONTAINER_multipeermap_destroy (map); | 763 | GNUNET_CONTAINER_multipeermap_destroy (map); |
@@ -842,9 +770,8 @@ handle_connection_create (void *cls, | |||
842 | GNUNET_CONTAINER_multipeermap_destroy (map); | 770 | GNUNET_CONTAINER_multipeermap_destroy (map); |
843 | } | 771 | } |
844 | /* Initiator is at offset 0, find us */ | 772 | /* Initiator is at offset 0, find us */ |
845 | for (off=1;off<path_length;off++) | 773 | for (off = 1; off < path_length; off++) |
846 | if (0 == GNUNET_memcmp (&my_full_id, | 774 | if (0 == GNUNET_memcmp (&my_full_id, &pids[off])) |
847 | &pids[off])) | ||
848 | break; | 775 | break; |
849 | if (off == path_length) | 776 | if (off == path_length) |
850 | { | 777 | { |
@@ -854,16 +781,14 @@ handle_connection_create (void *cls, | |||
854 | return; | 781 | return; |
855 | } | 782 | } |
856 | /* Check previous hop */ | 783 | /* Check previous hop */ |
857 | if (sender != GCP_get (&pids[off - 1], | 784 | if (sender != GCP_get (&pids[off - 1], GNUNET_NO)) |
858 | GNUNET_NO)) | ||
859 | { | 785 | { |
860 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 786 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
861 | "Dropping CADET_CONNECTION_CREATE without sender at previous hop in the path\n"); | 787 | "Dropping CADET_CONNECTION_CREATE without sender at previous hop in the path\n"); |
862 | GNUNET_break_op (0); | 788 | GNUNET_break_op (0); |
863 | return; | 789 | return; |
864 | } | 790 | } |
865 | if (NULL != | 791 | if (NULL != (route = get_route (&msg->cid))) |
866 | (route = get_route (&msg->cid))) | ||
867 | { | 792 | { |
868 | /* Duplicate CREATE, pass it on, previous one might have been lost! */ | 793 | /* Duplicate CREATE, pass it on, previous one might have been lost! */ |
869 | 794 | ||
@@ -872,7 +797,9 @@ handle_connection_create (void *cls, | |||
872 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 797 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
873 | route_message (sender, | 798 | route_message (sender, |
874 | &msg->cid, | 799 | &msg->cid, |
875 | &msg->header); | 800 | &msg->header, |
801 | GNUNET_MQ_PRIO_CRITICAL_CONTROL | | ||
802 | GNUNET_MQ_PREF_LOW_LATENCY); | ||
876 | return; | 803 | return; |
877 | } | 804 | } |
878 | if (off == path_length - 1) | 805 | if (off == path_length - 1) |
@@ -892,19 +819,15 @@ handle_connection_create (void *cls, | |||
892 | return; | 819 | return; |
893 | } | 820 | } |
894 | 821 | ||
895 | origin = GCP_get (&pids[0], | 822 | origin = GCP_get (&pids[0], GNUNET_YES); |
896 | GNUNET_YES); | ||
897 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 823 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
898 | "I am destination for CADET_CONNECTION_CREATE message from %s for connection %s, building inverse path\n", | 824 | "I am destination for CADET_CONNECTION_CREATE message from %s for connection %s, building inverse path\n", |
899 | GCP_2s (origin), | 825 | GCP_2s (origin), |
900 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 826 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
901 | path = GCPP_get_path_from_route (path_length - 1, | 827 | path = GCPP_get_path_from_route (path_length - 1, pids); |
902 | pids); | ||
903 | if (GNUNET_OK != | 828 | if (GNUNET_OK != |
904 | GCT_add_inbound_connection (GCP_get_tunnel (origin, | 829 | GCT_add_inbound_connection (GCP_get_tunnel (origin, GNUNET_YES), |
905 | GNUNET_YES), | ||
906 | &msg->cid, | 830 | &msg->cid, |
907 | (enum GNUNET_CADET_ChannelOption) ntohl (msg->options), | ||
908 | path)) | 831 | path)) |
909 | { | 832 | { |
910 | /* Send back BROKEN: duplicate connection on the same path, | 833 | /* Send back BROKEN: duplicate connection on the same path, |
@@ -914,18 +837,14 @@ handle_connection_create (void *cls, | |||
914 | GCP_2s (sender), | 837 | GCP_2s (sender), |
915 | GNUNET_sh2s (&msg->cid.connection_of_tunnel), | 838 | GNUNET_sh2s (&msg->cid.connection_of_tunnel), |
916 | GCPP_2s (path)); | 839 | GCPP_2s (path)); |
917 | send_broken_without_mqm (sender, | 840 | send_broken_without_mqm (sender, &msg->cid, NULL); |
918 | &msg->cid, | ||
919 | NULL); | ||
920 | return; | 841 | return; |
921 | } | 842 | } |
922 | return; | 843 | return; |
923 | } | 844 | } |
924 | /* We are merely a hop on the way, check if we can support the route */ | 845 | /* We are merely a hop on the way, check if we can support the route */ |
925 | next = GCP_get (&pids[off + 1], | 846 | next = GCP_get (&pids[off + 1], GNUNET_NO); |
926 | GNUNET_NO); | 847 | if ((NULL == next) || (GNUNET_NO == GCP_has_core_connection (next))) |
927 | if ( (NULL == next) || | ||
928 | (GNUNET_NO == GCP_has_core_connection (next)) ) | ||
929 | { | 848 | { |
930 | /* unworkable, send back BROKEN notification */ | 849 | /* unworkable, send back BROKEN notification */ |
931 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 850 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -934,9 +853,7 @@ handle_connection_create (void *cls, | |||
934 | GNUNET_sh2s (&msg->cid.connection_of_tunnel), | 853 | GNUNET_sh2s (&msg->cid.connection_of_tunnel), |
935 | GNUNET_i2s (&pids[off + 1]), | 854 | GNUNET_i2s (&pids[off + 1]), |
936 | off + 1); | 855 | off + 1); |
937 | send_broken_without_mqm (sender, | 856 | send_broken_without_mqm (sender, &msg->cid, &pids[off + 1]); |
938 | &msg->cid, | ||
939 | &pids[off + 1]); | ||
940 | return; | 857 | return; |
941 | } | 858 | } |
942 | if (max_routes <= GNUNET_CONTAINER_multishortmap_size (routes)) | 859 | if (max_routes <= GNUNET_CONTAINER_multishortmap_size (routes)) |
@@ -945,9 +862,7 @@ handle_connection_create (void *cls, | |||
945 | "Received CADET_CONNECTION_CREATE from %s for %s. We have reached our route limit. Sending BROKEN\n", | 862 | "Received CADET_CONNECTION_CREATE from %s for %s. We have reached our route limit. Sending BROKEN\n", |
946 | GCP_2s (sender), | 863 | GCP_2s (sender), |
947 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 864 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
948 | send_broken_without_mqm (sender, | 865 | send_broken_without_mqm (sender, &msg->cid, &pids[off - 1]); |
949 | &msg->cid, | ||
950 | &pids[off - 1]); | ||
951 | return; | 866 | return; |
952 | } | 867 | } |
953 | 868 | ||
@@ -959,20 +874,16 @@ handle_connection_create (void *cls, | |||
959 | GNUNET_i2s (&pids[off + 1]), | 874 | GNUNET_i2s (&pids[off + 1]), |
960 | off + 1); | 875 | off + 1); |
961 | route = GNUNET_new (struct CadetRoute); | 876 | route = GNUNET_new (struct CadetRoute); |
962 | route->options = options; | ||
963 | route->cid = msg->cid; | 877 | route->cid = msg->cid; |
964 | route->last_use = GNUNET_TIME_absolute_get (); | 878 | route->last_use = GNUNET_TIME_absolute_get (); |
965 | dir_init (&route->prev, | 879 | dir_init (&route->prev, route, sender); |
966 | route, | 880 | dir_init (&route->next, route, next); |
967 | sender); | ||
968 | dir_init (&route->next, | ||
969 | route, | ||
970 | next); | ||
971 | GNUNET_assert (GNUNET_OK == | 881 | GNUNET_assert (GNUNET_OK == |
972 | GNUNET_CONTAINER_multishortmap_put (routes, | 882 | GNUNET_CONTAINER_multishortmap_put ( |
973 | &route->cid.connection_of_tunnel, | 883 | routes, |
974 | route, | 884 | &route->cid.connection_of_tunnel, |
975 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 885 | route, |
886 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
976 | GNUNET_STATISTICS_set (stats, | 887 | GNUNET_STATISTICS_set (stats, |
977 | "# routes", | 888 | "# routes", |
978 | GNUNET_CONTAINER_multishortmap_size (routes), | 889 | GNUNET_CONTAINER_multishortmap_size (routes), |
@@ -981,14 +892,16 @@ handle_connection_create (void *cls, | |||
981 | route, | 892 | route, |
982 | route->last_use.abs_value_us); | 893 | route->last_use.abs_value_us); |
983 | if (NULL == timeout_task) | 894 | if (NULL == timeout_task) |
984 | timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (keepalive_period, | 895 | timeout_task = |
985 | 3), | 896 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (keepalive_period, |
986 | &timeout_cb, | 897 | 3), |
987 | NULL); | 898 | &timeout_cb, |
899 | NULL); | ||
988 | /* also pass CREATE message along to next hop */ | 900 | /* also pass CREATE message along to next hop */ |
989 | route_message (sender, | 901 | route_message (sender, |
990 | &msg->cid, | 902 | &msg->cid, |
991 | &msg->header); | 903 | &msg->header, |
904 | GNUNET_MQ_PRIO_CRITICAL_CONTROL | GNUNET_MQ_PREF_LOW_LATENCY); | ||
992 | } | 905 | } |
993 | 906 | ||
994 | 907 | ||
@@ -999,8 +912,9 @@ handle_connection_create (void *cls, | |||
999 | * @param msg Message itself. | 912 | * @param msg Message itself. |
1000 | */ | 913 | */ |
1001 | static void | 914 | static void |
1002 | handle_connection_create_ack (void *cls, | 915 | handle_connection_create_ack ( |
1003 | const struct GNUNET_CADET_ConnectionCreateAckMessage *msg) | 916 | void *cls, |
917 | const struct GNUNET_CADET_ConnectionCreateAckMessage *msg) | ||
1004 | { | 918 | { |
1005 | struct CadetPeer *peer = cls; | 919 | struct CadetPeer *peer = cls; |
1006 | struct CadetConnection *cc; | 920 | struct CadetConnection *cc; |
@@ -1011,12 +925,9 @@ handle_connection_create_ack (void *cls, | |||
1011 | { | 925 | { |
1012 | /* verify ACK came from the right direction */ | 926 | /* verify ACK came from the right direction */ |
1013 | unsigned int len; | 927 | unsigned int len; |
1014 | struct CadetPeerPath *path = GCC_get_path (cc, | 928 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1015 | &len); | ||
1016 | 929 | ||
1017 | if (peer != | 930 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1018 | GCPP_get_peer_at_offset (path, | ||
1019 | 0)) | ||
1020 | { | 931 | { |
1021 | /* received ACK from unexpected direction, ignore! */ | 932 | /* received ACK from unexpected direction, ignore! */ |
1022 | GNUNET_break_op (0); | 933 | GNUNET_break_op (0); |
@@ -1032,7 +943,8 @@ handle_connection_create_ack (void *cls, | |||
1032 | /* We're just an intermediary peer, route the message along its path */ | 943 | /* We're just an intermediary peer, route the message along its path */ |
1033 | route_message (peer, | 944 | route_message (peer, |
1034 | &msg->cid, | 945 | &msg->cid, |
1035 | &msg->header); | 946 | &msg->header, |
947 | GNUNET_MQ_PRIO_CRITICAL_CONTROL | GNUNET_MQ_PREF_LOW_LATENCY); | ||
1036 | } | 948 | } |
1037 | 949 | ||
1038 | 950 | ||
@@ -1044,8 +956,9 @@ handle_connection_create_ack (void *cls, | |||
1044 | * @deprecated duplicate logic with #handle_destroy(); dedup! | 956 | * @deprecated duplicate logic with #handle_destroy(); dedup! |
1045 | */ | 957 | */ |
1046 | static void | 958 | static void |
1047 | handle_connection_broken (void *cls, | 959 | handle_connection_broken ( |
1048 | const struct GNUNET_CADET_ConnectionBrokenMessage *msg) | 960 | void *cls, |
961 | const struct GNUNET_CADET_ConnectionBrokenMessage *msg) | ||
1049 | { | 962 | { |
1050 | struct CadetPeer *peer = cls; | 963 | struct CadetPeer *peer = cls; |
1051 | struct CadetConnection *cc; | 964 | struct CadetConnection *cc; |
@@ -1057,12 +970,9 @@ handle_connection_broken (void *cls, | |||
1057 | { | 970 | { |
1058 | /* verify message came from the right direction */ | 971 | /* verify message came from the right direction */ |
1059 | unsigned int len; | 972 | unsigned int len; |
1060 | struct CadetPeerPath *path = GCC_get_path (cc, | 973 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1061 | &len); | ||
1062 | 974 | ||
1063 | if (peer != | 975 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1064 | GCPP_get_peer_at_offset (path, | ||
1065 | 0)) | ||
1066 | { | 976 | { |
1067 | /* received message from unexpected direction, ignore! */ | 977 | /* received message from unexpected direction, ignore! */ |
1068 | GNUNET_break_op (0); | 978 | GNUNET_break_op (0); |
@@ -1080,7 +990,8 @@ handle_connection_broken (void *cls, | |||
1080 | /* We're just an intermediary peer, route the message along its path */ | 990 | /* We're just an intermediary peer, route the message along its path */ |
1081 | route_message (peer, | 991 | route_message (peer, |
1082 | &msg->cid, | 992 | &msg->cid, |
1083 | &msg->header); | 993 | &msg->header, |
994 | GNUNET_MQ_PREF_LOW_LATENCY | GNUNET_MQ_PRIO_CRITICAL_CONTROL); | ||
1084 | route = get_route (&msg->cid); | 995 | route = get_route (&msg->cid); |
1085 | if (NULL != route) | 996 | if (NULL != route) |
1086 | destroy_route (route); | 997 | destroy_route (route); |
@@ -1095,8 +1006,9 @@ handle_connection_broken (void *cls, | |||
1095 | * @param msg Message itself. | 1006 | * @param msg Message itself. |
1096 | */ | 1007 | */ |
1097 | static void | 1008 | static void |
1098 | handle_connection_destroy (void *cls, | 1009 | handle_connection_destroy ( |
1099 | const struct GNUNET_CADET_ConnectionDestroyMessage *msg) | 1010 | void *cls, |
1011 | const struct GNUNET_CADET_ConnectionDestroyMessage *msg) | ||
1100 | { | 1012 | { |
1101 | struct CadetPeer *peer = cls; | 1013 | struct CadetPeer *peer = cls; |
1102 | struct CadetConnection *cc; | 1014 | struct CadetConnection *cc; |
@@ -1108,12 +1020,9 @@ handle_connection_destroy (void *cls, | |||
1108 | { | 1020 | { |
1109 | /* verify message came from the right direction */ | 1021 | /* verify message came from the right direction */ |
1110 | unsigned int len; | 1022 | unsigned int len; |
1111 | struct CadetPeerPath *path = GCC_get_path (cc, | 1023 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1112 | &len); | ||
1113 | 1024 | ||
1114 | if (peer != | 1025 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1115 | GCPP_get_peer_at_offset (path, | ||
1116 | 0)) | ||
1117 | { | 1026 | { |
1118 | /* received message from unexpected direction, ignore! */ | 1027 | /* received message from unexpected direction, ignore! */ |
1119 | GNUNET_break_op (0); | 1028 | GNUNET_break_op (0); |
@@ -1133,7 +1042,8 @@ handle_connection_destroy (void *cls, | |||
1133 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 1042 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
1134 | route_message (peer, | 1043 | route_message (peer, |
1135 | &msg->cid, | 1044 | &msg->cid, |
1136 | &msg->header); | 1045 | &msg->header, |
1046 | GNUNET_MQ_PREF_LOW_LATENCY | GNUNET_MQ_PRIO_CRITICAL_CONTROL); | ||
1137 | route = get_route (&msg->cid); | 1047 | route = get_route (&msg->cid); |
1138 | if (NULL != route) | 1048 | if (NULL != route) |
1139 | destroy_route (route); | 1049 | destroy_route (route); |
@@ -1165,26 +1075,23 @@ handle_tunnel_kx (void *cls, | |||
1165 | { | 1075 | { |
1166 | /* verify message came from the right direction */ | 1076 | /* verify message came from the right direction */ |
1167 | unsigned int len; | 1077 | unsigned int len; |
1168 | struct CadetPeerPath *path = GCC_get_path (cc, | 1078 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1169 | &len); | ||
1170 | 1079 | ||
1171 | if (peer != | 1080 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1172 | GCPP_get_peer_at_offset (path, | ||
1173 | 0)) | ||
1174 | { | 1081 | { |
1175 | /* received message from unexpected direction, ignore! */ | 1082 | /* received message from unexpected direction, ignore! */ |
1176 | GNUNET_break_op (0); | 1083 | GNUNET_break_op (0); |
1177 | return; | 1084 | return; |
1178 | } | 1085 | } |
1179 | GCC_handle_kx (cc, | 1086 | GCC_handle_kx (cc, msg); |
1180 | msg); | ||
1181 | return; | 1087 | return; |
1182 | } | 1088 | } |
1183 | 1089 | ||
1184 | /* We're just an intermediary peer, route the message along its path */ | 1090 | /* We're just an intermediary peer, route the message along its path */ |
1185 | route_message (peer, | 1091 | route_message (peer, |
1186 | &msg->cid, | 1092 | &msg->cid, |
1187 | &msg->header); | 1093 | &msg->header, |
1094 | GNUNET_MQ_PRIO_CRITICAL_CONTROL | GNUNET_MQ_PREF_LOW_LATENCY); | ||
1188 | } | 1095 | } |
1189 | 1096 | ||
1190 | 1097 | ||
@@ -1195,8 +1102,9 @@ handle_tunnel_kx (void *cls, | |||
1195 | * @param msg Message itself. | 1102 | * @param msg Message itself. |
1196 | */ | 1103 | */ |
1197 | static void | 1104 | static void |
1198 | handle_tunnel_kx_auth (void *cls, | 1105 | handle_tunnel_kx_auth ( |
1199 | const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg) | 1106 | void *cls, |
1107 | const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg) | ||
1200 | { | 1108 | { |
1201 | struct CadetPeer *peer = cls; | 1109 | struct CadetPeer *peer = cls; |
1202 | struct CadetConnection *cc; | 1110 | struct CadetConnection *cc; |
@@ -1207,26 +1115,23 @@ handle_tunnel_kx_auth (void *cls, | |||
1207 | { | 1115 | { |
1208 | /* verify message came from the right direction */ | 1116 | /* verify message came from the right direction */ |
1209 | unsigned int len; | 1117 | unsigned int len; |
1210 | struct CadetPeerPath *path = GCC_get_path (cc, | 1118 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1211 | &len); | ||
1212 | 1119 | ||
1213 | if (peer != | 1120 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1214 | GCPP_get_peer_at_offset (path, | ||
1215 | 0)) | ||
1216 | { | 1121 | { |
1217 | /* received message from unexpected direction, ignore! */ | 1122 | /* received message from unexpected direction, ignore! */ |
1218 | GNUNET_break_op (0); | 1123 | GNUNET_break_op (0); |
1219 | return; | 1124 | return; |
1220 | } | 1125 | } |
1221 | GCC_handle_kx_auth (cc, | 1126 | GCC_handle_kx_auth (cc, msg); |
1222 | msg); | ||
1223 | return; | 1127 | return; |
1224 | } | 1128 | } |
1225 | 1129 | ||
1226 | /* We're just an intermediary peer, route the message along its path */ | 1130 | /* We're just an intermediary peer, route the message along its path */ |
1227 | route_message (peer, | 1131 | route_message (peer, |
1228 | &msg->kx.cid, | 1132 | &msg->kx.cid, |
1229 | &msg->kx.header); | 1133 | &msg->kx.header, |
1134 | GNUNET_MQ_PRIO_CRITICAL_CONTROL | GNUNET_MQ_PREF_LOW_LATENCY); | ||
1230 | } | 1135 | } |
1231 | 1136 | ||
1232 | 1137 | ||
@@ -1265,25 +1170,19 @@ handle_tunnel_encrypted (void *cls, | |||
1265 | { | 1170 | { |
1266 | /* verify message came from the right direction */ | 1171 | /* verify message came from the right direction */ |
1267 | unsigned int len; | 1172 | unsigned int len; |
1268 | struct CadetPeerPath *path = GCC_get_path (cc, | 1173 | struct CadetPeerPath *path = GCC_get_path (cc, &len); |
1269 | &len); | ||
1270 | 1174 | ||
1271 | if (peer != | 1175 | if (peer != GCPP_get_peer_at_offset (path, 0)) |
1272 | GCPP_get_peer_at_offset (path, | ||
1273 | 0)) | ||
1274 | { | 1176 | { |
1275 | /* received message from unexpected direction, ignore! */ | 1177 | /* received message from unexpected direction, ignore! */ |
1276 | GNUNET_break_op (0); | 1178 | GNUNET_break_op (0); |
1277 | return; | 1179 | return; |
1278 | } | 1180 | } |
1279 | GCC_handle_encrypted (cc, | 1181 | GCC_handle_encrypted (cc, msg); |
1280 | msg); | ||
1281 | return; | 1182 | return; |
1282 | } | 1183 | } |
1283 | /* We're just an intermediary peer, route the message along its path */ | 1184 | /* We're just an intermediary peer, route the message along its path */ |
1284 | route_message (peer, | 1185 | route_message (peer, &msg->cid, &msg->header, GNUNET_MQ_PRIO_BEST_EFFORT); |
1285 | &msg->cid, | ||
1286 | &msg->header); | ||
1287 | } | 1186 | } |
1288 | 1187 | ||
1289 | 1188 | ||
@@ -1300,17 +1199,14 @@ handle_tunnel_encrypted (void *cls, | |||
1300 | * @param my_identity ID of this peer, NULL if we failed | 1199 | * @param my_identity ID of this peer, NULL if we failed |
1301 | */ | 1200 | */ |
1302 | static void | 1201 | static void |
1303 | core_init_cb (void *cls, | 1202 | core_init_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
1304 | const struct GNUNET_PeerIdentity *my_identity) | ||
1305 | { | 1203 | { |
1306 | if (NULL == my_identity) | 1204 | if (NULL == my_identity) |
1307 | { | 1205 | { |
1308 | GNUNET_break (0); | 1206 | GNUNET_break (0); |
1309 | return; | 1207 | return; |
1310 | } | 1208 | } |
1311 | GNUNET_break (0 == | 1209 | GNUNET_break (0 == GNUNET_memcmp (my_identity, &my_full_id)); |
1312 | GNUNET_memcmp (my_identity, | ||
1313 | &my_full_id)); | ||
1314 | } | 1210 | } |
1315 | 1211 | ||
1316 | 1212 | ||
@@ -1330,10 +1226,8 @@ core_connect_cb (void *cls, | |||
1330 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1226 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1331 | "CORE connection to peer %s was established.\n", | 1227 | "CORE connection to peer %s was established.\n", |
1332 | GNUNET_i2s (peer)); | 1228 | GNUNET_i2s (peer)); |
1333 | cp = GCP_get (peer, | 1229 | cp = GCP_get (peer, GNUNET_YES); |
1334 | GNUNET_YES); | 1230 | GCP_set_mq (cp, mq); |
1335 | GCP_set_mq (cp, | ||
1336 | mq); | ||
1337 | return cp; | 1231 | return cp; |
1338 | } | 1232 | } |
1339 | 1233 | ||
@@ -1354,8 +1248,7 @@ core_disconnect_cb (void *cls, | |||
1354 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1248 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1355 | "CORE connection to peer %s went down.\n", | 1249 | "CORE connection to peer %s went down.\n", |
1356 | GNUNET_i2s (peer)); | 1250 | GNUNET_i2s (peer)); |
1357 | GCP_set_mq (cp, | 1251 | GCP_set_mq (cp, NULL); |
1358 | NULL); | ||
1359 | } | 1252 | } |
1360 | 1253 | ||
1361 | 1254 | ||
@@ -1367,52 +1260,48 @@ core_disconnect_cb (void *cls, | |||
1367 | void | 1260 | void |
1368 | GCO_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1261 | GCO_init (const struct GNUNET_CONFIGURATION_Handle *c) |
1369 | { | 1262 | { |
1370 | struct GNUNET_MQ_MessageHandler handlers[] = { | 1263 | struct GNUNET_MQ_MessageHandler handlers[] = |
1371 | GNUNET_MQ_hd_var_size (connection_create, | 1264 | {GNUNET_MQ_hd_var_size (connection_create, |
1372 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, | 1265 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, |
1373 | struct GNUNET_CADET_ConnectionCreateMessage, | 1266 | struct GNUNET_CADET_ConnectionCreateMessage, |
1374 | NULL), | 1267 | NULL), |
1375 | GNUNET_MQ_hd_fixed_size (connection_create_ack, | 1268 | GNUNET_MQ_hd_fixed_size (connection_create_ack, |
1376 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, | 1269 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, |
1377 | struct GNUNET_CADET_ConnectionCreateAckMessage, | 1270 | struct GNUNET_CADET_ConnectionCreateAckMessage, |
1378 | NULL), | 1271 | NULL), |
1379 | GNUNET_MQ_hd_fixed_size (connection_broken, | 1272 | GNUNET_MQ_hd_fixed_size (connection_broken, |
1380 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, | 1273 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, |
1381 | struct GNUNET_CADET_ConnectionBrokenMessage, | 1274 | struct GNUNET_CADET_ConnectionBrokenMessage, |
1382 | NULL), | 1275 | NULL), |
1383 | GNUNET_MQ_hd_fixed_size (connection_destroy, | 1276 | GNUNET_MQ_hd_fixed_size (connection_destroy, |
1384 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, | 1277 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, |
1385 | struct GNUNET_CADET_ConnectionDestroyMessage, | 1278 | struct GNUNET_CADET_ConnectionDestroyMessage, |
1386 | NULL), | 1279 | NULL), |
1387 | GNUNET_MQ_hd_fixed_size (tunnel_kx, | 1280 | GNUNET_MQ_hd_fixed_size (tunnel_kx, |
1388 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX, | 1281 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX, |
1389 | struct GNUNET_CADET_TunnelKeyExchangeMessage, | 1282 | struct GNUNET_CADET_TunnelKeyExchangeMessage, |
1390 | NULL), | 1283 | NULL), |
1391 | GNUNET_MQ_hd_fixed_size (tunnel_kx_auth, | 1284 | GNUNET_MQ_hd_fixed_size (tunnel_kx_auth, |
1392 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH, | 1285 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH, |
1393 | struct GNUNET_CADET_TunnelKeyExchangeAuthMessage, | 1286 | struct GNUNET_CADET_TunnelKeyExchangeAuthMessage, |
1394 | NULL), | 1287 | NULL), |
1395 | GNUNET_MQ_hd_var_size (tunnel_encrypted, | 1288 | GNUNET_MQ_hd_var_size (tunnel_encrypted, |
1396 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED, | 1289 | GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED, |
1397 | struct GNUNET_CADET_TunnelEncryptedMessage, | 1290 | struct GNUNET_CADET_TunnelEncryptedMessage, |
1398 | NULL), | 1291 | NULL), |
1399 | GNUNET_MQ_handler_end () | 1292 | GNUNET_MQ_handler_end ()}; |
1400 | }; | 1293 | |
1401 | 1294 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, | |
1402 | if (GNUNET_OK != | 1295 | "CADET", |
1403 | GNUNET_CONFIGURATION_get_value_number (c, | 1296 | "MAX_ROUTES", |
1404 | "CADET", | 1297 | &max_routes)) |
1405 | "MAX_ROUTES", | ||
1406 | &max_routes)) | ||
1407 | max_routes = 5000; | 1298 | max_routes = 5000; |
1408 | if (GNUNET_OK != | 1299 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, |
1409 | GNUNET_CONFIGURATION_get_value_number (c, | 1300 | "CADET", |
1410 | "CADET", | 1301 | "MAX_MSGS_QUEUE", |
1411 | "MAX_MSGS_QUEUE", | 1302 | &max_buffers)) |
1412 | &max_buffers)) | ||
1413 | max_buffers = 10000; | 1303 | max_buffers = 10000; |
1414 | routes = GNUNET_CONTAINER_multishortmap_create (1024, | 1304 | routes = GNUNET_CONTAINER_multishortmap_create (1024, GNUNET_NO); |
1415 | GNUNET_NO); | ||
1416 | route_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1305 | route_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
1417 | core = GNUNET_CORE_connect (c, | 1306 | core = GNUNET_CORE_connect (c, |
1418 | NULL, | 1307 | NULL, |
diff --git a/src/cadet/gnunet-service-cadet_tunnels.c b/src/cadet/gnunet-service-cadet_tunnels.c index a2a493ebd..11be2bce0 100644 --- a/src/cadet/gnunet-service-cadet_tunnels.c +++ b/src/cadet/gnunet-service-cadet_tunnels.c | |||
@@ -2731,7 +2731,6 @@ consider_path_cb (void *cls, | |||
2731 | ct->cc = GCC_create (t->destination, | 2731 | ct->cc = GCC_create (t->destination, |
2732 | path, | 2732 | path, |
2733 | off, | 2733 | off, |
2734 | GNUNET_CADET_OPTION_DEFAULT, /* FIXME: set based on what channels want/need! */ | ||
2735 | ct, | 2734 | ct, |
2736 | &connection_ready_cb, | 2735 | &connection_ready_cb, |
2737 | ct); | 2736 | ct); |
@@ -3204,7 +3203,6 @@ GCT_create_tunnel (struct CadetPeer *destination) | |||
3204 | int | 3203 | int |
3205 | GCT_add_inbound_connection (struct CadetTunnel *t, | 3204 | GCT_add_inbound_connection (struct CadetTunnel *t, |
3206 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 3205 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
3207 | enum GNUNET_CADET_ChannelOption options, | ||
3208 | struct CadetPeerPath *path) | 3206 | struct CadetPeerPath *path) |
3209 | { | 3207 | { |
3210 | struct CadetTConnection *ct; | 3208 | struct CadetTConnection *ct; |
@@ -3214,7 +3212,6 @@ GCT_add_inbound_connection (struct CadetTunnel *t, | |||
3214 | ct->t = t; | 3212 | ct->t = t; |
3215 | ct->cc = GCC_create_inbound (t->destination, | 3213 | ct->cc = GCC_create_inbound (t->destination, |
3216 | path, | 3214 | path, |
3217 | options, | ||
3218 | ct, | 3215 | ct, |
3219 | cid, | 3216 | cid, |
3220 | &connection_ready_cb, | 3217 | &connection_ready_cb, |
diff --git a/src/cadet/gnunet-service-cadet_tunnels.h b/src/cadet/gnunet-service-cadet_tunnels.h index c1bf2fcd5..47d9f98bf 100644 --- a/src/cadet/gnunet-service-cadet_tunnels.h +++ b/src/cadet/gnunet-service-cadet_tunnels.h | |||
@@ -119,7 +119,6 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t); | |||
119 | * | 119 | * |
120 | * @param t a tunnel | 120 | * @param t a tunnel |
121 | * @param cid connection identifer to use for the connection | 121 | * @param cid connection identifer to use for the connection |
122 | * @param options options for the connection | ||
123 | * @param path path to use for the connection | 122 | * @param path path to use for the connection |
124 | * @return #GNUNET_OK on success, | 123 | * @return #GNUNET_OK on success, |
125 | * #GNUNET_SYSERR on failure (duplicate connection) | 124 | * #GNUNET_SYSERR on failure (duplicate connection) |
@@ -127,7 +126,6 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t); | |||
127 | int | 126 | int |
128 | GCT_add_inbound_connection (struct CadetTunnel *t, | 127 | GCT_add_inbound_connection (struct CadetTunnel *t, |
129 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 128 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
130 | enum GNUNET_CADET_ChannelOption options, | ||
131 | struct CadetPeerPath *path); | 129 | struct CadetPeerPath *path); |
132 | 130 | ||
133 | 131 | ||
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 72c18cf9c..e87e173be 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c | |||
@@ -532,7 +532,6 @@ reconnect_op (void *cls) | |||
532 | }; | 532 | }; |
533 | long l = (long) cls; | 533 | long l = (long) cls; |
534 | struct CadetTestChannelWrapper *ch; | 534 | struct CadetTestChannelWrapper *ch; |
535 | enum GNUNET_CADET_ChannelOption flags; | ||
536 | 535 | ||
537 | reconnect_task = NULL; | 536 | reconnect_task = NULL; |
538 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 537 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -543,13 +542,11 @@ reconnect_op (void *cls) | |||
543 | GNUNET_CADET_channel_destroy (outgoing_ch); | 542 | GNUNET_CADET_channel_destroy (outgoing_ch); |
544 | outgoing_ch = NULL; | 543 | outgoing_ch = NULL; |
545 | } | 544 | } |
546 | flags = GNUNET_CADET_OPTION_DEFAULT; | ||
547 | ch = GNUNET_new (struct CadetTestChannelWrapper); | 545 | ch = GNUNET_new (struct CadetTestChannelWrapper); |
548 | outgoing_ch = GNUNET_CADET_channel_create (h1, | 546 | outgoing_ch = GNUNET_CADET_channel_create (h1, |
549 | ch, | 547 | ch, |
550 | p_id[1], | 548 | p_id[1], |
551 | &port, | 549 | &port, |
552 | flags, | ||
553 | NULL, | 550 | NULL, |
554 | &disconnect_handler, | 551 | &disconnect_handler, |
555 | handlers); | 552 | handlers); |
@@ -998,7 +995,6 @@ start_test (void *cls) | |||
998 | GNUNET_MQ_handler_end () | 995 | GNUNET_MQ_handler_end () |
999 | }; | 996 | }; |
1000 | struct CadetTestChannelWrapper *ch; | 997 | struct CadetTestChannelWrapper *ch; |
1001 | enum GNUNET_CADET_ChannelOption flags; | ||
1002 | 998 | ||
1003 | test_task = NULL; | 999 | test_task = NULL; |
1004 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name); | 1000 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name); |
@@ -1008,11 +1004,9 @@ start_test (void *cls) | |||
1008 | disconnect_task = NULL; | 1004 | disconnect_task = NULL; |
1009 | } | 1005 | } |
1010 | 1006 | ||
1011 | flags = GNUNET_CADET_OPTION_DEFAULT; | ||
1012 | if (SPEED_REL == test) | 1007 | if (SPEED_REL == test) |
1013 | { | 1008 | { |
1014 | test = SPEED; | 1009 | test = SPEED; |
1015 | flags |= GNUNET_CADET_OPTION_RELIABLE; | ||
1016 | } | 1010 | } |
1017 | 1011 | ||
1018 | ch = GNUNET_new (struct CadetTestChannelWrapper); | 1012 | ch = GNUNET_new (struct CadetTestChannelWrapper); |
@@ -1020,7 +1014,6 @@ start_test (void *cls) | |||
1020 | ch, | 1014 | ch, |
1021 | p_id[1], | 1015 | p_id[1], |
1022 | &port, | 1016 | &port, |
1023 | flags, | ||
1024 | NULL, | 1017 | NULL, |
1025 | &disconnect_handler, | 1018 | &disconnect_handler, |
1026 | handlers); | 1019 | handlers); |
diff --git a/src/cadet/test_cadet_local_mq.c b/src/cadet/test_cadet_local_mq.c index fc5561044..b2fed5bd6 100644 --- a/src/cadet/test_cadet_local_mq.c +++ b/src/cadet/test_cadet_local_mq.c | |||
@@ -243,7 +243,6 @@ do_connect (void *cls) | |||
243 | NULL, /* channel cls */ | 243 | NULL, /* channel cls */ |
244 | &id, /* destination */ | 244 | &id, /* destination */ |
245 | GC_u2h (TEST_MESSAGE_TYPE), /* port */ | 245 | GC_u2h (TEST_MESSAGE_TYPE), /* port */ |
246 | GNUNET_CADET_OPTION_DEFAULT, /* opt */ | ||
247 | NULL, /* window change */ | 246 | NULL, /* window change */ |
248 | &disconnected, /* disconnect handler */ | 247 | &disconnected, /* disconnect handler */ |
249 | handlers /* traffic handlers */ | 248 | handlers /* traffic handlers */ |