diff --git a/picoquic/frames.c b/picoquic/frames.c index 99fa6c1ac31f1bae8dcd0e59182fe7eb59bcca74..0d543a2c6093d2c5ccbcc4a8fbd506d96b4f237c 100644 --- a/picoquic/frames.c +++ b/picoquic/frames.c @@ -1646,6 +1646,9 @@ static int picoquic_process_ack_range( /* If the packet contained an ACK frame, perform the ACK of ACK pruning logic */ picoquic_process_possible_ack_of_ack_frame(cnx, p); + /* Keep track of reception of ACK of 1RTT data */ + cnx->data_acknowledged |= (p->ptype == picoquic_packet_1rtt_protected); + (void)picoquic_dequeue_retransmit_packet(cnx, p, 1); p = next; /* Any acknowledgement shows progress */ @@ -1989,7 +1992,7 @@ uint8_t* picoquic_decode_connection_close_frame(picoquic_cnx_t* cnx, uint8_t* by picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_FRAME_FORMAT_ERROR, picoquic_frame_type_connection_close); } else { - cnx->cnx_state = (cnx->cnx_state < picoquic_state_client_ready || cnx->crypto_context[3].aead_decrypt == NULL) ? picoquic_state_disconnected : picoquic_state_closing_received; + cnx->cnx_state = (cnx->cnx_state < picoquic_state_client_ready_start || cnx->crypto_context[3].aead_decrypt == NULL) ? picoquic_state_disconnected : picoquic_state_closing_received; if (cnx->callback_fn) { (cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_close, cnx->callback_ctx); @@ -2046,7 +2049,7 @@ uint8_t* picoquic_decode_application_close_frame(picoquic_cnx_t* cnx, uint8_t* b picoquic_frame_type_application_close); } else { - cnx->cnx_state = (cnx->cnx_state < picoquic_state_client_ready) ? picoquic_state_disconnected : picoquic_state_closing_received; + cnx->cnx_state = (cnx->cnx_state < picoquic_state_client_ready_start) ? picoquic_state_disconnected : picoquic_state_closing_received; if (cnx->callback_fn) { (cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_application_close, cnx->callback_ctx); } diff --git a/picoquic/logger.c b/picoquic/logger.c index f7f6098b63b2a351bf361d69f83914bca39922f4..56e1a8fa6c4e3330d92a25b928f1701c882a6bba 100644 --- a/picoquic/logger.c +++ b/picoquic/logger.c @@ -188,6 +188,9 @@ char const* picoquic_log_state_name(picoquic_state_enum state) case picoquic_state_server_false_start: state_name = "server_false_start"; break; + case picoquic_state_client_ready_start: + state_name = "client_ready_start"; + break; case picoquic_state_client_ready: state_name = "client_ready"; break; diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h index 5de47b887ad4fee21ac94fcf383caf2e8c1b90b1..beacb438b8276ef95eb41ef78b2da401e1477e20 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h @@ -115,6 +115,7 @@ typedef enum { picoquic_state_client_almost_ready, picoquic_state_server_almost_ready, picoquic_state_server_false_start, + picoquic_state_client_ready_start, picoquic_state_client_ready, picoquic_state_server_ready, picoquic_state_disconnecting, diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h index 21d9206aa8b1a4ee97e69258dec22aa320892083..5c6b9f1710bcf4fe9d783f7dbe11925fcf9cfde8 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h @@ -614,6 +614,7 @@ typedef struct st_picoquic_cnx_t { unsigned int client_mode : 1; /* Is this connection the client side? */ unsigned int key_phase_enc : 1; /* Key phase used in outgoing packets */ unsigned int key_phase_dec : 1; /* Key phase expected in incoming packets */ + unsigned int data_acknowledged : 1; /* 1RTT data acknowledged by peer */ /* Local and remote parameters */ diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c index 4b6e721f66ef0966daebb5e3746fd76077794754..36fabbec1f460c9235d56da1f6077cb45fba91a8 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c @@ -1795,12 +1795,13 @@ int picoquic_reset_cnx_version(picoquic_cnx_t* cnx, uint8_t* bytes, size_t lengt int picoquic_connection_error(picoquic_cnx_t* cnx, uint16_t local_error, uint64_t frame_type) { - if (cnx->cnx_state == picoquic_state_client_ready || cnx->cnx_state == picoquic_state_server_ready) { + if (cnx->cnx_state == picoquic_state_client_ready || cnx->cnx_state == picoquic_state_server_ready || + cnx->cnx_state == picoquic_state_client_ready_start || cnx->cnx_state == picoquic_state_server_false_start) { cnx->local_error = local_error; cnx->cnx_state = picoquic_state_disconnecting; DBG_PRINTF("Protocol error (%x)", local_error); - } else if (cnx->cnx_state < picoquic_state_client_ready) { + } else if (cnx->cnx_state < picoquic_state_server_false_start) { if (cnx->cnx_state != picoquic_state_handshake_failure) { cnx->local_error = local_error; } @@ -1999,7 +2000,7 @@ void picoquic_enable_keep_alive(picoquic_cnx_t* cnx, uint64_t interval) /* Examine the transport parameters */ uint64_t idle_timeout = cnx->local_parameters.idle_timeout; - if (cnx->cnx_state >= picoquic_state_client_ready && idle_timeout > cnx->remote_parameters.idle_timeout) { + if (cnx->cnx_state >= picoquic_state_client_ready_start && idle_timeout > cnx->remote_parameters.idle_timeout) { idle_timeout = cnx->remote_parameters.idle_timeout; } /* convert to microseconds */ diff --git a/picoquic/sender.c b/picoquic/sender.c index 9f909c55e259506212ca6d3b5312aae6e70dc024..07da1b4b65f6d537fb5a0982c880b7a443673f81 100644 --- a/picoquic/sender.c +++ b/picoquic/sender.c @@ -818,7 +818,7 @@ int picoquic_retransmit_needed(picoquic_cnx_t* cnx, length = picoquic_predict_packet_header_length(cnx, picoquic_packet_0rtt_protected); packet->ptype = picoquic_packet_0rtt_protected; packet->offset = length; - } else if (cnx->cnx_state < picoquic_state_client_ready) { + } else if (cnx->cnx_state < picoquic_state_client_ready_start) { should_retransmit = 0; } else { length = picoquic_predict_packet_header_length(cnx, picoquic_packet_1rtt_protected); @@ -1256,6 +1256,32 @@ uint32_t picoquic_prepare_packet_old_context(picoquic_cnx_t* cnx, picoquic_packe return length; } +/* Empty the handshake repeat queues when transitioning to the completely ready state */ +void picoquic_implicit_handshake_ack(picoquic_cnx_t* cnx, picoquic_packet_context_enum pc, uint64_t current_time) +{ + picoquic_packet_t* p = cnx->pkt_ctx[pc].retransmit_oldest; + + /* Remove packets from the retransmit queue */ + while (p != NULL) { + picoquic_packet_t* p_next = p->next_packet; + picoquic_path_t * old_path = p->send_path; + + /* Update the congestion control state for the path */ + if (old_path != NULL) { + if (cnx->congestion_alg != NULL) { + cnx->congestion_alg->alg_notify(old_path, + picoquic_congestion_notification_acknowledgement, + 0, p->length, 0, current_time); + } + } + /* Update the number of bytes in transit and remove old packet from queue */ + /* The packet will not be placed in the "retransmitted" queue */ + (void)picoquic_dequeue_retransmit_packet(cnx, p, 1); + + p = p_next; + } +} + /* Prepare the next packet to send when in one of the client initial states */ int picoquic_prepare_packet_client_init(picoquic_cnx_t* cnx, picoquic_path_t * path_x, picoquic_packet_t* packet, uint64_t current_time, uint8_t* send_buffer, size_t send_buffer_max, size_t* send_length) @@ -1471,7 +1497,7 @@ int picoquic_prepare_packet_client_init(picoquic_cnx_t* cnx, picoquic_path_t * p if (cnx->tls_stream[0].send_queue == NULL && cnx->tls_stream[1].send_queue == NULL && cnx->tls_stream[2].send_queue == NULL) { - cnx->cnx_state = picoquic_state_client_ready; + cnx->cnx_state = picoquic_state_client_ready_start; } break; default: @@ -1961,14 +1987,33 @@ int picoquic_prepare_packet_ready(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint32_t send_buffer_min_max = (send_buffer_max > path_x->send_mtu) ? path_x->send_mtu : (uint32_t)send_buffer_max; uint64_t next_wake_time = cnx->latest_progress_time + PICOQUIC_MICROSEC_SILENCE_MAX * (2 - cnx->client_mode); + /* + * Manage the end of false start transition. + */ + if (cnx->cnx_state == picoquic_state_server_false_start && cnx->crypto_context[3].aead_decrypt != NULL) { + /* Transition to server ready state. + * The handshake is complete, all the handshake packets are implicitly acknowledged */ cnx->cnx_state = picoquic_state_server_ready; + picoquic_implicit_handshake_ack(cnx, picoquic_packet_context_initial, current_time); + picoquic_implicit_handshake_ack(cnx, picoquic_packet_context_handshake, current_time); + } + else if (cnx->cnx_state == picoquic_state_client_ready_start && + cnx->data_acknowledged) { + /* Transition to client ready state. + * The handshake is complete, all the handshake packets are implicitly acknowledged */ + cnx->cnx_state = picoquic_state_client_ready; + picoquic_implicit_handshake_ack(cnx, picoquic_packet_context_initial, current_time); + picoquic_implicit_handshake_ack(cnx, picoquic_packet_context_handshake, current_time); } /* Verify first that there is no need for retransmit or ack * on initial or handshake context. This does not deal with EOED packets, - * as they are handled from within the general retransmission path */ + * as they are handled from within the general retransmission path. + * This is needed even with implicit acks for now, because the peer may + * be retransmitting data and thus requires acks. */ + if (ret == 0) { length = picoquic_prepare_packet_old_context(cnx, picoquic_packet_context_initial, path_x, packet, send_buffer_min_max, current_time, &next_wake_time, &header_length); @@ -2283,7 +2328,7 @@ int picoquic_prepare_segment(picoquic_cnx_t* cnx, picoquic_path_t * path_x, pico /* Check that the connection is still alive -- the timer is asymmetric, so client will drop faster */ if ((cnx->cnx_state < picoquic_state_disconnecting && (current_time - cnx->latest_progress_time) >= (PICOQUIC_MICROSEC_SILENCE_MAX*(2 - cnx->client_mode))) || - (cnx->cnx_state < picoquic_state_client_ready && + (cnx->cnx_state < picoquic_state_server_false_start && current_time >= cnx->start_time + PICOQUIC_MICROSEC_HANDSHAKE_MAX)) { /* Too long silence, break it. */ @@ -2311,6 +2356,7 @@ int picoquic_prepare_segment(picoquic_cnx_t* cnx, picoquic_path_t * path_x, pico ret = picoquic_prepare_packet_server_init(cnx, path_x, packet, current_time, send_buffer, send_buffer_max, send_length); break; case picoquic_state_server_false_start: + case picoquic_state_client_ready_start: case picoquic_state_client_ready: case picoquic_state_server_ready: ret = picoquic_prepare_packet_ready(cnx, path_x, packet, current_time, send_buffer, send_buffer_max, send_length); @@ -2351,7 +2397,8 @@ int picoquic_prepare_probe(picoquic_cnx_t* cnx, if (send_buffer_max < PICOQUIC_INITIAL_MTU_IPV6) { ret = PICOQUIC_ERROR_FRAME_BUFFER_TOO_SMALL; } else if (cnx->cnx_state == picoquic_state_client_ready || - cnx->cnx_state == picoquic_state_server_ready) + cnx->cnx_state == picoquic_state_server_ready || + cnx->cnx_state == picoquic_state_client_ready_start) { picoquic_probe_t * probe = cnx->probe_first; picoquic_packet_t * packet = NULL; @@ -2594,10 +2641,11 @@ int picoquic_close(picoquic_cnx_t* cnx, uint16_t reason_code) { int ret = 0; - if (cnx->cnx_state == picoquic_state_server_ready || cnx->cnx_state == picoquic_state_client_ready) { + if (cnx->cnx_state == picoquic_state_server_ready || cnx->cnx_state == picoquic_state_client_ready || + cnx->cnx_state == picoquic_state_server_false_start || cnx->cnx_state == picoquic_state_client_ready_start) { cnx->cnx_state = picoquic_state_disconnecting; cnx->application_error = reason_code; - } else if (cnx->cnx_state < picoquic_state_client_ready) { + } else if (cnx->cnx_state < picoquic_state_client_ready_start) { cnx->cnx_state = picoquic_state_handshake_failure; cnx->application_error = reason_code; } else { diff --git a/picoquic/tls_api.c b/picoquic/tls_api.c index 85e4b1e9f43cf3b78aa66643142e2ec21bbc7298..efe96bd26572ba171b381d5a9d8f4ec564816bda 100644 --- a/picoquic/tls_api.c +++ b/picoquic/tls_api.c @@ -1817,7 +1817,7 @@ int picoquic_tls_stream_process(picoquic_cnx_t* cnx) The server does not send any further packets, so, we can switch into false start state here. */ if (data_pushed == 0 && ((ptls_context_t*)cnx->quic->tls_master_ctx)->require_client_authentication == 1) { - cnx->cnx_state = picoquic_state_server_ready; + cnx->cnx_state = picoquic_state_server_false_start; } else { if (cnx->crypto_context[3].aead_encrypt != NULL) { @@ -1827,6 +1827,7 @@ int picoquic_tls_stream_process(picoquic_cnx_t* cnx) break; case picoquic_state_client_almost_ready: case picoquic_state_handshake_failure: + case picoquic_state_client_ready_start: case picoquic_state_client_ready: case picoquic_state_server_almost_ready: case picoquic_state_server_false_start: diff --git a/picoquicfirst/picoquicdemo.c b/picoquicfirst/picoquicdemo.c index c0a10b74fb7dec3034a307af87e8a4d2418efc20..5bf1adaad58b19722343aa453aa2fef10bcb2d3d 100644 --- a/picoquicfirst/picoquicdemo.c +++ b/picoquicfirst/picoquicdemo.c @@ -548,7 +548,7 @@ int quic_server(const char* server_name, int server_port, if (send_length > 0) { if (just_once != 0 || - cnx_next->cnx_state < picoquic_state_client_ready || + cnx_next->cnx_state < picoquic_state_server_false_start || cnx_next->cnx_state >= picoquic_state_disconnecting) { printf("%" PRIx64 ": ", picoquic_val64_connection_id(picoquic_get_logging_cnxid(cnx_next))); printf("Connection state = %d\n", @@ -1110,7 +1110,8 @@ int quic_client(const char* ip_address_text, int server_port, const char * sni, if (bytes_recv == 0 || (ret == 0 && client_receive_loop > PICOQUIC_DEMO_CLIENT_MAX_RECEIVE_BATCH)) { client_receive_loop = 0; - if (ret == 0 && picoquic_get_cnx_state(cnx_client) == picoquic_state_client_ready) { + if (ret == 0 && (picoquic_get_cnx_state(cnx_client) == picoquic_state_client_ready || + picoquic_get_cnx_state(cnx_client) == picoquic_state_client_ready_start)) { if (established == 0) { picoquic_log_transport_extension(F_log, cnx_client, 0); printf("Connection established. Version = %x, I-CID: %llx\n", diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c index e64fed5d6fc6656e09de56f0bdc77cec81473926..1440a863a8bfc601b4781e49d3dcc897c3d74433 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c @@ -912,6 +912,9 @@ static int tls_api_one_sim_round(picoquic_test_tls_api_ctx_t* test_ctx, return ret; } +#define TEST_CLIENT_READY (test_ctx->cnx_client->cnx_state == picoquic_state_client_ready || test_ctx->cnx_client->cnx_state == picoquic_state_client_ready_start) +#define TEST_SERVER_READY (test_ctx->cnx_server->cnx_state == picoquic_state_server_ready || test_ctx->cnx_server->cnx_state == picoquic_state_server_false_start) + static int tls_api_connection_loop(picoquic_test_tls_api_ctx_t* test_ctx, uint64_t* loss_mask, uint64_t queue_delay_max, uint64_t* simulated_time) { @@ -925,7 +928,7 @@ static int tls_api_connection_loop(picoquic_test_tls_api_ctx_t* test_ctx, test_ctx->c_to_s_link->queue_delay_max = queue_delay_max; test_ctx->s_to_c_link->queue_delay_max = queue_delay_max; - while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (test_ctx->cnx_client->cnx_state != picoquic_state_client_ready || (test_ctx->cnx_server == NULL || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready))) { + while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (!TEST_CLIENT_READY || (test_ctx->cnx_server == NULL || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready))) { int was_active = 0; nb_trials++; @@ -960,7 +963,7 @@ static int tls_api_data_sending_loop(picoquic_test_tls_api_ctx_t* test_ctx, max_trials = 100000; } - while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; nb_trials++; @@ -998,8 +1001,8 @@ static int wait_application_pn_enc_ready(picoquic_test_tls_api_ctx_t* test_ctx, int nb_inactive = 0; while (*simulated_time < time_out && - test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && - test_ctx->cnx_server->cnx_state == picoquic_state_server_ready && + TEST_CLIENT_READY && + TEST_SERVER_READY && test_ctx->cnx_server->crypto_context[3].aead_decrypt == NULL && nb_trials < 1024 && nb_inactive < 64 && @@ -1149,7 +1152,7 @@ int tls_api_silence_test() /* simulate 5 seconds of silence */ next_time = simulated_time + 5000000; - while (ret == 0 && simulated_time < next_time && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && simulated_time < next_time && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; ret = tls_api_one_sim_round(test_ctx, &simulated_time, next_time, &was_active); @@ -1343,12 +1346,12 @@ int tls_api_oneway_stream_test() int tls_api_q_and_r_stream_test() { - return tls_api_one_scenario_test(test_scenario_q_and_r, sizeof(test_scenario_q_and_r), 0, 0, 0, 0, 75000, NULL); + return tls_api_one_scenario_test(test_scenario_q_and_r, sizeof(test_scenario_q_and_r), 0, 0, 0, 0, 100000, NULL); } int tls_api_q2_and_r2_stream_test() { - return tls_api_one_scenario_test(test_scenario_q2_and_r2, sizeof(test_scenario_q2_and_r2), 0, 0, 0, 0, 80000, NULL); + return tls_api_one_scenario_test(test_scenario_q2_and_r2, sizeof(test_scenario_q2_and_r2), 0, 0, 0, 0, 100000, NULL); } int tls_api_very_long_stream_test() @@ -1483,7 +1486,7 @@ int tls_api_bad_server_reset_test() } /* check that the client is still up */ - if (ret == 0 && test_ctx->cnx_client->cnx_state != picoquic_state_client_ready) { + if (ret == 0 && !TEST_CLIENT_READY) { ret = -1; } @@ -1573,7 +1576,7 @@ int tls_api_two_connections_test() /* Verify that the connection is fully established */ uint64_t target_time = simulated_time + 2000000; - while (ret == 0 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready && simulated_time < target_time) { + while (ret == 0 && TEST_CLIENT_READY && TEST_SERVER_READY && simulated_time < target_time) { int was_active = 0; ret = tls_api_one_sim_round(test_ctx, &simulated_time, target_time, &was_active); } @@ -1704,7 +1707,7 @@ int keep_alive_test_impl(int keep_alive) if (test_ctx == NULL || test_ctx->cnx_client == NULL) { ret = -1; } else if (keep_alive != 0) { - if (test_ctx->cnx_client->cnx_state != picoquic_state_client_ready) { + if (!TEST_CLIENT_READY) { ret = -1; } else if (simulated_time < 2 * PICOQUIC_MICROSEC_SILENCE_MAX) { DBG_PRINTF("Keep alive test concludes after %llu microsecs instead of %llu, ret = %d\n", @@ -1757,8 +1760,8 @@ int session_resume_wait_for_ticket(picoquic_test_tls_api_ctx_t* test_ctx, int nb_inactive = 0; while (*simulated_time <time_out && - test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && - test_ctx->cnx_server->cnx_state == picoquic_state_server_ready && + TEST_CLIENT_READY && + TEST_SERVER_READY && test_ctx->qclient->p_first_ticket == NULL && nb_trials < 1024 && nb_inactive < 64 && @@ -2199,7 +2202,7 @@ int spurious_retransmit_test() /* simulate 1 second of silence */ next_time = simulated_time + 1000000; - while (ret == 0 && simulated_time < next_time && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && simulated_time < next_time && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; ret = tls_api_one_sim_round(test_ctx, &simulated_time, next_time, &was_active); @@ -2650,8 +2653,8 @@ int set_certificate_and_key_test() ret = tls_api_connection_loop(test_ctx, &loss_mask, 0, &simulated_time); } - if (ret == 0 && (test_ctx->cnx_client->cnx_state != picoquic_state_client_ready - || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready)) { + if (ret == 0 && (!TEST_CLIENT_READY + || !TEST_SERVER_READY)) { ret = -1; } @@ -2719,8 +2722,8 @@ int request_client_authentication_test() if (ret == 0) { if (test_ctx->cnx_client == NULL || test_ctx->cnx_server == NULL - || test_ctx->cnx_client->cnx_state != picoquic_state_client_ready - || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready) { + || !TEST_CLIENT_READY + || !TEST_SERVER_READY) { ret = -1; } } @@ -2855,8 +2858,8 @@ int nat_rebinding_test_one(uint64_t loss_mask_data) /* Add a time loop of 3 seconds to give some time for the challenge to be repeated */ next_time = simulated_time + 3000000; loss_mask = 0; - while (ret == 0 && simulated_time < next_time && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready - && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready + while (ret == 0 && simulated_time < next_time && TEST_CLIENT_READY + && TEST_SERVER_READY && test_ctx->cnx_server->path[0]->challenge_verified != 1) { int was_active = 0; @@ -2974,7 +2977,7 @@ int spin_bit_test() test_ctx->c_to_s_link->loss_mask = &loss_mask; test_ctx->s_to_c_link->loss_mask = &loss_mask; - while (ret == 0 && nb_trials < max_trials && simulated_time < next_time && nb_inactive < 256 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && nb_trials < max_trials && simulated_time < next_time && nb_inactive < 256 && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; nb_trials++; @@ -3540,8 +3543,8 @@ int migration_test_scenario(test_api_stream_desc_t * scenario, size_t size_of_sc /* Add a time loop of 3 seconds to give some time for the probes to be repeated */ next_time = simulated_time + 4000000; loss_mask = 0; - while (ret == 0 && simulated_time < next_time && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready - && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready + while (ret == 0 && simulated_time < next_time && TEST_CLIENT_READY + && TEST_SERVER_READY && (test_ctx->cnx_server->path[0]->challenge_verified != 1 || test_ctx->cnx_client->path[0]->path_is_demoted == 1 || initial_challenge == test_ctx->cnx_server->path[0]->challenge)) { int was_active = 0; @@ -3671,8 +3674,8 @@ int cnxid_renewal_test() /* Add a time loop of 3 seconds to give some time for the probes to be repeated */ next_time = simulated_time + 3000000; loss_mask = 0; - while (ret == 0 && simulated_time < next_time && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready - && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready + while (ret == 0 && simulated_time < next_time && TEST_CLIENT_READY + && TEST_SERVER_READY && test_ctx->cnx_server->path[0]->challenge_verified != 1) { int was_active = 0; @@ -4145,7 +4148,7 @@ static int key_rotation_test_one(int inject_bad_packet) * every 100 packets or so. To test robustness, inject bogus packets that * mimic a transition trigger */ - while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; nb_trials++; @@ -4296,7 +4299,7 @@ static int key_rotation_stress_test_one(int nb_packets) /* Perform a data sending loop, during which various key rotations are tried * every "nb_packets". */ - while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && nb_trials < max_trials && nb_inactive < 256 && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; nb_trials++; @@ -4339,7 +4342,7 @@ static int key_rotation_stress_test_one(int nb_packets) } } - if (ret == 0 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready) { + if (ret == 0 && TEST_CLIENT_READY) { ret = tls_api_attempt_to_close(test_ctx, &simulated_time); if (ret != 0) { @@ -4481,7 +4484,7 @@ int false_migration_test_scenario(test_api_stream_desc_t * scenario, size_t size /* Run a connection loop with injection test */ if (ret == 0) { - while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (test_ctx->cnx_client->cnx_state != picoquic_state_client_ready || (test_ctx->cnx_server == NULL || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready))) { + while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (!TEST_CLIENT_READY || (test_ctx->cnx_server == NULL || !TEST_SERVER_READY))) { int was_active = 0; nb_trials++; @@ -4529,7 +4532,7 @@ int false_migration_test_scenario(test_api_stream_desc_t * scenario, size_t size * every 100 packets or so. To test robustness, inject bogus packets that * mimic a transition trigger */ - while (ret == 0 && nb_trials < 1024 && nb_inactive < 256 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready && test_ctx->cnx_server->cnx_state == picoquic_state_server_ready) { + while (ret == 0 && nb_trials < 1024 && nb_inactive < 256 && TEST_CLIENT_READY && TEST_SERVER_READY) { int was_active = 0; nb_trials++; @@ -4638,7 +4641,7 @@ int nat_handshake_test_one(int test_rank) /* Run a connection loop with rebinding test */ if (ret == 0) { - while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (test_ctx->cnx_client->cnx_state != picoquic_state_client_ready || (test_ctx->cnx_server == NULL || test_ctx->cnx_server->cnx_state != picoquic_state_server_ready))) { + while (ret == 0 && nb_trials < 1024 && nb_inactive < 512 && (!TEST_CLIENT_READY || (test_ctx->cnx_server == NULL || !TEST_SERVER_READY))) { int was_active = 0; nb_trials++; @@ -4772,7 +4775,7 @@ static int short_initial_cid_test_one(uint8_t cid_length) } /* Check that both the client and server are ready. */ - if (ret == 0 && test_ctx->cnx_client->cnx_state == picoquic_state_client_ready) { + if (ret == 0 && TEST_CLIENT_READY) { if (cid_length < PICOQUIC_ENFORCED_INITIAL_CID_LENGTH) { DBG_PRINTF("Connection succeeds despites cid_length %d < %d\n", cid_length, PICOQUIC_ENFORCED_INITIAL_CID_LENGTH);