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

[+] release version 1.8.0 #435

Merged
merged 4 commits into from
Jul 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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
SSL_LIB_PATH_STR="${PWD}/third_party/boringssl/build/ssl/libssl.a;${PWD}/third_party/boringssl/build/crypto/libcrypto.a"
mkdir -p build
cd build
cmake -DGCOV=on -DCMAKE_BUILD_TYPE=Debug -DXQC_ENABLE_TESTING=1 -DXQC_SUPPORT_SENDMMSG_BUILD=1 -DXQC_ENABLE_EVENT_LOG=1 -DXQC_ENABLE_BBR2=1 -DXQC_ENABLE_RENO=1 -DSSL_TYPE=${SSL_TYPE_STR} -DSSL_PATH=${SSL_PATH_STR} -DSSL_INC_PATH=${SSL_INC_PATH_STR} -DSSL_LIB_PATH=${SSL_LIB_PATH_STR} ..
cmake -DGCOV=on -DCMAKE_BUILD_TYPE=Debug -DXQC_ENABLE_TESTING=1 -DXQC_PRINT_SECRET=1 -DXQC_SUPPORT_SENDMMSG_BUILD=1 -DXQC_ENABLE_EVENT_LOG=1 -DXQC_ENABLE_BBR2=1 -DXQC_ENABLE_RENO=1 -DSSL_TYPE=${SSL_TYPE_STR} -DSSL_PATH=${SSL_PATH_STR} -DXQC_ENABLE_UNLIMITED=1 -DXQC_ENABLE_COPA=1 -DXQC_COMPAT_DUPLICATE=1 -DXQC_ENABLE_FEC=1 -DXQC_ENABLE_XOR=1 -DXQC_ENABLE_RSC=1 ..
make -j

- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
SSL_LIB_PATH_STR="${PWD}/third_party/boringssl/build/ssl/libssl.a;${PWD}/third_party/boringssl/build/crypto/libcrypto.a"
mkdir -p build
cd build
cmake -DGCOV=on -DCMAKE_BUILD_TYPE=Debug -DXQC_ENABLE_TESTING=1 -DXQC_SUPPORT_SENDMMSG_BUILD=1 -DXQC_ENABLE_EVENT_LOG=1 -DXQC_ENABLE_BBR2=1 -DXQC_ENABLE_RENO=1 -DSSL_TYPE=${SSL_TYPE_STR} -DSSL_PATH=${SSL_PATH_STR} -DSSL_INC_PATH=${SSL_INC_PATH_STR} -DSSL_LIB_PATH=${SSL_LIB_PATH_STR} ..
cmake -DGCOV=on -DCMAKE_BUILD_TYPE=Debug -DXQC_ENABLE_TESTING=1 -DXQC_PRINT_SECRET=1 -DXQC_SUPPORT_SENDMMSG_BUILD=1 -DXQC_ENABLE_EVENT_LOG=1 -DXQC_ENABLE_BBR2=1 -DXQC_ENABLE_RENO=1 -DSSL_TYPE=${SSL_TYPE_STR} -DSSL_PATH=${SSL_PATH_STR} -DXQC_ENABLE_UNLIMITED=1 -DXQC_ENABLE_COPA=1 -DXQC_COMPAT_DUPLICATE=1 -DXQC_ENABLE_FEC=1 -DXQC_ENABLE_XOR=1 -DXQC_ENABLE_RSC=1 ..
make -j

- name: Perform CodeQL Analysis
Expand Down
40 changes: 36 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ option (XQC_ENABLE_UNLIMITED "enable unlimited cc" OFF)
option (XQC_ENABLE_MP_INTEROP "enable MPQUIC interop" OFF)
option (XQC_NO_PID_PACKET_PROCESS "do not expose path_id in xqc_engine_packet_process" OFF)
option (XQC_PROTECT_POOL_MEM "enable write protection for pool memory (for debug)" OFF)
option (XQC_COMPAT_DUPLICATE "qpack compat dup" OFF)
option (XQC_ENABLE_FEC "enable fec" OFF)
option (XQC_ENABLE_XOR "enable fec scheme xor" OFF)
option (XQC_ENABLE_RSC "enable fec scheme reed-solomon code" OFF)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
Expand Down Expand Up @@ -133,10 +137,6 @@ if(XQC_PRINT_SECRET)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXQC_PRINT_SECRET")
endif()

# compat with the duplicate instruction of HTTP/3 module before version v1.1.0
if(XQC_COMPAT_DUPLICATE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXQC_COMPAT_DUPLICATE")
endif()

# compat with the stateless reset before version v1.6.0
if(XQC_COMPAT_GENERATE_SR_PKT)
Expand Down Expand Up @@ -238,6 +238,38 @@ if(XQC_ENABLE_MP_INTEROP)
)
endif()

# fec framework
set(
FEC_FRAMEWORK_SOURCE
"src/transport/xqc_fec.c"
"src/transport/xqc_fec_scheme.c"
"src/transport/fec_schemes/xqc_galois_calculation.c"
)

if(XQC_ENABLE_XOR)
set(
FEC_FRAMEWORK_SOURCE
${FEC_FRAMEWORK_SOURCE}
"src/transport/fec_schemes/xqc_xor.c"
)
endif()

if(XQC_ENABLE_RSC)
set(
FEC_FRAMEWORK_SOURCE
${FEC_FRAMEWORK_SOURCE}
"src/transport/fec_schemes/xqc_reed_solomon.c"
)
endif()

if(XQC_ENABLE_FEC)
set(
TRANSPORT_SOURCES
${TRANSPORT_SOURCES}
${FEC_FRAMEWORK_SOURCE}
)
endif()

# TLS source
set (
TLS_SOURCE
Expand Down
33 changes: 33 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,39 @@ if(XQC_ENABLE_MP_INTEROP)
)
endif()


# fec framework
set(
FEC_FRAMEWORK_SOURCE
"src/transport/xqc_fec.c"
"src/transport/xqc_fec_scheme.c"
"src/transport/fec_schemes/xqc_galois_calculation.c"
)

if(XQC_ENABLE_XOR)
set(
FEC_FRAMEWORK_SOURCE
${FEC_FRAMEWORK_SOURCE}
"src/transport/fec_schemes/xqc_xor.c"
)
endif()

if(XQC_ENABLE_RSC)
set(
FEC_FRAMEWORK_SOURCE
${FEC_FRAMEWORK_SOURCE}
"src/transport/fec_schemes/xqc_reed_solomon.c"
)
endif()

if(XQC_ENABLE_FEC)
set(
TRANSPORT_SOURCES
${TRANSPORT_SOURCES}
${FEC_FRAMEWORK_SOURCE}
)
endif()

# TLS source
set (
TLS_SOURCE
Expand Down
28 changes: 25 additions & 3 deletions demo/demo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,24 @@ xqc_demo_cli_write_log_file(xqc_log_level_t lvl, const void *buf, size_t size, v
}
}

void
xqc_demo_cli_write_qlog_file(qlog_event_importance_t imp, const void *buf, size_t size, void *engine_user_data)
{
xqc_demo_cli_ctx_t *ctx = (xqc_demo_cli_ctx_t*)engine_user_data;
if (ctx->log_fd <= 0) {
return;
}
int write_len = write(ctx->log_fd, buf, size);
if (write_len < 0) {
printf("write qlog failed, errno: %d\n", get_sys_errno());
return;
}
write_len = write(ctx->log_fd, line_break, 1);
if (write_len < 0) {
printf("write qlog failed, errno: %d\n", get_sys_errno());
}
}


int
xqc_demo_cli_open_keylog_file(xqc_demo_cli_ctx_t *ctx)
Expand Down Expand Up @@ -2314,7 +2332,8 @@ xqc_demo_cli_init_callback(xqc_engine_callback_t *cb, xqc_transport_callbacks_t
static xqc_engine_callback_t callback = {
.log_callbacks = {
.xqc_log_write_err = xqc_demo_cli_write_log_file,
.xqc_log_write_stat = xqc_demo_cli_write_log_file
.xqc_log_write_stat = xqc_demo_cli_write_log_file,
.xqc_qlog_event_write = xqc_demo_cli_write_qlog_file,
},
.keylog_cb = xqc_demo_cli_keylog_cb,
.set_event_timer = xqc_demo_cli_set_event_timer,
Expand Down Expand Up @@ -2461,12 +2480,15 @@ xqc_demo_cli_init_xquic_connection(xqc_demo_cli_user_conn_t *user_conn,
memcpy(&user_conn->cid, cid, sizeof(xqc_cid_t));

} else {
user_conn->hqc_handle = xqc_hq_connect(user_conn->ctx->engine, &conn_settings,
const xqc_cid_t *cid = xqc_hq_connect(user_conn->ctx->engine, &conn_settings,
args->quic_cfg.token, args->quic_cfg.token_len, args->net_cfg.host, args->quic_cfg.no_encryption, &conn_ssl_config,
(struct sockaddr*)&args->net_cfg.addr, args->net_cfg.addr_len, user_conn);
if (user_conn->hqc_handle == NULL) {

if (cid == NULL) {
return -1;
}

memcpy(&user_conn->cid, cid, sizeof(xqc_cid_t));
}

if (conn_settings.enable_multipath
Expand Down
31 changes: 25 additions & 6 deletions demo/demo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ xqc_demo_svr_write_log_file(xqc_log_level_t lvl, const void *buf, size_t size, v
}
}

void
xqc_demo_svr_write_qlog_file(qlog_event_importance_t imp, const void *buf, size_t size, void *eng_user_data)
{
xqc_demo_svr_ctx_t *ctx = (xqc_demo_svr_ctx_t*)eng_user_data;
if (ctx->log_fd <= 0) {
return;
}

int write_len = write(ctx->log_fd, buf, size);
if (write_len < 0) {
printf("write qlog failed, errno: %d\n", get_sys_errno());
return;
}
write_len = write(ctx->log_fd, line_break, 1);
if (write_len < 0) {
printf("write qlog failed, errno: %d\n", get_sys_errno());
}
}

/**
* start of server keylog functions
Expand Down Expand Up @@ -1398,7 +1416,8 @@ xqc_demo_svr_init_callback(xqc_engine_callback_t *cb, xqc_transport_callbacks_t
.set_event_timer = xqc_demo_svr_set_event_timer,
.log_callbacks = {
.xqc_log_write_err = xqc_demo_svr_write_log_file,
.xqc_log_write_stat = xqc_demo_svr_write_log_file
.xqc_log_write_stat = xqc_demo_svr_write_log_file,
.xqc_qlog_event_write = xqc_demo_svr_write_qlog_file
},
.keylog_cb = xqc_demo_svr_keylog_cb,
};
Expand Down Expand Up @@ -1446,7 +1465,7 @@ xqc_demo_svr_init_ssl_config(xqc_engine_ssl_config_t *cfg, xqc_demo_svr_args_t *
}

void
xqc_demo_svr_init_conn_settings(xqc_demo_svr_args_t *args)
xqc_demo_svr_init_conn_settings(xqc_engine_t *engine, xqc_demo_svr_args_t *args)
{
xqc_cong_ctrl_callback_t ccc = {0};
switch (args->net_cfg.cc) {
Expand Down Expand Up @@ -1509,7 +1528,7 @@ xqc_demo_svr_init_conn_settings(xqc_demo_svr_args_t *args)
.anti_amplification_limit = 3,
};

xqc_server_set_conn_settings(&conn_settings);
xqc_server_set_conn_settings(engine, &conn_settings);
}


Expand Down Expand Up @@ -1576,9 +1595,6 @@ xqc_demo_svr_init_xquic_engine(xqc_demo_svr_ctx_t *ctx, xqc_demo_svr_args_t *arg
xqc_transport_callbacks_t transport_cbs;
xqc_demo_svr_init_callback(&callback, &transport_cbs, args);

/* init server connection settings */
xqc_demo_svr_init_conn_settings(args);

/* init engine config */
xqc_config_t config;
if (xqc_engine_get_default_config(&config, XQC_ENGINE_CLIENT) < 0) {
Expand Down Expand Up @@ -1613,6 +1629,9 @@ xqc_demo_svr_init_xquic_engine(xqc_demo_svr_ctx_t *ctx, xqc_demo_svr_args_t *arg
return -1;
}

/* init server connection settings */
xqc_demo_svr_init_conn_settings(ctx->engine, args);

if (xqc_demo_svr_init_alpn_ctx(ctx) < 0) {
printf("init alpn ctx error!");
return -1;
Expand Down
2 changes: 1 addition & 1 deletion demo/xqc_hq.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ xqc_hq_ctx_destroy(xqc_engine_t *engine);
* @brief hq connection functions
*/

xqc_hq_conn_t *
const xqc_cid_t *
xqc_hq_connect(xqc_engine_t *engine, const xqc_conn_settings_t *conn_settings,
const unsigned char *token, unsigned token_len, const char *server_host, int no_crypto_flag,
const xqc_conn_ssl_config_t *conn_ssl_config, const struct sockaddr *peer_addr,
Expand Down
63 changes: 16 additions & 47 deletions demo/xqc_hq_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
#include "src/transport/xqc_conn.h"


typedef struct xqc_hq_conn_s {
xqc_hq_conn_callbacks_t *hqc_cbs;

xqc_connection_t *conn;

xqc_log_t *log;

void *user_data;

} xqc_hq_conn_s;


xqc_hq_conn_t *
xqc_hq_conn_create(xqc_connection_t *conn, const xqc_cid_t *cid, void *user_data)
{
Expand All @@ -31,7 +19,12 @@ xqc_hq_conn_create(xqc_connection_t *conn, const xqc_cid_t *cid, void *user_data
return NULL;
}

if (xqc_hq_ctx_get_conn_callbacks(&hqc->hqc_cbs) != XQC_OK) {
xqc_hq_callbacks_t *hq_cbs = NULL;
xqc_int_t ret;

ret = xqc_hq_ctx_get_callbacks(conn->engine, conn->alpn, conn->alpn_len, &hq_cbs);

if (ret != XQC_OK || hq_cbs == NULL) {
PRINT_LOG("|create hq conn failed");
xqc_free(hqc);
return NULL;
Expand All @@ -40,6 +33,10 @@ xqc_hq_conn_create(xqc_connection_t *conn, const xqc_cid_t *cid, void *user_data
hqc->user_data = user_data;
hqc->log = conn->log;
hqc->conn = conn;
hqc->hqc_cbs = hq_cbs->hqc_cbs;
hqc->hqr_cbs = hq_cbs->hqr_cbs;

xqc_conn_set_alp_user_data(conn, hqc);

return hqc;
}
Expand All @@ -53,22 +50,7 @@ xqc_hq_conn_destroy(xqc_hq_conn_t *hqc)
}
}


xqc_hq_conn_t *
xqc_hq_conn_create_passive(xqc_connection_t *conn, const xqc_cid_t *cid)
{
xqc_hq_conn_t *hqc = xqc_hq_conn_create(conn, cid, NULL);
if (NULL == hqc) {
PRINT_LOG("|create hq conn failed");
return NULL;
}

xqc_conn_set_alp_user_data(conn, hqc);
return hqc;
}


xqc_hq_conn_t *
const xqc_cid_t*
xqc_hq_connect(xqc_engine_t *engine, const xqc_conn_settings_t *conn_settings,
const unsigned char *token, unsigned token_len, const char *server_host, int no_crypto_flag,
const xqc_conn_ssl_config_t *conn_ssl_config, const struct sockaddr *peer_addr,
Expand All @@ -78,18 +60,8 @@ xqc_hq_connect(xqc_engine_t *engine, const xqc_conn_settings_t *conn_settings,
const xqc_cid_t *cid = xqc_connect(engine, conn_settings, token, token_len, server_host,
no_crypto_flag, conn_ssl_config, peer_addr, peer_addrlen,
xqc_hq_alpn[conn_settings->proto_version], user_data);
if (cid == NULL) {
return NULL;
}

xqc_hq_conn_t *hqc = xqc_hq_conn_create(xqc_engine_conns_hash_find(engine, cid, 's'),
cid, user_data);
if (NULL == hqc) {
xqc_conn_close(engine, cid);
return NULL;
}

return hqc;
return cid;
}


Expand Down Expand Up @@ -125,12 +97,9 @@ xqc_hq_conn_create_notify(xqc_connection_t *conn, const xqc_cid_t *cid,
return -XQC_EMALLOC;
}

/* set hqc as conn's application-layer-protocol user_data */
xqc_conn_set_alp_user_data(conn, hqc);

if (hqc->hqc_cbs->conn_create_notify) {
if (hqc->hqc_cbs.conn_create_notify) {
/* NOTICE: if hqc is created passively, hqc->user_data is NULL */
return hqc->hqc_cbs->conn_create_notify(hqc, cid, hqc->user_data);
return hqc->hqc_cbs.conn_create_notify(hqc, cid, hqc->user_data);
}

return XQC_OK;
Expand All @@ -143,8 +112,8 @@ xqc_hq_conn_close_notify(xqc_connection_t *conn, const xqc_cid_t *cid,
xqc_int_t ret = XQC_OK;

xqc_hq_conn_t *hqc = (xqc_hq_conn_t *)conn_proto_data;
if (hqc->hqc_cbs->conn_close_notify) {
ret = hqc->hqc_cbs->conn_close_notify(hqc, cid, hqc->user_data);
if (hqc->hqc_cbs.conn_close_notify) {
ret = hqc->hqc_cbs.conn_close_notify(hqc, cid, hqc->user_data);
if (ret != XQC_OK) {
return ret;
}
Expand Down
13 changes: 13 additions & 0 deletions demo/xqc_hq_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

#include "xqc_hq.h"

typedef struct xqc_hq_conn_s {

xqc_hq_conn_callbacks_t hqc_cbs;
xqc_hq_request_callbacks_t hqr_cbs;

xqc_connection_t *conn;

xqc_log_t *log;

void *user_data;

} xqc_hq_conn_s;

extern const xqc_conn_callbacks_t hq_conn_callbacks;

#endif
Loading
Loading