comparison src/event/quic/ngx_event_quic_transport.c @ 8285:0697294f79a4 quic

QUIC: removed redundant "app" flag from ngx_quic_close_frame_t. The flag was introduced to create type-aware CONNECTION_CLOSE frames, and now is replaced with frame type information, directly accessible. Notably, this fixes type logging for received frames in b3d9e57d0f62.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 03 Feb 2021 12:39:41 +0300
parents 3443ee341cc1
children 9ed95726b99b
comparison
equal deleted inserted replaced
8284:250974f8f8e7 8285:0697294f79a4
114 ngx_quic_path_challenge_frame_t *pc); 114 ngx_quic_path_challenge_frame_t *pc);
115 static size_t ngx_quic_create_new_connection_id(u_char *p, 115 static size_t ngx_quic_create_new_connection_id(u_char *p,
116 ngx_quic_new_conn_id_frame_t *rcid); 116 ngx_quic_new_conn_id_frame_t *rcid);
117 static size_t ngx_quic_create_retire_connection_id(u_char *p, 117 static size_t ngx_quic_create_retire_connection_id(u_char *p,
118 ngx_quic_retire_cid_frame_t *rcid); 118 ngx_quic_retire_cid_frame_t *rcid);
119 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); 119 static size_t ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f);
120 120
121 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, 121 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end,
122 uint16_t id, ngx_quic_tp_t *dst); 122 uint16_t id, ngx_quic_tp_t *dst);
123 123
124 124
1247 return ngx_quic_create_stream(p, &f->u.stream, f->data); 1247 return ngx_quic_create_stream(p, &f->u.stream, f->data);
1248 1248
1249 case NGX_QUIC_FT_CONNECTION_CLOSE: 1249 case NGX_QUIC_FT_CONNECTION_CLOSE:
1250 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: 1250 case NGX_QUIC_FT_CONNECTION_CLOSE_APP:
1251 f->need_ack = 0; 1251 f->need_ack = 0;
1252 return ngx_quic_create_close(p, &f->u.close); 1252 return ngx_quic_create_close(p, f);
1253 1253
1254 case NGX_QUIC_FT_MAX_STREAMS: 1254 case NGX_QUIC_FT_MAX_STREAMS:
1255 return ngx_quic_create_max_streams(p, &f->u.max_streams); 1255 return ngx_quic_create_max_streams(p, &f->u.max_streams);
1256 1256
1257 case NGX_QUIC_FT_MAX_STREAM_DATA: 1257 case NGX_QUIC_FT_MAX_STREAM_DATA:
1954 return p - pos; 1954 return p - pos;
1955 } 1955 }
1956 1956
1957 1957
1958 static size_t 1958 static size_t
1959 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) 1959 ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f)
1960 { 1960 {
1961 size_t len; 1961 size_t len;
1962 u_char *start; 1962 u_char *start;
1963 ngx_uint_t type; 1963 ngx_quic_close_frame_t *cl;
1964 1964
1965 type = cl->app ? NGX_QUIC_FT_CONNECTION_CLOSE_APP 1965 cl = &f->u.close;
1966 : NGX_QUIC_FT_CONNECTION_CLOSE; 1966
1967 1967 if (p == NULL) {
1968 if (p == NULL) { 1968 len = ngx_quic_varint_len(f->type);
1969 len = ngx_quic_varint_len(type);
1970 len += ngx_quic_varint_len(cl->error_code); 1969 len += ngx_quic_varint_len(cl->error_code);
1971 1970
1972 if (!cl->app) { 1971 if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) {
1973 len += ngx_quic_varint_len(cl->frame_type); 1972 len += ngx_quic_varint_len(cl->frame_type);
1974 } 1973 }
1975 1974
1976 len += ngx_quic_varint_len(cl->reason.len); 1975 len += ngx_quic_varint_len(cl->reason.len);
1977 len += cl->reason.len; 1976 len += cl->reason.len;
1979 return len; 1978 return len;
1980 } 1979 }
1981 1980
1982 start = p; 1981 start = p;
1983 1982
1984 ngx_quic_build_int(&p, type); 1983 ngx_quic_build_int(&p, f->type);
1985 ngx_quic_build_int(&p, cl->error_code); 1984 ngx_quic_build_int(&p, cl->error_code);
1986 1985
1987 if (!cl->app) { 1986 if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) {
1988 ngx_quic_build_int(&p, cl->frame_type); 1987 ngx_quic_build_int(&p, cl->frame_type);
1989 } 1988 }
1990 1989
1991 ngx_quic_build_int(&p, cl->reason.len); 1990 ngx_quic_build_int(&p, cl->reason.len);
1992 p = ngx_cpymem(p, cl->reason.data, cl->reason.len); 1991 p = ngx_cpymem(p, cl->reason.data, cl->reason.len);