Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 8069:4ff2a0b747d1 quic
QUIC: handle PATH_CHALLENGE frame.
A PATH_RESPONSE frame with the same data is sent in response.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 28 Aug 2020 12:01:35 +0300 |
parents | 97da6521657c |
children | 62b58f0a4711 |
comparison
equal
deleted
inserted
replaced
8068:f882b1784f30 | 8069:4ff2a0b747d1 |
---|---|
82 ngx_quic_max_streams_frame_t *ms); | 82 ngx_quic_max_streams_frame_t *ms); |
83 static size_t ngx_quic_create_max_stream_data(u_char *p, | 83 static size_t ngx_quic_create_max_stream_data(u_char *p, |
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, | |
88 ngx_quic_path_challenge_frame_t *pc); | |
87 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); | 89 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); |
88 | 90 |
89 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, | 91 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, |
90 uint16_t id, ngx_quic_tp_t *dst); | 92 uint16_t id, ngx_quic_tp_t *dst); |
91 | 93 |
1002 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data); | 1004 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data); |
1003 if (p == NULL) { | 1005 if (p == NULL) { |
1004 goto error; | 1006 goto error; |
1005 } | 1007 } |
1006 | 1008 |
1007 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 1009 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
1008 "quic frame in: PATH_CHALLENGE"); | 1010 "quic frame in: PATH_CHALLENGE data:0x%xL", |
1009 | 1011 *(uint64_t *) &f->u.path_challenge.data); |
1010 #ifdef NGX_QUIC_DEBUG_FRAMES | |
1011 ngx_quic_hexdump(pkt->log, "quic PATH_CHALLENGE frame data", | |
1012 f->u.path_challenge.data, 8); | |
1013 #endif | |
1014 break; | 1012 break; |
1015 | 1013 |
1016 case NGX_QUIC_FT_PATH_RESPONSE: | 1014 case NGX_QUIC_FT_PATH_RESPONSE: |
1017 | 1015 |
1018 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data); | 1016 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data); |
1019 if (p == NULL) { | 1017 if (p == NULL) { |
1020 goto error; | 1018 goto error; |
1021 } | 1019 } |
1022 | 1020 |
1023 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 1021 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
1024 "quic frame in: PATH_RESPONSE"); | 1022 "quic frame in: PATH_RESPONSE data:0x%xL", |
1025 | 1023 *(uint64_t *) &f->u.path_response.data); |
1026 #ifdef NGX_QUIC_DEBUG_FRAMES | |
1027 ngx_quic_hexdump(pkt->log, "quic PATH_RESPONSE frame data", | |
1028 f->u.path_response.data, 8); | |
1029 #endif | |
1030 break; | 1024 break; |
1031 | 1025 |
1032 default: | 1026 default: |
1033 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | 1027 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
1034 "quic unknown frame type 0x%xi", f->type); | 1028 "quic unknown frame type 0x%xi", f->type); |
1201 return ngx_quic_create_max_stream_data(p, &f->u.max_stream_data); | 1195 return ngx_quic_create_max_stream_data(p, &f->u.max_stream_data); |
1202 | 1196 |
1203 case NGX_QUIC_FT_MAX_DATA: | 1197 case NGX_QUIC_FT_MAX_DATA: |
1204 return ngx_quic_create_max_data(p, &f->u.max_data); | 1198 return ngx_quic_create_max_data(p, &f->u.max_data); |
1205 | 1199 |
1200 case NGX_QUIC_FT_PATH_RESPONSE: | |
1201 return ngx_quic_create_path_response(p, &f->u.path_response); | |
1202 | |
1206 default: | 1203 default: |
1207 /* BUG: unsupported frame type generated */ | 1204 /* BUG: unsupported frame type generated */ |
1208 return NGX_ERROR; | 1205 return NGX_ERROR; |
1209 } | 1206 } |
1210 } | 1207 } |
1659 | 1656 |
1660 return p - start; | 1657 return p - start; |
1661 } | 1658 } |
1662 | 1659 |
1663 | 1660 |
1661 static size_t | |
1662 ngx_quic_create_path_response(u_char *p, ngx_quic_path_challenge_frame_t *pc) | |
1663 { | |
1664 size_t len; | |
1665 u_char *start; | |
1666 | |
1667 if (p == NULL) { | |
1668 len = ngx_quic_varint_len(NGX_QUIC_FT_PATH_RESPONSE); | |
1669 len += sizeof(pc->data); | |
1670 return len; | |
1671 } | |
1672 | |
1673 start = p; | |
1674 | |
1675 ngx_quic_build_int(&p, NGX_QUIC_FT_PATH_RESPONSE); | |
1676 p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); | |
1677 | |
1678 return p - start; | |
1679 } | |
1680 | |
1681 | |
1664 ssize_t | 1682 ssize_t |
1665 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, | 1683 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, |
1666 size_t *clen) | 1684 size_t *clen) |
1667 { | 1685 { |
1668 u_char *p; | 1686 u_char *p; |