mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Initial PlusWindows commit
This commit is contained in:
parent
00ee28ce61
commit
b93f59bea2
28 changed files with 722 additions and 465 deletions
|
@ -28,6 +28,7 @@ ENDIF()
|
|||
|
||||
MESSAGE(STATUS "DEVEL_MODE: ${DEVEL_MODE}")
|
||||
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
|
||||
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
|
||||
|
@ -113,6 +114,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|||
link_directories( /usr/local/lib )
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(http_client
|
||||
test/http_client.c
|
||||
|
@ -131,23 +133,23 @@ add_executable(http_client
|
|||
wincompat/getopt1.c
|
||||
)
|
||||
|
||||
target_link_libraries(http_client
|
||||
target_link_libraries(http_client
|
||||
debug $(SolutionDir)src/liblsquic/debug/lsquic.lib
|
||||
debug ${VCPKG_BASE_DIR}/debug/lib/event.lib
|
||||
debug ${VCPKG_BASE_DIR}/debug/lib/zlibd.lib
|
||||
debug ${BORINGSSL_BASE_LIB_DIR}/debug/ssl.lib
|
||||
debug ${BORINGSSL_BASE_LIB_DIR}/debug/ssl.lib
|
||||
debug ${BORINGSSL_BASE_LIB_DIR}/debug/crypto.lib
|
||||
ws2_32
|
||||
optimized $(SolutionDir)src/liblsquic/release/lsquic.lib
|
||||
optimized ${VCPKG_BASE_DIR}/lib/event.lib
|
||||
optimized ${VCPKG_BASE_DIR}/lib/zlib.lib
|
||||
optimized ${BORINGSSL_BASE_LIB_DIR}/ssl.lib
|
||||
optimized ${BORINGSSL_BASE_LIB_DIR}/ssl.lib
|
||||
optimized ${BORINGSSL_BASE_LIB_DIR}/crypto.lib
|
||||
${FIULIB} )
|
||||
|
||||
ENDIF()
|
||||
|
||||
|
||||
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <sys/uio.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <sys/queue.h>
|
||||
#else
|
||||
#include <vc_compat.h>
|
||||
#endif
|
||||
|
|
|
@ -445,7 +445,7 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
|
|||
{
|
||||
int ret;
|
||||
size_t i;
|
||||
uint8_t* uncompressed_data = NULL, *uncompressed_data_buf = NULL;
|
||||
uint8_t* uncompressed_data, *uncompressed_data_buf;
|
||||
lsquic_str_t *dict;
|
||||
uint32_t uncompressed_size;
|
||||
size_t count = *out_certs_count;
|
||||
|
@ -463,6 +463,9 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
|
|||
return -1;
|
||||
|
||||
uncompressed_data_buf = NULL;
|
||||
#ifdef WIN32
|
||||
uncompressed_data = NULL;
|
||||
#endif
|
||||
entries = malloc(count * sizeof(cert_entry_t));
|
||||
if (!entries)
|
||||
goto err;
|
||||
|
@ -487,6 +490,9 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
|
|||
goto err;
|
||||
|
||||
uncompressed_data_buf = uncompressed_data = malloc(uncompressed_size);
|
||||
if (!uncompressed_data)
|
||||
goto err;
|
||||
|
||||
memset(&z, 0, sizeof(z));
|
||||
z.next_out = uncompressed_data;
|
||||
z.avail_out = uncompressed_size;
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
#include "lsquic_data_in_if.h"
|
||||
|
||||
|
||||
static const struct data_in *error_data_in_ptr;
|
||||
|
||||
|
||||
|
||||
|
||||
struct data_in *
|
||||
data_in_error_new (struct lsquic_conn_public *conn_pub)
|
||||
{
|
||||
return (struct data_in *) error_data_in_ptr;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
|
@ -80,12 +84,12 @@ static const struct data_in_iface di_if_error = {
|
|||
.di_mem_used = error_di_mem_used,
|
||||
.di_switch_impl = error_di_switch_impl,
|
||||
};
|
||||
|
||||
|
||||
static const struct data_in error_data_in = {
|
||||
.di_if = &di_if_error,
|
||||
.di_flags = 0,
|
||||
};
|
||||
struct data_in *
|
||||
data_in_error_new (struct lsquic_conn_public *conn_pub)
|
||||
{
|
||||
return (struct data_in *) &error_data_in;
|
||||
}
|
||||
|
||||
|
||||
static const struct data_in *error_data_in_ptr = &error_data_in;
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef char db_block_is_4K[(sizeof(struct data_block) == 0x1000) ?1:- 1];
|
|||
TAILQ_HEAD(dblock_head, data_block);
|
||||
|
||||
|
||||
static const struct data_in_iface *di_if_hash_ptr;
|
||||
|
||||
|
||||
struct hash_data_in
|
||||
|
@ -108,6 +109,43 @@ my_log2 /* silly name to suppress compiler warning */ (unsigned sz)
|
|||
}
|
||||
|
||||
|
||||
struct data_in *
|
||||
data_in_hash_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id,
|
||||
uint64_t byteage)
|
||||
{
|
||||
struct hash_data_in *hdi;
|
||||
unsigned n;
|
||||
|
||||
hdi = malloc(sizeof(*hdi));
|
||||
if (!hdi)
|
||||
return NULL;
|
||||
|
||||
hdi->hdi_data_in.di_if = di_if_hash_ptr;
|
||||
hdi->hdi_data_in.di_flags = 0;
|
||||
hdi->hdi_conn_pub = conn_pub;
|
||||
hdi->hdi_stream_id = stream_id;
|
||||
hdi->hdi_fin_off = 0;
|
||||
hdi->hdi_flags = 0;
|
||||
hdi->hdi_last_block = NULL;
|
||||
if (byteage >= DB_DATA_SIZE /* __builtin_clz is undefined if
|
||||
argument is 0 */)
|
||||
hdi->hdi_nbits = my_log2(byteage / DB_DATA_SIZE) + 2;
|
||||
else
|
||||
hdi->hdi_nbits = 3;
|
||||
hdi->hdi_count = 0;
|
||||
hdi->hdi_buckets = malloc(sizeof(hdi->hdi_buckets[0]) *
|
||||
N_BUCKETS(hdi->hdi_nbits));
|
||||
if (!hdi->hdi_buckets)
|
||||
{
|
||||
free(hdi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (n = 0; n < N_BUCKETS(hdi->hdi_nbits); ++n)
|
||||
TAILQ_INIT(&hdi->hdi_buckets[n]);
|
||||
|
||||
return &hdi->hdi_data_in;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
|
@ -599,40 +637,5 @@ static const struct data_in_iface di_if_hash = {
|
|||
.di_mem_used = hash_di_mem_used,
|
||||
.di_switch_impl = hash_di_switch_impl,
|
||||
};
|
||||
struct data_in *
|
||||
data_in_hash_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id,
|
||||
uint64_t byteage)
|
||||
{
|
||||
struct hash_data_in *hdi;
|
||||
unsigned n;
|
||||
|
||||
hdi = malloc(sizeof(*hdi));
|
||||
if (!hdi)
|
||||
return NULL;
|
||||
|
||||
hdi->hdi_data_in.di_if = &di_if_hash;
|
||||
hdi->hdi_data_in.di_flags = 0;
|
||||
hdi->hdi_conn_pub = conn_pub;
|
||||
hdi->hdi_stream_id = stream_id;
|
||||
hdi->hdi_fin_off = 0;
|
||||
hdi->hdi_flags = 0;
|
||||
hdi->hdi_last_block = NULL;
|
||||
if (byteage >= DB_DATA_SIZE /* __builtin_clz is undefined if
|
||||
argument is 0 */)
|
||||
hdi->hdi_nbits = my_log2(byteage / DB_DATA_SIZE) + 2;
|
||||
else
|
||||
hdi->hdi_nbits = 3;
|
||||
hdi->hdi_count = 0;
|
||||
hdi->hdi_buckets = malloc(sizeof(hdi->hdi_buckets[0]) *
|
||||
N_BUCKETS(hdi->hdi_nbits));
|
||||
if (!hdi->hdi_buckets)
|
||||
{
|
||||
free(hdi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (n = 0; n < N_BUCKETS(hdi->hdi_nbits); ++n)
|
||||
TAILQ_INIT(&hdi->hdi_buckets[n]);
|
||||
|
||||
return &hdi->hdi_data_in;
|
||||
}
|
||||
static const struct data_in_iface *di_if_hash_ptr = &di_if_hash;
|
||||
|
|
|
@ -116,8 +116,30 @@ struct nocopy_data_in
|
|||
((unsigned char *) (data_frame) - offsetof(struct stream_frame, data_frame))
|
||||
|
||||
|
||||
static const struct data_in_iface *di_if_nocopy_ptr;
|
||||
|
||||
|
||||
struct data_in *
|
||||
data_in_nocopy_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id)
|
||||
{
|
||||
struct nocopy_data_in *ncdi;
|
||||
|
||||
ncdi = malloc(sizeof(*ncdi));
|
||||
if (!ncdi)
|
||||
return NULL;
|
||||
|
||||
TAILQ_INIT(&ncdi->ncdi_frames_in);
|
||||
ncdi->ncdi_data_in.di_if = di_if_nocopy_ptr;
|
||||
ncdi->ncdi_data_in.di_flags = 0;
|
||||
ncdi->ncdi_conn_pub = conn_pub;
|
||||
ncdi->ncdi_stream_id = stream_id;
|
||||
ncdi->ncdi_byteage = 0;
|
||||
ncdi->ncdi_n_frames = 0;
|
||||
ncdi->ncdi_n_holes = 0;
|
||||
ncdi->ncdi_cons_far = 0;
|
||||
return &ncdi->ncdi_data_in;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nocopy_di_destroy (struct data_in *data_in)
|
||||
|
@ -422,24 +444,5 @@ static const struct data_in_iface di_if_nocopy = {
|
|||
.di_mem_used = nocopy_di_mem_used,
|
||||
.di_switch_impl = nocopy_di_switch_impl,
|
||||
};
|
||||
struct data_in *
|
||||
data_in_nocopy_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id)
|
||||
{
|
||||
struct nocopy_data_in *ncdi;
|
||||
|
||||
ncdi = malloc(sizeof(*ncdi));
|
||||
if (!ncdi)
|
||||
return NULL;
|
||||
|
||||
TAILQ_INIT(&ncdi->ncdi_frames_in);
|
||||
ncdi->ncdi_data_in.di_if = &di_if_nocopy;
|
||||
ncdi->ncdi_data_in.di_flags = 0;
|
||||
ncdi->ncdi_conn_pub = conn_pub;
|
||||
ncdi->ncdi_stream_id = stream_id;
|
||||
ncdi->ncdi_byteage = 0;
|
||||
ncdi->ncdi_n_frames = 0;
|
||||
ncdi->ncdi_n_holes = 0;
|
||||
ncdi->ncdi_cons_far = 0;
|
||||
return &ncdi->ncdi_data_in;
|
||||
}
|
||||
|
||||
static const struct data_in_iface *di_if_nocopy_ptr = &di_if_nocopy;
|
||||
|
|
|
@ -19,171 +19,171 @@ struct uncompressed_headers;
|
|||
|
||||
|
||||
/* Log a generic event not tied to any particular connection */
|
||||
#define EV_LOG_GENERIC_EVENT(...) do { \
|
||||
#define EV_LOG_GENERIC_EVENT(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \
|
||||
lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/* Log a generic event associated with connection `cid' */
|
||||
#define EV_LOG_CONN_EVENT(cid, ...) do { \
|
||||
#define EV_LOG_CONN_EVENT(cid, ...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \
|
||||
lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_packet_in (lsquic_cid_t, const struct lsquic_packet_in *);
|
||||
|
||||
#define EV_LOG_PACKET_IN(...) do { \
|
||||
#define EV_LOG_PACKET_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_packet_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_packet_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_ack_frame_in (lsquic_cid_t, const struct ack_info *);
|
||||
|
||||
#define EV_LOG_ACK_FRAME_IN(...) do { \
|
||||
#define EV_LOG_ACK_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_ack_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_ack_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_stream_frame_in (lsquic_cid_t, const struct stream_frame *);
|
||||
|
||||
#define EV_LOG_STREAM_FRAME_IN(...) do { \
|
||||
#define EV_LOG_STREAM_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_stream_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_stream_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id,
|
||||
uint64_t offset);
|
||||
|
||||
#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \
|
||||
#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id);
|
||||
|
||||
#define EV_LOG_BLOCKED_FRAME_IN(...) do { \
|
||||
#define EV_LOG_BLOCKED_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t);
|
||||
|
||||
#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \
|
||||
#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code,
|
||||
int reason_len, const char *reason);
|
||||
|
||||
#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \
|
||||
#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code,
|
||||
uint32_t stream_id, int reason_len, const char *reason);
|
||||
|
||||
#define EV_LOG_GOAWAY_FRAME_IN(...) do { \
|
||||
#define EV_LOG_GOAWAY_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id,
|
||||
uint64_t offset, uint32_t error_code);
|
||||
|
||||
#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \
|
||||
#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len);
|
||||
|
||||
#define EV_LOG_PADDING_FRAME_IN(...) do { \
|
||||
#define EV_LOG_PADDING_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_padding_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_padding_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_ping_frame_in (lsquic_cid_t);
|
||||
|
||||
#define EV_LOG_PING_FRAME_IN(...) do { \
|
||||
#define EV_LOG_PING_FRAME_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_ping_frame_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_ping_frame_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *);
|
||||
|
||||
#define EV_LOG_PACKET_CREATED(...) do { \
|
||||
#define EV_LOG_PACKET_CREATED(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_packet_created(__VA_ARGS__); \
|
||||
lsquic_ev_log_packet_created(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *);
|
||||
|
||||
#define EV_LOG_PACKET_SENT(...) do { \
|
||||
#define EV_LOG_PACKET_SENT(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_packet_sent(__VA_ARGS__); \
|
||||
lsquic_ev_log_packet_sent(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *);
|
||||
|
||||
#define EV_LOG_PACKET_NOT_SENT(...) do { \
|
||||
#define EV_LOG_PACKET_NOT_SENT(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_packet_not_sent(__VA_ARGS__); \
|
||||
lsquic_ev_log_packet_not_sent(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server,
|
||||
const struct uncompressed_headers *);
|
||||
|
||||
#define EV_LOG_HTTP_HEADERS_IN(...) do { \
|
||||
#define EV_LOG_HTTP_HEADERS_IN(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_http_headers_in(__VA_ARGS__); \
|
||||
lsquic_ev_log_http_headers_in(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
|
||||
const unsigned char *, size_t len, const char *action);
|
||||
|
||||
#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \
|
||||
#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \
|
||||
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \
|
||||
} while (0)
|
||||
|
||||
#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \
|
||||
#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \
|
||||
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
|
||||
const unsigned char *, size_t len);
|
||||
|
||||
#define EV_LOG_GENERATED_ACK_FRAME(...) do { \
|
||||
#define EV_LOG_GENERATED_ACK_FRAME(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \
|
||||
lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
lsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
|
||||
|
||||
#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \
|
||||
#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \
|
||||
lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
|
@ -192,9 +192,9 @@ lsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
|
|||
const struct lsquic_http_headers *);
|
||||
|
||||
|
||||
#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \
|
||||
#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_generated_http_headers(__VA_ARGS__); \
|
||||
lsquic_ev_log_generated_http_headers(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
|
@ -203,9 +203,9 @@ lsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
|
|||
const struct lsquic_http_headers *headers,
|
||||
const struct lsquic_http_headers *extra_headers);
|
||||
|
||||
#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \
|
||||
#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \
|
||||
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
|
||||
lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \
|
||||
lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -648,8 +648,10 @@ add_pseudo_header_to_uh (const struct lsquic_frame_reader *fr,
|
|||
}
|
||||
|
||||
|
||||
#define HTTP_CODE_LEN 3
|
||||
|
||||
static const char *
|
||||
code_str_to_reason (const char *code_str, int code_len)
|
||||
code_str_to_reason (const char code_str[HTTP_CODE_LEN])
|
||||
{
|
||||
/* RFC 7231, Section 6: */
|
||||
static const char *const http_reason_phrases[] =
|
||||
|
@ -700,12 +702,11 @@ code_str_to_reason (const char *code_str, int code_len)
|
|||
};
|
||||
|
||||
long code;
|
||||
char * code_buf = malloc(code_len + 1 );
|
||||
char code_buf[HTTP_CODE_LEN + 1];
|
||||
|
||||
strncpy(code_buf, code_str, code_len);
|
||||
code_buf[code_len] = '\0';
|
||||
memcpy(code_buf, code_str, HTTP_CODE_LEN);
|
||||
code_buf[HTTP_CODE_LEN] = '\0';
|
||||
code = strtol(code_buf, NULL, 10) - 100;
|
||||
free(code_buf);
|
||||
if (code > 0 && code < (long) (sizeof(http_reason_phrases) /
|
||||
sizeof(http_reason_phrases[0])))
|
||||
return http_reason_phrases[code];
|
||||
|
@ -742,7 +743,7 @@ convert_response_pseudo_headers (const struct lsquic_frame_reader *fr,
|
|||
|
||||
HWC_UH_WRITE(hwc, "HTTP/1.1 ", 9);
|
||||
HWC_UH_WRITE(hwc, code_str, code_len);
|
||||
if (3 == code_len && (reason = code_str_to_reason(code_str, code_len)))
|
||||
if (HTTP_CODE_LEN == code_len && (reason = code_str_to_reason(code_str)))
|
||||
{
|
||||
HWC_UH_WRITE(hwc, " ", 1);
|
||||
HWC_UH_WRITE(hwc, reason, strlen(reason));
|
||||
|
|
|
@ -217,17 +217,17 @@ struct full_conn
|
|||
|
||||
#define MAX_ERRMSG 256
|
||||
|
||||
#define SET_ERRMSG(conn, ...) do { \
|
||||
#define SET_ERRMSG(conn, ...) do { \
|
||||
if (!(conn)->fc_errmsg) \
|
||||
(conn)->fc_errmsg = malloc(MAX_ERRMSG); \
|
||||
if ((conn)->fc_errmsg) \
|
||||
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
|
||||
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define ABORT_WITH_FLAG(conn, flag, ...) do { \
|
||||
SET_ERRMSG(conn, __VA_ARGS__); \
|
||||
#define ABORT_WITH_FLAG(conn, flag, ...) do { \
|
||||
SET_ERRMSG(conn, __VA_ARGS__); \
|
||||
(conn)->fc_flags |= flag; \
|
||||
LSQ_ERROR("Abort connection: " __VA_ARGS__); \
|
||||
LSQ_ERROR("Abort connection: " __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define ABORT_ERROR(...) ABORT_WITH_FLAG(conn, FC_ERROR, __VA_ARGS__)
|
||||
|
@ -258,6 +258,7 @@ write_is_possible (struct full_conn *);
|
|||
static int
|
||||
dispatch_stream_read_events (struct full_conn *, struct lsquic_stream *);
|
||||
|
||||
static const struct headers_stream_callbacks *headers_callbacks_ptr;
|
||||
|
||||
#if KEEP_CLOSED_STREAM_HISTORY
|
||||
|
||||
|
@ -520,9 +521,174 @@ apply_peer_settings (struct full_conn *conn)
|
|||
}
|
||||
|
||||
|
||||
static const struct conn_iface *full_conn_iface_ptr;
|
||||
|
||||
static struct full_conn *
|
||||
new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,
|
||||
const struct lsquic_stream_if *stream_if,
|
||||
void *stream_if_ctx, unsigned flags,
|
||||
unsigned short max_packet_size)
|
||||
{
|
||||
struct full_conn *conn;
|
||||
lsquic_stream_t *headers_stream;
|
||||
int saved_errno;
|
||||
|
||||
assert(0 == (flags & ~(FC_SERVER|FC_HTTP)));
|
||||
|
||||
conn = calloc(1, sizeof(*conn));
|
||||
if (!conn)
|
||||
return NULL;
|
||||
headers_stream = NULL;
|
||||
conn->fc_conn.cn_cid = cid;
|
||||
conn->fc_conn.cn_pack_size = max_packet_size;
|
||||
conn->fc_flags = flags;
|
||||
conn->fc_enpub = enpub;
|
||||
conn->fc_pub.enpub = enpub;
|
||||
conn->fc_pub.mm = &enpub->enp_mm;
|
||||
conn->fc_pub.lconn = &conn->fc_conn;
|
||||
conn->fc_pub.send_ctl = &conn->fc_send_ctl;
|
||||
conn->fc_pub.packet_out_malo =
|
||||
lsquic_malo_create(sizeof(struct lsquic_packet_out));
|
||||
conn->fc_stream_ifs[STREAM_IF_STD].stream_if = stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx = stream_if_ctx;
|
||||
conn->fc_settings = &enpub->enp_settings;
|
||||
/* Calculate maximum number of incoming streams using the same mechanism
|
||||
* and parameters as found in Chrome:
|
||||
*/
|
||||
conn->fc_cfg.max_streams_in =
|
||||
(unsigned) ((float) enpub->enp_settings.es_max_streams_in * 1.1f);
|
||||
if (conn->fc_cfg.max_streams_in <
|
||||
enpub->enp_settings.es_max_streams_in + 10)
|
||||
conn->fc_cfg.max_streams_in =
|
||||
enpub->enp_settings.es_max_streams_in + 10;
|
||||
/* `max_streams_out' gets reset when handshake is complete and we
|
||||
* learn of peer settings. 100 seems like a sane default value
|
||||
* because it is what other implementations use. In server mode,
|
||||
* we do not open any streams until the handshake is complete; in
|
||||
* client mode, we are limited to 98 outgoing requests alongside
|
||||
* handshake and headers streams.
|
||||
*/
|
||||
conn->fc_cfg.max_streams_out = 100;
|
||||
TAILQ_INIT(&conn->fc_pub.sending_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.read_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.write_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.service_streams);
|
||||
STAILQ_INIT(&conn->fc_stream_ids_to_reset);
|
||||
lsquic_conn_cap_init(&conn->fc_pub.conn_cap, LSQUIC_MIN_FCW);
|
||||
lsquic_alarmset_init(&conn->fc_alset, cid);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_IDLE, idle_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_ACK, ack_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_PING, ping_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_HANDSHAKE, handshake_alarm_expired, conn);
|
||||
lsquic_set32_init(&conn->fc_closed_stream_ids[0]);
|
||||
lsquic_set32_init(&conn->fc_closed_stream_ids[1]);
|
||||
lsquic_cfcw_init(&conn->fc_pub.cfcw, &conn->fc_pub, conn->fc_settings->es_cfcw);
|
||||
lsquic_send_ctl_init(&conn->fc_send_ctl, &conn->fc_alset, conn->fc_enpub,
|
||||
&conn->fc_ver_neg, &conn->fc_pub, conn->fc_conn.cn_pack_size);
|
||||
|
||||
conn->fc_pub.all_streams = lsquic_hash_create();
|
||||
if (!conn->fc_pub.all_streams)
|
||||
goto cleanup_on_error;
|
||||
lsquic_rechist_init(&conn->fc_rechist, cid);
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
{
|
||||
conn->fc_pub.hs = lsquic_headers_stream_new(
|
||||
!!(conn->fc_flags & FC_SERVER), conn->fc_pub.mm, conn->fc_settings,
|
||||
headers_callbacks_ptr, conn);
|
||||
if (!conn->fc_pub.hs)
|
||||
goto cleanup_on_error;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = lsquic_headers_stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = conn->fc_pub.hs;
|
||||
headers_stream = new_stream(conn, LSQUIC_STREAM_HEADERS,
|
||||
SCF_CALL_ON_NEW);
|
||||
if (!headers_stream)
|
||||
goto cleanup_on_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = stream_if_ctx;
|
||||
}
|
||||
if (conn->fc_settings->es_support_push)
|
||||
conn->fc_flags |= FC_SUPPORT_PUSH;
|
||||
conn->fc_conn.cn_if = full_conn_iface_ptr;
|
||||
return conn;
|
||||
|
||||
cleanup_on_error:
|
||||
saved_errno = errno;
|
||||
|
||||
if (conn->fc_pub.all_streams)
|
||||
lsquic_hash_destroy(conn->fc_pub.all_streams);
|
||||
lsquic_rechist_cleanup(&conn->fc_rechist);
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
{
|
||||
if (conn->fc_pub.hs)
|
||||
lsquic_headers_stream_destroy(conn->fc_pub.hs);
|
||||
if (headers_stream)
|
||||
lsquic_stream_destroy(headers_stream);
|
||||
}
|
||||
memset(conn, 0, sizeof(*conn));
|
||||
free(conn);
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct lsquic_conn *
|
||||
full_conn_client_new (struct lsquic_engine_public *enpub,
|
||||
const struct lsquic_stream_if *stream_if,
|
||||
void *stream_if_ctx, unsigned flags,
|
||||
const char *hostname, unsigned short max_packet_size)
|
||||
{
|
||||
struct full_conn *conn;
|
||||
enum lsquic_version version;
|
||||
lsquic_cid_t cid;
|
||||
const struct enc_session_funcs *esf;
|
||||
|
||||
version = highest_bit_set(enpub->enp_settings.es_versions);
|
||||
esf = select_esf_by_ver(version);
|
||||
cid = esf->esf_generate_cid();
|
||||
conn = new_conn_common(cid, enpub, stream_if, stream_if_ctx, flags,
|
||||
max_packet_size);
|
||||
if (!conn)
|
||||
return NULL;
|
||||
conn->fc_conn.cn_esf = esf;
|
||||
conn->fc_conn.cn_enc_session =
|
||||
conn->fc_conn.cn_esf->esf_create_client(hostname, cid, conn->fc_enpub);
|
||||
if (!conn->fc_conn.cn_enc_session)
|
||||
{
|
||||
LSQ_WARN("could not create enc session: %s", strerror(errno));
|
||||
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
conn->fc_last_stream_id = LSQUIC_STREAM_HEADERS; /* Client goes 5, 7, 9.... */
|
||||
else
|
||||
conn->fc_last_stream_id = LSQUIC_STREAM_HANDSHAKE;
|
||||
conn->fc_hsk_ctx.client.lconn = &conn->fc_conn;
|
||||
conn->fc_hsk_ctx.client.mm = &enpub->enp_mm;
|
||||
conn->fc_hsk_ctx.client.ver_neg = &conn->fc_ver_neg;
|
||||
conn->fc_stream_ifs[STREAM_IF_HSK]
|
||||
.stream_if = &lsquic_client_hsk_stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HSK].stream_if_ctx = &conn->fc_hsk_ctx.client;
|
||||
init_ver_neg(conn, conn->fc_settings->es_versions);
|
||||
conn->fc_conn.cn_pf = select_pf_by_ver(conn->fc_ver_neg.vn_ver);
|
||||
if (conn->fc_settings->es_handshake_to)
|
||||
lsquic_alarmset_set(&conn->fc_alset, AL_HANDSHAKE,
|
||||
lsquic_time_now() + conn->fc_settings->es_handshake_to);
|
||||
if (!new_stream(conn, LSQUIC_STREAM_HANDSHAKE, SCF_CALL_ON_NEW))
|
||||
{
|
||||
LSQ_WARN("could not create handshake stream: %s", strerror(errno));
|
||||
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
|
||||
return NULL;
|
||||
}
|
||||
conn->fc_flags |= FC_CREATED_OK;
|
||||
LSQ_INFO("Created new client connection");
|
||||
EV_LOG_CONN_EVENT(cid, "created full connection");
|
||||
return &conn->fc_conn;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
@ -829,7 +995,7 @@ lsquic_conn_get_engine (lsquic_conn_t *lconn)
|
|||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
static ptrdiff_t
|
||||
count_zero_bytes (const unsigned char *p, size_t len)
|
||||
{
|
||||
const unsigned char *const end = p + len;
|
||||
|
@ -844,11 +1010,11 @@ process_padding_frame (struct full_conn *conn, lsquic_packet_in_t *packet_in,
|
|||
const unsigned char *p, size_t len)
|
||||
{
|
||||
if (conn->fc_conn.cn_version >= LSQVER_038)
|
||||
return (unsigned)count_zero_bytes(p, len);
|
||||
return (unsigned) count_zero_bytes(p, len);
|
||||
if (lsquic_is_zero(p, len))
|
||||
{
|
||||
EV_LOG_PADDING_FRAME_IN(LSQUIC_LOG_CONN_ID, len);
|
||||
return (unsigned )len;
|
||||
return (unsigned) len;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
@ -1133,11 +1299,19 @@ static int
|
|||
process_saved_ack (struct full_conn *conn, int restore_parsed_ack)
|
||||
{
|
||||
struct ack_info *const acki = conn->fc_pub.mm->acki;
|
||||
struct lsquic_packno_range range = { 0 };
|
||||
unsigned n_ranges = 0, n_timestamps = 0;
|
||||
lsquic_time_t lack_delta = 0;
|
||||
struct lsquic_packno_range range;
|
||||
unsigned n_ranges, n_timestamps;
|
||||
lsquic_time_t lack_delta;
|
||||
int retval;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Useless initialization to mollify MSVC: */
|
||||
memset(&range, 0, sizeof(range));
|
||||
n_ranges = 0;
|
||||
n_timestamps = 0;
|
||||
lack_delta = 0;
|
||||
#endif
|
||||
|
||||
if (restore_parsed_ack)
|
||||
{
|
||||
n_ranges = acki->n_ranges;
|
||||
|
@ -3179,7 +3353,7 @@ static const struct headers_stream_callbacks headers_callbacks =
|
|||
.hsc_on_enable_push = headers_stream_on_enable_push,
|
||||
};
|
||||
|
||||
|
||||
static const struct headers_stream_callbacks *headers_callbacks_ptr = &headers_callbacks;
|
||||
|
||||
static const struct conn_iface full_conn_iface = {
|
||||
.ci_destroy = full_conn_ci_destroy,
|
||||
|
@ -3192,167 +3366,5 @@ static const struct conn_iface full_conn_iface = {
|
|||
.ci_tick = full_conn_ci_tick,
|
||||
.ci_user_wants_read = full_conn_ci_user_wants_read,
|
||||
};
|
||||
static struct full_conn *
|
||||
new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,
|
||||
const struct lsquic_stream_if *stream_if,
|
||||
void *stream_if_ctx, unsigned flags,
|
||||
unsigned short max_packet_size)
|
||||
{
|
||||
struct full_conn *conn;
|
||||
lsquic_stream_t *headers_stream;
|
||||
int saved_errno;
|
||||
|
||||
assert(0 == (flags & ~(FC_SERVER|FC_HTTP)));
|
||||
|
||||
conn = calloc(1, sizeof(*conn));
|
||||
if (!conn)
|
||||
return NULL;
|
||||
headers_stream = NULL;
|
||||
conn->fc_conn.cn_cid = cid;
|
||||
conn->fc_conn.cn_pack_size = max_packet_size;
|
||||
conn->fc_flags = flags;
|
||||
conn->fc_enpub = enpub;
|
||||
conn->fc_pub.enpub = enpub;
|
||||
conn->fc_pub.mm = &enpub->enp_mm;
|
||||
conn->fc_pub.lconn = &conn->fc_conn;
|
||||
conn->fc_pub.send_ctl = &conn->fc_send_ctl;
|
||||
conn->fc_pub.packet_out_malo =
|
||||
lsquic_malo_create(sizeof(struct lsquic_packet_out));
|
||||
conn->fc_stream_ifs[STREAM_IF_STD].stream_if = stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx = stream_if_ctx;
|
||||
conn->fc_settings = &enpub->enp_settings;
|
||||
/* Calculate maximum number of incoming streams using the same mechanism
|
||||
* and parameters as found in Chrome:
|
||||
*/
|
||||
conn->fc_cfg.max_streams_in =
|
||||
(unsigned) ((float) enpub->enp_settings.es_max_streams_in * 1.1f);
|
||||
if (conn->fc_cfg.max_streams_in <
|
||||
enpub->enp_settings.es_max_streams_in + 10)
|
||||
conn->fc_cfg.max_streams_in =
|
||||
enpub->enp_settings.es_max_streams_in + 10;
|
||||
/* `max_streams_out' gets reset when handshake is complete and we
|
||||
* learn of peer settings. 100 seems like a sane default value
|
||||
* because it is what other implementations use. In server mode,
|
||||
* we do not open any streams until the handshake is complete; in
|
||||
* client mode, we are limited to 98 outgoing requests alongside
|
||||
* handshake and headers streams.
|
||||
*/
|
||||
conn->fc_cfg.max_streams_out = 100;
|
||||
TAILQ_INIT(&conn->fc_pub.sending_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.read_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.write_streams);
|
||||
TAILQ_INIT(&conn->fc_pub.service_streams);
|
||||
STAILQ_INIT(&conn->fc_stream_ids_to_reset);
|
||||
lsquic_conn_cap_init(&conn->fc_pub.conn_cap, LSQUIC_MIN_FCW);
|
||||
lsquic_alarmset_init(&conn->fc_alset, cid);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_IDLE, idle_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_ACK, ack_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_PING, ping_alarm_expired, conn);
|
||||
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_HANDSHAKE, handshake_alarm_expired, conn);
|
||||
lsquic_set32_init(&conn->fc_closed_stream_ids[0]);
|
||||
lsquic_set32_init(&conn->fc_closed_stream_ids[1]);
|
||||
lsquic_cfcw_init(&conn->fc_pub.cfcw, &conn->fc_pub, conn->fc_settings->es_cfcw);
|
||||
lsquic_send_ctl_init(&conn->fc_send_ctl, &conn->fc_alset, conn->fc_enpub,
|
||||
&conn->fc_ver_neg, &conn->fc_pub, conn->fc_conn.cn_pack_size);
|
||||
|
||||
conn->fc_pub.all_streams = lsquic_hash_create();
|
||||
if (!conn->fc_pub.all_streams)
|
||||
goto cleanup_on_error;
|
||||
lsquic_rechist_init(&conn->fc_rechist, cid);
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
{
|
||||
conn->fc_pub.hs = lsquic_headers_stream_new(
|
||||
!!(conn->fc_flags & FC_SERVER), conn->fc_pub.mm, conn->fc_settings,
|
||||
&headers_callbacks, conn);
|
||||
if (!conn->fc_pub.hs)
|
||||
goto cleanup_on_error;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = lsquic_headers_stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = conn->fc_pub.hs;
|
||||
headers_stream = new_stream(conn, LSQUIC_STREAM_HEADERS,
|
||||
SCF_CALL_ON_NEW);
|
||||
if (!headers_stream)
|
||||
goto cleanup_on_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = stream_if_ctx;
|
||||
}
|
||||
if (conn->fc_settings->es_support_push)
|
||||
conn->fc_flags |= FC_SUPPORT_PUSH;
|
||||
conn->fc_conn.cn_if = &full_conn_iface;
|
||||
return conn;
|
||||
|
||||
cleanup_on_error:
|
||||
saved_errno = errno;
|
||||
|
||||
if (conn->fc_pub.all_streams)
|
||||
lsquic_hash_destroy(conn->fc_pub.all_streams);
|
||||
lsquic_rechist_cleanup(&conn->fc_rechist);
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
{
|
||||
if (conn->fc_pub.hs)
|
||||
lsquic_headers_stream_destroy(conn->fc_pub.hs);
|
||||
if (headers_stream)
|
||||
lsquic_stream_destroy(headers_stream);
|
||||
}
|
||||
memset(conn, 0, sizeof(*conn));
|
||||
free(conn);
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
struct lsquic_conn *
|
||||
full_conn_client_new (struct lsquic_engine_public *enpub,
|
||||
const struct lsquic_stream_if *stream_if,
|
||||
void *stream_if_ctx, unsigned flags,
|
||||
const char *hostname, unsigned short max_packet_size)
|
||||
{
|
||||
struct full_conn *conn;
|
||||
enum lsquic_version version;
|
||||
lsquic_cid_t cid;
|
||||
const struct enc_session_funcs *esf;
|
||||
|
||||
version = highest_bit_set(enpub->enp_settings.es_versions);
|
||||
esf = select_esf_by_ver(version);
|
||||
cid = esf->esf_generate_cid();
|
||||
conn = new_conn_common(cid, enpub, stream_if, stream_if_ctx, flags,
|
||||
max_packet_size);
|
||||
if (!conn)
|
||||
return NULL;
|
||||
conn->fc_conn.cn_esf = esf;
|
||||
conn->fc_conn.cn_enc_session =
|
||||
conn->fc_conn.cn_esf->esf_create_client(hostname, cid, conn->fc_enpub);
|
||||
if (!conn->fc_conn.cn_enc_session)
|
||||
{
|
||||
LSQ_WARN("could not create enc session: %s", strerror(errno));
|
||||
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (conn->fc_flags & FC_HTTP)
|
||||
conn->fc_last_stream_id = LSQUIC_STREAM_HEADERS; /* Client goes 5, 7, 9.... */
|
||||
else
|
||||
conn->fc_last_stream_id = LSQUIC_STREAM_HANDSHAKE;
|
||||
conn->fc_hsk_ctx.client.lconn = &conn->fc_conn;
|
||||
conn->fc_hsk_ctx.client.mm = &enpub->enp_mm;
|
||||
conn->fc_hsk_ctx.client.ver_neg = &conn->fc_ver_neg;
|
||||
conn->fc_stream_ifs[STREAM_IF_HSK]
|
||||
.stream_if = &lsquic_client_hsk_stream_if;
|
||||
conn->fc_stream_ifs[STREAM_IF_HSK].stream_if_ctx = &conn->fc_hsk_ctx.client;
|
||||
init_ver_neg(conn, conn->fc_settings->es_versions);
|
||||
conn->fc_conn.cn_pf = select_pf_by_ver(conn->fc_ver_neg.vn_ver);
|
||||
if (conn->fc_settings->es_handshake_to)
|
||||
lsquic_alarmset_set(&conn->fc_alset, AL_HANDSHAKE,
|
||||
lsquic_time_now() + conn->fc_settings->es_handshake_to);
|
||||
if (!new_stream(conn, LSQUIC_STREAM_HANDSHAKE, SCF_CALL_ON_NEW))
|
||||
{
|
||||
LSQ_WARN("could not create handshake stream: %s", strerror(errno));
|
||||
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
|
||||
return NULL;
|
||||
}
|
||||
conn->fc_flags |= FC_CREATED_OK;
|
||||
LSQ_INFO("Created new client connection");
|
||||
EV_LOG_CONN_EVENT(cid, "created full connection");
|
||||
return &conn->fc_conn;
|
||||
}
|
||||
static const struct conn_iface *full_conn_iface_ptr = &full_conn_iface;
|
||||
|
|
|
@ -935,7 +935,7 @@ lsquic_enc_session_gen_chlo (lsquic_enc_session_t *enc_session,
|
|||
unsigned char pub_key[32];
|
||||
size_t ua_len;
|
||||
uint32_t opts[1]; /* Only NSTP is supported for now */
|
||||
unsigned n_opts, msg_len, n_tags, pad_size = 0;
|
||||
unsigned n_opts, msg_len, n_tags, pad_size;
|
||||
struct message_writer mw;
|
||||
|
||||
/* Before we do anything else, sanity check: */
|
||||
|
@ -1014,6 +1014,10 @@ lsquic_enc_session_gen_chlo (lsquic_enc_session_t *enc_session,
|
|||
pad_size = 0;
|
||||
MSG_LEN_ADD(msg_len, pad_size); ++n_tags; /* PAD */
|
||||
}
|
||||
#ifdef WIN32
|
||||
else
|
||||
pad_size = 0;
|
||||
#endif
|
||||
|
||||
/* Check that we have enough room in the output buffer: */
|
||||
if (MSG_LEN_VAL(msg_len) > *len)
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
#ifdef MSVC
|
||||
#include <vc_compat.h>
|
||||
#endif
|
||||
|
||||
#include "lsquic_types.h"
|
||||
#include "lsquic_frame_common.h"
|
||||
|
@ -29,6 +31,7 @@
|
|||
#define LSQUIC_LOG_CONN_ID lsquic_conn_id(lsquic_stream_conn(hs->hs_stream))
|
||||
#include "lsquic_logger.h"
|
||||
|
||||
static const struct frame_reader_callbacks *frame_callbacks_ptr;
|
||||
|
||||
struct headers_stream
|
||||
{
|
||||
|
@ -48,7 +51,6 @@ struct headers_stream
|
|||
HS_HENC_INITED = (1 << 1),
|
||||
} hs_flags;
|
||||
};
|
||||
static lsquic_stream_ctx_t * headers_on_new_stream(void *stream_if_ctx, lsquic_stream_t *stream);
|
||||
|
||||
|
||||
int
|
||||
|
@ -71,6 +73,42 @@ lsquic_headers_stream_send_settings (struct headers_stream *hs,
|
|||
}
|
||||
|
||||
|
||||
static lsquic_stream_ctx_t *
|
||||
headers_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
|
||||
{
|
||||
struct headers_stream *hs = stream_if_ctx;
|
||||
lsquic_hdec_init(&hs->hs_hdec);
|
||||
if (0 != lsquic_henc_init(&hs->hs_henc))
|
||||
{
|
||||
LSQ_WARN("could not initialize HPACK encoder: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
hs->hs_flags |= HS_HENC_INITED;
|
||||
hs->hs_stream = stream;
|
||||
LSQ_DEBUG("stream created");
|
||||
hs->hs_fr = lsquic_frame_reader_new((hs->hs_flags & HS_IS_SERVER) ? FRF_SERVER : 0,
|
||||
MAX_HEADERS_SIZE, hs->hs_mm,
|
||||
stream, lsquic_stream_read, &hs->hs_hdec,
|
||||
frame_callbacks_ptr, hs);
|
||||
if (!hs->hs_fr)
|
||||
{
|
||||
LSQ_WARN("could not create frame reader: %s", strerror(errno));
|
||||
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
|
||||
return NULL;
|
||||
}
|
||||
hs->hs_fw = lsquic_frame_writer_new(hs->hs_mm, stream, 0, &hs->hs_henc,
|
||||
lsquic_stream_write,
|
||||
(hs->hs_flags & HS_IS_SERVER));
|
||||
if (!hs->hs_fw)
|
||||
{
|
||||
LSQ_WARN("could not create frame writer: %s", strerror(errno));
|
||||
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
|
||||
return NULL;
|
||||
}
|
||||
lsquic_stream_wantread(stream, 1);
|
||||
return (lsquic_stream_ctx_t *) hs;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
headers_on_read (lsquic_stream_t *stream, struct lsquic_stream_ctx *ctx)
|
||||
|
@ -379,39 +417,6 @@ static const struct frame_reader_callbacks frame_callbacks = {
|
|||
.frc_on_settings = headers_on_settings,
|
||||
.frc_on_priority = headers_on_priority,
|
||||
};
|
||||
static lsquic_stream_ctx_t *
|
||||
headers_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
|
||||
{
|
||||
struct headers_stream *hs = stream_if_ctx;
|
||||
lsquic_hdec_init(&hs->hs_hdec);
|
||||
if (0 != lsquic_henc_init(&hs->hs_henc))
|
||||
{
|
||||
LSQ_WARN("could not initialize HPACK encoder: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
hs->hs_flags |= HS_HENC_INITED;
|
||||
hs->hs_stream = stream;
|
||||
LSQ_DEBUG("stream created");
|
||||
hs->hs_fr = lsquic_frame_reader_new((hs->hs_flags & HS_IS_SERVER) ? FRF_SERVER : 0,
|
||||
MAX_HEADERS_SIZE, hs->hs_mm,
|
||||
stream, lsquic_stream_read, &hs->hs_hdec,
|
||||
&frame_callbacks, hs);
|
||||
if (!hs->hs_fr)
|
||||
{
|
||||
LSQ_WARN("could not create frame reader: %s", strerror(errno));
|
||||
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
|
||||
return NULL;
|
||||
}
|
||||
hs->hs_fw = lsquic_frame_writer_new(hs->hs_mm, stream, 0, &hs->hs_henc,
|
||||
lsquic_stream_write,
|
||||
(hs->hs_flags & HS_IS_SERVER));
|
||||
if (!hs->hs_fw)
|
||||
{
|
||||
LSQ_WARN("could not create frame writer: %s", strerror(errno));
|
||||
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
|
||||
return NULL;
|
||||
}
|
||||
lsquic_stream_wantread(stream, 1);
|
||||
return (lsquic_stream_ctx_t *) hs;
|
||||
}
|
||||
|
||||
static const struct frame_reader_callbacks *frame_callbacks_ptr = &frame_callbacks;
|
||||
|
||||
|
|
|
@ -121,10 +121,56 @@ lsquic_printf (const char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
static int
|
||||
gettimeofday (struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
FILETIME ft;
|
||||
unsigned __int64 tmpres = 0;
|
||||
static int tzflag;
|
||||
|
||||
if (NULL != tv)
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
|
||||
tmpres |= ft.dwHighDateTime;
|
||||
tmpres <<= 32;
|
||||
tmpres |= ft.dwLowDateTime;
|
||||
|
||||
/*converting file time to unix epoch */
|
||||
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
||||
tmpres /= 10; /*convert into microseconds */
|
||||
tv->tv_sec = (long) (tmpres / 1000000UL);
|
||||
tv->tv_usec = (long) (tmpres % 1000000UL);
|
||||
}
|
||||
|
||||
if (NULL != tz)
|
||||
{
|
||||
if (!tzflag)
|
||||
{
|
||||
_tzset();
|
||||
tzflag++;
|
||||
}
|
||||
tz->tz_minuteswest = _timezone / 60;
|
||||
tz->tz_dsttime = _daylight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
print_timestamp (void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct tm tm;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
@ -146,27 +192,6 @@ print_timestamp (void)
|
|||
else if (g_llts == LLTS_CHROMELIKE)
|
||||
lsquic_printf("%02d%02d/%02d%02d%02d.%06d ", tm.tm_mon + 1,
|
||||
tm.tm_mday,tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_usec);
|
||||
#else
|
||||
SYSTEMTIME tm = { 0 };
|
||||
GetSystemTime(&tm);
|
||||
if (g_llts == LLTS_YYYYMMDD_HHMMSSUS)
|
||||
lsquic_printf("%04d-%02d-%02d %02d:%02d:%02d.%06d ",
|
||||
tm.wYear + 1900, tm.wMonth + 1, tm.wDay,
|
||||
tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds*1000 );
|
||||
else if (g_llts == LLTS_YYYYMMDD_HHMMSSMS)
|
||||
lsquic_printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ",
|
||||
tm.wYear + 1900, tm.wMonth + 1, tm.wDay,
|
||||
tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds*1000 );
|
||||
else if (g_llts == LLTS_HHMMSSMS)
|
||||
lsquic_printf("%02d:%02d:%02d.%03d ", tm.wHour, tm.wMinute,
|
||||
tm.wSecond, tm.wMilliseconds );
|
||||
else if (g_llts == LLTS_HHMMSSUS)
|
||||
lsquic_printf("%02d:%02d:%02d.%03d ", tm.wHour, tm.wMinute,
|
||||
tm.wSecond, tm.wMilliseconds*1000 );
|
||||
else if (g_llts == LLTS_CHROMELIKE)
|
||||
lsquic_printf("%02d%02d/%02d%02d%02d.%06d ", tm.wMonth + 1,
|
||||
tm.wDay,tm.wHour, tm.wMinute, tm.wSecond, (int) tm.wMilliseconds*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,23 +65,23 @@ static const char * const frame_type_2_str[N_QUIC_FRAMES] = {
|
|||
};
|
||||
|
||||
|
||||
#define SLEN(x) (sizeof(#x) - sizeof("QUIC_FRAME_"))
|
||||
#define QUIC_FRAME_SLEN(x) (sizeof(#x) - sizeof("QUIC_FRAME_"))
|
||||
|
||||
|
||||
/* We don't need to include INVALID frame in this list because it is
|
||||
* never a part of any frame list bitmask (e.g. po_frame_types).
|
||||
*/
|
||||
#define lsquic_frame_types_str_sz \
|
||||
SLEN(QUIC_FRAME_STREAM) + 1 + \
|
||||
SLEN(QUIC_FRAME_ACK) + 1 + \
|
||||
SLEN(QUIC_FRAME_PADDING) + 1 + \
|
||||
SLEN(QUIC_FRAME_RST_STREAM) + 1 + \
|
||||
SLEN(QUIC_FRAME_CONNECTION_CLOSE) + 1 + \
|
||||
SLEN(QUIC_FRAME_GOAWAY) + 1 + \
|
||||
SLEN(QUIC_FRAME_WINDOW_UPDATE) + 1 + \
|
||||
SLEN(QUIC_FRAME_BLOCKED) + 1 + \
|
||||
SLEN(QUIC_FRAME_STOP_WAITING) + 1 + \
|
||||
SLEN(QUIC_FRAME_PING) + 1
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_STREAM) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_ACK) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_PADDING) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_RST_STREAM) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_CONNECTION_CLOSE) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_GOAWAY) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_WINDOW_UPDATE) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_BLOCKED) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_STOP_WAITING) + 1 + \
|
||||
QUIC_FRAME_SLEN(QUIC_FRAME_PING) + 1
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#ifndef LSQUIC_PACKET_IN_H
|
||||
#define LSQUIC_PACKET_IN_H 1
|
||||
|
||||
|
||||
struct lsquic_packet_in;
|
||||
|
||||
struct data_frame
|
||||
|
|
|
@ -615,7 +615,7 @@ lsquic_packet_out_split_in_two (struct lsquic_mm *mm,
|
|||
struct stream_rec **new_srecs, **srecs = local_arr;
|
||||
struct stream_rec *srec;
|
||||
unsigned n_srecs_alloced = sizeof(local_arr) / sizeof(local_arr[0]);
|
||||
unsigned n_srecs, max_idx = 0, n, nbytes;
|
||||
unsigned n_srecs, max_idx, n, nbytes;
|
||||
#ifndef NDEBUG
|
||||
unsigned short frame_sum = 0;
|
||||
#endif
|
||||
|
@ -627,6 +627,9 @@ lsquic_packet_out_split_in_two (struct lsquic_mm *mm,
|
|||
assert(packet_out->po_frame_types == (1 << QUIC_FRAME_STREAM));
|
||||
|
||||
n_srecs = 0;
|
||||
#ifdef WIN32
|
||||
max_idx = 0;
|
||||
#endif
|
||||
for (srec = posi_first(&posi, packet_out); srec; srec = posi_next(&posi))
|
||||
{
|
||||
/* We only expect references to STREAM frames (buffered packets): */
|
||||
|
|
|
@ -364,6 +364,7 @@ gquic_ietf_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
void *rechist, lsquic_time_t now, int *has_missing,
|
||||
lsquic_packno_t *largest_received)
|
||||
{
|
||||
lsquic_time_t time_diff;
|
||||
lsquic_packno_t tmp_packno;
|
||||
const struct lsquic_packno_range *const first = rechist_first(rechist);
|
||||
if (!first)
|
||||
|
@ -447,13 +448,11 @@ gquic_ietf_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
p += largest_acked_len;
|
||||
|
||||
CHECKOUT(2);
|
||||
{
|
||||
lsquic_time_t diff = now - rechist_largest_recv(rechist);
|
||||
gquic_be_write_float_time16(diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
}
|
||||
time_diff = now - rechist_largest_recv(rechist);
|
||||
gquic_be_write_float_time16(time_diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
|
||||
*has_missing = n_ranges > 1;
|
||||
if (n_ranges > 1)
|
||||
|
|
|
@ -796,6 +796,7 @@ gquic_be_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
void *rechist, lsquic_time_t now, int *has_missing,
|
||||
lsquic_packno_t *largest_received)
|
||||
{
|
||||
lsquic_time_t time_diff;
|
||||
lsquic_packno_t tmp_packno;
|
||||
const struct lsquic_packno_range *const first = rechist_first(rechist);
|
||||
if (!first)
|
||||
|
@ -865,13 +866,11 @@ gquic_be_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
p += largest_acked_len;
|
||||
|
||||
CHECKOUT(2);
|
||||
{
|
||||
lsquic_time_t diff = now - rechist_largest_recv(rechist);
|
||||
gquic_be_write_float_time16(diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
}
|
||||
time_diff = now - rechist_largest_recv(rechist);
|
||||
gquic_be_write_float_time16(time_diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
|
||||
if (n_ranges > 1)
|
||||
{
|
||||
|
|
|
@ -690,6 +690,7 @@ gquic_le_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
void *rechist, lsquic_time_t now, int *has_missing,
|
||||
lsquic_packno_t *largest_received)
|
||||
{
|
||||
lsquic_time_t time_diff;
|
||||
const struct lsquic_packno_range *const first = rechist_first(rechist);
|
||||
if (!first)
|
||||
{
|
||||
|
@ -753,13 +754,11 @@ gquic_le_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
|
|||
p += largest_acked_len;
|
||||
|
||||
CHECKOUT(2);
|
||||
{
|
||||
lsquic_time_t diff = now - rechist_largest_recv(rechist);
|
||||
gquic_le_write_float_time16(diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
}
|
||||
time_diff = now - rechist_largest_recv(rechist);
|
||||
gquic_le_write_float_time16(time_diff, p);
|
||||
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
|
||||
*(uint16_t*)p);
|
||||
p += 2;
|
||||
|
||||
if (n_ranges > 1)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef MSVC
|
||||
#include <vc_compat.h>
|
||||
#endif
|
||||
|
||||
#include "lsquic_int_types.h"
|
||||
#include "lsquic_types.h"
|
||||
|
|
|
@ -299,7 +299,7 @@ static void
|
|||
set_retx_alarm (lsquic_send_ctl_t *ctl)
|
||||
{
|
||||
enum retx_mode rm;
|
||||
lsquic_time_t delay = 0, now;
|
||||
lsquic_time_t delay, now;
|
||||
|
||||
assert(!TAILQ_EMPTY(&ctl->sc_unacked_packets));
|
||||
|
||||
|
@ -339,6 +339,10 @@ set_retx_alarm (lsquic_send_ctl_t *ctl)
|
|||
*/
|
||||
delay = calculate_packet_rto(ctl);
|
||||
break;
|
||||
#ifdef WIN32
|
||||
default:
|
||||
delay = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (delay > MAX_RTO_DELAY)
|
||||
|
@ -926,7 +930,7 @@ static void
|
|||
send_ctl_expire (lsquic_send_ctl_t *ctl, enum expire_filter filter)
|
||||
{
|
||||
lsquic_packet_out_t *packet_out, *next;
|
||||
int n_resubmitted =0;
|
||||
int n_resubmitted;
|
||||
static const char *const filter_type2str[] = {
|
||||
[EXFI_ALL] = "all",
|
||||
[EXFI_HSK] = "handshake",
|
||||
|
@ -957,6 +961,10 @@ send_ctl_expire (lsquic_send_ctl_t *ctl, enum expire_filter filter)
|
|||
else
|
||||
n_resubmitted = 0;
|
||||
break;
|
||||
#ifdef WIN32
|
||||
default:
|
||||
n_resubmitted = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
LSQ_DEBUG("consider %s packets lost: %d resubmitted",
|
||||
|
@ -1301,11 +1309,14 @@ lsquic_send_ctl_set_tcid0 (lsquic_send_ctl_t *ctl, int tcid0)
|
|||
void
|
||||
lsquic_send_ctl_elide_stream_frames (lsquic_send_ctl_t *ctl, uint32_t stream_id)
|
||||
{
|
||||
struct lsquic_packet_out *packet_out, *next = NULL;
|
||||
struct lsquic_packet_out *packet_out, *next;
|
||||
struct lsquic_packet_out *pre_dropped;
|
||||
unsigned n, adj;
|
||||
|
||||
pre_dropped = NULL;
|
||||
#ifdef WIN32
|
||||
next = NULL;
|
||||
#endif
|
||||
for (packet_out = TAILQ_FIRST(&ctl->sc_scheduled_packets); packet_out;
|
||||
packet_out = next)
|
||||
{
|
||||
|
|
|
@ -3,19 +3,250 @@ include_directories( BEFORE ../../ssl/include )
|
|||
include_directories( ../../include )
|
||||
include_directories( ../../src/liblsquic )
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value")
|
||||
set(MIN_LIBS_LIST "m ${FIULIB}")
|
||||
set(LIBS_LIST "pthread libssl.a libcrypto.a z ${MIN_LIBS_LIST}")
|
||||
|
||||
enable_testing()
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
|
||||
add_executable(test_rechist test_rechist.c)
|
||||
target_link_libraries(test_rechist lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(rechist test_rechist)
|
||||
|
||||
add_executable(test_senhist test_senhist.c)
|
||||
target_link_libraries(test_senhist lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(senhist test_senhist)
|
||||
|
||||
add_executable(test_rtt test_rtt.c)
|
||||
target_link_libraries(test_rtt lsquic m ${FIULIB})
|
||||
add_test(rtt test_rtt)
|
||||
|
||||
add_executable(test_set test_set.c)
|
||||
target_link_libraries(test_set lsquic m ${FIULIB})
|
||||
add_test(set test_set)
|
||||
|
||||
|
||||
add_executable(test_engine_ctor test_engine_ctor.c)
|
||||
target_link_libraries(test_engine_ctor lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(engine_ctor test_engine_ctor)
|
||||
|
||||
|
||||
add_executable(test_stream test_stream.c)
|
||||
target_link_libraries(test_stream lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(stream test_stream)
|
||||
add_test(stream_hash test_stream -h)
|
||||
add_test(stream_A test_stream -A)
|
||||
add_test(stream_hash_A test_stream -A -h)
|
||||
|
||||
add_executable(test_spi test_spi.c)
|
||||
target_link_libraries(test_spi lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(spi test_spi)
|
||||
|
||||
add_executable(test_malo test_malo.c)
|
||||
target_link_libraries(test_malo lsquic m ${FIULIB})
|
||||
add_test(malo test_malo)
|
||||
|
||||
add_executable(test_conn_hash test_conn_hash.c)
|
||||
target_link_libraries(test_conn_hash lsquic m ${FIULIB})
|
||||
add_test(conn_hash test_conn_hash)
|
||||
|
||||
add_executable(test_lsquic_hash test_lsquic_hash.c)
|
||||
target_link_libraries(test_lsquic_hash lsquic m ${FIULIB})
|
||||
add_test(lsquic_hash test_lsquic_hash)
|
||||
|
||||
add_executable(test_blocked_gquic_le test_blocked_gquic_le.c)
|
||||
target_link_libraries(test_blocked_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(blocked_gquic_le test_blocked_gquic_le)
|
||||
|
||||
add_executable(test_blocked_gquic_be test_blocked_gquic_be.c)
|
||||
target_link_libraries(test_blocked_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(blocked_gquic_be test_blocked_gquic_be)
|
||||
|
||||
add_executable(test_rst_stream_gquic_le test_rst_stream_gquic_le.c)
|
||||
target_link_libraries(test_rst_stream_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(rst_stream_gquic_le test_rst_stream_gquic_le)
|
||||
|
||||
add_executable(test_rst_stream_gquic_be test_rst_stream_gquic_be.c)
|
||||
target_link_libraries(test_rst_stream_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(rst_stream_gquic_be test_rst_stream_gquic_be)
|
||||
|
||||
add_executable(test_rst_stream_ietf test_rst_stream_ietf.c)
|
||||
target_link_libraries(test_rst_stream_ietf lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(rst_stream_ietf test_rst_stream_ietf)
|
||||
|
||||
add_executable(test_conn_close_gquic_le test_conn_close_gquic_le.c)
|
||||
target_link_libraries(test_conn_close_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(conn_close_gquic_le test_conn_close_gquic_le)
|
||||
|
||||
add_executable(test_conn_close_gquic_be test_conn_close_gquic_be.c)
|
||||
target_link_libraries(test_conn_close_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(conn_close_gquic_be test_conn_close_gquic_be)
|
||||
|
||||
add_executable(test_goaway_gquic_le test_goaway_gquic_le.c)
|
||||
target_link_libraries(test_goaway_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(goaway_gquic_le test_goaway_gquic_le)
|
||||
|
||||
add_executable(test_goaway_gquic_be test_goaway_gquic_be.c)
|
||||
target_link_libraries(test_goaway_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(goaway_gquic_be test_goaway_gquic_be)
|
||||
|
||||
add_executable(test_wuf_gquic_le test_wuf_gquic_le.c)
|
||||
target_link_libraries(test_wuf_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(wuf_gquic_le test_wuf_gquic_le)
|
||||
|
||||
add_executable(test_wuf_gquic_be test_wuf_gquic_be.c)
|
||||
target_link_libraries(test_wuf_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(wuf_gquic_be test_wuf_gquic_be)
|
||||
|
||||
add_executable(test_ackparse_gquic_le test_ackparse_gquic_le.c)
|
||||
target_link_libraries(test_ackparse_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackparse_gquic_le test_ackparse_gquic_le)
|
||||
|
||||
add_executable(test_ackparse_gquic_be test_ackparse_gquic_be.c)
|
||||
target_link_libraries(test_ackparse_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackparse_gquic_be test_ackparse_gquic_be)
|
||||
|
||||
add_executable(test_ackparse_gquic_ietf test_ackparse_gquic_ietf.c)
|
||||
target_link_libraries(test_ackparse_gquic_ietf lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackparse_gquic_ietf test_ackparse_gquic_ietf)
|
||||
|
||||
add_executable(test_ackgen_gquic_le test_ackgen_gquic_le.c)
|
||||
target_link_libraries(test_ackgen_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackgen_gquic_le test_ackgen_gquic_le)
|
||||
|
||||
add_executable(test_ackgen_gquic_be test_ackgen_gquic_be.c)
|
||||
target_link_libraries(test_ackgen_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackgen_gquic_be test_ackgen_gquic_be)
|
||||
|
||||
add_executable(test_ackgen_gquic_ietf test_ackgen_gquic_ietf.c)
|
||||
target_link_libraries(test_ackgen_gquic_ietf lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ackgen_gquic_ietf test_ackgen_gquic_ietf)
|
||||
|
||||
add_executable(test_sfcw test_sfcw.c)
|
||||
target_link_libraries(test_sfcw lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(sfcw test_sfcw)
|
||||
|
||||
add_executable(test_alarmset test_alarmset.c)
|
||||
target_link_libraries(test_alarmset lsquic m ${FIULIB})
|
||||
add_test(alarmset test_alarmset)
|
||||
|
||||
add_executable(graph_cubic graph_cubic.c)
|
||||
target_link_libraries(graph_cubic lsquic m ${FIULIB})
|
||||
|
||||
|
||||
add_executable(test_streamparse test_streamparse.c)
|
||||
target_link_libraries(test_streamparse lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(streamparse test_streamparse)
|
||||
|
||||
add_executable(test_packet_out test_packet_out.c)
|
||||
target_link_libraries(test_packet_out lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(packet_out test_packet_out)
|
||||
|
||||
add_executable(test_reg_pkt_headergen test_reg_pkt_headergen.c)
|
||||
target_link_libraries(test_reg_pkt_headergen lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(reg_pkt_headergen test_reg_pkt_headergen)
|
||||
|
||||
add_executable(test_ver_nego test_ver_nego.c)
|
||||
target_link_libraries(test_ver_nego lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(ver_nego test_ver_nego)
|
||||
|
||||
add_executable(test_packno_len test_packno_len.c)
|
||||
target_link_libraries(test_packno_len lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(packno_len test_packno_len)
|
||||
|
||||
|
||||
add_executable(test_streamgen test_streamgen.c)
|
||||
target_link_libraries(test_streamgen lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(streamgen test_streamgen)
|
||||
|
||||
add_executable(test_some_packets test_some_packets.c)
|
||||
target_link_libraries(test_some_packets lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(some_packets test_some_packets)
|
||||
|
||||
|
||||
add_executable(test_elision test_elision.c)
|
||||
target_link_libraries(test_elision lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(elision test_elision)
|
||||
|
||||
add_executable(test_stop_waiting_gquic_le test_stop_waiting_gquic_le.c)
|
||||
target_link_libraries(test_stop_waiting_gquic_le lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(stop_waiting_gquic_le test_stop_waiting_gquic_le)
|
||||
|
||||
add_executable(test_stop_waiting_gquic_be test_stop_waiting_gquic_be.c)
|
||||
target_link_libraries(test_stop_waiting_gquic_be lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(stop_waiting_gquic_be test_stop_waiting_gquic_be)
|
||||
|
||||
add_executable(test_parse_packet_in test_parse_packet_in.c)
|
||||
target_link_libraries(test_parse_packet_in lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(parse_packet_in test_parse_packet_in)
|
||||
|
||||
add_executable(test_quic_le_floats test_quic_le_floats.c)
|
||||
target_link_libraries(test_quic_le_floats lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(quic_le_floats test_quic_le_floats)
|
||||
|
||||
add_executable(test_quic_be_floats test_quic_be_floats.c)
|
||||
target_link_libraries(test_quic_be_floats lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(quic_be_floats test_quic_be_floats)
|
||||
|
||||
add_executable(test_export_key test_export_key.c)
|
||||
target_link_libraries(test_export_key lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(export_key test_export_key)
|
||||
|
||||
add_executable(test_frame_reader test_frame_reader.c)
|
||||
target_link_libraries(test_frame_reader lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(frame_reader test_frame_reader)
|
||||
|
||||
add_executable(test_frame_writer test_frame_writer.c)
|
||||
target_link_libraries(test_frame_writer lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(frame_writer test_frame_writer)
|
||||
|
||||
add_executable(test_frame_chop test_frame_chop.c)
|
||||
target_link_libraries(test_frame_chop lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(frame_chop test_frame_chop)
|
||||
|
||||
IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
add_executable(test_frame_rw test_frame_rw.c)
|
||||
target_link_libraries(test_frame_rw lsquic pthread libssl.a libcrypto.a z m ${FIULIB})
|
||||
add_test(frame_rw test_frame_rw)
|
||||
ENDIF()
|
||||
|
||||
add_executable(test_hpack test_hpack.c)
|
||||
target_link_libraries(test_hpack lsquic m ${FIULIB})
|
||||
add_test(hpack test_hpack)
|
||||
|
||||
add_executable(test_hkdf test_hkdf.c)
|
||||
target_link_libraries(test_hkdf lsquic pthread libssl.a libcrypto.a m ${FIULIB})
|
||||
add_test(hkdf test_hkdf)
|
||||
|
||||
|
||||
|
||||
add_executable(test_attq test_attq.c)
|
||||
target_link_libraries(test_attq lsquic pthread libssl.a libcrypto.a m ${FIULIB})
|
||||
add_test(attq test_attq)
|
||||
|
||||
add_executable(test_arr test_arr.c)
|
||||
target_link_libraries(test_arr lsquic pthread libssl.a libcrypto.a m ${FIULIB})
|
||||
add_test(arr test_arr)
|
||||
|
||||
add_executable(test_buf test_buf.c)
|
||||
target_link_libraries(test_buf lsquic pthread libssl.a libcrypto.a m ${FIULIB})
|
||||
add_test(buf test_buf)
|
||||
|
||||
add_executable(test_cubic test_cubic.c)
|
||||
target_link_libraries(test_cubic lsquic pthread libssl.a libcrypto.a m ${FIULIB})
|
||||
add_test(cubic test_cubic)
|
||||
|
||||
add_executable(test_dec test_dec.c)
|
||||
target_link_libraries(test_dec libssl.a libcrypto.a z m pthread ${FIULIB})
|
||||
|
||||
|
||||
#MSVC
|
||||
ELSE()
|
||||
|
||||
SET (UGH_LIB_LIST debug $(SolutionDir)src/liblsquic/debug/lsquic.lib debug ${VCPKG_BASE_DIR}/debug/lib/event.lib debug ${VCPKG_BASE_DIR}/debug/lib/zlibd.lib debug ${BORINGSSL_BASE_LIB_DIR}/debug/ssl.lib debug ${BORINGSSL_BASE_LIB_DIR}/debug/crypto.lib optimized $(SolutionDir)src/liblsquic/release/lsquic.lib optimized ${VCPKG_BASE_DIR}/lib/event.lib optimized ${VCPKG_BASE_DIR}/lib/zlib.lib optimized ${BORINGSSL_BASE_LIB_DIR}/ssl.lib optimized ${BORINGSSL_BASE_LIB_DIR}/crypto.lib)
|
||||
|
||||
set(MIN_LIBS_LIST ${FIULIB} ws2_32)
|
||||
set(LIBS_LIST ${UGH_LIB_LIST} ${MIN_LIBS_LIST})
|
||||
ENDIF()
|
||||
|
||||
enable_testing()
|
||||
|
||||
|
||||
add_executable(test_rechist test_rechist.c)
|
||||
target_link_libraries(test_rechist lsquic ${LIBS_LIST})
|
||||
|
@ -38,13 +269,8 @@ add_executable(test_engine_ctor test_engine_ctor.c)
|
|||
target_link_libraries(test_engine_ctor lsquic ${LIBS_LIST})
|
||||
add_test(engine_ctor test_engine_ctor)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_stream test_stream.c)
|
||||
target_link_libraries(test_stream lsquic ${LIBS_LIST})
|
||||
ELSE()
|
||||
add_executable(test_stream test_stream.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
target_link_libraries(test_stream lsquic ${LIBS_LIST} -FORCE:multiple)
|
||||
ENDIF()
|
||||
|
||||
add_test(stream test_stream)
|
||||
add_test(stream_hash test_stream -h)
|
||||
|
@ -55,11 +281,7 @@ add_executable(test_spi test_spi.c)
|
|||
target_link_libraries(test_spi lsquic ${LIBS_LIST})
|
||||
add_test(spi test_spi)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_malo test_malo.c)
|
||||
ELSE()
|
||||
add_executable(test_malo test_malo.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
ENDIF()
|
||||
target_link_libraries(test_malo lsquic ${MIN_LIBS_LIST})
|
||||
add_test(malo test_malo)
|
||||
|
||||
|
@ -147,11 +369,7 @@ add_executable(test_alarmset test_alarmset.c)
|
|||
target_link_libraries(test_alarmset lsquic ${MIN_LIBS_LIST})
|
||||
add_test(alarmset test_alarmset)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(graph_cubic graph_cubic.c)
|
||||
ELSE()
|
||||
add_executable(graph_cubic graph_cubic.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
ENDIF()
|
||||
target_link_libraries(graph_cubic lsquic ${MIN_LIBS_LIST})
|
||||
|
||||
|
||||
|
@ -186,11 +404,7 @@ add_test(some_packets test_some_packets)
|
|||
|
||||
|
||||
add_executable(test_elision test_elision.c)
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
target_link_libraries(test_elision lsquic ${LIBS_LIST})
|
||||
ELSE()
|
||||
target_link_libraries(test_elision lsquic ${LIBS_LIST} -FORCE:multiple)
|
||||
ENDIF()
|
||||
add_test(elision test_elision)
|
||||
|
||||
add_executable(test_stop_waiting_gquic_le test_stop_waiting_gquic_le.c)
|
||||
|
@ -217,11 +431,7 @@ add_executable(test_export_key test_export_key.c)
|
|||
target_link_libraries(test_export_key lsquic ${LIBS_LIST})
|
||||
add_test(export_key test_export_key)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_frame_reader test_frame_reader.c)
|
||||
ELSE()
|
||||
add_executable(test_frame_reader test_frame_reader.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
ENDIF()
|
||||
target_link_libraries(test_frame_reader lsquic ${LIBS_LIST})
|
||||
add_test(frame_reader test_frame_reader)
|
||||
|
||||
|
@ -229,20 +439,10 @@ add_executable(test_frame_writer test_frame_writer.c)
|
|||
target_link_libraries(test_frame_writer lsquic ${LIBS_LIST})
|
||||
add_test(frame_writer test_frame_writer)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_frame_chop test_frame_chop.c)
|
||||
ELSE()
|
||||
add_executable(test_frame_chop test_frame_chop.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
ENDIF()
|
||||
target_link_libraries(test_frame_chop lsquic ${LIBS_LIST})
|
||||
add_test(frame_chop test_frame_chop)
|
||||
|
||||
IF (NOT ( (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR (CMAKE_C_COMPILER MATCHES "MSVC")) )
|
||||
add_executable(test_frame_rw test_frame_rw.c)
|
||||
target_link_libraries(test_frame_rw lsquic ${LIBS_LIST})
|
||||
add_test(frame_rw test_frame_rw)
|
||||
ENDIF()
|
||||
|
||||
add_executable(test_hpack test_hpack.c)
|
||||
target_link_libraries(test_hpack lsquic ${MIN_LIBS_LIST})
|
||||
add_test(hpack test_hpack)
|
||||
|
@ -252,7 +452,6 @@ target_link_libraries(test_hkdf lsquic ${LIBS_LIST})
|
|||
add_test(hkdf test_hkdf)
|
||||
|
||||
|
||||
|
||||
add_executable(test_attq test_attq.c)
|
||||
target_link_libraries(test_attq lsquic ${LIBS_LIST})
|
||||
add_test(attq test_attq)
|
||||
|
@ -265,18 +464,13 @@ add_executable(test_buf test_buf.c)
|
|||
target_link_libraries(test_buf lsquic ${LIBS_LIST})
|
||||
add_test(buf test_buf)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_cubic test_cubic.c)
|
||||
ELSE()
|
||||
add_executable(test_cubic test_cubic.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
ENDIF()
|
||||
target_link_libraries(test_cubic lsquic ${LIBS_LIST})
|
||||
add_test(cubic test_cubic)
|
||||
|
||||
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
||||
add_executable(test_dec test_dec.c)
|
||||
ELSE()
|
||||
add_executable(test_dec test_dec.c ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
target_link_libraries(test_dec ${LIBS_LIST})
|
||||
|
||||
ENDIF()
|
||||
|
||||
target_link_libraries(test_dec ${LIBS_LIST})
|
||||
|
||||
|
|
|
@ -83,9 +83,7 @@ lsquic_stream_acked (lsquic_stream_t *stream)
|
|||
static void
|
||||
elide_single_stream_frame (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
struct packet_out_srec_iter posi;
|
||||
#endif
|
||||
struct lsquic_engine_public enpub;
|
||||
lsquic_stream_t streams[1];
|
||||
lsquic_packet_out_t *packet_out;
|
||||
|
|
|
@ -440,9 +440,9 @@ run_ekt_test (const struct export_key_test *test)
|
|||
assert(test->ekt_server_iv_sz < sizeof(server_iv));
|
||||
assert(test->ekt_client_iv_sz < sizeof(client_iv));
|
||||
|
||||
s = export_key_material(test->ekt_ikm, (uint16_t)test->ekt_ikm_sz,
|
||||
test->ekt_salt, (uint16_t)test->ekt_salt_sz,
|
||||
test->ekt_context, (uint16_t)test->ekt_context_sz,
|
||||
s = export_key_material(test->ekt_ikm, (uint32_t)test->ekt_ikm_sz,
|
||||
test->ekt_salt, (int)test->ekt_salt_sz,
|
||||
test->ekt_context, (uint32_t)test->ekt_context_sz,
|
||||
(uint16_t)test->ekt_client_key_sz, client_key,
|
||||
(uint16_t)test->ekt_server_key_sz, server_key,
|
||||
(uint16_t)test->ekt_client_iv_sz, client_iv,
|
||||
|
|
|
@ -185,28 +185,24 @@ void displayHeader(unsigned char *buf, int len)
|
|||
static void
|
||||
printTable (struct lsquic_henc *enc)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
struct enc_dyn_table_entry entry;
|
||||
lsquic_henc_iter_reset(enc);
|
||||
printf("Dynamic Table : \n");
|
||||
while (0 == lsquic_henc_iter_next(enc, &entry))
|
||||
printf("[%d] `%.*s' = `%.*s'\n",
|
||||
entry.entry_id, entry.name_len, entry.name, entry.value_len, entry.value);
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
void testNameValue(const char *name, const char *val, int result,
|
||||
int val_match_result)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
int val_match;
|
||||
int index = lsquic_henc_get_stx_tab_id((char *)name, (uint16_t)strlen(name) ,
|
||||
(char *)val, (uint16_t)strlen(val), &val_match);
|
||||
printf("name: %s, val: %s, index = %d match = %d\n", name, val, index,
|
||||
val_match);
|
||||
assert(index == result && val_match == val_match_result);
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
@ -659,7 +655,6 @@ test_hpack_encode_and_decode (void)
|
|||
static void
|
||||
test_hpack_self_enc_dec_test_firefox_error (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
unsigned char respBuf[8192] = {0};
|
||||
unsigned char *respBufEnd;
|
||||
// Hpack hpack;
|
||||
|
@ -737,7 +732,6 @@ test_hpack_self_enc_dec_test_firefox_error (void)
|
|||
assert(memcmp(respBuf, buf, 90) == 0);
|
||||
lsquic_henc_cleanup(&henc);
|
||||
lsquic_hdec_cleanup(&hdec);
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
@ -991,7 +985,6 @@ test_henc_long_uncompressable (void)
|
|||
static void
|
||||
test_static_table_search_exhaustive (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
int i;
|
||||
int count = sizeof(g_HpackStaticTableTset) / sizeof(hpack_hdr_tbl_t);
|
||||
assert(count == 61);
|
||||
|
@ -1053,14 +1046,12 @@ test_static_table_search_exhaustive (void)
|
|||
assert(val_matched == 0);
|
||||
|
||||
printf("%s Done.\n", __func__);
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_integer_decoding (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
static const struct integer_decoding_test
|
||||
{
|
||||
int idt_lineno;
|
||||
|
@ -1138,14 +1129,12 @@ test_integer_decoding (void)
|
|||
if (0 == s)
|
||||
assert(value == test->idt_value);
|
||||
}
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_huffman_encoding_corner_cases (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
int s;
|
||||
unsigned char buf[0x10];
|
||||
|
||||
|
@ -1173,7 +1162,6 @@ test_huffman_encoding_corner_cases (void)
|
|||
s = lsquic_henc_enc_str(buf, 1, (unsigned char *) "a", 1000);
|
||||
assert(-1 == s);
|
||||
assert(0 == buf[1]);
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -255,8 +255,11 @@ test_restore (enum lsquic_packno_bits bits)
|
|||
unsigned len, n;
|
||||
enum { OP_PLUS, OP_MINUS, N_OPS } op;
|
||||
uint64_t epoch, epoch_delta;
|
||||
lsquic_packno_t orig_packno= 0, cur_packno, restored_packno;
|
||||
lsquic_packno_t orig_packno, cur_packno, restored_packno;
|
||||
|
||||
#ifdef WIN32
|
||||
orig_packno = 0;
|
||||
#endif
|
||||
len = packno_bits2len(bits);
|
||||
epoch_delta = 1ULL << (len << 3);
|
||||
epoch = epoch_delta * 11 /* Just some number */;
|
||||
|
|
|
@ -88,7 +88,6 @@ static const struct float_test to_float_tests[] = {
|
|||
static void
|
||||
run_to_float_tests (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const struct float_test *test;
|
||||
const struct float_test *const test_end =
|
||||
&to_float_tests[ sizeof(to_float_tests) / sizeof(to_float_tests[0]) ];
|
||||
|
@ -99,7 +98,6 @@ run_to_float_tests (void)
|
|||
assert(("Convertion to QUIC float format is successful",
|
||||
0 == memcmp(out, test->float_time, 2)));
|
||||
}
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +149,6 @@ static const struct float_test from_float_tests[] = {
|
|||
static void
|
||||
run_from_float_tests (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const struct float_test *test;
|
||||
const struct float_test *const test_end =
|
||||
&from_float_tests[ sizeof(from_float_tests) / sizeof(from_float_tests[0]) ];
|
||||
|
@ -161,7 +158,6 @@ run_from_float_tests (void)
|
|||
assert(("Convertion to QUIC float format is successful",
|
||||
result == test->long_time));
|
||||
}
|
||||
#endif // NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ static const struct float_test to_float_tests[] = {
|
|||
static void
|
||||
run_to_float_tests (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const struct float_test *test;
|
||||
const struct float_test *const test_end =
|
||||
&to_float_tests[ sizeof(to_float_tests) / sizeof(to_float_tests[0]) ];
|
||||
|
@ -99,7 +98,6 @@ run_to_float_tests (void)
|
|||
assert(("Convertion to QUIC float format is successful",
|
||||
0 == memcmp(out, test->float_time, 2)));
|
||||
}
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +149,6 @@ static const struct float_test from_float_tests[] = {
|
|||
static void
|
||||
run_from_float_tests (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const struct float_test *test;
|
||||
const struct float_test *const test_end =
|
||||
&from_float_tests[ sizeof(from_float_tests) / sizeof(from_float_tests[0]) ];
|
||||
|
@ -161,7 +158,6 @@ run_from_float_tests (void)
|
|||
assert(("Convertion to QUIC float format is successful",
|
||||
result == test->long_time));
|
||||
}
|
||||
#endif //NDEBUG
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
struct lsquic_senhist hist = { 0 };
|
||||
struct lsquic_senhist hist = { 0
|
||||
#if !LSQUIC_SENHIST_FATAL
|
||||
, 0
|
||||
#endif
|
||||
};
|
||||
lsquic_packno_t packno;
|
||||
|
||||
lsquic_senhist_init(&hist);
|
||||
|
|
Loading…
Reference in a new issue