aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-08-28 13:31:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-08-28 13:31:48 +0000
commit56dd92a399fdebc4d2771b9f3e7790026831867b (patch)
tree164c8891d887cae79c8ed720d4321daaa196a4f7 /src
parent55e4ea7e6853ee2c29ae0152b517bf5c39c7dbc4 (diff)
downloadgnunet-56dd92a399fdebc4d2771b9f3e7790026831867b.tar.gz
gnunet-56dd92a399fdebc4d2771b9f3e7790026831867b.zip
using tcp terminology for 3 way handshake: syn/syn_ack/ack
renaming all functions, states, messages ...
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_protocols.h14
-rw-r--r--src/include/gnunet_transport_service.h57
-rw-r--r--src/transport/gnunet-service-transport.c14
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c410
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h4
-rw-r--r--src/transport/transport_api_monitor_peers.c24
6 files changed, 261 insertions, 262 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index ec6d64d9c..16dc9ae9a 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1269,20 +1269,20 @@ extern "C"
1269#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT 374 1269#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT 374
1270 1270
1271/** 1271/**
1272 * Transport CONNECT message exchanged between transport services to 1272 * Transport SYN message exchanged between transport services to
1273 * indicate that a session should be marked as 'connected'. 1273 * indicate that a session should be marked as 'connected'.
1274 */ 1274 */
1275#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT 375 1275#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN 375
1276 1276
1277/** 1277/**
1278 * Transport CONNECT_ACK message exchanged between transport services to 1278 * Transport SYN_ACK message exchanged between transport services to
1279 * indicate that a CONNECT message was accepted 1279 * indicate that a SYN message was accepted
1280 */ 1280 */
1281#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK 376 1281#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK 376
1282 1282
1283/** 1283/**
1284 * Transport CONNECT_ACK message exchanged between transport services to 1284 * Transport ACK message exchanged between transport services to
1285 * indicate that a CONNECT message was accepted 1285 * indicate that a SYN_ACK message was accepted
1286 */ 1286 */
1287#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK 377 1287#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK 377
1288 1288
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index a7550f2c4..e7ee35d3c 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -493,37 +493,37 @@ GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStri
493/** 493/**
494 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED. 494 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
495 * 495 *
496 * Then, there are two main paths. If we receive a CONNECT message, we give 496 * Then, there are two main paths. If we receive a SYN message, we give
497 * the inbound address to ATS. After the check we ask ATS for a suggestion 497 * the inbound address to ATS. After the check we ask ATS for a suggestion
498 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we 498 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we
499 * send our CONNECT_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. 499 * send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
500 * If we receive a SESSION_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED 500 * If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
501 * (and notify everyone about the new connection). If the operation times out, 501 * (and notify everyone about the new connection). If the operation times out,
502 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT. 502 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
503 * 503 *
504 * The other case is where we transmit a CONNECT message first. We 504 * The other case is where we transmit a SYN message first. We
505 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send 505 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
506 * the CONNECT message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT. 506 * the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
507 * Once we receive a CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED 507 * Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
508 * (and notify everyone about the new connection and send 508 * (and notify everyone about the new connection and send
509 * back a SESSION_ACK). If the operation times out, we go to 509 * back a ACK). If the operation times out, we go to
510 * #GNUNET_TRANSPORT_PS_DISCONNECT. 510 * #GNUNET_TRANSPORT_PS_DISCONNECT.
511 * 511 *
512 * If the session is in trouble (i.e. transport-level disconnect or 512 * If the session is in trouble (i.e. transport-level disconnect or
513 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new 513 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new
514 * address (we don't notify anyone about the disconnect yet). Once we 514 * address (we don't notify anyone about the disconnect yet). Once we
515 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a 515 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a
516 * CONNECT message. If we receive a 516 * SYN message. If we receive a
517 * CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had 517 * SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
518 * trouble; we also send a SESSION_ACK at this time just in case. If 518 * trouble; we also send a ACK at this time just in case. If
519 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone 519 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone
520 * about the lost connection). 520 * about the lost connection).
521 * 521 *
522 * If ATS decides to switch addresses while we have a normal 522 * If ATS decides to switch addresses while we have a normal
523 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT 523 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT
524 * and send a SESSION_CONNECT. If we get a SESSION_ACK back, we switch the 524 * and send a SESSION_CONNECT. If we get a ACK back, we switch the
525 * primary connection to the suggested alternative from ATS, go back 525 * primary connection to the suggested alternative from ATS, go back
526 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a SESSION_ACK to the other peer just to be 526 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be
527 * sure. If the operation times out 527 * sure. If the operation times out
528 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative 528 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative
529 * address is "invalid"). 529 * address is "invalid").
@@ -534,13 +534,13 @@ GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStri
534 * generating disconnect notifications. 534 * generating disconnect notifications.
535 * 535 *
536 * Note that it is quite possible that while we are in any of these 536 * Note that it is quite possible that while we are in any of these
537 * states, we could receive a 'CONNECT' request from the other peer. 537 * states, we could receive a 'SYN' request from the other peer.
538 * We then enter a 'weird' state where we pursue our own primary state 538 * We then enter a 'weird' state where we pursue our own primary state
539 * machine (as described above), but with the 'send_connect_ack' flag 539 * machine (as described above), but with the 'send_connect_ack' flag
540 * set to 1. If our state machine allows us to send a 'CONNECT_ACK' 540 * set to 1. If our state machine allows us to send a 'SYN_ACK'
541 * (because we have an acceptable address), we send the 'CONNECT_ACK' 541 * (because we have an acceptable address), we send the 'SYN_ACK'
542 * and set the 'send_connect_ack' to 2. If we then receive a 542 * and set the 'send_connect_ack' to 2. If we then receive a
543 * 'SESSION_ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack' 543 * 'ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
544 * to 0). 544 * to 0).
545 * 545 *
546 */ 546 */
@@ -557,23 +557,22 @@ enum GNUNET_TRANSPORT_PeerState
557 GNUNET_TRANSPORT_PS_INIT_ATS, 557 GNUNET_TRANSPORT_PS_INIT_ATS,
558 558
559 /** 559 /**
560 * Sent CONNECT message to other peer, waiting for CONNECT_ACK 560 * Sent SYN message to other peer, waiting for SYN_ACK
561 */ 561 */
562 GNUNET_TRANSPORT_PS_CONNECT_SENT, 562 GNUNET_TRANSPORT_PS_SYN_SENT,
563 563
564 /** 564 /**
565 * Received a CONNECT, asking ATS about address suggestions. 565 * Received a SYN, asking ATS about address suggestions.
566 */ 566 */
567 GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, 567 GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
568 568
569 /** 569 /**
570 * CONNECT request from other peer was CONNECT_ACK'ed, waiting for 570 * SYN request from other peer was SYN_ACK'ed, waiting for ACK.
571 * SESSION_ACK.
572 */ 571 */
573 GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, 572 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
574 573
575 /** 574 /**
576 * Got our CONNECT_ACK/SESSION_ACK, connection is up. 575 * Got our SYN_ACK/ACK, connection is up.
577 */ 576 */
578 GNUNET_TRANSPORT_PS_CONNECTED, 577 GNUNET_TRANSPORT_PS_CONNECTED,
579 578
@@ -584,7 +583,7 @@ enum GNUNET_TRANSPORT_PeerState
584 GNUNET_TRANSPORT_PS_RECONNECT_ATS, 583 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
585 584
586 /** 585 /**
587 * Sent CONNECT over new address (either by ATS telling us to switch 586 * Sent SYN over new address (either by ATS telling us to switch
588 * addresses or from RECONNECT_ATS); if this fails, we need to tell 587 * addresses or from RECONNECT_ATS); if this fails, we need to tell
589 * the rest of the system about a disconnect. 588 * the rest of the system about a disconnect.
590 */ 589 */
@@ -592,11 +591,11 @@ enum GNUNET_TRANSPORT_PeerState
592 591
593 /** 592 /**
594 * We have some primary connection, but ATS suggested we switch 593 * We have some primary connection, but ATS suggested we switch
595 * to some alternative; we now sent a CONNECT message for the 594 * to some alternative; we now sent a SYN message for the
596 * alternative session to the other peer and waiting for a 595 * alternative session to the other peer and waiting for a
597 * CONNECT_ACK to make this our primary connection. 596 * SYN_ACK to make this our primary connection.
598 */ 597 */
599 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, 598 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT,
600 599
601 /** 600 /**
602 * Disconnect in progress (we're sending the DISCONNECT message to the 601 * Disconnect in progress (we're sending the DISCONNECT message to the
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 870e541a9..ba9eb38d8 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -328,12 +328,12 @@ connect_bl_check_cont (void *cls,
328 328
329 if (GNUNET_OK == result) 329 if (GNUNET_OK == result)
330 { 330 {
331 /* Blacklist allows to speak to this peer, forward CONNECT to neighbours */ 331 /* Blacklist allows to speak to this peer, forward SYN to neighbours */
332 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 332 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
333 "Received CONNECT message from peer `%s' with `%s' %p\n", 333 "Received SYN message from peer `%s' with `%s' %p\n",
334 GNUNET_i2s (peer), GST_plugins_a2s (blctx->address), blctx->session); 334 GNUNET_i2s (peer), GST_plugins_a2s (blctx->address), blctx->session);
335 335
336 if (GNUNET_OK != GST_neighbours_handle_connect (blctx->msg, 336 if (GNUNET_OK != GST_neighbours_handle_session_syn (blctx->msg,
337 &blctx->address->peer)) 337 &blctx->address->peer))
338 { 338 {
339 cancel_pending_blacklist_checks (blctx->address, blctx->session); 339 cancel_pending_blacklist_checks (blctx->address, blctx->session);
@@ -345,7 +345,7 @@ connect_bl_check_cont (void *cls,
345 /* Blacklist denies to speak to this peer */ 345 /* Blacklist denies to speak to this peer */
346 346
347 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 347 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
348 "Discarding CONNECT message from `%s' due to denied blacklist check\n", 348 "Discarding SYN message from `%s' due to denied blacklist check\n",
349 GNUNET_i2s (peer)); 349 GNUNET_i2s (peer));
350 cancel_pending_blacklist_checks (blctx->address, blctx->session); 350 cancel_pending_blacklist_checks (blctx->address, blctx->session);
351 kill_session (blctx->address->transport_name, blctx->session); 351 kill_session (blctx->address->transport_name, blctx->session);
@@ -457,7 +457,7 @@ GST_receive_callback (void *cls,
457 kill_session (plugin_name, session); 457 kill_session (plugin_name, session);
458 } 458 }
459 break; 459 break;
460 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 460 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN:
461 /* Do blacklist check if communication with this peer is allowed */ 461 /* Do blacklist check if communication with this peer is allowed */
462 blctx = GNUNET_new (struct BlacklistCheckContext); 462 blctx = GNUNET_new (struct BlacklistCheckContext);
463 blctx->address = GNUNET_HELLO_address_copy (address); 463 blctx->address = GNUNET_HELLO_address_copy (address);
@@ -483,8 +483,8 @@ GST_receive_callback (void *cls,
483 blctx->blc = blc; 483 blctx->blc = blc;
484 } 484 }
485 break; 485 break;
486 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: 486 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK:
487 if (GNUNET_OK != GST_neighbours_handle_connect_ack (message, 487 if (GNUNET_OK != GST_neighbours_handle_session_syn_ack (message,
488 &address->peer, address, session)) 488 &address->peer, address, session))
489 { 489 {
490 cancel_pending_blacklist_checks (address, session); 490 cancel_pending_blacklist_checks (address, session);
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 6ec8c9a03..286e009d3 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -90,17 +90,17 @@
90enum GST_ACK_State 90enum GST_ACK_State
91{ 91{
92 /** 92 /**
93 * We did not receive a CONNECT message for this neighbour 93 * We did not receive a SYN message for this neighbour
94 */ 94 */
95 ACK_UNDEFINED = 0, 95 ACK_UNDEFINED = 0,
96 96
97 /* The neighbour received a CONNECT message and has to send a CONNECT_ACK 97 /* The neighbour received a SYN message and has to send a SYN_ACK
98 * as reply */ 98 * as reply */
99 ACK_SEND_CONNECT_ACK = 1, 99 ACK_SEND_SYN_ACK = 1,
100 100
101 /* The neighbour sent a CONNECT_ACK message and has to send a SESSION_ACK 101 /* The neighbour sent a SYN_ACK message and has to send a ACK
102 * as reply */ 102 * as reply */
103 ACK_SEND_SESSION_ACK = 2 103 ACK_SEND_ACK = 2
104}; 104};
105 105
106 106
@@ -108,17 +108,17 @@ GNUNET_NETWORK_STRUCT_BEGIN
108 108
109/** 109/**
110 * Message a peer sends to another to indicate that it intends to 110 * Message a peer sends to another to indicate that it intends to
111 * setup a connection/session for data exchange. A 'SESSION_CONNECT' 111 * setup a connection/session for data exchange. A 'SESSION_SYN'
112 * should be answered with a 'SESSION_CONNECT_ACK' with the same body 112 * should be answered with a 'SESSION_SYN_ACK' with the same body
113 * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with 113 * to confirm. A 'SESSION_SYN_ACK' should then be followed with
114 * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers 114 * a 'ACK'. Once the 'ACK' is received, both peers
115 * should be connected. 115 * should be connected.
116 */ 116 */
117struct SessionConnectMessage 117struct TransportSynMessage
118{ 118{
119 /** 119 /**
120 * Header of type #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT 120 * Header of type #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
121 * or #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK 121 * or #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
122 */ 122 */
123 struct GNUNET_MessageHeader header; 123 struct GNUNET_MessageHeader header;
124 124
@@ -196,7 +196,7 @@ struct SessionDisconnectMessage
196 /** 196 /**
197 * Signature of the peer that sends us the disconnect. Only 197 * Signature of the peer that sends us the disconnect. Only
198 * valid if the timestamp is AFTER the timestamp from the 198 * valid if the timestamp is AFTER the timestamp from the
199 * corresponding 'CONNECT' message. 199 * corresponding 'SYN' message.
200 */ 200 */
201 struct GNUNET_CRYPTO_EddsaSignature signature; 201 struct GNUNET_CRYPTO_EddsaSignature signature;
202 202
@@ -272,7 +272,7 @@ struct NeighbourAddress
272 /** 272 /**
273 * Timestamp of the 'SESSION_CONNECT' message we sent to the other 273 * Timestamp of the 'SESSION_CONNECT' message we sent to the other
274 * peer for this address. Use to check that the ACK is in response 274 * peer for this address. Use to check that the ACK is in response
275 * to our most recent 'CONNECT'. 275 * to our most recent 'SYN'.
276 */ 276 */
277 struct GNUNET_TIME_Absolute connect_timestamp; 277 struct GNUNET_TIME_Absolute connect_timestamp;
278 278
@@ -359,9 +359,9 @@ struct NeighbourMapEntry
359 struct GNUNET_TIME_Absolute last_keep_alive_time; 359 struct GNUNET_TIME_Absolute last_keep_alive_time;
360 360
361 /** 361 /**
362 * Timestamp we should include in our next CONNECT_ACK message. 362 * Timestamp we should include in our next SYN_ACK message.
363 * (only valid if 'send_connect_ack' is #GNUNET_YES). Used to build 363 * (only valid if 'send_connect_ack' is #GNUNET_YES). Used to build
364 * our CONNECT_ACK message. 364 * our SYN_ACK message.
365 */ 365 */
366 struct GNUNET_TIME_Absolute connect_ack_timestamp; 366 struct GNUNET_TIME_Absolute connect_ack_timestamp;
367 367
@@ -405,17 +405,17 @@ struct NeighbourMapEntry
405 int expect_latency_response; 405 int expect_latency_response;
406 406
407 /** 407 /**
408 * When a peer wants to connect we have to reply to the 1st CONNECT message 408 * When a peer wants to connect we have to reply to the 1st SYN message
409 * with a CONNECT_ACK message. But sometime we cannot send this message 409 * with a SYN_ACK message. But sometime we cannot send this message
410 * immediately since we do not have an address and then we have to remember 410 * immediately since we do not have an address and then we have to remember
411 * to send this message as soon as we have an address. 411 * to send this message as soon as we have an address.
412 * 412 *
413 * Flag to set if we still need to send a CONNECT_ACK message to the other peer 413 * Flag to set if we still need to send a SYN_ACK message to the other peer
414 * (once we have an address to use and the peer has been allowed by our 414 * (once we have an address to use and the peer has been allowed by our
415 * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_CONNECT_ACK 415 * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK
416 * if we need to send a CONNECT_ACK. Set to #ACK_SEND_SESSION_ACK if we did 416 * if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did
417 * send a CONNECT_ACK and should go to 'S_CONNECTED' upon receiving a 417 * send a SYN_ACK and should go to 'S_CONNECTED' upon receiving a
418 * 'SESSION_ACK' (regardless of what our own state machine might say). 418 * 'ACK' (regardless of what our own state machine might say).
419 */ 419 */
420 enum GST_ACK_State ack_state; 420 enum GST_ACK_State ack_state;
421 421
@@ -546,10 +546,10 @@ print_ack_state (enum GST_ACK_State s)
546 switch (s) { 546 switch (s) {
547 case ACK_UNDEFINED: 547 case ACK_UNDEFINED:
548 return "UNDEFINED"; 548 return "UNDEFINED";
549 case ACK_SEND_CONNECT_ACK: 549 case ACK_SEND_SYN_ACK:
550 return "SEND_CONNECT_ACK"; 550 return "SEND_SYN_ACK";
551 case ACK_SEND_SESSION_ACK: 551 case ACK_SEND_ACK:
552 return "SEND_SESSION_ACK"; 552 return "SEND_ACK";
553 default: 553 default:
554 GNUNET_break (0); 554 GNUNET_break (0);
555 return "N/A"; 555 return "N/A";
@@ -1118,20 +1118,20 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1118 /* other peer is completely unaware of us, no need to send DISCONNECT */ 1118 /* other peer is completely unaware of us, no need to send DISCONNECT */
1119 free_neighbour (n, GNUNET_NO); 1119 free_neighbour (n, GNUNET_NO);
1120 return; 1120 return;
1121 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 1121 case GNUNET_TRANSPORT_PS_SYN_SENT:
1122 send_disconnect (n); 1122 send_disconnect (n);
1123 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); 1123 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT);
1124 break; 1124 break;
1125 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 1125 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
1126 /* we never ACK'ed the other peer's request, no need to send DISCONNECT */ 1126 /* we never ACK'ed the other peer's request, no need to send DISCONNECT */
1127 free_neighbour (n, GNUNET_NO); 1127 free_neighbour (n, GNUNET_NO);
1128 return; 1128 return;
1129 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 1129 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
1130 /* we DID ACK the other peer's request, must send DISCONNECT */ 1130 /* we DID ACK the other peer's request, must send DISCONNECT */
1131 send_disconnect (n); 1131 send_disconnect (n);
1132 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); 1132 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT);
1133 break; 1133 break;
1134 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 1134 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
1135 case GNUNET_TRANSPORT_PS_CONNECTED: 1135 case GNUNET_TRANSPORT_PS_CONNECTED:
1136 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 1136 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
1137 /* we are currently connected, need to send disconnect and do 1137 /* we are currently connected, need to send disconnect and do
@@ -1325,7 +1325,7 @@ send_keepalive (struct NeighbourMapEntry *n)
1325 uint32_t nonce; 1325 uint32_t nonce;
1326 1326
1327 GNUNET_assert ((GNUNET_TRANSPORT_PS_CONNECTED == n->state) || 1327 GNUNET_assert ((GNUNET_TRANSPORT_PS_CONNECTED == n->state) ||
1328 (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT)); 1328 (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT));
1329 if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value_us > 0) 1329 if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value_us > 0)
1330 return; /* no keepalive needed at this time */ 1330 return; /* no keepalive needed at this time */
1331 1331
@@ -1663,17 +1663,17 @@ send_session_connect_cont (void *cls,
1663 n = lookup_neighbour (target); 1663 n = lookup_neighbour (target);
1664 if (NULL == n) 1664 if (NULL == n)
1665 { 1665 {
1666 /* CONNECT continuation was called after neighbor was freed, 1666 /* SYN continuation was called after neighbor was freed,
1667 * for example due to a time out for the state or the session 1667 * for example due to a time out for the state or the session
1668 * used was already terminated: nothing to do here... */ 1668 * used was already terminated: nothing to do here... */
1669 return; 1669 return;
1670 } 1670 }
1671 1671
1672 if ( (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) && 1672 if ( (GNUNET_TRANSPORT_PS_SYN_SENT != n->state) &&
1673 (GNUNET_TRANSPORT_PS_RECONNECT_SENT != n->state) && 1673 (GNUNET_TRANSPORT_PS_RECONNECT_SENT != n->state) &&
1674 (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT != n->state)) 1674 (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT != n->state))
1675 { 1675 {
1676 /* CONNECT continuation was called after neighbor changed state, 1676 /* SYN continuation was called after neighbor changed state,
1677 * for example due to a time out for the state or the session 1677 * for example due to a time out for the state or the session
1678 * used was already terminated: nothing to do here... */ 1678 * used was already terminated: nothing to do here... */
1679 return; 1679 return;
@@ -1682,13 +1682,13 @@ send_session_connect_cont (void *cls,
1682 return; 1682 return;
1683 1683
1684 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1684 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1685 _("Failed to send CONNECT message to peer `%s' using address `%s' session %p\n"), 1685 _("Failed to send SYN message to peer `%s' using address `%s' session %p\n"),
1686 GNUNET_i2s (target), 1686 GNUNET_i2s (target),
1687 GST_plugins_a2s (n->primary_address.address), 1687 GST_plugins_a2s (n->primary_address.address),
1688 n->primary_address.session); 1688 n->primary_address.session);
1689 1689
1690 switch (n->state) { 1690 switch (n->state) {
1691 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 1691 case GNUNET_TRANSPORT_PS_SYN_SENT:
1692 /* Remove address and request and additional one */ 1692 /* Remove address and request and additional one */
1693 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, 1693 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1694 n->primary_address.session); 1694 n->primary_address.session);
@@ -1706,10 +1706,10 @@ send_session_connect_cont (void *cls,
1706 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 1706 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
1707 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1707 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
1708 break; 1708 break;
1709 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 1709 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
1710 /* Remove address and request and go back to primary address */ 1710 /* Remove address and request and go back to primary address */
1711 GNUNET_STATISTICS_update (GST_stats, gettext_noop 1711 GNUNET_STATISTICS_update (GST_stats, gettext_noop
1712 ("# Failed attempts to switch addresses (failed to send CONNECT CONT)"), 1, GNUNET_NO); 1712 ("# Failed attempts to switch addresses (failed to send SYN CONT)"), 1, GNUNET_NO);
1713 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, 1713 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address,
1714 n->alternative_address.session); 1714 n->alternative_address.session);
1715 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, 1715 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address,
@@ -1725,19 +1725,19 @@ send_session_connect_cont (void *cls,
1725} 1725}
1726 1726
1727/** 1727/**
1728 * Send a SESSION_CONNECT message via the given address. 1728 * Send a SYN message via the given address.
1729 * 1729 *
1730 * @param na address to use 1730 * @param na address to use
1731 */ 1731 */
1732static void 1732static void
1733send_session_connect (struct NeighbourAddress *na) 1733send_syn (struct NeighbourAddress *na)
1734{ 1734{
1735 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1735 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1736 struct SessionConnectMessage connect_msg; 1736 struct TransportSynMessage connect_msg;
1737 struct NeighbourMapEntry *n; 1737 struct NeighbourMapEntry *n;
1738 1738
1739 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1739 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1740 "Sending SESSION_CONNECT message to peer `%s'\n", 1740 "Sending SYN message to peer `%s'\n",
1741 GNUNET_i2s (&na->address->peer)); 1741 GNUNET_i2s (&na->address->peer));
1742 1742
1743 if (NULL == (papi = GST_plugins_find (na->address->transport_name))) 1743 if (NULL == (papi = GST_plugins_find (na->address->transport_name)))
@@ -1754,23 +1754,23 @@ send_session_connect (struct NeighbourAddress *na)
1754 } 1754 }
1755 GNUNET_STATISTICS_update (GST_stats, 1755 GNUNET_STATISTICS_update (GST_stats,
1756 gettext_noop 1756 gettext_noop
1757 ("# SESSION_CONNECT messages sent"), 1757 ("# SYN messages sent"),
1758 1, GNUNET_NO); 1758 1, GNUNET_NO);
1759 na->connect_timestamp = GNUNET_TIME_absolute_get (); 1759 na->connect_timestamp = GNUNET_TIME_absolute_get ();
1760 connect_msg.header.size = htons (sizeof (struct SessionConnectMessage)); 1760 connect_msg.header.size = htons (sizeof (struct TransportSynMessage));
1761 connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT); 1761 connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN);
1762 connect_msg.reserved = htonl (0); 1762 connect_msg.reserved = htonl (0);
1763 connect_msg.timestamp = GNUNET_TIME_absolute_hton (na->connect_timestamp); 1763 connect_msg.timestamp = GNUNET_TIME_absolute_hton (na->connect_timestamp);
1764 if (-1 == 1764 if (-1 ==
1765 papi->send (papi->cls, 1765 papi->send (papi->cls,
1766 na->session, 1766 na->session,
1767 (const char *) &connect_msg, sizeof (struct SessionConnectMessage), 1767 (const char *) &connect_msg, sizeof (struct TransportSynMessage),
1768 UINT_MAX, 1768 UINT_MAX,
1769 SETUP_CONNECTION_TIMEOUT, 1769 SETUP_CONNECTION_TIMEOUT,
1770 send_session_connect_cont, NULL)) 1770 send_session_connect_cont, NULL))
1771 { 1771 {
1772 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1772 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1773 _("Failed to transmit CONNECT message via plugin to %s\n"), 1773 _("Failed to transmit SYN message via plugin to %s\n"),
1774 GST_plugins_a2s (na->address)); 1774 GST_plugins_a2s (na->address));
1775 1775
1776 n = lookup_neighbour (&na->address->peer); 1776 n = lookup_neighbour (&na->address->peer);
@@ -1781,12 +1781,12 @@ send_session_connect (struct NeighbourAddress *na)
1781 } 1781 }
1782 1782
1783 switch (n->state) { 1783 switch (n->state) {
1784 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 1784 case GNUNET_TRANSPORT_PS_SYN_SENT:
1785 /* Remove address and request and additional one */ 1785 /* Remove address and request and additional one */
1786 unset_primary_address (n); 1786 unset_primary_address (n);
1787 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 1787 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
1788 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 1788 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
1789 /* Hard failure to send the CONNECT message with this address: 1789 /* Hard failure to send the SYN message with this address:
1790 Destroy address and session */ 1790 Destroy address and session */
1791 break; 1791 break;
1792 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 1792 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
@@ -1795,9 +1795,9 @@ send_session_connect (struct NeighbourAddress *na)
1795 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 1795 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
1796 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1796 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
1797 break; 1797 break;
1798 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 1798 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
1799 GNUNET_STATISTICS_update (GST_stats, gettext_noop 1799 GNUNET_STATISTICS_update (GST_stats, gettext_noop
1800 ("# Failed attempts to switch addresses (failed to send CONNECT)"), 1, GNUNET_NO); 1800 ("# Failed attempts to switch addresses (failed to send SYN)"), 1, GNUNET_NO);
1801 /* Remove address and request and additional one */ 1801 /* Remove address and request and additional one */
1802 unset_alternative_address (n); 1802 unset_alternative_address (n);
1803 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 1803 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
@@ -1813,7 +1813,7 @@ send_session_connect (struct NeighbourAddress *na)
1813 GST_neighbours_notify_data_sent (&na->address->peer, 1813 GST_neighbours_notify_data_sent (&na->address->peer,
1814 na->address, 1814 na->address,
1815 na->session, 1815 na->session,
1816 sizeof (struct SessionConnectMessage)); 1816 sizeof (struct TransportSynMessage));
1817} 1817}
1818 1818
1819 1819
@@ -1829,15 +1829,15 @@ send_session_connect_ack_cont (void *cls,
1829 n = lookup_neighbour (target); 1829 n = lookup_neighbour (target);
1830 if (NULL == n) 1830 if (NULL == n)
1831 { 1831 {
1832 /* CONNECT_ACK continuation was called after neighbor was freed, 1832 /* SYN_ACK continuation was called after neighbor was freed,
1833 * for example due to a time out for the state or the session 1833 * for example due to a time out for the state or the session
1834 * used was already terminated: nothing to do here... */ 1834 * used was already terminated: nothing to do here... */
1835 return; 1835 return;
1836 } 1836 }
1837 1837
1838 if (GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK != n->state) 1838 if (GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state)
1839 { 1839 {
1840 /* CONNECT_ACK continuation was called after neighbor changed state, 1840 /* SYN_ACK continuation was called after neighbor changed state,
1841 * for example due to a time out for the state or the session 1841 * for example due to a time out for the state or the session
1842 * used was already terminated: nothing to do here... */ 1842 * used was already terminated: nothing to do here... */
1843 return; 1843 return;
@@ -1846,12 +1846,12 @@ send_session_connect_ack_cont (void *cls,
1846 return; 1846 return;
1847 1847
1848 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1848 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1849 _("Failed to send CONNECT_ACK message to peer `%s' using address `%s' session %p\n"), 1849 _("Failed to send SYN_ACK message to peer `%s' using address `%s' session %p\n"),
1850 GNUNET_i2s (target), 1850 GNUNET_i2s (target),
1851 GST_plugins_a2s (n->primary_address.address), 1851 GST_plugins_a2s (n->primary_address.address),
1852 n->primary_address.session); 1852 n->primary_address.session);
1853 1853
1854 /* Failed to send CONNECT_ACK message with this address */ 1854 /* Failed to send SYN_ACK message with this address */
1855 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, 1855 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1856 n->primary_address.session); 1856 n->primary_address.session);
1857 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, 1857 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
@@ -1859,15 +1859,15 @@ send_session_connect_ack_cont (void *cls,
1859 1859
1860 /* Remove address and request and additional one */ 1860 /* Remove address and request and additional one */
1861 unset_primary_address (n); 1861 unset_primary_address (n);
1862 n->ack_state = ACK_SEND_CONNECT_ACK; 1862 n->ack_state = ACK_SEND_SYN_ACK;
1863 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, 1863 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
1864 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1864 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
1865 return; 1865 return;
1866} 1866}
1867 1867
1868 1868
1869/** 1869/**
1870 * Send a CONNECT_ACK message via the given address. 1870 * Send a SYN_ACK message via the given address.
1871 * 1871 *
1872 * @param address address to use 1872 * @param address address to use
1873 * @param session session to use 1873 * @param session session to use
@@ -1880,11 +1880,11 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1880 struct GNUNET_TIME_Absolute timestamp) 1880 struct GNUNET_TIME_Absolute timestamp)
1881{ 1881{
1882 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1882 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1883 struct SessionConnectMessage connect_msg; 1883 struct TransportSynMessage connect_msg;
1884 struct NeighbourMapEntry *n; 1884 struct NeighbourMapEntry *n;
1885 1885
1886 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1886 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1887 "Sending CONNECT_ACK to peer `%s'\n", 1887 "Sending SYN_ACK to peer `%s'\n",
1888 GNUNET_i2s (&address->peer)); 1888 GNUNET_i2s (&address->peer));
1889 1889
1890 if (NULL == (papi = GST_plugins_find (address->transport_name))) 1890 if (NULL == (papi = GST_plugins_find (address->transport_name)))
@@ -1901,22 +1901,22 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1901 } 1901 }
1902 GNUNET_STATISTICS_update (GST_stats, 1902 GNUNET_STATISTICS_update (GST_stats,
1903 gettext_noop 1903 gettext_noop
1904 ("# CONNECT_ACK messages sent"), 1904 ("# SYN_ACK messages sent"),
1905 1, GNUNET_NO); 1905 1, GNUNET_NO);
1906 connect_msg.header.size = htons (sizeof (struct SessionConnectMessage)); 1906 connect_msg.header.size = htons (sizeof (struct TransportSynMessage));
1907 connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK); 1907 connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK);
1908 connect_msg.reserved = htonl (0); 1908 connect_msg.reserved = htonl (0);
1909 connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp); 1909 connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp);
1910 1910
1911 if (GNUNET_SYSERR == papi->send (papi->cls, 1911 if (GNUNET_SYSERR == papi->send (papi->cls,
1912 session, 1912 session,
1913 (const char *) &connect_msg, sizeof (struct SessionConnectMessage), 1913 (const char *) &connect_msg, sizeof (struct TransportSynMessage),
1914 UINT_MAX, 1914 UINT_MAX,
1915 GNUNET_TIME_UNIT_FOREVER_REL, 1915 GNUNET_TIME_UNIT_FOREVER_REL,
1916 send_session_connect_ack_cont, NULL)) 1916 send_session_connect_ack_cont, NULL))
1917 { 1917 {
1918 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1918 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1919 _("Failed to transmit CONNECT_ACK message via plugin to %s\n"), 1919 _("Failed to transmit SYN_ACK message via plugin to %s\n"),
1920 GST_plugins_a2s (address)); 1920 GST_plugins_a2s (address));
1921 1921
1922 n = lookup_neighbour (&address->peer); 1922 n = lookup_neighbour (&address->peer);
@@ -1925,7 +1925,7 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1925 GNUNET_break (0); 1925 GNUNET_break (0);
1926 return; 1926 return;
1927 } 1927 }
1928 /* Hard failure to send the CONNECT_ACK message with this address: 1928 /* Hard failure to send the SYN_ACK message with this address:
1929 Destroy session (and address) */ 1929 Destroy session (and address) */
1930 if (GNUNET_YES == GNUNET_HELLO_address_check_option(address, 1930 if (GNUNET_YES == GNUNET_HELLO_address_check_option(address,
1931 GNUNET_HELLO_ADDRESS_INFO_INBOUND)) 1931 GNUNET_HELLO_ADDRESS_INFO_INBOUND))
@@ -1938,8 +1938,8 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1938 1938
1939 /* Remove address and request and additional one */ 1939 /* Remove address and request and additional one */
1940 unset_primary_address (n); 1940 unset_primary_address (n);
1941 n->ack_state = ACK_SEND_CONNECT_ACK; 1941 n->ack_state = ACK_SEND_SYN_ACK;
1942 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, 1942 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
1943 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1943 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
1944 return; 1944 return;
1945 } 1945 }
@@ -2245,9 +2245,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2245 free_neighbour (n, GNUNET_NO); 2245 free_neighbour (n, GNUNET_NO);
2246 break; 2246 break;
2247 case GNUNET_TRANSPORT_PS_INIT_ATS: 2247 case GNUNET_TRANSPORT_PS_INIT_ATS:
2248 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 2248 case GNUNET_TRANSPORT_PS_SYN_SENT:
2249 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 2249 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
2250 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 2250 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
2251 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2251 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2252 "Ignoring request to try to connect to `%s', already trying!\n", 2252 "Ignoring request to try to connect to `%s', already trying!\n",
2253 GNUNET_i2s (target)); 2253 GNUNET_i2s (target));
@@ -2255,7 +2255,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2255 case GNUNET_TRANSPORT_PS_CONNECTED: 2255 case GNUNET_TRANSPORT_PS_CONNECTED:
2256 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 2256 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
2257 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 2257 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
2258 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 2258 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
2259 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2259 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2260 "Ignoring request to try to connect, already connected to `%s'!\n", 2260 "Ignoring request to try to connect, already connected to `%s'!\n",
2261 GNUNET_i2s (target)); 2261 GNUNET_i2s (target));
@@ -2291,38 +2291,38 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2291 2291
2292 2292
2293/** 2293/**
2294 * We received a 'SESSION_CONNECT' message from the other peer. 2294 * We received a 'SYN' message from the other peer.
2295 * Consider switching to it. 2295 * Consider switching to it.
2296 * 2296 *
2297 * @param message possibly a 'struct SessionConnectMessage' (check format) 2297 * @param message possibly a 'struct TransportSynMessage' (check format)
2298 * @param peer identity of the peer to switch the address for 2298 * @param peer identity of the peer to switch the address for
2299 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error 2299 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
2300 */ 2300 */
2301int 2301int
2302GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 2302GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message,
2303 const struct GNUNET_PeerIdentity *peer) 2303 const struct GNUNET_PeerIdentity *peer)
2304{ 2304{
2305 const struct SessionConnectMessage *scm; 2305 const struct TransportSynMessage *scm;
2306 struct NeighbourMapEntry *n; 2306 struct NeighbourMapEntry *n;
2307 struct GNUNET_TIME_Absolute ts; 2307 struct GNUNET_TIME_Absolute ts;
2308 2308
2309 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 2309 if (ntohs (message->size) != sizeof (struct TransportSynMessage))
2310 { 2310 {
2311 GNUNET_break_op (0); 2311 GNUNET_break_op (0);
2312 return GNUNET_SYSERR; 2312 return GNUNET_SYSERR;
2313 } 2313 }
2314 GNUNET_STATISTICS_update (GST_stats, 2314 GNUNET_STATISTICS_update (GST_stats,
2315 gettext_noop 2315 gettext_noop
2316 ("# CONNECT messages received"), 2316 ("# SYN messages received"),
2317 1, GNUNET_NO); 2317 1, GNUNET_NO);
2318 if (NULL == neighbours) 2318 if (NULL == neighbours)
2319 { 2319 {
2320 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2320 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2321 _("CONNECT request from peer `%s' ignored due impending shutdown\n"), 2321 _("SYN request from peer `%s' ignored due impending shutdown\n"),
2322 GNUNET_i2s (peer)); 2322 GNUNET_i2s (peer));
2323 return GNUNET_OK; /* we're shutting down */ 2323 return GNUNET_OK; /* we're shutting down */
2324 } 2324 }
2325 scm = (const struct SessionConnectMessage *) message; 2325 scm = (const struct TransportSynMessage *) message;
2326 GNUNET_break_op (0 == ntohl (scm->reserved)); 2326 GNUNET_break_op (0 == ntohl (scm->reserved));
2327 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); 2327 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
2328 n = lookup_neighbour (peer); 2328 n = lookup_neighbour (peer);
@@ -2332,12 +2332,12 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2332 n = setup_neighbour (peer); 2332 n = setup_neighbour (peer);
2333 } 2333 }
2334 2334
2335 /* Remember this CONNECT message in neighbour */ 2335 /* Remember this SYN message in neighbour */
2336 n->ack_state = ACK_SEND_CONNECT_ACK; 2336 n->ack_state = ACK_SEND_SYN_ACK;
2337 n->connect_ack_timestamp = ts; 2337 n->connect_ack_timestamp = ts;
2338 2338
2339 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2339 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2340 "Received CONNECT for peer `%s' in state %s/%s\n", 2340 "Received SYN for peer `%s' in state %s/%s\n",
2341 GNUNET_i2s (peer), 2341 GNUNET_i2s (peer),
2342 GNUNET_TRANSPORT_ps2s (n->state), 2342 GNUNET_TRANSPORT_ps2s (n->state),
2343 print_ack_state (n->ack_state)); 2343 print_ack_state (n->ack_state));
@@ -2345,25 +2345,25 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2345 switch (n->state) 2345 switch (n->state)
2346 { 2346 {
2347 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 2347 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
2348 /* Request an address from ATS to send CONNECT_ACK to this peer */ 2348 /* Request an address from ATS to send SYN_ACK to this peer */
2349 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, 2349 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
2350 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 2350 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
2351 if (NULL == n->suggest_handle) 2351 if (NULL == n->suggest_handle)
2352 GNUNET_ATS_suggest_address (GST_ats, peer, address_suggest_cont, n); 2352 GNUNET_ATS_suggest_address (GST_ats, peer, address_suggest_cont, n);
2353 break; 2353 break;
2354 case GNUNET_TRANSPORT_PS_INIT_ATS: 2354 case GNUNET_TRANSPORT_PS_INIT_ATS:
2355 /* CONNECT message takes priority over us asking ATS for address: 2355 /* SYN message takes priority over us asking ATS for address:
2356 * Wait for ATS to suggest an address and send CONNECT_ACK */ 2356 * Wait for ATS to suggest an address and send SYN_ACK */
2357 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, 2357 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
2358 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 2358 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
2359 break; 2359 break;
2360 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 2360 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
2361 /* We already wait for an address to send an CONNECT_ACK */ 2361 /* We already wait for an address to send an SYN_ACK */
2362 break; 2362 break;
2363 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 2363 case GNUNET_TRANSPORT_PS_SYN_SENT:
2364 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 2364 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
2365 /* Send ACK immediately */ 2365 /* Send ACK immediately */
2366 n->ack_state = ACK_SEND_SESSION_ACK; 2366 n->ack_state = ACK_SEND_ACK;
2367 send_connect_ack_message (n->primary_address.address, 2367 send_connect_ack_message (n->primary_address.address,
2368 n->primary_address.session, ts); 2368 n->primary_address.session, ts);
2369 break; 2369 break;
@@ -2371,7 +2371,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2371 /* we are already connected and can thus send the ACK immediately */ 2371 /* we are already connected and can thus send the ACK immediately */
2372 GNUNET_assert (NULL != n->primary_address.address); 2372 GNUNET_assert (NULL != n->primary_address.address);
2373 GNUNET_assert (NULL != n->primary_address.session); 2373 GNUNET_assert (NULL != n->primary_address.session);
2374 n->ack_state = ACK_SEND_SESSION_ACK; 2374 n->ack_state = ACK_SEND_ACK;
2375 send_connect_ack_message (n->primary_address.address, 2375 send_connect_ack_message (n->primary_address.address,
2376 n->primary_address.session, ts); 2376 n->primary_address.session, ts);
2377 break; 2377 break;
@@ -2379,19 +2379,19 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2379 /* We wait for ATS address suggestion */ 2379 /* We wait for ATS address suggestion */
2380 break; 2380 break;
2381 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 2381 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
2382 /* We received a CONNECT message while waiting for a CONNECT_ACK in fast 2382 /* We received a SYN message while waiting for a SYN_ACK in fast
2383 * reconnect. Send CONNECT_ACK immediately */ 2383 * reconnect. Send SYN_ACK immediately */
2384 n->ack_state = ACK_SEND_SESSION_ACK; 2384 n->ack_state = ACK_SEND_ACK;
2385 send_connect_ack_message (n->primary_address.address, 2385 send_connect_ack_message (n->primary_address.address,
2386 n->primary_address.session, n->connect_ack_timestamp); 2386 n->primary_address.session, n->connect_ack_timestamp);
2387 break; 2387 break;
2388 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 2388 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
2389 /* We are already connected and can thus send the ACK immediately; 2389 /* We are already connected and can thus send the ACK immediately;
2390 still, it can never hurt to have an alternative address, so also 2390 still, it can never hurt to have an alternative address, so also
2391 tell ATS about it */ 2391 tell ATS about it */
2392 GNUNET_assert (NULL != n->primary_address.address); 2392 GNUNET_assert (NULL != n->primary_address.address);
2393 GNUNET_assert (NULL != n->primary_address.session); 2393 GNUNET_assert (NULL != n->primary_address.session);
2394 n->ack_state = ACK_SEND_SESSION_ACK; 2394 n->ack_state = ACK_SEND_ACK;
2395 send_connect_ack_message (n->primary_address.address, 2395 send_connect_ack_message (n->primary_address.address,
2396 n->primary_address.session, ts); 2396 n->primary_address.session, ts);
2397 break; 2397 break;
@@ -2399,13 +2399,13 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2399 /* Get rid of remains without terminating sessions, ready to re-try */ 2399 /* Get rid of remains without terminating sessions, ready to re-try */
2400 free_neighbour (n, GNUNET_YES); 2400 free_neighbour (n, GNUNET_YES);
2401 n = setup_neighbour (peer); 2401 n = setup_neighbour (peer);
2402 /* Remember the CONNECT time stamp for ACK message */ 2402 /* Remember the SYN time stamp for ACK message */
2403 n->ack_state = ACK_SEND_CONNECT_ACK; 2403 n->ack_state = ACK_SEND_SYN_ACK;
2404 n->connect_ack_timestamp = ts; 2404 n->connect_ack_timestamp = ts;
2405 /* Request an address for the peer */ 2405 /* Request an address for the peer */
2406 GNUNET_ATS_suggest_address (GST_ats, peer, address_suggest_cont, n); 2406 GNUNET_ATS_suggest_address (GST_ats, peer, address_suggest_cont, n);
2407 GNUNET_ATS_reset_backoff (GST_ats, peer); 2407 GNUNET_ATS_reset_backoff (GST_ats, peer);
2408 set_state (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS); 2408 set_state (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS);
2409 break; 2409 break;
2410 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 2410 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
2411 /* should not be possible */ 2411 /* should not be possible */
@@ -2538,64 +2538,64 @@ switch_address_bl_check_cont (void *cls,
2538 return; 2538 return;
2539 case GNUNET_TRANSPORT_PS_INIT_ATS: 2539 case GNUNET_TRANSPORT_PS_INIT_ATS:
2540 /* We requested an address and ATS suggests one: 2540 /* We requested an address and ATS suggests one:
2541 * set primary address and send CONNECT message*/ 2541 * set primary address and send SYN message*/
2542 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2542 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2543 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2543 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2544 if ( (ACK_SEND_CONNECT_ACK == n->ack_state) ) 2544 if ( (ACK_SEND_SYN_ACK == n->ack_state) )
2545 { 2545 {
2546 /* Send pending CONNECT_ACK message */ 2546 /* Send pending SYN_ACK message */
2547 n->ack_state = ACK_SEND_SESSION_ACK; 2547 n->ack_state = ACK_SEND_ACK;
2548 send_connect_ack_message (n->primary_address.address, 2548 send_connect_ack_message (n->primary_address.address,
2549 n->primary_address.session, n->connect_ack_timestamp); 2549 n->primary_address.session, n->connect_ack_timestamp);
2550 } 2550 }
2551 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_SENT, 2551 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_SENT,
2552 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2552 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2553 send_session_connect (&n->primary_address); 2553 send_syn (&n->primary_address);
2554 break; 2554 break;
2555 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 2555 case GNUNET_TRANSPORT_PS_SYN_SENT:
2556 /* ATS suggested a new address while waiting for an CONNECT_ACK: 2556 /* ATS suggested a new address while waiting for an SYN_ACK:
2557 * Switch and send new CONNECT */ 2557 * Switch and send new SYN */
2558 /* ATS suggests a different address, switch again */ 2558 /* ATS suggests a different address, switch again */
2559 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2559 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2560 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2560 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2561 if (ACK_SEND_CONNECT_ACK == n->ack_state) 2561 if (ACK_SEND_SYN_ACK == n->ack_state)
2562 { 2562 {
2563 /* Send pending CONNECT_ACK message */ 2563 /* Send pending SYN_ACK message */
2564 n->ack_state = ACK_SEND_SESSION_ACK; 2564 n->ack_state = ACK_SEND_ACK;
2565 send_connect_ack_message (n->primary_address.address, 2565 send_connect_ack_message (n->primary_address.address,
2566 n->primary_address.session, n->connect_ack_timestamp); 2566 n->primary_address.session, n->connect_ack_timestamp);
2567 } 2567 }
2568 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_SENT, 2568 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_SENT,
2569 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2569 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2570 send_session_connect (&n->primary_address); 2570 send_syn (&n->primary_address);
2571 break; 2571 break;
2572 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 2572 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
2573 /* We requested an address and ATS suggests one: 2573 /* We requested an address and ATS suggests one:
2574 * set primary address and send CONNECT_ACK message*/ 2574 * set primary address and send SYN_ACK message*/
2575 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2575 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2576 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2576 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2577 /* Send an ACK message as a response to the CONNECT msg */ 2577 /* Send an ACK message as a response to the SYN msg */
2578 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, 2578 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
2579 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2579 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2580 send_connect_ack_message (n->primary_address.address, 2580 send_connect_ack_message (n->primary_address.address,
2581 n->primary_address.session, 2581 n->primary_address.session,
2582 n->connect_ack_timestamp); 2582 n->connect_ack_timestamp);
2583 if ( (ACK_SEND_CONNECT_ACK == n->ack_state) || 2583 if ( (ACK_SEND_SYN_ACK == n->ack_state) ||
2584 (ACK_UNDEFINED == n->ack_state) ) 2584 (ACK_UNDEFINED == n->ack_state) )
2585 n->ack_state = ACK_SEND_SESSION_ACK; 2585 n->ack_state = ACK_SEND_ACK;
2586 break; 2586 break;
2587 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 2587 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
2588 /* ATS asks us to switch while we were trying to connect; switch to new 2588 /* ATS asks us to switch while we were trying to connect; switch to new
2589 address and check blacklist again */ 2589 address and check blacklist again */
2590 if ( (ACK_SEND_CONNECT_ACK == n->ack_state) ) 2590 if ( (ACK_SEND_SYN_ACK == n->ack_state) )
2591 { 2591 {
2592 n->ack_state = ACK_SEND_SESSION_ACK; 2592 n->ack_state = ACK_SEND_ACK;
2593 send_connect_ack_message (n->primary_address.address, 2593 send_connect_ack_message (n->primary_address.address,
2594 n->primary_address.session, n->connect_ack_timestamp); 2594 n->primary_address.session, n->connect_ack_timestamp);
2595 } 2595 }
2596 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2596 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2597 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2597 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2598 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, 2598 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
2599 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2599 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2600 break; 2600 break;
2601 case GNUNET_TRANSPORT_PS_CONNECTED: 2601 case GNUNET_TRANSPORT_PS_CONNECTED:
@@ -2609,39 +2609,39 @@ switch_address_bl_check_cont (void *cls,
2609 break; 2609 break;
2610 } 2610 }
2611 /* ATS asks us to switch a life connection; see if we can get 2611 /* ATS asks us to switch a life connection; see if we can get
2612 a CONNECT_ACK on it before we actually do this! */ 2612 a SYN_ACK on it before we actually do this! */
2613 set_alternative_address (n, blc_ctx->address, blc_ctx->session, 2613 set_alternative_address (n, blc_ctx->address, blc_ctx->session,
2614 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); 2614 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out);
2615 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, 2615 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT,
2616 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2616 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2617 GNUNET_STATISTICS_update (GST_stats, gettext_noop 2617 GNUNET_STATISTICS_update (GST_stats, gettext_noop
2618 ("# Attempts to switch addresses"), 1, GNUNET_NO); 2618 ("# Attempts to switch addresses"), 1, GNUNET_NO);
2619 send_session_connect (&n->alternative_address); 2619 send_syn (&n->alternative_address);
2620 break; 2620 break;
2621 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 2621 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
2622 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2622 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2623 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2623 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2624 if ( (ACK_SEND_CONNECT_ACK == n->ack_state) ) 2624 if ( (ACK_SEND_SYN_ACK == n->ack_state) )
2625 { 2625 {
2626 /* Send pending CONNECT_ACK message */ 2626 /* Send pending SYN_ACK message */
2627 n->ack_state = ACK_SEND_SESSION_ACK; 2627 n->ack_state = ACK_SEND_ACK;
2628 send_connect_ack_message (n->primary_address.address, 2628 send_connect_ack_message (n->primary_address.address,
2629 n->primary_address.session, n->connect_ack_timestamp); 2629 n->primary_address.session, n->connect_ack_timestamp);
2630 } 2630 }
2631 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT, 2631 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT,
2632 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 2632 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
2633 send_session_connect (&n->primary_address); 2633 send_syn (&n->primary_address);
2634 break; 2634 break;
2635 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 2635 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
2636 /* ATS asks us to switch while we were trying to reconnect; switch to new 2636 /* ATS asks us to switch while we were trying to reconnect; switch to new
2637 address and send CONNECT again */ 2637 address and send SYN again */
2638 set_primary_address (n, blc_ctx->address, blc_ctx->session, 2638 set_primary_address (n, blc_ctx->address, blc_ctx->session,
2639 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); 2639 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO);
2640 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT, 2640 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT,
2641 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 2641 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
2642 send_session_connect (&n->primary_address); 2642 send_syn (&n->primary_address);
2643 break; 2643 break;
2644 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 2644 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
2645 if ( (0 == GNUNET_HELLO_address_cmp(n->primary_address.address, 2645 if ( (0 == GNUNET_HELLO_address_cmp(n->primary_address.address,
2646 blc_ctx->address) && n->primary_address.session == blc_ctx->session) ) 2646 blc_ctx->address) && n->primary_address.session == blc_ctx->session) )
2647 { 2647 {
@@ -2653,9 +2653,9 @@ switch_address_bl_check_cont (void *cls,
2653 /* ATS asks us to switch a life connection, send */ 2653 /* ATS asks us to switch a life connection, send */
2654 set_alternative_address (n, blc_ctx->address, blc_ctx->session, 2654 set_alternative_address (n, blc_ctx->address, blc_ctx->session,
2655 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); 2655 blc_ctx->bandwidth_in, blc_ctx->bandwidth_out);
2656 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, 2656 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT,
2657 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2657 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
2658 send_session_connect (&n->alternative_address); 2658 send_syn (&n->alternative_address);
2659 break; 2659 break;
2660 case GNUNET_TRANSPORT_PS_DISCONNECT: 2660 case GNUNET_TRANSPORT_PS_DISCONNECT:
2661 /* not going to switch addresses while disconnecting */ 2661 /* not going to switch addresses while disconnecting */
@@ -2958,11 +2958,11 @@ master_task (void *cls,
2958 return; 2958 return;
2959 } 2959 }
2960 break; 2960 break;
2961 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 2961 case GNUNET_TRANSPORT_PS_SYN_SENT:
2962 if (0 == delay.rel_value_us) 2962 if (0 == delay.rel_value_us)
2963 { 2963 {
2964 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2964 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2965 "Connection to `%s' timed out waiting for other peer to send CONNECT_ACK\n", 2965 "Connection to `%s' timed out waiting for other peer to send SYN_ACK\n",
2966 GNUNET_i2s (&n->id)); 2966 GNUNET_i2s (&n->id));
2967 /* We could not send to this address, delete address and session */ 2967 /* We could not send to this address, delete address and session */
2968 if (NULL != n->primary_address.session) 2968 if (NULL != n->primary_address.session)
@@ -2977,21 +2977,21 @@ master_task (void *cls,
2977 return; 2977 return;
2978 } 2978 }
2979 break; 2979 break;
2980 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 2980 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
2981 if (0 == delay.rel_value_us) 2981 if (0 == delay.rel_value_us)
2982 { 2982 {
2983 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2983 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2984 "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", 2984 "Connection to `%s' timed out waiting ATS to provide address to use for SYN_ACK\n",
2985 GNUNET_i2s (&n->id)); 2985 GNUNET_i2s (&n->id));
2986 free_neighbour (n, GNUNET_NO); 2986 free_neighbour (n, GNUNET_NO);
2987 return; 2987 return;
2988 } 2988 }
2989 break; 2989 break;
2990 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 2990 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
2991 if (0 == delay.rel_value_us) 2991 if (0 == delay.rel_value_us)
2992 { 2992 {
2993 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2993 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2994 "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", 2994 "Connection to `%s' timed out waiting for other peer to send ACK\n",
2995 GNUNET_i2s (&n->id)); 2995 GNUNET_i2s (&n->id));
2996 disconnect_neighbour (n); 2996 disconnect_neighbour (n);
2997 return; 2997 return;
@@ -3023,17 +3023,17 @@ master_task (void *cls,
3023 if (0 == delay.rel_value_us) 3023 if (0 == delay.rel_value_us)
3024 { 3024 {
3025 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3025 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3026 "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", 3026 "Connection to `%s' timed out, waiting for other peer to SYN_ACK replacement address\n",
3027 GNUNET_i2s (&n->id)); 3027 GNUNET_i2s (&n->id));
3028 disconnect_neighbour (n); 3028 disconnect_neighbour (n);
3029 return; 3029 return;
3030 } 3030 }
3031 break; 3031 break;
3032 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 3032 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
3033 if (0 == delay.rel_value_us) 3033 if (0 == delay.rel_value_us)
3034 { 3034 {
3035 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3035 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3036 "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", 3036 "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to SYN on alternative address)\n",
3037 GNUNET_i2s (&n->id)); 3037 GNUNET_i2s (&n->id));
3038 GNUNET_STATISTICS_update (GST_stats, gettext_noop 3038 GNUNET_STATISTICS_update (GST_stats, gettext_noop
3039 ("# Failed attempts to switch addresses (no response)"), 1, GNUNET_NO); 3039 ("# Failed attempts to switch addresses (no response)"), 1, GNUNET_NO);
@@ -3060,7 +3060,7 @@ master_task (void *cls,
3060 GNUNET_break (0); 3060 GNUNET_break (0);
3061 break; 3061 break;
3062 } 3062 }
3063 if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) || 3063 if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT == n->state) ||
3064 (GNUNET_TRANSPORT_PS_CONNECTED == n->state) ) 3064 (GNUNET_TRANSPORT_PS_CONNECTED == n->state) )
3065 { 3065 {
3066 /* if we are *now* in one of the two states, we're sending 3066 /* if we are *now* in one of the two states, we're sending
@@ -3077,17 +3077,17 @@ master_task (void *cls,
3077 3077
3078 3078
3079/** 3079/**
3080 * Send a SESSION_ACK message to the neighbour to confirm that we 3080 * Send a ACK message to the neighbour to confirm that we
3081 * got his CONNECT_ACK. 3081 * got his SYN_ACK.
3082 * 3082 *
3083 * @param n neighbour to send the SESSION_ACK to 3083 * @param n neighbour to send the ACK to
3084 */ 3084 */
3085static void 3085static void
3086send_session_ack_message (struct NeighbourMapEntry *n) 3086send_session_ack_message (struct NeighbourMapEntry *n)
3087{ 3087{
3088 struct GNUNET_MessageHeader msg; 3088 struct GNUNET_MessageHeader msg;
3089 3089
3090 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sending SESSION_ACK message to peer `%s'\n", 3090 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sending ACK message to peer `%s'\n",
3091 GNUNET_i2s (&n->id)); 3091 GNUNET_i2s (&n->id));
3092 3092
3093 msg.size = htons (sizeof (struct GNUNET_MessageHeader)); 3093 msg.size = htons (sizeof (struct GNUNET_MessageHeader));
@@ -3100,7 +3100,7 @@ send_session_ack_message (struct NeighbourMapEntry *n)
3100 3100
3101 3101
3102/** 3102/**
3103 * We received a 'SESSION_CONNECT_ACK' message from the other peer. 3103 * We received a 'SESSION_SYN_ACK' message from the other peer.
3104 * Consider switching to it. 3104 * Consider switching to it.
3105 * 3105 *
3106 * @param message possibly a 'struct SessionConnectMessage' (check format) 3106 * @param message possibly a 'struct SessionConnectMessage' (check format)
@@ -3111,35 +3111,35 @@ send_session_ack_message (struct NeighbourMapEntry *n)
3111 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error 3111 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
3112 */ 3112 */
3113int 3113int
3114GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 3114GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message,
3115 const struct GNUNET_PeerIdentity *peer, 3115 const struct GNUNET_PeerIdentity *peer,
3116 const struct GNUNET_HELLO_Address *address, 3116 const struct GNUNET_HELLO_Address *address,
3117 struct Session *session) 3117 struct Session *session)
3118{ 3118{
3119 const struct SessionConnectMessage *scm; 3119 const struct TransportSynMessage *scm;
3120 struct GNUNET_TIME_Absolute ts; 3120 struct GNUNET_TIME_Absolute ts;
3121 struct NeighbourMapEntry *n; 3121 struct NeighbourMapEntry *n;
3122 3122
3123 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3123 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3124 "Received CONNECT_ACK message from peer `%s'\n", 3124 "Received SYN_ACK message from peer `%s'\n",
3125 GNUNET_i2s (peer)); 3125 GNUNET_i2s (peer));
3126 3126
3127 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 3127 if (ntohs (message->size) != sizeof (struct TransportSynMessage))
3128 { 3128 {
3129 GNUNET_break_op (0); 3129 GNUNET_break_op (0);
3130 return GNUNET_SYSERR; 3130 return GNUNET_SYSERR;
3131 } 3131 }
3132 GNUNET_STATISTICS_update (GST_stats, 3132 GNUNET_STATISTICS_update (GST_stats,
3133 gettext_noop 3133 gettext_noop
3134 ("# CONNECT_ACK messages received"), 3134 ("# SYN_ACK messages received"),
3135 1, GNUNET_NO); 3135 1, GNUNET_NO);
3136 scm = (const struct SessionConnectMessage *) message; 3136 scm = (const struct TransportSynMessage *) message;
3137 GNUNET_break_op (ntohl (scm->reserved) == 0); 3137 GNUNET_break_op (ntohl (scm->reserved) == 0);
3138 if (NULL == (n = lookup_neighbour (peer))) 3138 if (NULL == (n = lookup_neighbour (peer)))
3139 { 3139 {
3140 GNUNET_STATISTICS_update (GST_stats, 3140 GNUNET_STATISTICS_update (GST_stats,
3141 gettext_noop 3141 gettext_noop
3142 ("# unexpected CONNECT_ACK messages (no peer)"), 3142 ("# unexpected SYN_ACK messages (no peer)"),
3143 1, GNUNET_NO); 3143 1, GNUNET_NO);
3144 return GNUNET_SYSERR; 3144 return GNUNET_SYSERR;
3145 } 3145 }
@@ -3153,14 +3153,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
3153 case GNUNET_TRANSPORT_PS_INIT_ATS: 3153 case GNUNET_TRANSPORT_PS_INIT_ATS:
3154 GNUNET_STATISTICS_update (GST_stats, 3154 GNUNET_STATISTICS_update (GST_stats,
3155 gettext_noop 3155 gettext_noop
3156 ("# unexpected CONNECT_ACK messages (not ready)"), 3156 ("# unexpected SYN_ACK messages (not ready)"),
3157 1, GNUNET_NO); 3157 1, GNUNET_NO);
3158 break; 3158 break;
3159 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 3159 case GNUNET_TRANSPORT_PS_SYN_SENT:
3160 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) 3160 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
3161 { 3161 {
3162 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3162 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3163 "CONNECT_ACK ignored as the timestamp does not match our CONNECT request\n"); 3163 "SYN_ACK ignored as the timestamp does not match our SYN request\n");
3164 return GNUNET_OK; 3164 return GNUNET_OK;
3165 } 3165 }
3166 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 3166 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
@@ -3172,7 +3172,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
3172 connect_notify_cb (callback_cls, &n->id, 3172 connect_notify_cb (callback_cls, &n->id,
3173 n->primary_address.bandwidth_in, 3173 n->primary_address.bandwidth_in,
3174 n->primary_address.bandwidth_out); 3174 n->primary_address.bandwidth_out);
3175 /* Tell ATS that the outbound session we created to send CONNECT was successful */ 3175 /* Tell ATS that the outbound session we created to send SYN was successful */
3176 GST_ats_add_address (n->primary_address.address, 3176 GST_ats_add_address (n->primary_address.address,
3177 n->primary_address.session, 3177 n->primary_address.session,
3178 NULL, 0); 3178 NULL, 0);
@@ -3184,23 +3184,23 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
3184 GNUNET_YES); 3184 GNUNET_YES);
3185 send_session_ack_message (n); 3185 send_session_ack_message (n);
3186 break; 3186 break;
3187 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 3187 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
3188 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 3188 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
3189 GNUNET_STATISTICS_update (GST_stats, 3189 GNUNET_STATISTICS_update (GST_stats,
3190 gettext_noop 3190 gettext_noop
3191 ("# unexpected CONNECT_ACK messages (not ready)"), 3191 ("# unexpected SYN_ACK messages (not ready)"),
3192 1, GNUNET_NO); 3192 1, GNUNET_NO);
3193 break; 3193 break;
3194 case GNUNET_TRANSPORT_PS_CONNECTED: 3194 case GNUNET_TRANSPORT_PS_CONNECTED:
3195 /* duplicate CONNECT_ACK, let's answer by duplicate SESSION_ACK just in case */ 3195 /* duplicate SYN_ACK, let's answer by duplicate ACK just in case */
3196 send_session_ack_message (n); 3196 send_session_ack_message (n);
3197 break; 3197 break;
3198 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 3198 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
3199 /* we didn't expect any CONNECT_ACK, as we are waiting for ATS 3199 /* we didn't expect any SYN_ACK, as we are waiting for ATS
3200 to give us a new address... */ 3200 to give us a new address... */
3201 GNUNET_STATISTICS_update (GST_stats, 3201 GNUNET_STATISTICS_update (GST_stats,
3202 gettext_noop 3202 gettext_noop
3203 ("# unexpected CONNECT_ACK messages (waiting on ATS)"), 3203 ("# unexpected SYN_ACK messages (waiting on ATS)"),
3204 1, GNUNET_NO); 3204 1, GNUNET_NO);
3205 break; 3205 break;
3206 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 3206 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
@@ -3209,7 +3209,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
3209 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); 3209 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
3210 send_session_ack_message (n); 3210 send_session_ack_message (n);
3211 break; 3211 break;
3212 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 3212 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
3213 /* new address worked; adopt it and go back to connected! */ 3213 /* new address worked; adopt it and go back to connected! */
3214 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 3214 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
3215 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); 3215 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
@@ -3231,7 +3231,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
3231 case GNUNET_TRANSPORT_PS_DISCONNECT: 3231 case GNUNET_TRANSPORT_PS_DISCONNECT:
3232 GNUNET_STATISTICS_update (GST_stats, 3232 GNUNET_STATISTICS_update (GST_stats,
3233 gettext_noop 3233 gettext_noop
3234 ("# unexpected CONNECT_ACK messages (disconnecting)"), 3234 ("# unexpected SYN_ACK messages (disconnecting)"),
3235 1, GNUNET_NO); 3235 1, GNUNET_NO);
3236 return GNUNET_SYSERR; 3236 return GNUNET_SYSERR;
3237 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 3237 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
@@ -3288,7 +3288,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3288 /* Free alternative address */ 3288 /* Free alternative address */
3289 if (session == n->alternative_address.session) 3289 if (session == n->alternative_address.session)
3290 { 3290 {
3291 if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) ) 3291 if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT == n->state) )
3292 set_state (n, GNUNET_TRANSPORT_PS_CONNECTED); 3292 set_state (n, GNUNET_TRANSPORT_PS_CONNECTED);
3293 free_address (&n->alternative_address); 3293 free_address (&n->alternative_address);
3294 } 3294 }
@@ -3307,11 +3307,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3307 GNUNET_break (0); 3307 GNUNET_break (0);
3308 free_neighbour (n, GNUNET_NO); 3308 free_neighbour (n, GNUNET_NO);
3309 return GNUNET_YES; 3309 return GNUNET_YES;
3310 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 3310 case GNUNET_TRANSPORT_PS_SYN_SENT:
3311 /* The session used to send the CONNECT terminated: 3311 /* The session used to send the SYN terminated:
3312 * this implies a connect error*/ 3312 * this implies a connect error*/
3313 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3313 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3314 "Failed to send CONNECT in %s with `%s' %p: session terminated\n", 3314 "Failed to send SYN in %s with `%s' %p: session terminated\n",
3315 "CONNECT_SENT", 3315 "CONNECT_SENT",
3316 GST_plugins_a2s (n->primary_address.address), 3316 GST_plugins_a2s (n->primary_address.address),
3317 n->primary_address.session, 3317 n->primary_address.session,
@@ -3323,8 +3323,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3323 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 3323 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
3324 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 3324 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
3325 break; 3325 break;
3326 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 3326 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
3327 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 3327 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
3328 /* error on inbound session; free neighbour entirely */ 3328 /* error on inbound session; free neighbour entirely */
3329 free_address (&n->primary_address); 3329 free_address (&n->primary_address);
3330 free_neighbour (n, GNUNET_NO); 3330 free_neighbour (n, GNUNET_NO);
@@ -3341,7 +3341,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3341 break; 3341 break;
3342 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 3342 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
3343 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3343 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3344 "Failed to send CONNECT in %s with `%s' %p: session terminated\n", 3344 "Failed to send SYN in %s with `%s' %p: session terminated\n",
3345 "RECONNECT_SENT", 3345 "RECONNECT_SENT",
3346 GST_plugins_a2s (n->primary_address.address), 3346 GST_plugins_a2s (n->primary_address.address),
3347 n->primary_address.session, 3347 n->primary_address.session,
@@ -3353,8 +3353,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3353 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 3353 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
3354 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 3354 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
3355 break; 3355 break;
3356 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 3356 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
3357 /* primary went down while we were waiting for CONNECT_ACK on secondary; 3357 /* primary went down while we were waiting for SYN_ACK on secondary;
3358 secondary as primary */ 3358 secondary as primary */
3359 3359
3360 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3360 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -3401,8 +3401,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3401 3401
3402 3402
3403/** 3403/**
3404 * We received a 'SESSION_ACK' message from the other peer. 3404 * We received a 'ACK' message from the other peer.
3405 * If we sent a 'CONNECT_ACK' last, this means we are now 3405 * If we sent a 'SYN_ACK' last, this means we are now
3406 * connected. Otherwise, do nothing. 3406 * connected. Otherwise, do nothing.
3407 * 3407 *
3408 * @param message possibly a 'struct SessionConnectMessage' (check format) 3408 * @param message possibly a 'struct SessionConnectMessage' (check format)
@@ -3421,7 +3421,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3421 struct NeighbourMapEntry *n; 3421 struct NeighbourMapEntry *n;
3422 3422
3423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3424 "Received SESSION_ACK message from peer `%s'\n", 3424 "Received ACK message from peer `%s'\n",
3425 GNUNET_i2s (peer)); 3425 GNUNET_i2s (peer));
3426 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) 3426 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
3427 { 3427 {
@@ -3430,7 +3430,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3430 } 3430 }
3431 GNUNET_STATISTICS_update (GST_stats, 3431 GNUNET_STATISTICS_update (GST_stats,
3432 gettext_noop 3432 gettext_noop
3433 ("# SESSION_ACK messages received"), 3433 ("# ACK messages received"),
3434 1, GNUNET_NO); 3434 1, GNUNET_NO);
3435 if (NULL == (n = lookup_neighbour (peer))) 3435 if (NULL == (n = lookup_neighbour (peer)))
3436 { 3436 {
@@ -3440,33 +3440,33 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3440 3440
3441 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3441 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3442 "Received %s for peer `%s' in state %s/%s\n", 3442 "Received %s for peer `%s' in state %s/%s\n",
3443 "SESSION_ACK", 3443 "ACK",
3444 GNUNET_i2s (peer), 3444 GNUNET_i2s (peer),
3445 GNUNET_TRANSPORT_ps2s (n->state), 3445 GNUNET_TRANSPORT_ps2s (n->state),
3446 print_ack_state (n->ack_state)); 3446 print_ack_state (n->ack_state));
3447 3447
3448 /* Check if we are in a plausible state for having sent 3448 /* Check if we are in a plausible state for having sent
3449 a CONNECT_ACK. If not, return, otherwise break. 3449 a SYN_ACK. If not, return, otherwise break.
3450 3450
3451 The remote peers sends a SESSION_ACK as a response for a CONNECT_ACK 3451 The remote peers sends a ACK as a response for a SYN_ACK
3452 message. 3452 message.
3453 3453
3454 We expect a SESSION_ACK: 3454 We expect a ACK:
3455 - If a remote peer has sent a CONNECT, we responded with a CONNECT_ACK and 3455 - If a remote peer has sent a SYN, we responded with a SYN_ACK and
3456 now wait for the ACK to finally be connected 3456 now wait for the ACK to finally be connected
3457 - If we sent a CONNECT_ACK to this peer before */ 3457 - If we sent a SYN_ACK to this peer before */
3458 3458
3459 if ( (GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK != n->state) && 3459 if ( (GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state) &&
3460 (ACK_SEND_SESSION_ACK != n->ack_state)) 3460 (ACK_SEND_ACK != n->ack_state))
3461 { 3461 {
3462 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3462 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3463 "Received unexpected SESSION_ACK message from peer `%s' in state %s/%s\n", 3463 "Received unexpected ACK message from peer `%s' in state %s/%s\n",
3464 GNUNET_i2s (peer), 3464 GNUNET_i2s (peer),
3465 GNUNET_TRANSPORT_ps2s (n->state), 3465 GNUNET_TRANSPORT_ps2s (n->state),
3466 print_ack_state (n->ack_state)); 3466 print_ack_state (n->ack_state));
3467 3467
3468 GNUNET_STATISTICS_update (GST_stats, 3468 GNUNET_STATISTICS_update (GST_stats,
3469 gettext_noop ("# unexpected SESSION_ACK messages"), 1, 3469 gettext_noop ("# unexpected ACK messages"), 1,
3470 GNUNET_NO); 3470 GNUNET_NO);
3471 return GNUNET_OK; 3471 return GNUNET_OK;
3472 } 3472 }
@@ -3485,10 +3485,10 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3485 GNUNET_NO); 3485 GNUNET_NO);
3486 } 3486 }
3487 3487
3488 if (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) 3488 if (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT == n->state)
3489 { 3489 {
3490 /* We tried to switch addresses while being connect. We explicitly wait 3490 /* We tried to switch addresses while being connect. We explicitly wait
3491 * for a CONNECT_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED, 3491 * for a SYN_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED,
3492 * so we do not want to set the address as in use! */ 3492 * so we do not want to set the address as in use! */
3493 return GNUNET_OK; 3493 return GNUNET_OK;
3494 } 3494 }
@@ -3764,15 +3764,15 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
3764 switch (n->state) 3764 switch (n->state)
3765 { 3765 {
3766 case GNUNET_TRANSPORT_PS_CONNECTED: 3766 case GNUNET_TRANSPORT_PS_CONNECTED:
3767 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 3767 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
3768 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 3768 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
3769 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 3769 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
3770 return n->latency; 3770 return n->latency;
3771 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 3771 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
3772 case GNUNET_TRANSPORT_PS_INIT_ATS: 3772 case GNUNET_TRANSPORT_PS_INIT_ATS:
3773 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 3773 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
3774 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 3774 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
3775 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 3775 case GNUNET_TRANSPORT_PS_SYN_SENT:
3776 case GNUNET_TRANSPORT_PS_DISCONNECT: 3776 case GNUNET_TRANSPORT_PS_DISCONNECT:
3777 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 3777 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
3778 return GNUNET_TIME_UNIT_FOREVER_REL; 3778 return GNUNET_TIME_UNIT_FOREVER_REL;
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 64291548f..eb33ce2ce 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -279,7 +279,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
279 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error 279 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
280 */ 280 */
281int 281int
282GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 282GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message,
283 const struct GNUNET_PeerIdentity *peer); 283 const struct GNUNET_PeerIdentity *peer);
284 284
285 285
@@ -295,7 +295,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
295 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error 295 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
296 */ 296 */
297int 297int
298GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 298GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message,
299 const struct GNUNET_PeerIdentity *peer, 299 const struct GNUNET_PeerIdentity *peer,
300 const struct GNUNET_HELLO_Address *address, 300 const struct GNUNET_HELLO_Address *address,
301 struct Session *session); 301 struct Session *session);
diff --git a/src/transport/transport_api_monitor_peers.c b/src/transport/transport_api_monitor_peers.c
index e04819711..8d5740d4d 100644
--- a/src/transport/transport_api_monitor_peers.c
+++ b/src/transport/transport_api_monitor_peers.c
@@ -101,14 +101,14 @@ GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state)
101 { 101 {
102 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 102 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
103 case GNUNET_TRANSPORT_PS_INIT_ATS: 103 case GNUNET_TRANSPORT_PS_INIT_ATS:
104 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 104 case GNUNET_TRANSPORT_PS_SYN_SENT:
105 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 105 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
106 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 106 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
107 return GNUNET_NO; 107 return GNUNET_NO;
108 case GNUNET_TRANSPORT_PS_CONNECTED: 108 case GNUNET_TRANSPORT_PS_CONNECTED:
109 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 109 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
110 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 110 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
111 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 111 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
112 return GNUNET_YES; 112 return GNUNET_YES;
113 case GNUNET_TRANSPORT_PS_DISCONNECT: 113 case GNUNET_TRANSPORT_PS_DISCONNECT:
114 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 114 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
@@ -139,20 +139,20 @@ GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state)
139 return "S_NOT_CONNECTED"; 139 return "S_NOT_CONNECTED";
140 case GNUNET_TRANSPORT_PS_INIT_ATS: 140 case GNUNET_TRANSPORT_PS_INIT_ATS:
141 return "S_INIT_ATS"; 141 return "S_INIT_ATS";
142 case GNUNET_TRANSPORT_PS_CONNECT_SENT: 142 case GNUNET_TRANSPORT_PS_SYN_SENT:
143 return "S_CONNECT_SENT"; 143 return "S_SYN_SENT";
144 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: 144 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
145 return "S_CONNECT_RECV_ATS"; 145 return "S_SYN_RECV_ATS";
146 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: 146 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
147 return "S_CONNECT_RECV_ACK"; 147 return "S_SYN_RECV_ACK";
148 case GNUNET_TRANSPORT_PS_CONNECTED: 148 case GNUNET_TRANSPORT_PS_CONNECTED:
149 return "S_CONNECTED"; 149 return "S_CONNECTED";
150 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 150 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
151 return "S_RECONNECT_ATS"; 151 return "S_RECONNECT_ATS";
152 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 152 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
153 return "S_RECONNECT_SENT"; 153 return "S_RECONNECT_SENT";
154 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: 154 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT:
155 return "S_CONNECTED_SWITCHING_CONNECT_SENT"; 155 return "S_CONNECTED_SWITCHING_SYN_SENT";
156 case GNUNET_TRANSPORT_PS_DISCONNECT: 156 case GNUNET_TRANSPORT_PS_DISCONNECT:
157 return "S_DISCONNECT"; 157 return "S_DISCONNECT";
158 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 158 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: