Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 8076: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 |
comparison
equal
deleted
inserted
replaced
8075:88676e7f4449 | 8076:3afaaaa930ab |
---|---|
84 ngx_quic_max_stream_data_frame_t *ms); | 84 ngx_quic_max_stream_data_frame_t *ms); |
85 static size_t ngx_quic_create_max_data(u_char *p, | 85 static size_t ngx_quic_create_max_data(u_char *p, |
86 ngx_quic_max_data_frame_t *md); | 86 ngx_quic_max_data_frame_t *md); |
87 static size_t ngx_quic_create_path_response(u_char *p, | 87 static size_t ngx_quic_create_path_response(u_char *p, |
88 ngx_quic_path_challenge_frame_t *pc); | 88 ngx_quic_path_challenge_frame_t *pc); |
89 static size_t ngx_quic_create_retire_connection_id(u_char *p, | |
90 ngx_quic_retire_cid_frame_t *rcid); | |
89 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); | 91 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); |
90 | 92 |
91 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, | 93 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, |
92 uint16_t id, ngx_quic_tp_t *dst); | 94 uint16_t id, ngx_quic_tp_t *dst); |
93 | 95 |
729 p = ngx_quic_parse_int(p, end, &f->u.ncid.retire); | 731 p = ngx_quic_parse_int(p, end, &f->u.ncid.retire); |
730 if (p == NULL) { | 732 if (p == NULL) { |
731 goto error; | 733 goto error; |
732 } | 734 } |
733 | 735 |
736 if (f->u.ncid.retire > f->u.ncid.seqnum) { | |
737 goto error; | |
738 } | |
739 | |
734 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); | 740 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); |
735 if (p == NULL) { | 741 if (p == NULL) { |
736 goto error; | 742 goto error; |
737 } | 743 } |
738 | 744 |
745 if (f->u.ncid.len < 1 || f->u.ncid.len > NGX_QUIC_CID_LEN_MAX) { | |
746 goto error; | |
747 } | |
748 | |
739 p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid); | 749 p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid); |
740 if (p == NULL) { | 750 if (p == NULL) { |
741 goto error; | 751 goto error; |
742 } | 752 } |
743 | 753 |
744 p = ngx_quic_copy_bytes(p, end, 16, f->u.ncid.srt); | 754 p = ngx_quic_copy_bytes(p, end, NGX_QUIC_SRT_LEN, f->u.ncid.srt); |
745 if (p == NULL) { | 755 if (p == NULL) { |
746 goto error; | 756 goto error; |
747 } | 757 } |
748 | 758 |
749 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 759 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
1198 return ngx_quic_create_max_data(p, &f->u.max_data); | 1208 return ngx_quic_create_max_data(p, &f->u.max_data); |
1199 | 1209 |
1200 case NGX_QUIC_FT_PATH_RESPONSE: | 1210 case NGX_QUIC_FT_PATH_RESPONSE: |
1201 return ngx_quic_create_path_response(p, &f->u.path_response); | 1211 return ngx_quic_create_path_response(p, &f->u.path_response); |
1202 | 1212 |
1213 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: | |
1214 return ngx_quic_create_retire_connection_id(p, &f->u.retire_cid); | |
1215 | |
1203 default: | 1216 default: |
1204 /* BUG: unsupported frame type generated */ | 1217 /* BUG: unsupported frame type generated */ |
1205 return NGX_ERROR; | 1218 return NGX_ERROR; |
1206 } | 1219 } |
1207 } | 1220 } |
1677 | 1690 |
1678 return p - start; | 1691 return p - start; |
1679 } | 1692 } |
1680 | 1693 |
1681 | 1694 |
1695 static size_t | |
1696 ngx_quic_create_retire_connection_id(u_char *p, | |
1697 ngx_quic_retire_cid_frame_t *rcid) | |
1698 { | |
1699 size_t len; | |
1700 u_char *start; | |
1701 | |
1702 if (p == NULL) { | |
1703 len = ngx_quic_varint_len(NGX_QUIC_FT_RETIRE_CONNECTION_ID); | |
1704 len += ngx_quic_varint_len(rcid->sequence_number); | |
1705 return len; | |
1706 } | |
1707 | |
1708 start = p; | |
1709 | |
1710 ngx_quic_build_int(&p, NGX_QUIC_FT_RETIRE_CONNECTION_ID); | |
1711 ngx_quic_build_int(&p, rcid->sequence_number); | |
1712 | |
1713 return p - start; | |
1714 } | |
1715 | |
1716 | |
1682 ssize_t | 1717 ssize_t |
1683 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, | 1718 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, |
1684 size_t *clen) | 1719 size_t *clen) |
1685 { | 1720 { |
1686 u_char *p; | 1721 u_char *p; |