Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests of web transport and more tests of h3zero #1798

Merged
merged 8 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else()
endif()

project(picoquic
VERSION 1.1.28.9
VERSION 1.1.28.10
DESCRIPTION "picoquic library"
LANGUAGES C CXX)

Expand Down
18 changes: 18 additions & 0 deletions UnitTest1/unittest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,12 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(h3zero_capsule) {
int ret = h3zero_capsule_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(h3zero_client_data) {
int ret = h3zero_client_data_test();

Expand Down Expand Up @@ -3110,6 +3116,18 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(picowt_drain) {
int ret = picowt_drain_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(picowt_tp) {
int ret = picowt_tp_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(quicperf_parse) {
int ret = quicperf_parse_test();

Expand Down
46 changes: 18 additions & 28 deletions picohttp/h3zero_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,40 +2021,30 @@ const uint8_t* h3zero_accumulate_capsule(const uint8_t* bytes, const uint8_t* by
}
length_of_type = VARINT_LEN_T(capsule->header_buffer, size_t);

if (length_of_type + 1 > H3ZERO_CAPSULE_HEADER_SIZE_MAX) {
bytes = NULL;
while (capsule->header_read < length_of_type && bytes < bytes_max) {
capsule->header_buffer[capsule->header_read++] = *bytes++;
}
else {
while (capsule->header_read < length_of_type && bytes < bytes_max) {
if (capsule->header_read >= length_of_type) {
(void)picoquic_frames_varint_decode(capsule->header_buffer, capsule->header_buffer + length_of_type,
&capsule->capsule_type);

while (capsule->header_read < length_of_type + 1 && bytes < bytes_max) {
capsule->header_buffer[capsule->header_read++] = *bytes++;
}
if (capsule->header_read >= length_of_type) {
(void)picoquic_frames_varint_decode(capsule->header_buffer, capsule->header_buffer + length_of_type,
&capsule->capsule_type);

while (capsule->header_read < length_of_type + 1 && bytes < bytes_max) {
if (capsule->header_read >= length_of_type + 1) {
/* No change in state, wait for more bytes */
length_of_length = VARINT_LEN_T((capsule->header_buffer + length_of_type), size_t);

capsule->header_length = length_of_type + length_of_length;
while (capsule->header_read < capsule->header_length && bytes < bytes_max) {
capsule->header_buffer[capsule->header_read++] = *bytes++;
}

if (capsule->header_read >= length_of_type + 1) {
/* No change in state, wait for more bytes */
length_of_length = VARINT_LEN_T((capsule->header_buffer + length_of_type), size_t);

capsule->header_length = length_of_type + length_of_length;
if (capsule->header_length > H3ZERO_CAPSULE_HEADER_SIZE_MAX) {
bytes = NULL;
}
else {
while (capsule->header_read < capsule->header_length && bytes < bytes_max) {
capsule->header_buffer[capsule->header_read++] = *bytes++;
}
if (capsule->header_read >= capsule->header_length) {
(void)picoquic_frames_varlen_decode(capsule->header_buffer + length_of_type,
capsule->header_buffer + length_of_type + length_of_length,
&capsule->capsule_length);
capsule->is_length_known = 1;
}
}
if (capsule->header_read >= capsule->header_length) {
(void)picoquic_frames_varlen_decode(capsule->header_buffer + length_of_type,
capsule->header_buffer + length_of_type + length_of_length,
&capsule->capsule_length);
capsule->is_length_known = 1;
}
}
}
Expand Down
36 changes: 9 additions & 27 deletions picohttp/webtransport.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,19 @@ int picowt_prepare_client_cnx(picoquic_quic_t* quic, struct sockaddr* server_add

/* use the generic H3 callback */
/* Set the client callback context */
if (*p_h3_ctx == NULL) {
*p_h3_ctx = h3zero_callback_create_context(NULL);
}
if (*p_h3_ctx == NULL) {
if ((*p_h3_ctx == NULL && (*p_h3_ctx = h3zero_callback_create_context(NULL)) == NULL) ||
(*p_cnx == NULL && ((*p_cnx = picoquic_create_cnx(quic, picoquic_null_connection_id, picoquic_null_connection_id,
(struct sockaddr*)server_address, current_time, 0, sni, "h3", 1)) == NULL)) ||
((*p_stream_ctx = picowt_set_control_stream(*p_cnx, *p_h3_ctx)) == NULL)) {
ret = 1;
}
else
{
/* Create a client connection */
if (*p_cnx == NULL) {
*p_cnx = picoquic_create_cnx(quic, picoquic_null_connection_id, picoquic_null_connection_id,
(struct sockaddr*)server_address, current_time, 0, sni, "h3", 1);
}
if (*p_cnx == NULL) {
fprintf(stderr, "Could not create connection context\n");
ret = -1;
}
else {
picowt_set_transport_parameters(*p_cnx);
picoquic_set_callback(*p_cnx, h3zero_callback, *p_h3_ctx);
*p_stream_ctx = picowt_set_control_stream(*p_cnx, *p_h3_ctx);

if (*p_stream_ctx == NULL) {
ret = -1;
}
else {
/* Perform the initialization, settings and QPACK streams
*/
ret = h3zero_protocol_init(*p_cnx);
}
}
picowt_set_transport_parameters(*p_cnx);
picoquic_set_callback(*p_cnx, h3zero_callback, *p_h3_ctx);
/* Perform the initialization, settings and QPACK streams
*/
ret = h3zero_protocol_init(*p_cnx);
}
return ret;
}
Expand Down
3 changes: 3 additions & 0 deletions picohttp_t/picohttp_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static const picoquic_test_def_t test_table[] = {
{ "h3zero_incoming_unidir", h3zero_incoming_unidir_test },
{ "h3zero_unidir_error", h3zero_unidir_error_test },
{ "h3zero_setting_error", h3zero_setting_error_test },
{ "h3zero_capsule", h3zero_capsule_test },
{ "h3zero_client_data", h3zero_client_data_test },
{ "qpack_huffman", qpack_huffman_test },
{ "qpack_huffman_base", qpack_huffman_base_test},
Expand Down Expand Up @@ -99,6 +100,8 @@ static const picoquic_test_def_t test_table[] = {
{ "picowt_baton_random", picowt_baton_random_test },
{ "picowt_baton_uri", picowt_baton_uri_test },
{ "picowt_baton_wrong", picowt_baton_wrong_test },
{ "picowt_drain", picowt_drain_test },
{ "picowt_tp", picowt_tp_test },
{ "quicperf_parse", quicperf_parse_test },
{ "quicperf_batch", quicperf_batch_test },
{ "quicperf_datagram", quicperf_datagram_test },
Expand Down
2 changes: 1 addition & 1 deletion picoquic/picoquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
extern "C" {
#endif

#define PICOQUIC_VERSION "1.1.28.9"
#define PICOQUIC_VERSION "1.1.28.10"
#define PICOQUIC_ERROR_CLASS 0x400
#define PICOQUIC_ERROR_DUPLICATE (PICOQUIC_ERROR_CLASS + 1)
#define PICOQUIC_ERROR_AEAD_CHECK (PICOQUIC_ERROR_CLASS + 3)
Expand Down
Loading
Loading