Skip to content

Commit

Permalink
[+] add support for draft-12 transport param and new frame type
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanmei-Liu committed Jan 28, 2025
1 parent aaf82bb commit 167bf7a
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/xquic/xquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ typedef enum {
XQC_ERR_MULTIPATH_VERSION = 0x00,
XQC_MULTIPATH_10 = 0x0a,
XQC_MULTIPATH_11 = 0x0b,
XQC_MULTIPATH_12 = 0x0c,
} xqc_multipath_version_t;

typedef enum {
Expand Down
10 changes: 10 additions & 0 deletions src/transport/xqc_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ xqc_process_frames(xqc_connection_t *conn, xqc_packet_in_t *packet_in)
if (conn->conn_settings.multipath_version >= XQC_MULTIPATH_11) {
ret = xqc_process_path_blocked_frame(conn, packet_in);

} else {
xqc_log(conn->log, XQC_LOG_ERROR, "|mp_version error|v:%ud|f:%xL|",
conn->conn_settings.multipath_version, frame_type);
ret = -XQC_EMP_INVALID_MP_VERTION;
}
break;
case XQC_TRANS_FRAME_TYPE_PATH_CIDS_BLOCKED:
if (conn->conn_settings.multipath_version >= XQC_MULTIPATH_12) {
ret = xqc_process_path_blocked_frame(conn, packet_in);

} else {
xqc_log(conn->log, XQC_LOG_ERROR, "|mp_version error|v:%ud|f:%xL|",
conn->conn_settings.multipath_version, frame_type);
Expand Down
2 changes: 2 additions & 0 deletions src/transport/xqc_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum {
XQC_FRAME_MP_RETIRE_CONNECTION_ID,
XQC_FRAME_MAX_PATH_ID,
XQC_FRAME_PATH_BLOCKED,
XQC_FRAME_PATH_CIDS_BLOCKED,
XQC_FRAME_PATH_FROZEN,
XQC_FRAME_DATAGRAM,
XQC_FRAME_Extension,
Expand Down Expand Up @@ -75,6 +76,7 @@ typedef enum {
XQC_FRAME_BIT_MP_RETIRE_CONNECTION_ID = 1ULL << XQC_FRAME_MP_RETIRE_CONNECTION_ID,
XQC_FRAME_BIT_MAX_PATH_ID = 1ULL << XQC_FRAME_MAX_PATH_ID,
XQC_FRAME_BIT_PATH_BLOCKED = 1ULL << XQC_FRAME_PATH_BLOCKED,
XQC_FRAME_BIT_PATH_CIDS_BLOCKED = 1ULL << XQC_FRAME_PATH_CIDS_BLOCKED,
XQC_FRAME_BIT_PATH_FROZEN = 1ULL << XQC_FRAME_PATH_FROZEN,
XQC_FRAME_BIT_DATAGRAM = 1ULL << XQC_FRAME_DATAGRAM,
XQC_FRAME_BIT_Extension = 1ULL << XQC_FRAME_Extension,
Expand Down
60 changes: 60 additions & 0 deletions src/transport/xqc_frame_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3018,5 +3018,65 @@ xqc_parse_path_blocked_frame(xqc_packet_in_t *packet_in, uint64_t *max_path_id)

packet_in->pi_frame_types |= XQC_FRAME_BIT_PATH_BLOCKED;

return XQC_OK;
}



/*
*
* PATH_CIDS_BLOCKED Frame {
* Type (i) = TBD-09 (experiments use 0x15228c0e),
* Path Identifier (i),
* }
* Figure 11: PATH_CIDS_BLOCKED Frame Format
*
* */
ssize_t
xqc_gen_path_cids_blocked_frame(xqc_packet_out_t *packet_out, uint64_t path_id)
{
unsigned char *dst_buf = packet_out->po_buf + packet_out->po_used_size;
const unsigned char *begin = dst_buf;

/* write frame type */
uint64_t frame_type = XQC_TRANS_FRAME_TYPE_PATH_CIDS_BLOCKED;
unsigned frame_type_bits = xqc_vint_get_2bit(frame_type);
xqc_vint_write(dst_buf, frame_type, frame_type_bits, xqc_vint_len(frame_type_bits));
dst_buf += xqc_vint_len(frame_type_bits);

unsigned max_paths_bits = xqc_vint_get_2bit(path_id);
xqc_vint_write(dst_buf, path_id, max_paths_bits, xqc_vint_len(max_paths_bits));
dst_buf += xqc_vint_len(max_paths_bits);

packet_out->po_frame_types |= XQC_FRAME_BIT_PATH_CIDS_BLOCKED;

return dst_buf - begin;
}

xqc_int_t
xqc_parse_path_cids_blocked_frame(xqc_packet_in_t *packet_in, uint64_t *path_id)
{
unsigned char *p = packet_in->pos;
const unsigned char *end = packet_in->last;
int vlen;

/* frame type */
uint64_t frame_type = 0;
vlen = xqc_vint_read(p, end, &frame_type); /* get frame_type */
if (vlen < 0) {
return -XQC_EVINTREAD;
}
p += vlen;

vlen = xqc_vint_read(p, end, path_id);
if (vlen < 0) {
return -XQC_EVINTREAD;
}
p += vlen;

packet_in->pos = p;

packet_in->pi_frame_types |= XQC_FRAME_BIT_PATH_CIDS_BLOCKED;

return XQC_OK;
}
4 changes: 4 additions & 0 deletions src/transport/xqc_frame_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define XQC_TRANS_FRAME_TYPE_MP_RETIRE_CONN_ID 0x15228c0a
#define XQC_TRANS_FRAME_TYPE_MAX_PATH_ID 0x15228c0c
#define XQC_TRANS_FRAME_TYPE_PATH_BLOCKED 0x15228c0d
#define XQC_TRANS_FRAME_TYPE_PATH_CIDS_BLOCKED 0x15228c0e
#define XQC_TRANS_FRAME_TYPE_MP_FROZEN 0x15228cff

/**
Expand Down Expand Up @@ -182,5 +183,8 @@ xqc_int_t xqc_parse_max_path_id_frame(xqc_packet_in_t *packet_in, uint64_t *max_
ssize_t xqc_gen_path_blocked_frame(xqc_packet_out_t *packet_out, uint64_t max_path_id);
xqc_int_t xqc_parse_path_blocked_frame(xqc_packet_in_t *packet_in, uint64_t *max_path_id);

ssize_t xqc_gen_path_cids_blocked_frame(xqc_packet_out_t *packet_out, uint64_t path_id);
xqc_int_t xqc_parse_path_cids_blocked_frame(xqc_packet_in_t *packet_in, uint64_t *path_id);

void xqc_try_process_fec_decode(xqc_connection_t *conn, xqc_int_t block_id);
#endif /*_XQC_FRAME_PARSER_H_INCLUDED_*/
1 change: 1 addition & 0 deletions src/transport/xqc_multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ xqc_conn_is_current_mp_version_supported(xqc_multipath_version_t mp_version)
switch (mp_version) {
case XQC_MULTIPATH_10:
case XQC_MULTIPATH_11:
case XQC_MULTIPATH_12:
ret = XQC_OK;
break;
default:
Expand Down
13 changes: 13 additions & 0 deletions src/transport/xqc_transport_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ xqc_transport_params_calc_length(const xqc_transport_params_t *params,
len += xqc_put_varint_len(XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V11) +
xqc_put_varint_len(xqc_put_varint_len(params->init_max_path_id)) +
xqc_put_varint_len(params->init_max_path_id);

} else if (params->multipath_version == XQC_MULTIPATH_12) {
len += xqc_put_varint_len(XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V12) +
xqc_put_varint_len(xqc_put_varint_len(params->init_max_path_id)) +
xqc_put_varint_len(params->init_max_path_id);
}
}

Expand Down Expand Up @@ -399,6 +404,9 @@ xqc_encode_transport_params(const xqc_transport_params_t *params,

} else if (params->multipath_version == XQC_MULTIPATH_11) {
p = xqc_put_varint_param(p, XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V11, params->init_max_path_id);

} else if (params->multipath_version == XQC_MULTIPATH_12) {
p = xqc_put_varint_param(p, XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V12, params->init_max_path_id);
}
}

Expand Down Expand Up @@ -710,6 +718,11 @@ xqc_decode_enable_multipath(xqc_transport_params_t *params, xqc_transport_params
params->multipath_version = XQC_MULTIPATH_11;
XQC_DECODE_VINT_VALUE(&params->init_max_path_id, p, end);
return XQC_OK;
} else if (param_type == XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V12) {
params->enable_multipath = 1;
params->multipath_version = XQC_MULTIPATH_12;
XQC_DECODE_VINT_VALUE(&params->init_max_path_id, p, end);
return XQC_OK;
}
return XQC_OK;
}
Expand Down
1 change: 1 addition & 0 deletions src/transport/xqc_transport_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef enum {
/* multipath quic attributes */
XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V10 = 0x0f739bbc1b666d09,
XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V11 = 0x0f739bbc1b666d11,
XQC_TRANSPORT_PARAM_INIT_MAX_PATH_ID_V12 = 0x0f739bbc1b666d0c,

/* google connection options */
XQC_TRANSPORT_PARAM_GOOGLE_CO = 0x3128,
Expand Down

0 comments on commit 167bf7a

Please sign in to comment.