Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 7953:e0f92f68e018 quic
QUIC: Introduced ngx_quic_finalize_connection().
The function finalizes QUIC connection with an application protocol error
code and sends a CONNECTION_CLOSE frame with type=0x1d.
Also, renamed NGX_QUIC_FT_CONNECTION_CLOSE2 to NGX_QUIC_FT_CONNECTION_CLOSE_APP.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 02 Jul 2020 16:33:59 +0300 |
parents | 97adb87f149b |
children | 0d1ad81dd65c |
comparison
equal
deleted
inserted
replaced
7952:a7f64438aa3c | 7953:e0f92f68e018 |
---|---|
724 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 724 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
725 "quic frame in: NCID seq:%ui retire:%ui len:%ui", | 725 "quic frame in: NCID seq:%ui retire:%ui len:%ui", |
726 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); | 726 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); |
727 break; | 727 break; |
728 | 728 |
729 case NGX_QUIC_FT_CONNECTION_CLOSE2: | |
730 /* fall through */ | |
731 | |
732 case NGX_QUIC_FT_CONNECTION_CLOSE: | 729 case NGX_QUIC_FT_CONNECTION_CLOSE: |
730 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: | |
733 | 731 |
734 p = ngx_quic_parse_int(p, end, &f->u.close.error_code); | 732 p = ngx_quic_parse_int(p, end, &f->u.close.error_code); |
735 if (p == NULL) { | 733 if (p == NULL) { |
736 goto error; | 734 goto error; |
737 } | 735 } |
765 f->u.close.error_code, f->u.close.frame_type, | 763 f->u.close.error_code, f->u.close.frame_type, |
766 &f->u.close.reason); | 764 &f->u.close.reason); |
767 } else { | 765 } else { |
768 | 766 |
769 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 767 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
770 "quic frame in: CONNECTION_CLOSE2:" | 768 "quic frame in: CONNECTION_CLOSE_APP:" |
771 " code:0x%xi reason:'%V'", | 769 " code:0x%xi reason:'%V'", |
772 f->u.close.error_code, &f->u.close.reason); | 770 f->u.close.error_code, &f->u.close.reason); |
773 } | 771 } |
774 | 772 |
775 break; | 773 break; |
1172 case NGX_QUIC_FT_STREAM6: | 1170 case NGX_QUIC_FT_STREAM6: |
1173 case NGX_QUIC_FT_STREAM7: | 1171 case NGX_QUIC_FT_STREAM7: |
1174 return ngx_quic_create_stream(p, &f->u.stream); | 1172 return ngx_quic_create_stream(p, &f->u.stream); |
1175 | 1173 |
1176 case NGX_QUIC_FT_CONNECTION_CLOSE: | 1174 case NGX_QUIC_FT_CONNECTION_CLOSE: |
1175 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: | |
1177 f->need_ack = 0; | 1176 f->need_ack = 0; |
1178 return ngx_quic_create_close(p, &f->u.close); | 1177 return ngx_quic_create_close(p, &f->u.close); |
1179 | 1178 |
1180 case NGX_QUIC_FT_MAX_STREAMS: | 1179 case NGX_QUIC_FT_MAX_STREAMS: |
1181 return ngx_quic_create_max_streams(p, &f->u.max_streams); | 1180 return ngx_quic_create_max_streams(p, &f->u.max_streams); |
1740 | 1739 |
1741 | 1740 |
1742 static size_t | 1741 static size_t |
1743 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) | 1742 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) |
1744 { | 1743 { |
1745 size_t len; | 1744 size_t len; |
1746 u_char *start; | 1745 u_char *start; |
1747 | 1746 ngx_uint_t type; |
1748 if (p == NULL) { | 1747 |
1749 len = ngx_quic_varint_len(NGX_QUIC_FT_CONNECTION_CLOSE); | 1748 type = cl->app ? NGX_QUIC_FT_CONNECTION_CLOSE_APP |
1749 : NGX_QUIC_FT_CONNECTION_CLOSE; | |
1750 | |
1751 if (p == NULL) { | |
1752 len = ngx_quic_varint_len(type); | |
1750 len += ngx_quic_varint_len(cl->error_code); | 1753 len += ngx_quic_varint_len(cl->error_code); |
1751 len += ngx_quic_varint_len(cl->frame_type); | 1754 |
1755 if (!cl->app) { | |
1756 len += ngx_quic_varint_len(cl->frame_type); | |
1757 } | |
1758 | |
1752 len += ngx_quic_varint_len(cl->reason.len); | 1759 len += ngx_quic_varint_len(cl->reason.len); |
1753 len += cl->reason.len; | 1760 len += cl->reason.len; |
1754 | 1761 |
1755 return len; | 1762 return len; |
1756 } | 1763 } |
1757 | 1764 |
1758 start = p; | 1765 start = p; |
1759 | 1766 |
1760 ngx_quic_build_int(&p, NGX_QUIC_FT_CONNECTION_CLOSE); | 1767 ngx_quic_build_int(&p, type); |
1761 ngx_quic_build_int(&p, cl->error_code); | 1768 ngx_quic_build_int(&p, cl->error_code); |
1762 ngx_quic_build_int(&p, cl->frame_type); | 1769 |
1770 if (!cl->app) { | |
1771 ngx_quic_build_int(&p, cl->frame_type); | |
1772 } | |
1773 | |
1763 ngx_quic_build_int(&p, cl->reason.len); | 1774 ngx_quic_build_int(&p, cl->reason.len); |
1764 p = ngx_cpymem(p, cl->reason.data, cl->reason.len); | 1775 p = ngx_cpymem(p, cl->reason.data, cl->reason.len); |
1765 | 1776 |
1766 return p - start; | 1777 return p - start; |
1767 } | 1778 } |