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

[+] QUIC datagram (RFC9221), sending datagrams and bytestreams on http3 connections (non-standard extensions), and bugfix #307

Merged
merged 7 commits into from
May 24, 2023
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
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ set(
"src/http3/qpack/xqc_ins.c"
"src/http3/qpack/stable/xqc_stable.c"
"src/http3/qpack/dtable/xqc_dtable.c"
"src/http3/xqc_h3_ext_dgram.c"
"src/http3/xqc_h3_ext_bytestream.c"
)

# Transport source
Expand All @@ -160,6 +162,7 @@ set(
"src/transport/xqc_packet_parser.c"
"src/transport/xqc_frame_parser.c"
"src/transport/xqc_stream.c"
"src/transport/xqc_datagram.c"
"src/transport/xqc_packet_out.c"
"src/transport/xqc_packet_in.c"
"src/transport/xqc_send_ctl.c"
Expand Down Expand Up @@ -233,6 +236,8 @@ set(
CONGESTION_CONTROL_SOURCES
"src/congestion_control/xqc_cubic.c"
"src/congestion_control/xqc_bbr.c"
"src/congestion_control/xqc_unlimited_cc.c"
"src/congestion_control/xqc_copa.c"
"src/congestion_control/xqc_window_filter.c"
"src/congestion_control/xqc_sample.c"
)
Expand All @@ -259,7 +264,7 @@ endif()

# xquic source
set (
XQC_SOURCE
XQC_SOURCE
${HTTP3_SOURCES}
${TRANSPORT_SOURCES}
${TLS_SOURCE}
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ In no particular order, thanks to these excellent individuals who contributed co
* 曾柯(毅丝)
* 徐盟欣(象谦)
* Bai Shi(白石)
* 周瑞琪(凼凼)
* @chinsyo
* @L1MeN9Yu
* @flx413
Expand Down
5 changes: 5 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ set(
"src/http3/qpack/xqc_ins.c"
"src/http3/qpack/stable/xqc_stable.c"
"src/http3/qpack/dtable/xqc_dtable.c"
"src/http3/xqc_h3_ext_dgram.c"
"src/http3/xqc_h3_ext_bytestream.c"
)

# Transport source
Expand All @@ -161,6 +163,7 @@ set(
"src/transport/xqc_packet_parser.c"
"src/transport/xqc_frame_parser.c"
"src/transport/xqc_stream.c"
"src/transport/xqc_datagram.c"
"src/transport/xqc_packet_out.c"
"src/transport/xqc_packet_in.c"
"src/transport/xqc_send_ctl.c"
Expand Down Expand Up @@ -234,6 +237,8 @@ set(
CONGESTION_CONTROL_SOURCES
"src/congestion_control/xqc_cubic.c"
"src/congestion_control/xqc_bbr.c"
"src/congestion_control/xqc_unlimited_cc.c"
"src/congestion_control/xqc_copa.c"
"src/congestion_control/xqc_window_filter.c"
"src/congestion_control/xqc_sample.c"
)
Expand Down
10 changes: 9 additions & 1 deletion demo/demo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ xqc_demo_cli_close_keylog_file(xqc_demo_cli_ctx_t *ctx)
}

void
xqc_demo_cli_keylog_cb(const char *line, void *engine_user_data)
xqc_demo_cli_keylog_cb(const xqc_cid_t *scid, const char *line, void *engine_user_data)
{
xqc_demo_cli_ctx_t *ctx = (xqc_demo_cli_ctx_t*)engine_user_data;
if (ctx->keylog_fd <= 0) {
Expand Down Expand Up @@ -585,6 +585,13 @@ xqc_demo_cli_write_socket(const unsigned char *buf, size_t size, const struct so
return res;
}

ssize_t
xqc_demo_cli_write_socket_ex(uint64_t path_id, const unsigned char *buf, size_t size,
const struct sockaddr *peer_addr, socklen_t peer_addrlen, void *conn_user_data)
{
return xqc_demo_cli_write_socket(buf, size, peer_addr, peer_addrlen, conn_user_data);
}


#if defined(XQC_SUPPORT_SENDMMSG)
ssize_t
Expand Down Expand Up @@ -1638,6 +1645,7 @@ xqc_demo_cli_init_callback(xqc_engine_callback_t *cb, xqc_transport_callbacks_t

static xqc_transport_callbacks_t tcb = {
.write_socket = xqc_demo_cli_write_socket,
.write_socket_ex = xqc_demo_cli_write_socket_ex,
.save_token = xqc_demo_cli_save_token, /* save token */
.save_session_cb = xqc_demo_cli_save_session_cb,
.save_tp_cb = xqc_demo_cli_save_tp_cb,
Expand Down
11 changes: 10 additions & 1 deletion demo/demo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ int
xqc_demo_svr_open_keylog_file(xqc_demo_svr_ctx_t *ctx)
{
ctx->keylog_fd = open(ctx->args->env_cfg.key_out_path, (O_WRONLY | O_APPEND | O_CREAT), 0644);
printf("%s %d\n", ctx->args->env_cfg.key_out_path, ctx->keylog_fd);
if (ctx->keylog_fd <= 0) {
return -1;
}
Expand All @@ -295,7 +296,7 @@ xqc_demo_svr_close_keylog_file(xqc_demo_svr_ctx_t *ctx)
}

void
xqc_demo_svr_keylog_cb(const char *line, void *eng_user_data)
xqc_demo_svr_keylog_cb(const xqc_cid_t *scid, const char *line, void *eng_user_data)
{
xqc_demo_svr_ctx_t *ctx = (xqc_demo_svr_ctx_t*)eng_user_data;
if (ctx->keylog_fd <= 0) {
Expand Down Expand Up @@ -928,6 +929,12 @@ xqc_demo_svr_write_socket(const unsigned char *buf, size_t size, const struct so
return res;
}

ssize_t
xqc_demo_svr_write_socket_ex(uint64_t path_id, const unsigned char *buf, size_t size,
const struct sockaddr *peer_addr,socklen_t peer_addrlen, void *conn_user_data)
{
return xqc_demo_svr_write_socket(buf, size, peer_addr, peer_addrlen, conn_user_data);
}

void
xqc_demo_svr_socket_write_handler(xqc_demo_svr_ctx_t *ctx, int fd)
Expand Down Expand Up @@ -1136,6 +1143,7 @@ xqc_demo_svr_init_args(xqc_demo_svr_args_t *args)
args->env_cfg.log_level = XQC_LOG_DEBUG;
strncpy(args->env_cfg.log_path, LOG_PATH, TLS_GROUPS_LEN - 1);
strncpy(args->env_cfg.source_file_dir, SOURCE_DIR, RESOURCE_LEN - 1);
strncpy(args->env_cfg.key_out_path, KEY_PATH, PATH_LEN - 1);
strncpy(args->env_cfg.priv_key_path, PRIV_KEY_PATH, PATH_LEN - 1);
strncpy(args->env_cfg.cert_pem_path, CERT_PEM_PATH, PATH_LEN - 1);
}
Expand Down Expand Up @@ -1239,6 +1247,7 @@ xqc_demo_svr_init_callback(xqc_engine_callback_t *cb, xqc_transport_callbacks_t
static xqc_transport_callbacks_t tcb = {
.server_accept = xqc_demo_svr_accept,
.write_socket = xqc_demo_svr_write_socket,
.write_socket_ex = xqc_demo_svr_write_socket_ex,
.conn_update_cid_notify = xqc_demo_svr_conn_update_cid_notify,
};

Expand Down
11 changes: 10 additions & 1 deletion include/xquic/xqc_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef enum {
TRA_INVALID_TOKEN = 0xB,
TRA_APPLICATION_ERROR = 0xC,
TRA_CRYPTO_BUFFER_EXCEEDED = 0xD,
TRA_0RTT_TRANS_PARAMS_ERROR = 0xE, /* MUST delete the current saved 0RTT transport parameters */
TRA_HS_CERTIFICATE_VERIFY_FAIL = 0x1FE, /* for handshake certificate verify error */
TRA_CRYPTO_ERROR = 0x1FF, /* 0x1XX */
} xqc_trans_err_code_t;
Expand Down Expand Up @@ -121,7 +122,10 @@ typedef enum {

XQC_EENCRYPT_LB_CID = 670, /* load balance connection ID encryption error */
XQC_EENCRYPT_AES_128_ECB = 671, /* aes_128_ecb algorithm error */


XQC_EDGRAM_NOT_SUPPORTED = 680, /* Datagram - not supported */
XQC_EDGRAM_TOO_LARGE = 681, /* Datagram - payload size too large */

XQC_E_MAX,
} xqc_transport_error_t;

Expand Down Expand Up @@ -216,6 +220,11 @@ typedef enum {
XQC_H3_BLOCKED_STREAM_EXCEED = 825, /* blocked_stream exceed limit */
XQC_H3_STREAM_RECV_ERROR = 826, /* call xqc_stream_recv error */
XQC_H3_INVALID_PRIORITY = 827, /* invalid http priority params or values */
XQC_H3_INVALID_BIDI_STREAM_TYPE = 828, /* invalid bidi stream type */
XQC_H3_ECREATE_BYTESTREAM = 829, /* fail to create a bytestream */
XQC_H3_EPROC_BYTESTREAM = 830, /* fail to process bytestream */
XQC_H3_BYTESTREAM_FIN_SENT = 831, /* try to send data on a bytestream that already sent FIN */
XQC_H3_BYTESTREAM_MSG_BUF_EXIST = 832, /* try to create a msg buf while it already exists */

XQC_H3_ERR_MAX,
} xqc_h3_error_t;
Expand Down
Loading