Mercurial > hg > nginx
diff src/event/ngx_event_quic_transport.c @ 8538:3afaaaa930ab quic
QUIC: added support for multiple connection IDs.
The peer may issue additional connection IDs up to the limit defined by
transport parameter "active_connection_id_limit", using NEW_CONNECTION_ID
frames, and retire such IDs using RETIRE_CONNECTION_ID frame.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 03 Sep 2020 13:11:27 +0300 |
parents | 88676e7f4449 |
children | d3489d225f8f |
line wrap: on
line diff
--- a/src/event/ngx_event_quic_transport.c Thu Aug 27 10:15:37 2020 +0300 +++ b/src/event/ngx_event_quic_transport.c Thu Sep 03 13:11:27 2020 +0300 @@ -86,6 +86,8 @@ ngx_quic_max_data_frame_t *md); static size_t ngx_quic_create_path_response(u_char *p, ngx_quic_path_challenge_frame_t *pc); +static size_t ngx_quic_create_retire_connection_id(u_char *p, + ngx_quic_retire_cid_frame_t *rcid); static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, @@ -731,17 +733,25 @@ goto error; } + if (f->u.ncid.retire > f->u.ncid.seqnum) { + goto error; + } + p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); if (p == NULL) { goto error; } + if (f->u.ncid.len < 1 || f->u.ncid.len > NGX_QUIC_CID_LEN_MAX) { + goto error; + } + p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid); if (p == NULL) { goto error; } - p = ngx_quic_copy_bytes(p, end, 16, f->u.ncid.srt); + p = ngx_quic_copy_bytes(p, end, NGX_QUIC_SRT_LEN, f->u.ncid.srt); if (p == NULL) { goto error; } @@ -1200,6 +1210,9 @@ case NGX_QUIC_FT_PATH_RESPONSE: return ngx_quic_create_path_response(p, &f->u.path_response); + case NGX_QUIC_FT_RETIRE_CONNECTION_ID: + return ngx_quic_create_retire_connection_id(p, &f->u.retire_cid); + default: /* BUG: unsupported frame type generated */ return NGX_ERROR; @@ -1679,6 +1692,28 @@ } +static size_t +ngx_quic_create_retire_connection_id(u_char *p, + ngx_quic_retire_cid_frame_t *rcid) +{ + size_t len; + u_char *start; + + if (p == NULL) { + len = ngx_quic_varint_len(NGX_QUIC_FT_RETIRE_CONNECTION_ID); + len += ngx_quic_varint_len(rcid->sequence_number); + return len; + } + + start = p; + + ngx_quic_build_int(&p, NGX_QUIC_FT_RETIRE_CONNECTION_ID); + ngx_quic_build_int(&p, rcid->sequence_number); + + return p - start; +} + + ssize_t ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, size_t *clen)