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