Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_transport.c @ 8829:e00295b76395 quic
QUIC: revised ngx_quic_handle_datagram() error codes.
The NGX_DECLINED is replaced with NGX_DONE to match closer to return code
of ngx_quic_handle_packet() and ngx_quic_close_connection() rc argument.
The ngx_quic_close_connection() rc code is used only when quic connection
exists, thus anything goes if qc == NULL.
The ngx_quic_handle_datagram() does not return NG_OK in cases when quic
connection is not yet created.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 01 Feb 2022 14:35:31 +0300 |
parents | d8865baab732 |
children | 430755fcdb61 |
rev | line source |
---|---|
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
8415
b4e6b7049984
QUIC: normalize header inclusion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8403
diff
changeset
|
10 #include <ngx_event_quic_connection.h> |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
13 #define NGX_QUIC_LONG_DCID_LEN_OFFSET 5 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
14 #define NGX_QUIC_LONG_DCID_OFFSET 6 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
15 #define NGX_QUIC_SHORT_DCID_OFFSET 1 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
16 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
17 #define NGX_QUIC_STREAM_FRAME_FIN 0x01 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
18 #define NGX_QUIC_STREAM_FRAME_LEN 0x02 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
19 #define NGX_QUIC_STREAM_FRAME_OFF 0x04 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
20 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
21 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
22 #if (NGX_HAVE_NONALIGNED) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 #define ngx_quic_parse_uint16(p) ntohs(*(uint16_t *) (p)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 #define ngx_quic_parse_uint32(p) ntohl(*(uint32_t *) (p)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 #define ngx_quic_write_uint16 ngx_quic_write_uint16_aligned |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 #define ngx_quic_write_uint32 ngx_quic_write_uint32_aligned |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 #else |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 #define ngx_quic_parse_uint16(p) ((p)[0] << 8 | (p)[1]) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 #define ngx_quic_parse_uint32(p) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3]) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 #define ngx_quic_write_uint16(p, s) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 ((p)[0] = (u_char) ((s) >> 8), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 (p)[1] = (u_char) (s), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 (p) + sizeof(uint16_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
40 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 #define ngx_quic_write_uint32(p, s) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 ((p)[0] = (u_char) ((s) >> 24), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 (p)[1] = (u_char) ((s) >> 16), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
44 (p)[2] = (u_char) ((s) >> 8), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
45 (p)[3] = (u_char) (s), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 (p) + sizeof(uint32_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
47 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
48 #endif |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
49 |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
50 #define ngx_quic_write_uint64(p, s) \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
51 ((p)[0] = (u_char) ((s) >> 56), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
52 (p)[1] = (u_char) ((s) >> 48), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
53 (p)[2] = (u_char) ((s) >> 40), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
54 (p)[3] = (u_char) ((s) >> 32), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
55 (p)[4] = (u_char) ((s) >> 24), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
56 (p)[5] = (u_char) ((s) >> 16), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
57 (p)[6] = (u_char) ((s) >> 8), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
58 (p)[7] = (u_char) (s), \ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
59 (p) + sizeof(uint64_t)) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
60 |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
61 #define ngx_quic_write_uint24(p, s) \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
62 ((p)[0] = (u_char) ((s) >> 16), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
63 (p)[1] = (u_char) ((s) >> 8), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
64 (p)[2] = (u_char) (s), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
65 (p) + 3) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 #define ngx_quic_write_uint16_aligned(p, s) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
68 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 #define ngx_quic_write_uint32_aligned(p, s) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
73 #define ngx_quic_build_int_set(p, value, len, bits) \ |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
74 (*(p)++ = ((value >> ((len) * 8)) & 0xff) | ((bits) << 6)) |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
75 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
77 static u_char *ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out); |
8264
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
78 static ngx_uint_t ngx_quic_varint_len(uint64_t value); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
79 static void ngx_quic_build_int(u_char **pos, uint64_t value); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
80 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
81 static u_char *ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
82 static u_char *ngx_quic_read_uint32(u_char *pos, u_char *end, uint32_t *value); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
83 static u_char *ngx_quic_read_bytes(u_char *pos, u_char *end, size_t len, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
84 u_char **out); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
85 static u_char *ngx_quic_copy_bytes(u_char *pos, u_char *end, size_t len, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
86 u_char *dst); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
87 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
88 static ngx_int_t ngx_quic_parse_short_header(ngx_quic_header_t *pkt, |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
89 size_t dcid_len); |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
90 static ngx_int_t ngx_quic_parse_long_header(ngx_quic_header_t *pkt); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
91 static ngx_int_t ngx_quic_supported_version(uint32_t version); |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
92 static ngx_int_t ngx_quic_parse_long_header_v1(ngx_quic_header_t *pkt); |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
93 |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
94 static size_t ngx_quic_create_long_header(ngx_quic_header_t *pkt, u_char *out, |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
95 u_char **pnp); |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
96 static size_t ngx_quic_create_short_header(ngx_quic_header_t *pkt, u_char *out, |
8682
126a15530136
QUIC: removed unused argument in ngx_quic_create_short_header().
Vladimir Homutov <vl@nginx.com>
parents:
8629
diff
changeset
|
97 u_char **pnp); |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
98 |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
99 static ngx_int_t ngx_quic_frame_allowed(ngx_quic_header_t *pkt, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
100 ngx_uint_t frame_type); |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
101 static size_t ngx_quic_create_ping(u_char *p); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
102 static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
103 ngx_chain_t *ranges); |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
104 static size_t ngx_quic_create_reset_stream(u_char *p, |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
105 ngx_quic_reset_stream_frame_t *rs); |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
106 static size_t ngx_quic_create_stop_sending(u_char *p, |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
107 ngx_quic_stop_sending_frame_t *ss); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
108 static size_t ngx_quic_create_crypto(u_char *p, |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
109 ngx_quic_crypto_frame_t *crypto, ngx_chain_t *data); |
7739
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
110 static size_t ngx_quic_create_hs_done(u_char *p); |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
111 static size_t ngx_quic_create_new_token(u_char *p, |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
112 ngx_quic_new_token_frame_t *token); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
113 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
114 ngx_chain_t *data); |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
115 static size_t ngx_quic_create_max_streams(u_char *p, |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
116 ngx_quic_max_streams_frame_t *ms); |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
117 static size_t ngx_quic_create_max_stream_data(u_char *p, |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
118 ngx_quic_max_stream_data_frame_t *ms); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
119 static size_t ngx_quic_create_max_data(u_char *p, |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
120 ngx_quic_max_data_frame_t *md); |
8388
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
121 static size_t ngx_quic_create_path_challenge(u_char *p, |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
122 ngx_quic_path_challenge_frame_t *pc); |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
123 static size_t ngx_quic_create_path_response(u_char *p, |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
124 ngx_quic_path_challenge_frame_t *pc); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
125 static size_t ngx_quic_create_new_connection_id(u_char *p, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
126 ngx_quic_new_conn_id_frame_t *rcid); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
127 static size_t ngx_quic_create_retire_connection_id(u_char *p, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
128 ngx_quic_retire_cid_frame_t *rcid); |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
129 static size_t ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
131 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
132 uint16_t id, ngx_quic_tp_t *dst); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
133 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
134 |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
135 uint32_t ngx_quic_versions[] = { |
8271
3443ee341cc1
QUIC: draft-33 salt and retry keys.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8269
diff
changeset
|
136 /* QUICv1 */ |
3443ee341cc1
QUIC: draft-33 salt and retry keys.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8269
diff
changeset
|
137 0x00000001, |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
138 }; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
139 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
140 #define NGX_QUIC_NVERSIONS \ |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
141 (sizeof(ngx_quic_versions) / sizeof(ngx_quic_versions[0])) |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
142 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
143 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
144 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
145 ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
146 { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
147 u_char *p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
148 uint64_t value; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
149 ngx_uint_t len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
150 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
151 if (pos >= end) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
152 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
153 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
154 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
155 p = pos; |
8206
ad7ca043edf5
QUIC: microoptimization in varint parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8204
diff
changeset
|
156 len = 1 << (*p >> 6); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
157 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 value = *p++ & 0x3f; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
160 if ((size_t)(end - p) < (len - 1)) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
161 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
162 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
163 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
164 while (--len) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 value = (value << 8) + *p++; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
166 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
167 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
168 *out = value; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
169 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
170 return p; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
171 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
172 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
173 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
174 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
175 ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value) |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
176 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
177 if ((size_t)(end - pos) < 1) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
178 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
179 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
180 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
181 *value = *pos; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
182 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
183 return pos + 1; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
184 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
185 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
186 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
187 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
188 ngx_quic_read_uint32(u_char *pos, u_char *end, uint32_t *value) |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
189 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
190 if ((size_t)(end - pos) < sizeof(uint32_t)) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
191 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
192 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
193 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
194 *value = ngx_quic_parse_uint32(pos); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
195 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
196 return pos + sizeof(uint32_t); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
197 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
198 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
199 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
200 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
201 ngx_quic_read_bytes(u_char *pos, u_char *end, size_t len, u_char **out) |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
202 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
203 if ((size_t)(end - pos) < len) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
204 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
205 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
206 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
207 *out = pos; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
208 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
209 return pos + len; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
210 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
211 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
212 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
213 static u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
214 ngx_quic_copy_bytes(u_char *pos, u_char *end, size_t len, u_char *dst) |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
215 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
216 if ((size_t)(end - pos) < len) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
217 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
218 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
219 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
220 ngx_memcpy(dst, pos, len); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
221 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
222 return pos + len; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
223 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
224 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
225 |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
226 static ngx_inline ngx_uint_t |
8264
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
227 ngx_quic_varint_len(uint64_t value) |
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
228 { |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
229 if (value < (1 << 6)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
230 return 1; |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
231 } |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
232 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
233 if (value < (1 << 14)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
234 return 2; |
8264
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
235 } |
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
236 |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
237 if (value < (1 << 30)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
238 return 4; |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
239 } |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
240 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
241 return 8; |
8264
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
242 } |
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
243 |
5247461c17e1
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov <pluknet@nginx.com>
parents:
8241
diff
changeset
|
244 |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
245 static ngx_inline void |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 ngx_quic_build_int(u_char **pos, uint64_t value) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 { |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
248 u_char *p; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
249 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 p = *pos; |
8441
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
251 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
252 if (value < (1 << 6)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
253 ngx_quic_build_int_set(p, value, 0, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
254 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
255 } else if (value < (1 << 14)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
256 ngx_quic_build_int_set(p, value, 1, 1); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
257 ngx_quic_build_int_set(p, value, 0, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
258 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
259 } else if (value < (1 << 30)) { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
260 ngx_quic_build_int_set(p, value, 3, 2); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
261 ngx_quic_build_int_set(p, value, 2, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
262 ngx_quic_build_int_set(p, value, 1, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
263 ngx_quic_build_int_set(p, value, 0, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
264 |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
265 } else { |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
266 ngx_quic_build_int_set(p, value, 7, 3); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
267 ngx_quic_build_int_set(p, value, 6, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
268 ngx_quic_build_int_set(p, value, 5, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
269 ngx_quic_build_int_set(p, value, 4, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
270 ngx_quic_build_int_set(p, value, 3, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
271 ngx_quic_build_int_set(p, value, 2, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
272 ngx_quic_build_int_set(p, value, 1, 0); |
81d491f0dc8c
QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8419
diff
changeset
|
273 ngx_quic_build_int_set(p, value, 0, 0); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
274 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
275 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
276 *pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
277 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
278 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
279 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 ngx_int_t |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
281 ngx_quic_parse_packet(ngx_quic_header_t *pkt) |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
282 { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
283 if (!ngx_quic_long_pkt(pkt->flags)) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
284 pkt->level = ssl_encryption_application; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
285 |
8128
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
286 if (ngx_quic_parse_short_header(pkt, NGX_QUIC_SERVER_CID_LEN) != NGX_OK) |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
287 { |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
288 return NGX_DECLINED; |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
289 } |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
290 |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
291 return NGX_OK; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
292 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
293 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
294 if (ngx_quic_parse_long_header(pkt) != NGX_OK) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
295 return NGX_DECLINED; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
296 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
297 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8172
diff
changeset
|
298 if (!ngx_quic_supported_version(pkt->version)) { |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
299 return NGX_ABORT; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
300 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
301 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
302 if (ngx_quic_parse_long_header_v1(pkt) != NGX_OK) { |
8128
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
303 return NGX_DECLINED; |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
304 } |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
305 |
a6784cf32c13
QUIC: fixed handling of incorrect packets.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
306 return NGX_OK; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
307 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
308 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
309 |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
310 static ngx_int_t |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
311 ngx_quic_parse_short_header(ngx_quic_header_t *pkt, size_t dcid_len) |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
312 { |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
313 u_char *p, *end; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
314 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
315 p = pkt->raw->pos; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
316 end = pkt->data + pkt->len; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
317 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
318 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
319 "quic packet rx short flags:%xd", pkt->flags); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
320 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
321 if (!(pkt->flags & NGX_QUIC_PKT_FIXED_BIT)) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
322 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic fixed bit is not set"); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
323 return NGX_ERROR; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
324 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
325 |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
326 pkt->dcid.len = dcid_len; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
327 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
328 p = ngx_quic_read_bytes(p, end, dcid_len, &pkt->dcid.data); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
329 if (p == NULL) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
330 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
331 "quic packet is too small to read dcid"); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
332 return NGX_ERROR; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
333 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
334 |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
335 pkt->raw->pos = p; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
336 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
337 return NGX_OK; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
338 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
339 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
340 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
341 static ngx_int_t |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
342 ngx_quic_parse_long_header(ngx_quic_header_t *pkt) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 { |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
344 u_char *p, *end; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
345 uint8_t idlen; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 |
8097
a89a58c642ef
QUIC: simplified packet header parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8096
diff
changeset
|
347 p = pkt->raw->pos; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
348 end = pkt->data + pkt->len; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
350 p = ngx_quic_read_uint32(p, end, &pkt->version); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
351 if (p == NULL) { |
7741 | 352 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 353 "quic packet is too small to read version"); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
354 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
355 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
356 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
357 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8168
f32740ddd484
QUIC: got rid of "pkt" abbreviation in logs.
Vladimir Homutov <vl@nginx.com>
parents:
8167
diff
changeset
|
358 "quic packet rx long flags:%xd version:%xD", |
7836 | 359 pkt->flags, pkt->version); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
360 |
7863
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
7862
diff
changeset
|
361 if (!(pkt->flags & NGX_QUIC_PKT_FIXED_BIT)) { |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
7862
diff
changeset
|
362 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic fixed bit is not set"); |
8071
62b58f0a4711
QUIC: discard incorrect packets instead of closing the connection.
Vladimir Homutov <vl@nginx.com>
parents:
8069
diff
changeset
|
363 return NGX_ERROR; |
7863
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
7862
diff
changeset
|
364 } |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
7862
diff
changeset
|
365 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
366 p = ngx_quic_read_uint8(p, end, &idlen); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
367 if (p == NULL) { |
7741 | 368 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 369 "quic packet is too small to read dcid len"); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 |
7864
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
373 if (idlen > NGX_QUIC_CID_LEN_MAX) { |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
374 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
375 "quic packet dcid is too long"); |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
376 return NGX_ERROR; |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
377 } |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
378 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
379 pkt->dcid.len = idlen; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
380 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
381 p = ngx_quic_read_bytes(p, end, idlen, &pkt->dcid.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
382 if (p == NULL) { |
7741 | 383 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 384 "quic packet is too small to read dcid"); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
385 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
386 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
387 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
388 p = ngx_quic_read_uint8(p, end, &idlen); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
389 if (p == NULL) { |
7741 | 390 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 391 "quic packet is too small to read scid len"); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
392 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
393 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
394 |
7864
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
395 if (idlen > NGX_QUIC_CID_LEN_MAX) { |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
396 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
397 "quic packet scid is too long"); |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
398 return NGX_ERROR; |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
399 } |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
400 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
401 pkt->scid.len = idlen; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
402 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
403 p = ngx_quic_read_bytes(p, end, idlen, &pkt->scid.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
404 if (p == NULL) { |
7741 | 405 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 406 "quic packet is too small to read scid"); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
407 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
408 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
410 pkt->raw->pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
411 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 return NGX_OK; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
414 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
415 |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
416 static ngx_int_t |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
417 ngx_quic_supported_version(uint32_t version) |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
418 { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
419 ngx_uint_t i; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
420 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
421 for (i = 0; i < NGX_QUIC_NVERSIONS; i++) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
422 if (ngx_quic_versions[i] == version) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
423 return 1; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
424 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
425 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
426 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
427 return 0; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
428 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
429 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
430 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
431 static ngx_int_t |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
432 ngx_quic_parse_long_header_v1(ngx_quic_header_t *pkt) |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
433 { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
434 u_char *p, *end; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
435 uint64_t varint; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
436 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
437 p = pkt->raw->pos; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
438 end = pkt->raw->last; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
439 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
440 pkt->log->action = "parsing quic long header"; |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
441 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
442 if (ngx_quic_pkt_in(pkt->flags)) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
443 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
444 if (pkt->len < NGX_QUIC_MIN_INITIAL_SIZE) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
445 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
446 "quic UDP datagram is too small for initial packet"); |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
447 return NGX_DECLINED; |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
448 } |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
449 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
450 p = ngx_quic_parse_int(p, end, &varint); |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
451 if (p == NULL) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
452 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
453 "quic failed to parse token length"); |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
454 return NGX_ERROR; |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
455 } |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
456 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
457 pkt->token.len = varint; |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
458 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
459 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data); |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
460 if (p == NULL) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
461 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
462 "quic packet too small to read token data"); |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
463 return NGX_ERROR; |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
464 } |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
465 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
466 pkt->level = ssl_encryption_initial; |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
467 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
468 } else if (ngx_quic_pkt_zrtt(pkt->flags)) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
469 pkt->level = ssl_encryption_early_data; |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
470 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
471 } else if (ngx_quic_pkt_hs(pkt->flags)) { |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
472 pkt->level = ssl_encryption_handshake; |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
473 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
474 } else { |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
475 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
476 "quic bad packet type"); |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
477 return NGX_DECLINED; |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
478 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
479 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
480 p = ngx_quic_parse_int(p, end, &varint); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
481 if (p == NULL) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
482 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic bad packet length"); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
483 return NGX_ERROR; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
484 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
485 |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
486 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
487 "quic packet rx %s len:%uL", |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
488 ngx_quic_level_name(pkt->level), varint); |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
489 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
490 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) { |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
491 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic truncated %s packet", |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8210
diff
changeset
|
492 ngx_quic_level_name(pkt->level)); |
8210
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
493 return NGX_ERROR; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
494 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
495 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
496 pkt->raw->pos = p; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
497 pkt->len = p + varint - pkt->data; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
498 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
499 return NGX_OK; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
500 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
501 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
502 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
503 ngx_int_t |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
504 ngx_quic_get_packet_dcid(ngx_log_t *log, u_char *data, size_t n, |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
505 ngx_str_t *dcid) |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
506 { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
507 size_t len, offset; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
508 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
509 if (n == 0) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
510 goto failed; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
511 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
512 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
513 if (ngx_quic_long_pkt(*data)) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
514 if (n < NGX_QUIC_LONG_DCID_LEN_OFFSET + 1) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
515 goto failed; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
516 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
517 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
518 len = data[NGX_QUIC_LONG_DCID_LEN_OFFSET]; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
519 offset = NGX_QUIC_LONG_DCID_OFFSET; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
520 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
521 } else { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
522 len = NGX_QUIC_SERVER_CID_LEN; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
523 offset = NGX_QUIC_SHORT_DCID_OFFSET; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
524 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
525 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
526 if (n < len + offset) { |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
527 goto failed; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
528 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
529 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
530 dcid->len = len; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
531 dcid->data = &data[offset]; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
532 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
533 return NGX_OK; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
534 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
535 failed: |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
536 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
537 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0, "quic malformed packet"); |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
538 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
539 return NGX_ERROR; |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
540 } |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
541 |
46374c3fee3f
QUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8206
diff
changeset
|
542 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
543 size_t |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
544 ngx_quic_create_version_negotiation(ngx_quic_header_t *pkt, u_char *out) |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
545 { |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
546 u_char *p, *start; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
547 ngx_uint_t i; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
548 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
549 p = start = out; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
550 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
551 *p++ = pkt->flags; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
552 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
553 /* |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
554 * The Version field of a Version Negotiation packet |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
555 * MUST be set to 0x00000000 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
556 */ |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
557 p = ngx_quic_write_uint32(p, 0); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
558 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
559 *p++ = pkt->dcid.len; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
560 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
561 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
562 *p++ = pkt->scid.len; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
563 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
564 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
565 for (i = 0; i < NGX_QUIC_NVERSIONS; i++) { |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
566 p = ngx_quic_write_uint32(p, ngx_quic_versions[i]); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
567 } |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
568 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
569 return p - start; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
570 } |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
571 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
572 |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
573 /* returns the amount of payload quic packet of "pkt_len" size may fit or 0 */ |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8017
diff
changeset
|
574 size_t |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
575 ngx_quic_payload_size(ngx_quic_header_t *pkt, size_t pkt_len) |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
576 { |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
577 size_t len; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
578 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
579 if ngx_quic_short_pkt(pkt->flags) { |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
580 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
581 len = 1 + pkt->dcid.len + pkt->num_len + EVP_GCM_TLS_TAG_LEN; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
582 if (len > pkt_len) { |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
583 return 0; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
584 } |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
585 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
586 return pkt_len - len; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
587 } |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
588 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
589 /* flags, version, dcid and scid with lengths and zero-length token */ |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
590 len = 5 + 2 + pkt->dcid.len + pkt->scid.len |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
591 + (pkt->level == ssl_encryption_initial ? 1 : 0); |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
592 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
593 if (len > pkt_len) { |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
594 return 0; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
595 } |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
596 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
597 /* (pkt_len - len) is 'remainder' packet length (see RFC 9000, 17.2) */ |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
598 len += ngx_quic_varint_len(pkt_len - len) |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
599 + pkt->num_len + EVP_GCM_TLS_TAG_LEN; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
600 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
601 if (len > pkt_len) { |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
602 return 0; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
603 } |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
604 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
605 return pkt_len - len; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
606 } |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
607 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
608 |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
609 size_t |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
610 ngx_quic_create_header(ngx_quic_header_t *pkt, u_char *out, u_char **pnp) |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
611 { |
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
612 return ngx_quic_short_pkt(pkt->flags) |
8682
126a15530136
QUIC: removed unused argument in ngx_quic_create_short_header().
Vladimir Homutov <vl@nginx.com>
parents:
8629
diff
changeset
|
613 ? ngx_quic_create_short_header(pkt, out, pnp) |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
614 : ngx_quic_create_long_header(pkt, out, pnp); |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
615 } |
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
616 |
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
617 |
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
618 static size_t |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
619 ngx_quic_create_long_header(ngx_quic_header_t *pkt, u_char *out, |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
620 u_char **pnp) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
621 { |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
622 size_t rem_len; |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
623 u_char *p, *start; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
624 |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
625 rem_len = pkt->num_len + pkt->payload.len + EVP_GCM_TLS_TAG_LEN; |
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
626 |
8153
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
627 if (out == NULL) { |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
628 return 5 + 2 + pkt->dcid.len + pkt->scid.len |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
629 + ngx_quic_varint_len(rem_len) + pkt->num_len |
8153
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
630 + (pkt->level == ssl_encryption_initial ? 1 : 0); |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
631 } |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
632 |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
633 p = start = out; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
635 *p++ = pkt->flags; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
636 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8172
diff
changeset
|
637 p = ngx_quic_write_uint32(p, pkt->version); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
638 |
7821
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
7819
diff
changeset
|
639 *p++ = pkt->dcid.len; |
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
7819
diff
changeset
|
640 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
7819
diff
changeset
|
641 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
642 *p++ = pkt->scid.len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
644 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
645 if (pkt->level == ssl_encryption_initial) { |
8152
d8a0bb1e85bf
QUIC: simplified ngx_quic_create_long_header().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8148
diff
changeset
|
646 ngx_quic_build_int(&p, 0); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
647 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
648 |
8683
de7b9af30fc6
QUIC: refactored packet creation.
Vladimir Homutov <vl@nginx.com>
parents:
8682
diff
changeset
|
649 ngx_quic_build_int(&p, rem_len); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
650 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
651 *pnp = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
653 switch (pkt->num_len) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
654 case 1: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
655 *p++ = pkt->trunc; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
656 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
657 case 2: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
658 p = ngx_quic_write_uint16(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
659 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
660 case 3: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
661 p = ngx_quic_write_uint24(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
662 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
663 case 4: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
664 p = ngx_quic_write_uint32(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
665 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
666 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
667 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
668 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
669 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
670 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
671 |
8212
05b1ee464350
QUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8211
diff
changeset
|
672 static size_t |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
673 ngx_quic_create_short_header(ngx_quic_header_t *pkt, u_char *out, |
8682
126a15530136
QUIC: removed unused argument in ngx_quic_create_short_header().
Vladimir Homutov <vl@nginx.com>
parents:
8629
diff
changeset
|
674 u_char **pnp) |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
675 { |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
676 u_char *p, *start; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
677 |
8153
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
678 if (out == NULL) { |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
679 return 1 + pkt->dcid.len + pkt->num_len; |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
680 } |
ee06a813756c
QUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8152
diff
changeset
|
681 |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
682 p = start = out; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
683 |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
684 *p++ = pkt->flags; |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
685 |
7821
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
7819
diff
changeset
|
686 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
687 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
688 *pnp = p; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
689 |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
690 switch (pkt->num_len) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
691 case 1: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
692 *p++ = pkt->trunc; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
693 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
694 case 2: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
695 p = ngx_quic_write_uint16(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
696 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
697 case 3: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
698 p = ngx_quic_write_uint24(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
699 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
700 case 4: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
701 p = ngx_quic_write_uint32(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
702 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7774
diff
changeset
|
703 } |
7751
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
704 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
705 return p - start; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
706 } |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
707 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
7743
diff
changeset
|
708 |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
709 size_t |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
710 ngx_quic_create_retry_itag(ngx_quic_header_t *pkt, u_char *out, |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
711 u_char **start) |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
712 { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
713 u_char *p; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
714 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
715 p = out; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
716 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
717 *p++ = pkt->odcid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
718 p = ngx_cpymem(p, pkt->odcid.data, pkt->odcid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
719 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
720 *start = p; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
721 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
722 *p++ = 0xff; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
723 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8172
diff
changeset
|
724 p = ngx_quic_write_uint32(p, pkt->version); |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
725 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
726 *p++ = pkt->dcid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
727 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
728 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
729 *p++ = pkt->scid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
730 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
731 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
732 p = ngx_cpymem(p, pkt->token.data, pkt->token.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
733 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
734 return p - out; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
735 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
736 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
737 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
738 ssize_t |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
739 ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
740 ngx_quic_frame_t *f) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
741 { |
7792 | 742 u_char *p; |
743 uint64_t varint; | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
744 ngx_buf_t *b; |
7792 | 745 ngx_uint_t i; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
747 b = f->data->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
748 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
749 p = start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 |
7708 | 751 p = ngx_quic_parse_int(p, end, &varint); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
752 if (p == NULL) { |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
753 pkt->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
7741 | 754 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
755 "quic failed to obtain quic frame type"); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
756 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
757 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
758 |
8417
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
759 if (varint > NGX_QUIC_FT_LAST) { |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
760 pkt->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
761 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
762 "quic unknown frame type 0x%xL", varint); |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
763 return NGX_ERROR; |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
764 } |
dcc57827098d
QUIC: fixed parsing of unknown frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
765 |
7708 | 766 f->type = varint; |
767 | |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
768 if (ngx_quic_frame_allowed(pkt, f->type) != NGX_OK) { |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
769 pkt->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION; |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
770 return NGX_ERROR; |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
771 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
772 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
773 switch (f->type) { |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
774 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
775 case NGX_QUIC_FT_CRYPTO: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
776 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
777 p = ngx_quic_parse_int(p, end, &f->u.crypto.offset); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
778 if (p == NULL) { |
7838 | 779 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
780 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
781 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
782 p = ngx_quic_parse_int(p, end, &f->u.crypto.length); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
783 if (p == NULL) { |
7838 | 784 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
785 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
787 p = ngx_quic_read_bytes(p, end, f->u.crypto.length, &b->pos); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
788 if (p == NULL) { |
7838 | 789 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
790 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
791 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
792 b->last = p; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
793 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
796 case NGX_QUIC_FT_PADDING: |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
797 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
798 while (p < end && *p == NGX_QUIC_FT_PADDING) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
799 p++; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
804 case NGX_QUIC_FT_ACK: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 case NGX_QUIC_FT_ACK_ECN: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
806 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
807 if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.largest)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
808 && (p = ngx_quic_parse_int(p, end, &f->u.ack.delay)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
809 && (p = ngx_quic_parse_int(p, end, &f->u.ack.range_count)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
810 && (p = ngx_quic_parse_int(p, end, &f->u.ack.first_range)))) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
811 { |
7838 | 812 goto error; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
814 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
815 b->pos = p; |
7792 | 816 |
817 /* process all ranges to get bounds, values are ignored */ | |
818 for (i = 0; i < f->u.ack.range_count; i++) { | |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
819 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
820 p = ngx_quic_parse_int(p, end, &varint); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
821 if (p) { |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
822 p = ngx_quic_parse_int(p, end, &varint); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
823 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
824 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
825 if (p == NULL) { |
7838 | 826 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
827 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
828 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
829 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
830 b->last = p; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
831 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
832 f->u.ack.ranges_length = b->last - b->pos; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
833 |
7792 | 834 if (f->type == NGX_QUIC_FT_ACK_ECN) { |
835 | |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
836 if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.ect0)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
837 && (p = ngx_quic_parse_int(p, end, &f->u.ack.ect1)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
838 && (p = ngx_quic_parse_int(p, end, &f->u.ack.ce)))) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
839 { |
7838 | 840 goto error; |
7792 | 841 } |
842 | |
843 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
844 "quic ACK ECN counters ect0:%uL ect1:%uL ce:%uL", |
7792 | 845 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); |
846 } | |
847 | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
848 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
849 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
850 case NGX_QUIC_FT_PING: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
851 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
854 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
855 p = ngx_quic_parse_int(p, end, &f->u.ncid.seqnum); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
856 if (p == NULL) { |
7838 | 857 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
858 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
859 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
860 p = ngx_quic_parse_int(p, end, &f->u.ncid.retire); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
861 if (p == NULL) { |
7838 | 862 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
863 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
864 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
865 if (f->u.ncid.retire > f->u.ncid.seqnum) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
866 goto error; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
867 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
868 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
869 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
870 if (p == NULL) { |
7838 | 871 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
872 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
873 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
874 if (f->u.ncid.len < 1 || f->u.ncid.len > NGX_QUIC_CID_LEN_MAX) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
875 goto error; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
876 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
877 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
878 p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
879 if (p == NULL) { |
7838 | 880 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
881 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
883 p = ngx_quic_copy_bytes(p, end, NGX_QUIC_SR_TOKEN_LEN, f->u.ncid.srt); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
884 if (p == NULL) { |
7838 | 885 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
886 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
887 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
888 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
889 |
8075 | 890 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
891 | |
892 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number); | |
893 if (p == NULL) { | |
894 goto error; | |
895 } | |
896 | |
897 break; | |
898 | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
899 case NGX_QUIC_FT_CONNECTION_CLOSE: |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
900 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
901 |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
902 p = ngx_quic_parse_int(p, end, &f->u.close.error_code); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
903 if (p == NULL) { |
7838 | 904 goto error; |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
905 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
906 |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
907 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
908 p = ngx_quic_parse_int(p, end, &f->u.close.frame_type); |
7722
0a18893299fe
Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7721
diff
changeset
|
909 if (p == NULL) { |
7838 | 910 goto error; |
7722
0a18893299fe
Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7721
diff
changeset
|
911 } |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
912 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
913 |
7720
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
914 p = ngx_quic_parse_int(p, end, &varint); |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
915 if (p == NULL) { |
7838 | 916 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
917 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
918 |
7720
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
919 f->u.close.reason.len = varint; |
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
920 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
921 p = ngx_quic_read_bytes(p, end, f->u.close.reason.len, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
922 &f->u.close.reason.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
923 if (p == NULL) { |
7838 | 924 goto error; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
925 } |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
926 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
927 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
928 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
929 case NGX_QUIC_FT_STREAM: |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
930 case NGX_QUIC_FT_STREAM1: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
931 case NGX_QUIC_FT_STREAM2: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
932 case NGX_QUIC_FT_STREAM3: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
933 case NGX_QUIC_FT_STREAM4: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
934 case NGX_QUIC_FT_STREAM5: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
935 case NGX_QUIC_FT_STREAM6: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
936 case NGX_QUIC_FT_STREAM7: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
937 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
938 f->u.stream.fin = (f->type & NGX_QUIC_STREAM_FRAME_FIN) ? 1 : 0; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
939 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
940 p = ngx_quic_parse_int(p, end, &f->u.stream.stream_id); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
941 if (p == NULL) { |
7838 | 942 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
943 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
944 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
945 if (f->type & NGX_QUIC_STREAM_FRAME_OFF) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
946 f->u.stream.off = 1; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
947 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
948 p = ngx_quic_parse_int(p, end, &f->u.stream.offset); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
949 if (p == NULL) { |
7838 | 950 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
951 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
952 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
953 } else { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
954 f->u.stream.off = 0; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
955 f->u.stream.offset = 0; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
956 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
957 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
958 if (f->type & NGX_QUIC_STREAM_FRAME_LEN) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
959 f->u.stream.len = 1; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
960 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
961 p = ngx_quic_parse_int(p, end, &f->u.stream.length); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
962 if (p == NULL) { |
7838 | 963 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
964 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
965 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
966 } else { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
967 f->u.stream.len = 0; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
968 f->u.stream.length = end - p; /* up to packet end */ |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
969 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
970 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
971 p = ngx_quic_read_bytes(p, end, f->u.stream.length, &b->pos); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
972 if (p == NULL) { |
7838 | 973 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
974 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
975 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
976 b->last = p; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
977 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
978 f->type = NGX_QUIC_FT_STREAM; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
979 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
980 |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
981 case NGX_QUIC_FT_MAX_DATA: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
982 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
983 p = ngx_quic_parse_int(p, end, &f->u.max_data.max_data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
984 if (p == NULL) { |
7838 | 985 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
986 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
987 |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
988 break; |
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
989 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
990 case NGX_QUIC_FT_RESET_STREAM: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
991 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
992 if (!((p = ngx_quic_parse_int(p, end, &f->u.reset_stream.id)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
993 && (p = ngx_quic_parse_int(p, end, &f->u.reset_stream.error_code)) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
994 && (p = ngx_quic_parse_int(p, end, |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
995 &f->u.reset_stream.final_size)))) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
996 { |
7838 | 997 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
998 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
999 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1000 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1001 |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1002 case NGX_QUIC_FT_STOP_SENDING: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1003 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1004 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.id); |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1005 if (p == NULL) { |
7838 | 1006 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1007 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1008 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1009 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.error_code); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1010 if (p == NULL) { |
7838 | 1011 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1012 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1013 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1014 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1015 |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1016 case NGX_QUIC_FT_STREAMS_BLOCKED: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1017 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1018 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1019 p = ngx_quic_parse_int(p, end, &f->u.streams_blocked.limit); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1020 if (p == NULL) { |
7838 | 1021 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1022 } |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1023 |
8418
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1024 if (f->u.streams_blocked.limit > 0x1000000000000000) { |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1025 goto error; |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1026 } |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1027 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1028 f->u.streams_blocked.bidi = |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1029 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0; |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1030 break; |
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1031 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1032 case NGX_QUIC_FT_MAX_STREAMS: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1033 case NGX_QUIC_FT_MAX_STREAMS2: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1034 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1035 p = ngx_quic_parse_int(p, end, &f->u.max_streams.limit); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1036 if (p == NULL) { |
7838 | 1037 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1038 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1039 |
8418
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1040 if (f->u.max_streams.limit > 0x1000000000000000) { |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1041 goto error; |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1042 } |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1043 |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1044 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1045 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1046 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1047 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1048 case NGX_QUIC_FT_MAX_STREAM_DATA: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1049 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1050 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.id); |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1051 if (p == NULL) { |
7838 | 1052 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1053 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1054 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1055 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.limit); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1056 if (p == NULL) { |
7838 | 1057 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1058 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1059 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1060 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1061 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1062 case NGX_QUIC_FT_DATA_BLOCKED: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1063 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1064 p = ngx_quic_parse_int(p, end, &f->u.data_blocked.limit); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1065 if (p == NULL) { |
7838 | 1066 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1067 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1068 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1069 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1070 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1071 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1072 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1073 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.id); |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1074 if (p == NULL) { |
7838 | 1075 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1076 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1077 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1078 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.limit); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1079 if (p == NULL) { |
7838 | 1080 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1081 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1082 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1083 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1084 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1085 case NGX_QUIC_FT_PATH_CHALLENGE: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1086 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1087 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1088 if (p == NULL) { |
7838 | 1089 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1090 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1091 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1092 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1093 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1094 case NGX_QUIC_FT_PATH_RESPONSE: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1095 |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1096 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1097 if (p == NULL) { |
7838 | 1098 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1099 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1100 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1101 break; |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1102 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1103 default: |
7741 | 1104 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 1105 "quic unknown frame type 0x%xi", f->type); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1106 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1107 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1108 |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1109 f->level = pkt->level; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1110 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1111 return p - start; |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1112 |
7838 | 1113 error: |
1114 | |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
1115 pkt->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
1116 |
7838 | 1117 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1118 "quic failed to parse frame type:0x%xi", f->type); |
7838 | 1119 |
1120 return NGX_ERROR; | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1121 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1122 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1123 |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1124 static ngx_int_t |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1125 ngx_quic_frame_allowed(ngx_quic_header_t *pkt, ngx_uint_t frame_type) |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1126 { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1127 uint8_t ptype; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1128 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1129 /* |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1130 * RFC 9000, 12.4. Frames and Frame Types: Table 3 |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1131 * |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1132 * Frame permissions per packet: 4 bits: IH01 |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1133 */ |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1134 static uint8_t ngx_quic_frame_masks[] = { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1135 /* PADDING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1136 /* PING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1137 /* ACK */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1138 /* ACK_ECN */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1139 /* RESET_STREAM */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1140 /* STOP_SENDING */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1141 /* CRYPTO */ 0xD, |
7919
c70446e3d771
Treat receipt of NEW_TOKEN as connection error PROTOCOL_VIOLATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7917
diff
changeset
|
1142 /* NEW_TOKEN */ 0x0, /* only sent by server */ |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1143 /* STREAM */ 0x3, |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1144 /* STREAM1 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1145 /* STREAM2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1146 /* STREAM3 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1147 /* STREAM4 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1148 /* STREAM5 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1149 /* STREAM6 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1150 /* STREAM7 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1151 /* MAX_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1152 /* MAX_STREAM_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1153 /* MAX_STREAMS */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1154 /* MAX_STREAMS2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1155 /* DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1156 /* STREAM_DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1157 /* STREAMS_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1158 /* STREAMS_BLOCKED2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1159 /* NEW_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1160 /* RETIRE_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1161 /* PATH_CHALLENGE */ 0x3, |
8419
515ac3c8435c
QUIC: fixed permitted packet types for PATH_RESPONSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8418
diff
changeset
|
1162 /* PATH_RESPONSE */ 0x1, |
7920
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
1163 /* CONNECTION_CLOSE */ 0xF, |
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
1164 /* CONNECTION_CLOSE2 */ 0x3, |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1165 /* HANDSHAKE_DONE */ 0x0, /* only sent by server */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1166 }; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1167 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1168 if (ngx_quic_long_pkt(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1169 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1170 if (ngx_quic_pkt_in(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1171 ptype = 8; /* initial */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1172 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1173 } else if (ngx_quic_pkt_hs(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1174 ptype = 4; /* handshake */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1175 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1176 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1177 ptype = 2; /* zero-rtt */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1178 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1179 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1180 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1181 ptype = 1; /* application data */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1182 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1183 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1184 if (ptype & ngx_quic_frame_masks[frame_type]) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1185 return NGX_OK; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1186 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1187 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1188 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1189 "quic frame type 0x%xi is not " |
7996
d2f716e668e8
Fixed format specifiers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7988
diff
changeset
|
1190 "allowed in packet with flags 0x%xd", |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1191 frame_type, pkt->flags); |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1192 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1193 return NGX_DECLINED; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1194 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1195 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1196 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1197 ssize_t |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1198 ngx_quic_parse_ack_range(ngx_log_t *log, u_char *start, u_char *end, |
7792 | 1199 uint64_t *gap, uint64_t *range) |
1200 { | |
1201 u_char *p; | |
1202 | |
1203 p = start; | |
1204 | |
1205 p = ngx_quic_parse_int(p, end, gap); | |
1206 if (p == NULL) { | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1207 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1208 "quic failed to parse ack frame gap"); |
7792 | 1209 return NGX_ERROR; |
1210 } | |
1211 | |
1212 p = ngx_quic_parse_int(p, end, range); | |
1213 if (p == NULL) { | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1214 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1215 "quic failed to parse ack frame range"); |
7792 | 1216 return NGX_ERROR; |
1217 } | |
1218 | |
1219 return p - start; | |
1220 } | |
1221 | |
1222 | |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1223 size_t |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1224 ngx_quic_create_ack_range(u_char *p, uint64_t gap, uint64_t range) |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1225 { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1226 size_t len; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1227 u_char *start; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1228 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1229 if (p == NULL) { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1230 len = ngx_quic_varint_len(gap); |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1231 len += ngx_quic_varint_len(range); |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1232 return len; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1233 } |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1234 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1235 start = p; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1236 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1237 ngx_quic_build_int(&p, gap); |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1238 ngx_quic_build_int(&p, range); |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1239 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1240 return p - start; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1241 } |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1242 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1243 |
7792 | 1244 ssize_t |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1245 ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1246 { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1247 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1248 * RFC 9002, 2. Conventions and Definitions |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1249 * |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1250 * Ack-eliciting frames: All frames other than ACK, PADDING, and |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1251 * CONNECTION_CLOSE are considered ack-eliciting. |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1252 */ |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1253 f->need_ack = 1; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1254 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1255 switch (f->type) { |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1256 case NGX_QUIC_FT_PING: |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1257 return ngx_quic_create_ping(p); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1258 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1259 case NGX_QUIC_FT_ACK: |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1260 f->need_ack = 0; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1261 return ngx_quic_create_ack(p, &f->u.ack, f->data); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1262 |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1263 case NGX_QUIC_FT_RESET_STREAM: |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1264 return ngx_quic_create_reset_stream(p, &f->u.reset_stream); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1265 |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1266 case NGX_QUIC_FT_STOP_SENDING: |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1267 return ngx_quic_create_stop_sending(p, &f->u.stop_sending); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1268 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1269 case NGX_QUIC_FT_CRYPTO: |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1270 return ngx_quic_create_crypto(p, &f->u.crypto, f->data); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1271 |
7739
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1272 case NGX_QUIC_FT_HANDSHAKE_DONE: |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1273 return ngx_quic_create_hs_done(p); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1274 |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1275 case NGX_QUIC_FT_NEW_TOKEN: |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1276 return ngx_quic_create_new_token(p, &f->u.token); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1277 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1278 case NGX_QUIC_FT_STREAM: |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1279 return ngx_quic_create_stream(p, &f->u.stream, f->data); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1280 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1281 case NGX_QUIC_FT_CONNECTION_CLOSE: |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
1282 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1283 f->need_ack = 0; |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
1284 return ngx_quic_create_close(p, f); |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1285 |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1286 case NGX_QUIC_FT_MAX_STREAMS: |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1287 return ngx_quic_create_max_streams(p, &f->u.max_streams); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1288 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1289 case NGX_QUIC_FT_MAX_STREAM_DATA: |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1290 return ngx_quic_create_max_stream_data(p, &f->u.max_stream_data); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1291 |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1292 case NGX_QUIC_FT_MAX_DATA: |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1293 return ngx_quic_create_max_data(p, &f->u.max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1294 |
8388
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1295 case NGX_QUIC_FT_PATH_CHALLENGE: |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1296 return ngx_quic_create_path_challenge(p, &f->u.path_challenge); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1297 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1298 case NGX_QUIC_FT_PATH_RESPONSE: |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1299 return ngx_quic_create_path_response(p, &f->u.path_response); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1300 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1301 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1302 return ngx_quic_create_new_connection_id(p, &f->u.ncid); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1303 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1304 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1305 return ngx_quic_create_retire_connection_id(p, &f->u.retire_cid); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1306 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1307 default: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1308 /* BUG: unsupported frame type generated */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1309 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1310 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1311 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1312 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1313 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1314 static size_t |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1315 ngx_quic_create_ping(u_char *p) |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1316 { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1317 u_char *start; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1318 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1319 if (p == NULL) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1320 return ngx_quic_varint_len(NGX_QUIC_FT_PING); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1321 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1322 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1323 start = p; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1324 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1325 ngx_quic_build_int(&p, NGX_QUIC_FT_PING); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1326 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1327 return p - start; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1328 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1329 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1330 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1331 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1332 ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack, ngx_chain_t *ranges) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1333 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1334 size_t len; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1335 u_char *start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1336 ngx_buf_t *b; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1337 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1338 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1339 len = ngx_quic_varint_len(NGX_QUIC_FT_ACK); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1340 len += ngx_quic_varint_len(ack->largest); |
7988
0d1ad81dd65c
QUIC: delay field of an ACK frame is now calculated.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1341 len += ngx_quic_varint_len(ack->delay); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1342 len += ngx_quic_varint_len(ack->range_count); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1343 len += ngx_quic_varint_len(ack->first_range); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1344 len += ack->ranges_length; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1345 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1346 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1347 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1348 |
7710
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1349 start = p; |
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1350 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1351 ngx_quic_build_int(&p, NGX_QUIC_FT_ACK); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1352 ngx_quic_build_int(&p, ack->largest); |
7988
0d1ad81dd65c
QUIC: delay field of an ACK frame is now calculated.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1353 ngx_quic_build_int(&p, ack->delay); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1354 ngx_quic_build_int(&p, ack->range_count); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1355 ngx_quic_build_int(&p, ack->first_range); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1356 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1357 while (ranges) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1358 b = ranges->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1359 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1360 ranges = ranges->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1361 } |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1362 |
7710
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1363 return p - start; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1364 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1365 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1366 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1367 static size_t |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1368 ngx_quic_create_reset_stream(u_char *p, ngx_quic_reset_stream_frame_t *rs) |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1369 { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1370 size_t len; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1371 u_char *start; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1372 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1373 if (p == NULL) { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1374 len = ngx_quic_varint_len(NGX_QUIC_FT_RESET_STREAM); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1375 len += ngx_quic_varint_len(rs->id); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1376 len += ngx_quic_varint_len(rs->error_code); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1377 len += ngx_quic_varint_len(rs->final_size); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1378 return len; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1379 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1380 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1381 start = p; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1382 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1383 ngx_quic_build_int(&p, NGX_QUIC_FT_RESET_STREAM); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1384 ngx_quic_build_int(&p, rs->id); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1385 ngx_quic_build_int(&p, rs->error_code); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1386 ngx_quic_build_int(&p, rs->final_size); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1387 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1388 return p - start; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1389 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1390 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1391 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1392 static size_t |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1393 ngx_quic_create_stop_sending(u_char *p, ngx_quic_stop_sending_frame_t *ss) |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1394 { |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1395 size_t len; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1396 u_char *start; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1397 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1398 if (p == NULL) { |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1399 len = ngx_quic_varint_len(NGX_QUIC_FT_STOP_SENDING); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1400 len += ngx_quic_varint_len(ss->id); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1401 len += ngx_quic_varint_len(ss->error_code); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1402 return len; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1403 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1404 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1405 start = p; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1406 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1407 ngx_quic_build_int(&p, NGX_QUIC_FT_STOP_SENDING); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1408 ngx_quic_build_int(&p, ss->id); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1409 ngx_quic_build_int(&p, ss->error_code); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1410 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1411 return p - start; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1412 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1413 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1414 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1415 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1416 ngx_quic_create_crypto(u_char *p, ngx_quic_crypto_frame_t *crypto, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1417 ngx_chain_t *data) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1418 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1419 size_t len; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1420 u_char *start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1421 ngx_buf_t *b; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1422 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1423 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1424 len = ngx_quic_varint_len(NGX_QUIC_FT_CRYPTO); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1425 len += ngx_quic_varint_len(crypto->offset); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1426 len += ngx_quic_varint_len(crypto->length); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1427 len += crypto->length; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1428 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1429 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1430 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1431 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1432 start = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1433 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1434 ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1435 ngx_quic_build_int(&p, crypto->offset); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1436 ngx_quic_build_int(&p, crypto->length); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1437 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1438 while (data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1439 b = data->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1440 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1441 data = data->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1442 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1443 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1444 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1445 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1446 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1447 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1448 static size_t |
7739
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1449 ngx_quic_create_hs_done(u_char *p) |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1450 { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1451 u_char *start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1452 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1453 if (p == NULL) { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1454 return ngx_quic_varint_len(NGX_QUIC_FT_HANDSHAKE_DONE); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1455 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1456 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1457 start = p; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1458 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1459 ngx_quic_build_int(&p, NGX_QUIC_FT_HANDSHAKE_DONE); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1460 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1461 return p - start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1462 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1463 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1464 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1465 static size_t |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1466 ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token) |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1467 { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1468 size_t len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1469 u_char *start; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1470 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1471 if (p == NULL) { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1472 len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1473 len += ngx_quic_varint_len(token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1474 len += token->length; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1475 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1476 return len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1477 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1478 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1479 start = p; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1480 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1481 ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_TOKEN); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1482 ngx_quic_build_int(&p, token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1483 p = ngx_cpymem(p, token->data, token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1484 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1485 return p - start; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1486 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1487 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1488 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1489 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1490 ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1491 ngx_chain_t *data) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1492 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1493 size_t len; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1494 u_char *start, type; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1495 ngx_buf_t *b; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1496 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1497 type = NGX_QUIC_FT_STREAM; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1498 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1499 if (sf->off) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1500 type |= NGX_QUIC_STREAM_FRAME_OFF; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1501 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1502 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1503 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1504 type |= NGX_QUIC_STREAM_FRAME_LEN; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1505 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1506 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1507 if (sf->fin) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1508 type |= NGX_QUIC_STREAM_FRAME_FIN; |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1509 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1510 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1511 if (p == NULL) { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1512 len = ngx_quic_varint_len(type); |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1513 len += ngx_quic_varint_len(sf->stream_id); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1514 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1515 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1516 len += ngx_quic_varint_len(sf->offset); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1517 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1518 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1519 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1520 len += ngx_quic_varint_len(sf->length); |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1521 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1522 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1523 len += sf->length; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1524 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1525 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1526 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1527 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1528 start = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1529 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1530 ngx_quic_build_int(&p, type); |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1531 ngx_quic_build_int(&p, sf->stream_id); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1532 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1533 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1534 ngx_quic_build_int(&p, sf->offset); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1535 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1536 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1537 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1538 ngx_quic_build_int(&p, sf->length); |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1539 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1540 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1541 while (data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1542 b = data->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1543 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1544 data = data->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1545 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1546 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1547 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1548 } |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1549 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1550 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1551 static size_t |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1552 ngx_quic_create_max_streams(u_char *p, ngx_quic_max_streams_frame_t *ms) |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1553 { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1554 size_t len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1555 u_char *start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1556 ngx_uint_t type; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1557 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1558 type = ms->bidi ? NGX_QUIC_FT_MAX_STREAMS : NGX_QUIC_FT_MAX_STREAMS2; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1559 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1560 if (p == NULL) { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1561 len = ngx_quic_varint_len(type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1562 len += ngx_quic_varint_len(ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1563 return len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1564 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1565 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1566 start = p; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1567 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1568 ngx_quic_build_int(&p, type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1569 ngx_quic_build_int(&p, ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1570 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1571 return p - start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1572 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1573 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1574 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1575 static ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1576 ngx_quic_parse_transport_param(u_char *p, u_char *end, uint16_t id, |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1577 ngx_quic_tp_t *dst) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1578 { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1579 uint64_t varint; |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1580 ngx_str_t str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1581 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1582 varint = 0; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1583 ngx_str_null(&str); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1584 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1585 switch (id) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1586 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1587 case NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1588 /* zero-length option */ |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1589 if (end - p != 0) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1590 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1591 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1592 dst->disable_active_migration = 1; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1593 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1594 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1595 case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1596 case NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE: |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1597 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1598 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1599 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1600 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1601 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1602 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1603 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1604 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1605 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1606 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1607 p = ngx_quic_parse_int(p, end, &varint); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1608 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1609 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1610 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1611 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1612 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1613 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1614 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1615 str.len = end - p; |
8141
b95aa1cb8f98
QUIC: fixed dead store assignment.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8128
diff
changeset
|
1616 str.data = p; |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1617 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1618 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1619 default: |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1620 return NGX_DECLINED; |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1621 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1622 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1623 switch (id) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1624 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1625 case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1626 dst->max_idle_timeout = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1627 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1628 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1629 case NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE: |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1630 dst->max_udp_payload_size = varint; |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1631 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1632 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1633 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1634 dst->initial_max_data = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1635 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1636 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1637 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1638 dst->initial_max_stream_data_bidi_local = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1639 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1640 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1641 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1642 dst->initial_max_stream_data_bidi_remote = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1643 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1644 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1645 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1646 dst->initial_max_stream_data_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1647 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1648 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1649 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1650 dst->initial_max_streams_bidi = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1651 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1652 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1653 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1654 dst->initial_max_streams_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1655 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1656 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1657 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1658 dst->ack_delay_exponent = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1659 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1660 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1661 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1662 dst->max_ack_delay = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1663 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1664 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1665 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1666 dst->active_connection_id_limit = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1667 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1668 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1669 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1670 dst->initial_scid = str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1671 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1672 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1673 default: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1674 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1675 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1676 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1677 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1678 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1679 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1680 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1681 ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1682 ngx_quic_parse_transport_params(u_char *p, u_char *end, ngx_quic_tp_t *tp, |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1683 ngx_log_t *log) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1684 { |
7833
42198f77ac85
Removed support of drafts older than currently latest 27.
Vladimir Homutov <vl@nginx.com>
parents:
7828
diff
changeset
|
1685 uint64_t id, len; |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1686 ngx_int_t rc; |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1687 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1688 while (p < end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1689 p = ngx_quic_parse_int(p, end, &id); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1690 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1691 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1692 "quic failed to parse transport param id"); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1693 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1694 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1695 |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1696 switch (id) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1697 case NGX_QUIC_TP_ORIGINAL_DCID: |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1698 case NGX_QUIC_TP_PREFERRED_ADDRESS: |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1699 case NGX_QUIC_TP_RETRY_SCID: |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1700 case NGX_QUIC_TP_SR_TOKEN: |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1701 ngx_log_error(NGX_LOG_INFO, log, 0, |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1702 "quic client sent forbidden transport param" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1703 " id:0x%xL", id); |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1704 return NGX_ERROR; |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1705 } |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1706 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1707 p = ngx_quic_parse_int(p, end, &len); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1708 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1709 ngx_log_error(NGX_LOG_INFO, log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
1710 "quic failed to parse" |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
1711 " transport param id:0x%xL length", id); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1712 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1713 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1714 |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1715 rc = ngx_quic_parse_transport_param(p, p + len, id, tp); |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1716 |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1717 if (rc == NGX_ERROR) { |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1718 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1719 "quic failed to parse" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1720 " transport param id:0x%xL data", id); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1721 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1722 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1723 |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1724 if (rc == NGX_DECLINED) { |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1725 ngx_log_error(NGX_LOG_INFO, log, 0, |
8292
e24e5650d7b4
QUIC: distinguish reserved transport parameters in logging.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1726 "quic %s transport param id:0x%xL, skipped", |
e24e5650d7b4
QUIC: distinguish reserved transport parameters in logging.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1727 (id % 31 == 27) ? "reserved" : "unknown", id); |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1728 } |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1729 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1730 p += len; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1731 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1732 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1733 if (p != end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1734 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1735 "quic trailing garbage in" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1736 " transport parameters: bytes:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1737 end - p); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1738 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1739 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1740 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1741 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0, |
7836 | 1742 "quic transport parameters parsed ok"); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1743 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1744 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
7836 | 1745 "quic tp disable active migration: %ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1746 tp->disable_active_migration); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1747 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1748 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp idle_timeout:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1749 tp->max_idle_timeout); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1750 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1751 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1752 "quic tp max_udp_payload_size:%ui", |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1753 tp->max_udp_payload_size); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1754 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1755 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_data:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1756 tp->initial_max_data); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1757 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1758 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1759 "quic tp max_stream_data_bidi_local:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1760 tp->initial_max_stream_data_bidi_local); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1761 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1762 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1763 "quic tp max_stream_data_bidi_remote:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1764 tp->initial_max_stream_data_bidi_remote); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1765 |
7836 | 1766 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1767 "quic tp max_stream_data_uni:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1768 tp->initial_max_stream_data_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1769 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1770 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1771 "quic tp initial_max_streams_bidi:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1772 tp->initial_max_streams_bidi); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1773 |
7836 | 1774 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1775 "quic tp initial_max_streams_uni:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1776 tp->initial_max_streams_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1777 |
7836 | 1778 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1779 "quic tp ack_delay_exponent:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1780 tp->ack_delay_exponent); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1781 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1782 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_ack_delay:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1783 tp->max_ack_delay); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1784 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1785 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1786 "quic tp active_connection_id_limit:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1787 tp->active_connection_id_limit); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1788 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1789 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1790 "quic tp initial source_connection_id len:%uz %xV", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1791 tp->initial_scid.len, &tp->initial_scid); |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1792 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1793 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1794 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1795 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1796 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1797 static size_t |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1798 ngx_quic_create_max_stream_data(u_char *p, ngx_quic_max_stream_data_frame_t *ms) |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1799 { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1800 size_t len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1801 u_char *start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1802 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1803 if (p == NULL) { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1804 len = ngx_quic_varint_len(NGX_QUIC_FT_MAX_STREAM_DATA); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1805 len += ngx_quic_varint_len(ms->id); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1806 len += ngx_quic_varint_len(ms->limit); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1807 return len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1808 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1809 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1810 start = p; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1811 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1812 ngx_quic_build_int(&p, NGX_QUIC_FT_MAX_STREAM_DATA); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1813 ngx_quic_build_int(&p, ms->id); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1814 ngx_quic_build_int(&p, ms->limit); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1815 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1816 return p - start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1817 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1818 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1819 |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1820 static size_t |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1821 ngx_quic_create_max_data(u_char *p, ngx_quic_max_data_frame_t *md) |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1822 { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1823 size_t len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1824 u_char *start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1825 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1826 if (p == NULL) { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1827 len = ngx_quic_varint_len(NGX_QUIC_FT_MAX_DATA); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1828 len += ngx_quic_varint_len(md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1829 return len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1830 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1831 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1832 start = p; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1833 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1834 ngx_quic_build_int(&p, NGX_QUIC_FT_MAX_DATA); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1835 ngx_quic_build_int(&p, md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1836 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1837 return p - start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1838 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1839 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1840 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1841 static size_t |
8388
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1842 ngx_quic_create_path_challenge(u_char *p, ngx_quic_path_challenge_frame_t *pc) |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1843 { |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1844 size_t len; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1845 u_char *start; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1846 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1847 if (p == NULL) { |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1848 len = ngx_quic_varint_len(NGX_QUIC_FT_PATH_CHALLENGE); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1849 len += sizeof(pc->data); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1850 return len; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1851 } |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1852 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1853 start = p; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1854 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1855 ngx_quic_build_int(&p, NGX_QUIC_FT_PATH_CHALLENGE); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1856 p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1857 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1858 return p - start; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1859 } |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1860 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1861 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1862 static size_t |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1863 ngx_quic_create_path_response(u_char *p, ngx_quic_path_challenge_frame_t *pc) |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1864 { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1865 size_t len; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1866 u_char *start; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1867 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1868 if (p == NULL) { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1869 len = ngx_quic_varint_len(NGX_QUIC_FT_PATH_RESPONSE); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1870 len += sizeof(pc->data); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1871 return len; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1872 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1873 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1874 start = p; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1875 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1876 ngx_quic_build_int(&p, NGX_QUIC_FT_PATH_RESPONSE); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1877 p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1878 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1879 return p - start; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1880 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1881 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1882 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1883 static size_t |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1884 ngx_quic_create_new_connection_id(u_char *p, ngx_quic_new_conn_id_frame_t *ncid) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1885 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1886 size_t len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1887 u_char *start; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1888 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1889 if (p == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1890 len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_CONNECTION_ID); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1891 len += ngx_quic_varint_len(ncid->seqnum); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1892 len += ngx_quic_varint_len(ncid->retire); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1893 len++; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1894 len += ncid->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1895 len += NGX_QUIC_SR_TOKEN_LEN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1896 return len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1897 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1898 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1899 start = p; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1900 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1901 ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_CONNECTION_ID); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1902 ngx_quic_build_int(&p, ncid->seqnum); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1903 ngx_quic_build_int(&p, ncid->retire); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1904 *p++ = ncid->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1905 p = ngx_cpymem(p, ncid->cid, ncid->len); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1906 p = ngx_cpymem(p, ncid->srt, NGX_QUIC_SR_TOKEN_LEN); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1907 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1908 return p - start; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1909 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1910 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1911 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1912 static size_t |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1913 ngx_quic_create_retire_connection_id(u_char *p, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1914 ngx_quic_retire_cid_frame_t *rcid) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1915 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1916 size_t len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1917 u_char *start; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1918 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1919 if (p == NULL) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1920 len = ngx_quic_varint_len(NGX_QUIC_FT_RETIRE_CONNECTION_ID); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1921 len += ngx_quic_varint_len(rcid->sequence_number); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1922 return len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1923 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1924 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1925 start = p; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1926 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1927 ngx_quic_build_int(&p, NGX_QUIC_FT_RETIRE_CONNECTION_ID); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1928 ngx_quic_build_int(&p, rcid->sequence_number); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1929 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1930 return p - start; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1931 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1932 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1933 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1934 ngx_int_t |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1935 ngx_quic_init_transport_params(ngx_quic_tp_t *tp, ngx_quic_conf_t *qcf) |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1936 { |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1937 ngx_uint_t nstreams; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1938 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1939 ngx_memzero(tp, sizeof(ngx_quic_tp_t)); |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1940 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1941 /* |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1942 * set by ngx_memzero(): |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1943 * |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1944 * tp->disable_active_migration = 0; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1945 * tp->original_dcid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1946 * tp->initial_scid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1947 * tp->retry_scid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1948 * tp->sr_token = { 0 } |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1949 * tp->sr_enabled = 0 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1950 * tp->preferred_address = NULL |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1951 */ |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1952 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1953 tp->max_idle_timeout = qcf->timeout; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1954 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1955 tp->max_udp_payload_size = qcf->mtu; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1956 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1957 nstreams = qcf->max_concurrent_streams_bidi |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1958 + qcf->max_concurrent_streams_uni; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1959 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1960 tp->initial_max_data = nstreams * qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1961 tp->initial_max_stream_data_bidi_local = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1962 tp->initial_max_stream_data_bidi_remote = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1963 tp->initial_max_stream_data_uni = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1964 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1965 tp->initial_max_streams_bidi = qcf->max_concurrent_streams_bidi; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1966 tp->initial_max_streams_uni = qcf->max_concurrent_streams_uni; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1967 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1968 tp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1969 tp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1970 |
8796
7106a918a277
QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8713
diff
changeset
|
1971 tp->active_connection_id_limit = qcf->active_connection_id_limit; |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1972 tp->disable_active_migration = qcf->disable_active_migration; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1973 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1974 return NGX_OK; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1975 } |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1976 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1977 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1978 ssize_t |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1979 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1980 size_t *clen) |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1981 { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1982 u_char *p; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1983 size_t len; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1984 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1985 #define ngx_quic_tp_len(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1986 ngx_quic_varint_len(id) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1987 + ngx_quic_varint_len(value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1988 + ngx_quic_varint_len(ngx_quic_varint_len(value)) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1989 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1990 #define ngx_quic_tp_vint(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1991 do { \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1992 ngx_quic_build_int(&p, id); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1993 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1994 ngx_quic_build_int(&p, value); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1995 } while (0) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
1996 |
7911
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
1997 #define ngx_quic_tp_strlen(id, value) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
1998 ngx_quic_varint_len(id) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
1999 + ngx_quic_varint_len(value.len) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2000 + value.len |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2001 |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2002 #define ngx_quic_tp_str(id, value) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2003 do { \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2004 ngx_quic_build_int(&p, id); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2005 ngx_quic_build_int(&p, value.len); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2006 p = ngx_cpymem(p, value.data, value.len); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2007 } while (0) |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2008 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2009 len = ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_DATA, tp->initial_max_data); |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2010 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2011 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2012 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2013 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2014 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2015 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2016 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2017 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2018 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2019 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2020 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2021 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2022 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2023 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2024 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2025 |
7743
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2026 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2027 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2028 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2029 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2030 tp->max_udp_payload_size); |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2031 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2032 if (tp->disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2033 len += ngx_quic_varint_len(NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2034 len += ngx_quic_varint_len(0); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2035 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2036 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2037 len += ngx_quic_tp_len(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2038 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2039 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2040 /* transport parameters listed above will be saved in 0-RTT context */ |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2041 if (clen) { |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2042 *clen = len; |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2043 } |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2044 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2045 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_ACK_DELAY, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2046 tp->max_ack_delay); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2047 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2048 len += ngx_quic_tp_len(NGX_QUIC_TP_ACK_DELAY_EXPONENT, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2049 tp->ack_delay_exponent); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2050 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2051 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2052 len += ngx_quic_tp_strlen(NGX_QUIC_TP_INITIAL_SCID, tp->initial_scid); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2053 |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2054 if (tp->retry_scid.len) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2055 len += ngx_quic_tp_strlen(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2056 } |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
2057 |
8204
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2058 len += ngx_quic_varint_len(NGX_QUIC_TP_SR_TOKEN); |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2059 len += ngx_quic_varint_len(NGX_QUIC_SR_TOKEN_LEN); |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2060 len += NGX_QUIC_SR_TOKEN_LEN; |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2061 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2062 if (pos == NULL) { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2063 return len; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2064 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2065 |
8629
40f2f059145a
QUIC: moved a variable initialization near to its use.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
2066 p = pos; |
40f2f059145a
QUIC: moved a variable initialization near to its use.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
2067 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2068 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_DATA, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2069 tp->initial_max_data); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2070 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2071 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2072 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2073 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2074 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2075 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2076 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2077 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2078 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2079 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2080 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2081 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2082 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2083 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2084 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2085 |
7743
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2086 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2087 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2088 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2089 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2090 tp->max_udp_payload_size); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2091 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2092 if (tp->disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2093 ngx_quic_build_int(&p, NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2094 ngx_quic_build_int(&p, 0); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2095 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2096 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2097 ngx_quic_tp_vint(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2098 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2099 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2100 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_ACK_DELAY, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2101 tp->max_ack_delay); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2102 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2103 ngx_quic_tp_vint(NGX_QUIC_TP_ACK_DELAY_EXPONENT, |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2104 tp->ack_delay_exponent); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2105 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2106 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2107 ngx_quic_tp_str(NGX_QUIC_TP_INITIAL_SCID, tp->initial_scid); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2108 |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2109 if (tp->retry_scid.len) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2110 ngx_quic_tp_str(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2111 } |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
2112 |
8204
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2113 ngx_quic_build_int(&p, NGX_QUIC_TP_SR_TOKEN); |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2114 ngx_quic_build_int(&p, NGX_QUIC_SR_TOKEN_LEN); |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2115 p = ngx_cpymem(p, tp->sr_token, NGX_QUIC_SR_TOKEN_LEN); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2116 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2117 return p - pos; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2118 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2119 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2120 |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
2121 static size_t |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2122 ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f) |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2123 { |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2124 size_t len; |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2125 u_char *start; |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2126 ngx_quic_close_frame_t *cl; |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2127 |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2128 cl = &f->u.close; |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2129 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2130 if (p == NULL) { |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2131 len = ngx_quic_varint_len(f->type); |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2132 len += ngx_quic_varint_len(cl->error_code); |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2133 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2134 if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) { |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2135 len += ngx_quic_varint_len(cl->frame_type); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2136 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2137 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2138 len += ngx_quic_varint_len(cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2139 len += cl->reason.len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2140 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2141 return len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2142 } |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2143 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2144 start = p; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2145 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2146 ngx_quic_build_int(&p, f->type); |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2147 ngx_quic_build_int(&p, cl->error_code); |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2148 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2149 if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) { |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2150 ngx_quic_build_int(&p, cl->frame_type); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2151 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2152 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2153 ngx_quic_build_int(&p, cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2154 p = ngx_cpymem(p, cl->reason.data, cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2155 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2156 return p - start; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2157 } |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2158 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2159 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2160 void |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2161 ngx_quic_dcid_encode_key(u_char *dcid, uint64_t key) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2162 { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2163 (void) ngx_quic_write_uint64(dcid, key); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2164 } |