Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_transport.c @ 9028:0f4f781e57c1 quic
QUIC: using ngx_ssl_handshake_log().
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 23 Feb 2023 16:17:29 +0400 |
parents | def8e398d7c5 |
children | efd91f6afa8d |
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, |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
112 ngx_quic_new_token_frame_t *token, ngx_chain_t *data); |
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 { |
8831 | 288 return NGX_ERROR; |
8128
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) { |
8831 | 295 return NGX_ERROR; |
8098
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) { |
8831 | 303 return NGX_ERROR; |
8128
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 |
8860
a2fbae359828
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8831
diff
changeset
|
591 + (pkt->level == ssl_encryption_initial ? 1 : 0); |
8683
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 |
8965
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
807 p = ngx_quic_parse_int(p, end, &f->u.ack.largest); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
808 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
809 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
810 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
811 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
812 p = ngx_quic_parse_int(p, end, &f->u.ack.delay); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
813 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
814 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
815 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
816 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
817 p = ngx_quic_parse_int(p, end, &f->u.ack.range_count); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
818 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
819 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
820 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
821 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
822 p = ngx_quic_parse_int(p, end, &f->u.ack.first_range); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
823 if (p == NULL) { |
7838 | 824 goto error; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
825 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
827 b->pos = p; |
7792 | 828 |
829 /* process all ranges to get bounds, values are ignored */ | |
830 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
|
831 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
832 p = ngx_quic_parse_int(p, end, &varint); |
8965
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
833 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
834 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
835 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
836 |
8965
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
837 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
|
838 if (p == NULL) { |
7838 | 839 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
840 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
841 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
842 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
843 b->last = p; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
844 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
845 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
|
846 |
7792 | 847 if (f->type == NGX_QUIC_FT_ACK_ECN) { |
848 | |
8965
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
849 p = ngx_quic_parse_int(p, end, &f->u.ack.ect0); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
850 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
851 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
852 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
853 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
854 p = ngx_quic_parse_int(p, end, &f->u.ack.ect1); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
855 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
856 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
857 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
858 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
859 p = ngx_quic_parse_int(p, end, &f->u.ack.ce); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
860 if (p == NULL) { |
7838 | 861 goto error; |
7792 | 862 } |
863 | |
864 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
|
865 "quic ACK ECN counters ect0:%uL ect1:%uL ce:%uL", |
7792 | 866 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); |
867 } | |
868 | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
869 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
870 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
871 case NGX_QUIC_FT_PING: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
872 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
873 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
874 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
|
875 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
876 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
|
877 if (p == NULL) { |
7838 | 878 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
879 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
880 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
881 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
|
882 if (p == NULL) { |
7838 | 883 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
884 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
885 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
886 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
|
887 goto error; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
888 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
889 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
890 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
|
891 if (p == NULL) { |
7838 | 892 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
893 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
894 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
895 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
|
896 goto error; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
897 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
898 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
899 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
|
900 if (p == NULL) { |
7838 | 901 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
902 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
904 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
|
905 if (p == NULL) { |
7838 | 906 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
907 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
908 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
909 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
910 |
8075 | 911 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
912 | |
913 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number); | |
914 if (p == NULL) { | |
915 goto error; | |
916 } | |
917 | |
918 break; | |
919 | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
920 case NGX_QUIC_FT_CONNECTION_CLOSE: |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
921 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
922 |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
923 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
|
924 if (p == NULL) { |
7838 | 925 goto error; |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
926 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
927 |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
928 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
929 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
|
930 if (p == NULL) { |
7838 | 931 goto error; |
7722
0a18893299fe
Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7721
diff
changeset
|
932 } |
7716
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
933 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
7715
diff
changeset
|
934 |
7720
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
935 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
|
936 if (p == NULL) { |
7838 | 937 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
938 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
939 |
7720
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
940 f->u.close.reason.len = varint; |
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7717
diff
changeset
|
941 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
942 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
|
943 &f->u.close.reason.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
944 if (p == NULL) { |
7838 | 945 goto error; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
946 } |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
947 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
948 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
949 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
950 case NGX_QUIC_FT_STREAM: |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
951 case NGX_QUIC_FT_STREAM1: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
952 case NGX_QUIC_FT_STREAM2: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
953 case NGX_QUIC_FT_STREAM3: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
954 case NGX_QUIC_FT_STREAM4: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
955 case NGX_QUIC_FT_STREAM5: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
956 case NGX_QUIC_FT_STREAM6: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
957 case NGX_QUIC_FT_STREAM7: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
958 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
959 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
|
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.stream_id); |
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 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
966 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
|
967 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
|
968 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
969 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
|
970 if (p == NULL) { |
7838 | 971 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
972 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
973 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
974 } else { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
975 f->u.stream.off = 0; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
976 f->u.stream.offset = 0; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
977 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
978 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
979 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
|
980 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
|
981 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
982 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
|
983 if (p == NULL) { |
7838 | 984 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
985 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
986 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
987 } else { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
988 f->u.stream.len = 0; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
989 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
|
990 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
991 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
992 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
|
993 if (p == NULL) { |
7838 | 994 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
995 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
996 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
997 b->last = p; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
998 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
999 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
|
1000 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1001 |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
1002 case NGX_QUIC_FT_MAX_DATA: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1003 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1004 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
|
1005 if (p == NULL) { |
7838 | 1006 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1007 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1008 |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
1009 break; |
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
1010 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1011 case NGX_QUIC_FT_RESET_STREAM: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1012 |
8965
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1013 p = ngx_quic_parse_int(p, end, &f->u.reset_stream.id); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1014 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1015 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1016 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1017 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1018 p = ngx_quic_parse_int(p, end, &f->u.reset_stream.error_code); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1019 if (p == NULL) { |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1020 goto error; |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1021 } |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1022 |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1023 p = ngx_quic_parse_int(p, end, &f->u.reset_stream.final_size); |
a26897674420
QUIC: fixed C4706 warnings with MSVC 2010.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
1024 if (p == NULL) { |
7838 | 1025 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1026 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1027 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1028 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1029 |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1030 case NGX_QUIC_FT_STOP_SENDING: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1031 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1032 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
|
1033 if (p == NULL) { |
7838 | 1034 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1035 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1036 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1037 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
|
1038 if (p == NULL) { |
7838 | 1039 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1040 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1041 |
7697
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1042 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
7690
diff
changeset
|
1043 |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1044 case NGX_QUIC_FT_STREAMS_BLOCKED: |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1045 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1046 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1047 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
|
1048 if (p == NULL) { |
7838 | 1049 goto error; |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1050 } |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1051 |
8418
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1052 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
|
1053 goto error; |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1054 } |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1055 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1056 f->u.streams_blocked.bidi = |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7703
diff
changeset
|
1057 (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
|
1058 break; |
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
1059 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1060 case NGX_QUIC_FT_MAX_STREAMS: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1061 case NGX_QUIC_FT_MAX_STREAMS2: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1062 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1063 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
|
1064 if (p == NULL) { |
7838 | 1065 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1066 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1067 |
8418
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1068 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
|
1069 goto error; |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1070 } |
17492dfd4744
QUIC: added missing checks for limits in stream frames parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8417
diff
changeset
|
1071 |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1072 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
|
1073 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1074 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1075 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1076 case NGX_QUIC_FT_MAX_STREAM_DATA: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1077 |
7834
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.max_stream_data.id); |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1079 if (p == NULL) { |
7838 | 1080 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1081 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1082 |
8860
a2fbae359828
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8831
diff
changeset
|
1083 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.limit); |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1084 if (p == NULL) { |
7838 | 1085 goto error; |
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 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1088 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1089 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1090 case NGX_QUIC_FT_DATA_BLOCKED: |
7723
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 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
|
1093 if (p == NULL) { |
7838 | 1094 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1095 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1096 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1097 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1098 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1099 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1100 |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1101 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
|
1102 if (p == NULL) { |
7838 | 1103 goto error; |
7834
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1104 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1105 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
7833
diff
changeset
|
1106 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
|
1107 if (p == NULL) { |
7838 | 1108 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1109 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1110 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1111 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1112 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1113 case NGX_QUIC_FT_PATH_CHALLENGE: |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1114 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1115 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
|
1116 if (p == NULL) { |
7838 | 1117 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1118 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1119 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1120 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1121 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1122 case NGX_QUIC_FT_PATH_RESPONSE: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1123 |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1124 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
|
1125 if (p == NULL) { |
7838 | 1126 goto error; |
7723
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1127 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7722
diff
changeset
|
1128 |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1129 break; |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1130 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1131 default: |
7741 | 1132 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
7838 | 1133 "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
|
1134 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1135 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1136 |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1137 f->level = pkt->level; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1138 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1139 return p - start; |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7716
diff
changeset
|
1140 |
7838 | 1141 error: |
1142 | |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
1143 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
|
1144 |
7838 | 1145 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
|
1146 "quic failed to parse frame type:0x%xi", f->type); |
7838 | 1147 |
1148 return NGX_ERROR; | |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1149 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1150 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1151 |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1152 static ngx_int_t |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1153 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
|
1154 { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1155 uint8_t ptype; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1156 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1157 /* |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1158 * RFC 9000, 12.4. Frames and Frame Types: Table 3 |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1159 * |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1160 * Frame permissions per packet: 4 bits: IH01 |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1161 */ |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1162 static uint8_t ngx_quic_frame_masks[] = { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1163 /* PADDING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1164 /* PING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1165 /* ACK */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1166 /* ACK_ECN */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1167 /* RESET_STREAM */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1168 /* STOP_SENDING */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1169 /* CRYPTO */ 0xD, |
7919
c70446e3d771
Treat receipt of NEW_TOKEN as connection error PROTOCOL_VIOLATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7917
diff
changeset
|
1170 /* 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
|
1171 /* STREAM */ 0x3, |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1172 /* STREAM1 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1173 /* STREAM2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1174 /* STREAM3 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1175 /* STREAM4 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1176 /* STREAM5 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1177 /* STREAM6 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1178 /* STREAM7 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1179 /* MAX_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1180 /* MAX_STREAM_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1181 /* MAX_STREAMS */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1182 /* MAX_STREAMS2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1183 /* DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1184 /* STREAM_DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1185 /* STREAMS_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1186 /* STREAMS_BLOCKED2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1187 /* NEW_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1188 /* RETIRE_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1189 /* PATH_CHALLENGE */ 0x3, |
8419
515ac3c8435c
QUIC: fixed permitted packet types for PATH_RESPONSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8418
diff
changeset
|
1190 /* 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
|
1191 /* 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
|
1192 /* CONNECTION_CLOSE2 */ 0x3, |
7847
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1193 /* HANDSHAKE_DONE */ 0x0, /* only sent by server */ |
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 if (ngx_quic_long_pkt(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1197 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1198 if (ngx_quic_pkt_in(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1199 ptype = 8; /* initial */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1200 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1201 } 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
|
1202 ptype = 4; /* handshake */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1203 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1204 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1205 ptype = 2; /* zero-rtt */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1206 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1207 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1208 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1209 ptype = 1; /* application data */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1210 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1211 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1212 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
|
1213 return NGX_OK; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1214 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1215 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1216 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
|
1217 "quic frame type 0x%xi is not " |
7996
d2f716e668e8
Fixed format specifiers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7988
diff
changeset
|
1218 "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
|
1219 frame_type, pkt->flags); |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1220 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1221 return NGX_DECLINED; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1222 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1223 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
7838
diff
changeset
|
1224 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1225 ssize_t |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1226 ngx_quic_parse_ack_range(ngx_log_t *log, u_char *start, u_char *end, |
7792 | 1227 uint64_t *gap, uint64_t *range) |
1228 { | |
1229 u_char *p; | |
1230 | |
1231 p = start; | |
1232 | |
1233 p = ngx_quic_parse_int(p, end, gap); | |
1234 if (p == NULL) { | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1235 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1236 "quic failed to parse ack frame gap"); |
7792 | 1237 return NGX_ERROR; |
1238 } | |
1239 | |
1240 p = ngx_quic_parse_int(p, end, range); | |
1241 if (p == NULL) { | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
1242 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1243 "quic failed to parse ack frame range"); |
7792 | 1244 return NGX_ERROR; |
1245 } | |
1246 | |
1247 return p - start; | |
1248 } | |
1249 | |
1250 | |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1251 size_t |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1252 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
|
1253 { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1254 size_t len; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1255 u_char *start; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1256 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1257 if (p == NULL) { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1258 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
|
1259 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
|
1260 return len; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1261 } |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1262 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1263 start = p; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1264 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1265 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
|
1266 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
|
1267 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1268 return p - start; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1269 } |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1270 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8168
diff
changeset
|
1271 |
7792 | 1272 ssize_t |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1273 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
|
1274 { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1275 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1276 * RFC 9002, 2. Conventions and Definitions |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1277 * |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8441
diff
changeset
|
1278 * 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
|
1279 * CONNECTION_CLOSE are considered ack-eliciting. |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1280 */ |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1281 f->need_ack = 1; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1282 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1283 switch (f->type) { |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1284 case NGX_QUIC_FT_PING: |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1285 return ngx_quic_create_ping(p); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1286 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1287 case NGX_QUIC_FT_ACK: |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1288 f->need_ack = 0; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1289 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
|
1290 |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1291 case NGX_QUIC_FT_RESET_STREAM: |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1292 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
|
1293 |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1294 case NGX_QUIC_FT_STOP_SENDING: |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1295 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
|
1296 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1297 case NGX_QUIC_FT_CRYPTO: |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1298 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
|
1299 |
7739
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1300 case NGX_QUIC_FT_HANDSHAKE_DONE: |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1301 return ngx_quic_create_hs_done(p); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1302 |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1303 case NGX_QUIC_FT_NEW_TOKEN: |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1304 return ngx_quic_create_new_token(p, &f->u.token, f->data); |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1305 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1306 case NGX_QUIC_FT_STREAM: |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1307 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
|
1308 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1309 case NGX_QUIC_FT_CONNECTION_CLOSE: |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
1310 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1311 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
|
1312 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
|
1313 |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1314 case NGX_QUIC_FT_MAX_STREAMS: |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1315 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
|
1316 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1317 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
|
1318 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
|
1319 |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1320 case NGX_QUIC_FT_MAX_DATA: |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1321 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
|
1322 |
8388
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1323 case NGX_QUIC_FT_PATH_CHALLENGE: |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1324 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
|
1325 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1326 case NGX_QUIC_FT_PATH_RESPONSE: |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1327 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
|
1328 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1329 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1330 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
|
1331 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1332 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1333 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
|
1334 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1335 default: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1336 /* BUG: unsupported frame type generated */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1337 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1338 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1339 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1340 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1341 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1342 static size_t |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1343 ngx_quic_create_ping(u_char *p) |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1344 { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1345 u_char *start; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1346 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1347 if (p == NULL) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1348 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
|
1349 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1350 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1351 start = p; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1352 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1353 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
|
1354 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1355 return p - start; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1356 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1357 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1358 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
1359 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1360 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
|
1361 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1362 size_t len; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1363 u_char *start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1364 ngx_buf_t *b; |
7690
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 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1367 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
|
1368 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
|
1369 len += ngx_quic_varint_len(ack->delay); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1370 len += ngx_quic_varint_len(ack->range_count); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1371 len += ngx_quic_varint_len(ack->first_range); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1372 len += ack->ranges_length; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1373 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1374 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1375 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1376 |
7710
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1377 start = p; |
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1378 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1379 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
|
1380 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
|
1381 ngx_quic_build_int(&p, ack->delay); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1382 ngx_quic_build_int(&p, ack->range_count); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1383 ngx_quic_build_int(&p, ack->first_range); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1384 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1385 while (ranges) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1386 b = ranges->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1387 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1388 ranges = ranges->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1389 } |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8153
diff
changeset
|
1390 |
7710
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
7709
diff
changeset
|
1391 return p - start; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1392 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1393 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1394 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1395 static size_t |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1396 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
|
1397 { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1398 size_t len; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1399 u_char *start; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1400 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1401 if (p == NULL) { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1402 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
|
1403 len += ngx_quic_varint_len(rs->id); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1404 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
|
1405 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
|
1406 return len; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1407 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1408 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1409 start = p; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1410 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1411 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
|
1412 ngx_quic_build_int(&p, rs->id); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1413 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
|
1414 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
|
1415 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1416 return p - start; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1417 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1418 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1419 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
1420 static size_t |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1421 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
|
1422 { |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1423 size_t len; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1424 u_char *start; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1425 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1426 if (p == NULL) { |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1427 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
|
1428 len += ngx_quic_varint_len(ss->id); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1429 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
|
1430 return len; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1431 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1432 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1433 start = p; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1434 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1435 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
|
1436 ngx_quic_build_int(&p, ss->id); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1437 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
|
1438 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1439 return p - start; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1440 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1441 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1442 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8063
diff
changeset
|
1443 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1444 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
|
1445 ngx_chain_t *data) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1446 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1447 size_t len; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1448 u_char *start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1449 ngx_buf_t *b; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1450 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1451 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1452 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
|
1453 len += ngx_quic_varint_len(crypto->offset); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1454 len += ngx_quic_varint_len(crypto->length); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1455 len += crypto->length; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1456 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1457 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1458 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1459 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1460 start = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1461 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1462 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
|
1463 ngx_quic_build_int(&p, crypto->offset); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7792
diff
changeset
|
1464 ngx_quic_build_int(&p, crypto->length); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1465 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1466 while (data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1467 b = data->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1468 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1469 data = data->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1470 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1471 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1472 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1473 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1474 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1475 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1476 static size_t |
7739
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1477 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
|
1478 { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1479 u_char *start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1480 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1481 if (p == NULL) { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1482 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
|
1483 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1484 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1485 start = p; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1486 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1487 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
|
1488 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1489 return p - start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1490 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1491 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1492 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
7735
diff
changeset
|
1493 static size_t |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1494 ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token, |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1495 ngx_chain_t *data) |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1496 { |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1497 size_t len; |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1498 u_char *start; |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1499 ngx_buf_t *b; |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1500 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1501 if (p == NULL) { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1502 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
|
1503 len += ngx_quic_varint_len(token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1504 len += token->length; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1505 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1506 return len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1507 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1508 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1509 start = p; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1510 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1511 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
|
1512 ngx_quic_build_int(&p, token->length); |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1513 |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1514 while (data) { |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1515 b = data->buf; |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1516 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1517 data = data->next; |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
8965
diff
changeset
|
1518 } |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1519 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1520 return p - start; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1521 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1522 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1523 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
1524 static size_t |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1525 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
|
1526 ngx_chain_t *data) |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1527 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1528 size_t len; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1529 u_char *start, type; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1530 ngx_buf_t *b; |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1531 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1532 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
|
1533 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1534 if (sf->off) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1535 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
|
1536 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1537 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1538 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1539 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
|
1540 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1541 |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1542 if (sf->fin) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1543 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
|
1544 } |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1545 |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1546 if (p == NULL) { |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1547 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
|
1548 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
|
1549 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1550 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1551 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
|
1552 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1553 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1554 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1555 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
|
1556 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1557 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1558 len += sf->length; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1559 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1560 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1561 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1562 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1563 start = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1564 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1565 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
|
1566 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
|
1567 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1568 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1569 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
|
1570 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1571 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1572 if (sf->len) { |
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
1573 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
|
1574 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1575 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1576 while (data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1577 b = data->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1578 p = ngx_cpymem(p, b->pos, b->last - b->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1579 data = data->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8235
diff
changeset
|
1580 } |
7690
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1581 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1582 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1583 } |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1584 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1585 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
1586 static size_t |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1587 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
|
1588 { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1589 size_t len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1590 u_char *start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1591 ngx_uint_t type; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1592 |
8860
a2fbae359828
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8831
diff
changeset
|
1593 type = ms->bidi ? NGX_QUIC_FT_MAX_STREAMS : NGX_QUIC_FT_MAX_STREAMS2; |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1594 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1595 if (p == NULL) { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1596 len = ngx_quic_varint_len(type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1597 len += ngx_quic_varint_len(ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1598 return len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1599 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1600 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1601 start = p; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1602 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1603 ngx_quic_build_int(&p, type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1604 ngx_quic_build_int(&p, ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1605 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1606 return p - start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1607 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1608 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
1609 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1610 static ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1611 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
|
1612 ngx_quic_tp_t *dst) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1613 { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1614 uint64_t varint; |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1615 ngx_str_t str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1616 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1617 varint = 0; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1618 ngx_str_null(&str); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1619 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1620 switch (id) { |
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 case NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1623 /* zero-length option */ |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1624 if (end - p != 0) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1625 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1626 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1627 dst->disable_active_migration = 1; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1628 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1629 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1630 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
|
1631 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
|
1632 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1633 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
|
1634 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
|
1635 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
|
1636 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1637 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1638 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1639 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1640 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1641 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1642 p = ngx_quic_parse_int(p, end, &varint); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1643 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1644 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1645 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1646 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1647 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1648 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1649 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1650 str.len = end - p; |
8141
b95aa1cb8f98
QUIC: fixed dead store assignment.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8128
diff
changeset
|
1651 str.data = p; |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1652 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1653 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1654 default: |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1655 return NGX_DECLINED; |
7726
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 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1658 switch (id) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1659 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1660 case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1661 dst->max_idle_timeout = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1662 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1663 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1664 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
|
1665 dst->max_udp_payload_size = varint; |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1666 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1667 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1668 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1669 dst->initial_max_data = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1670 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1671 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1672 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
|
1673 dst->initial_max_stream_data_bidi_local = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1674 break; |
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 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
|
1677 dst->initial_max_stream_data_bidi_remote = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1678 break; |
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 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
|
1681 dst->initial_max_stream_data_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1682 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1683 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1684 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1685 dst->initial_max_streams_bidi = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1686 break; |
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 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1689 dst->initial_max_streams_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1690 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1691 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1692 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1693 dst->ack_delay_exponent = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1694 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1695 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1696 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1697 dst->max_ack_delay = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1698 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1699 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1700 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1701 dst->active_connection_id_limit = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1702 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1703 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1704 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1705 dst->initial_scid = str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1706 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1707 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1708 default: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1709 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1710 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1711 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1712 return NGX_OK; |
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 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1715 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1716 ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1717 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
|
1718 ngx_log_t *log) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1719 { |
7833
42198f77ac85
Removed support of drafts older than currently latest 27.
Vladimir Homutov <vl@nginx.com>
parents:
7828
diff
changeset
|
1720 uint64_t id, len; |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1721 ngx_int_t rc; |
7726
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 while (p < end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1724 p = ngx_quic_parse_int(p, end, &id); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1725 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1726 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1727 "quic failed to parse transport param id"); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1728 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1729 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1730 |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1731 switch (id) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1732 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
|
1733 case NGX_QUIC_TP_PREFERRED_ADDRESS: |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1734 case NGX_QUIC_TP_RETRY_SCID: |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1735 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
|
1736 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
|
1737 "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
|
1738 " id:0x%xL", id); |
7909
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1739 return NGX_ERROR; |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1740 } |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7868
diff
changeset
|
1741 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1742 p = ngx_quic_parse_int(p, end, &len); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1743 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1744 ngx_log_error(NGX_LOG_INFO, log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
1745 "quic failed to parse" |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8293
diff
changeset
|
1746 " transport param id:0x%xL length", id); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1747 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1748 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1749 |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1750 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
|
1751 |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1752 if (rc == NGX_ERROR) { |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1753 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1754 "quic failed to parse" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1755 " transport param id:0x%xL data", id); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1756 return NGX_ERROR; |
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 |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1759 if (rc == NGX_DECLINED) { |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1760 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
|
1761 "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
|
1762 (id % 31 == 27) ? "reserved" : "unknown", id); |
7728
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1763 } |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7727
diff
changeset
|
1764 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1765 p += len; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1766 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1767 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1768 if (p != end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1769 ngx_log_error(NGX_LOG_INFO, log, 0, |
7838 | 1770 "quic trailing garbage in" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1771 " transport parameters: bytes:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1772 end - p); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1773 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1774 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1775 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1776 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0, |
7836 | 1777 "quic transport parameters parsed ok"); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1778 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1779 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
7836 | 1780 "quic tp disable active migration: %ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1781 tp->disable_active_migration); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1782 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1783 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
|
1784 tp->max_idle_timeout); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1785 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7909
diff
changeset
|
1786 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
|
1787 "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
|
1788 tp->max_udp_payload_size); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1789 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1790 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
|
1791 tp->initial_max_data); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1792 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1793 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
|
1794 "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
|
1795 tp->initial_max_stream_data_bidi_local); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1796 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1797 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
|
1798 "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
|
1799 tp->initial_max_stream_data_bidi_remote); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1800 |
7836 | 1801 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
|
1802 "quic tp max_stream_data_uni:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1803 tp->initial_max_stream_data_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1804 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1805 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
|
1806 "quic tp initial_max_streams_bidi:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1807 tp->initial_max_streams_bidi); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1808 |
7836 | 1809 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
|
1810 "quic tp initial_max_streams_uni:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1811 tp->initial_max_streams_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1812 |
7836 | 1813 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
|
1814 "quic tp ack_delay_exponent:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1815 tp->ack_delay_exponent); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1816 |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1817 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
|
1818 tp->max_ack_delay); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1819 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1820 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
|
1821 "quic tp active_connection_id_limit:%ui", |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1822 tp->active_connection_id_limit); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1823 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1824 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
|
1825 "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
|
1826 tp->initial_scid.len, &tp->initial_scid); |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
1827 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1828 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1829 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1830 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7723
diff
changeset
|
1831 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1832 static size_t |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1833 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
|
1834 { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1835 size_t len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1836 u_char *start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1837 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1838 if (p == NULL) { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1839 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
|
1840 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
|
1841 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
|
1842 return len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1843 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1844 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1845 start = p; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1846 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1847 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
|
1848 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
|
1849 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
|
1850 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1851 return p - start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1852 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1853 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7730
diff
changeset
|
1854 |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1855 static size_t |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1856 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
|
1857 { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1858 size_t len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1859 u_char *start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1860 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1861 if (p == NULL) { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1862 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
|
1863 len += ngx_quic_varint_len(md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1864 return len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1865 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1866 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1867 start = p; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1868 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1869 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
|
1870 ngx_quic_build_int(&p, md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1871 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1872 return p - start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1873 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1874 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
1875 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1876 static size_t |
8388
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1877 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
|
1878 { |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1879 size_t len; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1880 u_char *start; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1881 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1882 if (p == NULL) { |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1883 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
|
1884 len += sizeof(pc->data); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1885 return len; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1886 } |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1887 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1888 start = p; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1889 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1890 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
|
1891 p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1892 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1893 return p - start; |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1894 } |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1895 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1896 |
47e0009e53a7
QUIC: PATH_CHALLENGE frame creation.
Vladimir Homutov <vl@nginx.com>
parents:
8322
diff
changeset
|
1897 static size_t |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1898 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
|
1899 { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1900 size_t len; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1901 u_char *start; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1902 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1903 if (p == NULL) { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1904 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
|
1905 len += sizeof(pc->data); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1906 return len; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1907 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1908 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1909 start = p; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1910 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1911 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
|
1912 p = ngx_cpymem(p, &pc->data, sizeof(pc->data)); |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1913 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1914 return p - start; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1915 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1916 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
1917 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1918 static size_t |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1919 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
|
1920 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1921 size_t len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1922 u_char *start; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1923 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1924 if (p == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1925 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
|
1926 len += ngx_quic_varint_len(ncid->seqnum); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1927 len += ngx_quic_varint_len(ncid->retire); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1928 len++; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1929 len += ncid->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1930 len += NGX_QUIC_SR_TOKEN_LEN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1931 return len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1932 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1933 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1934 start = p; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1935 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1936 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
|
1937 ngx_quic_build_int(&p, ncid->seqnum); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1938 ngx_quic_build_int(&p, ncid->retire); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1939 *p++ = ncid->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1940 p = ngx_cpymem(p, ncid->cid, ncid->len); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1941 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
|
1942 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1943 return p - start; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1944 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1945 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1946 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
1947 static size_t |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1948 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
|
1949 ngx_quic_retire_cid_frame_t *rcid) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1950 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1951 size_t len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1952 u_char *start; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1953 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1954 if (p == NULL) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1955 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
|
1956 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
|
1957 return len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1958 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1959 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1960 start = p; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1961 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1962 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
|
1963 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
|
1964 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1965 return p - start; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1966 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1967 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8075
diff
changeset
|
1968 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1969 ngx_int_t |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1970 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
|
1971 { |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1972 ngx_uint_t nstreams; |
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 ngx_memzero(tp, sizeof(ngx_quic_tp_t)); |
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 * set by ngx_memzero(): |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1978 * |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1979 * tp->disable_active_migration = 0; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1980 * tp->original_dcid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1981 * tp->initial_scid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1982 * tp->retry_scid = { 0, NULL }; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1983 * tp->sr_token = { 0 } |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1984 * tp->sr_enabled = 0 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1985 * tp->preferred_address = NULL |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1986 */ |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1987 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1988 tp->max_idle_timeout = qcf->timeout; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1989 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1990 tp->max_udp_payload_size = qcf->mtu; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1991 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1992 nstreams = qcf->max_concurrent_streams_bidi |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1993 + qcf->max_concurrent_streams_uni; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1994 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1995 tp->initial_max_data = nstreams * qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1996 tp->initial_max_stream_data_bidi_local = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1997 tp->initial_max_stream_data_bidi_remote = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1998 tp->initial_max_stream_data_uni = qcf->stream_buffer_size; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
1999 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2000 tp->initial_max_streams_bidi = qcf->max_concurrent_streams_bidi; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2001 tp->initial_max_streams_uni = qcf->max_concurrent_streams_uni; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2002 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2003 tp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2004 tp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2005 |
8796
7106a918a277
QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8713
diff
changeset
|
2006 tp->active_connection_id_limit = qcf->active_connection_id_limit; |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2007 tp->disable_active_migration = qcf->disable_active_migration; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2008 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2009 return NGX_OK; |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2010 } |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2011 |
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8687
diff
changeset
|
2012 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2013 ssize_t |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2014 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
|
2015 size_t *clen) |
7713
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 u_char *p; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2018 size_t len; |
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 #define ngx_quic_tp_len(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2021 ngx_quic_varint_len(id) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2022 + ngx_quic_varint_len(value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2023 + ngx_quic_varint_len(ngx_quic_varint_len(value)) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2024 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2025 #define ngx_quic_tp_vint(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2026 do { \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2027 ngx_quic_build_int(&p, id); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2028 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2029 ngx_quic_build_int(&p, value); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2030 } while (0) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2031 |
7911
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2032 #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
|
2033 ngx_quic_varint_len(id) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2034 + ngx_quic_varint_len(value.len) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2035 + value.len |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2036 |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2037 #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
|
2038 do { \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2039 ngx_quic_build_int(&p, id); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2040 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
|
2041 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
|
2042 } while (0) |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
2043 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2044 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
|
2045 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2046 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
|
2047 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2048 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2049 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
|
2050 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2051 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2052 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
|
2053 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2054 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2055 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
|
2056 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2057 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2058 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
|
2059 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2060 |
7743
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2061 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
|
2062 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2063 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2064 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
|
2065 tp->max_udp_payload_size); |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2066 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2067 if (tp->disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2068 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
|
2069 len += ngx_quic_varint_len(0); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2070 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2071 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2072 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
|
2073 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2074 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2075 /* 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
|
2076 if (clen) { |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2077 *clen = len; |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2078 } |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2079 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2080 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
|
2081 tp->max_ack_delay); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2082 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2083 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
|
2084 tp->ack_delay_exponent); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2085 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2086 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
|
2087 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
|
2088 |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2089 if (tp->retry_scid.len) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2090 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
|
2091 } |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
2092 |
8204
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2093 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
|
2094 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
|
2095 len += NGX_QUIC_SR_TOKEN_LEN; |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2096 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2097 if (pos == NULL) { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2098 return len; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2099 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2100 |
8629
40f2f059145a
QUIC: moved a variable initialization near to its use.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
2101 p = pos; |
40f2f059145a
QUIC: moved a variable initialization near to its use.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
2102 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2103 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_DATA, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2104 tp->initial_max_data); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2105 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2106 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2107 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2108 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2109 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2110 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2111 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2112 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
|
2113 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2114 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2115 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
|
2116 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2117 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2118 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
|
2119 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2120 |
7743
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2121 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
|
2122 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7741
diff
changeset
|
2123 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2124 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
|
2125 tp->max_udp_payload_size); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2126 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2127 if (tp->disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2128 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
|
2129 ngx_quic_build_int(&p, 0); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2130 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8195
diff
changeset
|
2131 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2132 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
|
2133 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
2134 |
8293
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2135 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
|
2136 tp->max_ack_delay); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2137 |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2138 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
|
2139 tp->ack_delay_exponent); |
75603531064a
QUIC: updated list of transport parameters to be sent.
Vladimir Homutov <vl@nginx.com>
parents:
8292
diff
changeset
|
2140 |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2141 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
|
2142 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
|
2143 |
7916
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7912
diff
changeset
|
2144 if (tp->retry_scid.len) { |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7911
diff
changeset
|
2145 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
|
2146 } |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7847
diff
changeset
|
2147 |
8204
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2148 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
|
2149 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
|
2150 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
|
2151 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2152 return p - pos; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2153 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2154 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7711
diff
changeset
|
2155 |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7710
diff
changeset
|
2156 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
|
2157 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
|
2158 { |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2159 size_t len; |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2160 u_char *start; |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2161 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
|
2162 |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2163 cl = &f->u.close; |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2164 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2165 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
|
2166 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
|
2167 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
|
2168 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2169 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
|
2170 len += ngx_quic_varint_len(cl->frame_type); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2171 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2172 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2173 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
|
2174 len += cl->reason.len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2175 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2176 return len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2177 } |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2178 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2179 start = p; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2180 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2181 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
|
2182 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
|
2183 |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8271
diff
changeset
|
2184 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
|
2185 ngx_quic_build_int(&p, cl->frame_type); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2186 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7942
diff
changeset
|
2187 |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2188 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
|
2189 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
|
2190 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2191 return p - start; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7697
diff
changeset
|
2192 } |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2193 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2194 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2195 void |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2196 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
|
2197 { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2198 (void) ngx_quic_write_uint64(dcid, key); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8266
diff
changeset
|
2199 } |