Mercurial > hg > nginx
diff src/event/ngx_event_quic_transport.c @ 8531: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 |
line wrap: on
line diff
--- a/src/event/ngx_event_quic_transport.c Tue Aug 25 17:22:57 2020 +0300 +++ b/src/event/ngx_event_quic_transport.c Fri Aug 28 12:01:35 2020 +0300 @@ -84,6 +84,8 @@ ngx_quic_max_stream_data_frame_t *ms); static size_t ngx_quic_create_max_data(u_char *p, 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_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, @@ -1004,13 +1006,9 @@ goto error; } - ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, - "quic frame in: PATH_CHALLENGE"); - -#ifdef NGX_QUIC_DEBUG_FRAMES - ngx_quic_hexdump(pkt->log, "quic PATH_CHALLENGE frame data", - f->u.path_challenge.data, 8); -#endif + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, + "quic frame in: PATH_CHALLENGE data:0x%xL", + *(uint64_t *) &f->u.path_challenge.data); break; case NGX_QUIC_FT_PATH_RESPONSE: @@ -1020,13 +1018,9 @@ goto error; } - ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, - "quic frame in: PATH_RESPONSE"); - -#ifdef NGX_QUIC_DEBUG_FRAMES - ngx_quic_hexdump(pkt->log, "quic PATH_RESPONSE frame data", - f->u.path_response.data, 8); -#endif + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, + "quic frame in: PATH_RESPONSE data:0x%xL", + *(uint64_t *) &f->u.path_response.data); break; default: @@ -1203,6 +1197,9 @@ case NGX_QUIC_FT_MAX_DATA: return ngx_quic_create_max_data(p, &f->u.max_data); + case NGX_QUIC_FT_PATH_RESPONSE: + return ngx_quic_create_path_response(p, &f->u.path_response); + default: /* BUG: unsupported frame type generated */ return NGX_ERROR; @@ -1661,6 +1658,27 @@ } +static size_t +ngx_quic_create_path_response(u_char *p, ngx_quic_path_challenge_frame_t *pc) +{ + size_t len; + u_char *start; + + if (p == NULL) { + len = ngx_quic_varint_len(NGX_QUIC_FT_PATH_RESPONSE); + len += sizeof(pc->data); + return len; + } + + start = p; + + ngx_quic_build_int(&p, NGX_QUIC_FT_PATH_RESPONSE); + p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); + + return p - start; +} + + ssize_t ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, size_t *clen)