Mercurial > hg > nginx
annotate src/event/ngx_event_quic_transport.c @ 8452:a6675a976560 quic
HTTP/3: fixed dropping first non-pseudo header.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 26 Jun 2020 10:05:28 +0300 |
parents | 97adb87f149b |
children | e0f92f68e018 |
rev | line source |
---|---|
8224
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> |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
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 #if (NGX_HAVE_NONALIGNED) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 #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
|
15 #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
|
16 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 #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
|
18 #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
|
19 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
20 #else |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
21 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
22 #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
|
23 #define ngx_quic_parse_uint32(p) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 ((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
|
25 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 #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
|
27 ((p)[0] = (u_char) ((s) >> 8), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 (p)[1] = (u_char) (s), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 (p) + sizeof(uint16_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 #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
|
32 ((p)[0] = (u_char) ((s) >> 24), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 (p)[1] = (u_char) ((s) >> 16), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 (p)[2] = (u_char) ((s) >> 8), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 (p)[3] = (u_char) (s), \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 (p) + sizeof(uint32_t)) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 #endif |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 |
8315
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
40 #define ngx_quic_write_uint24(p, s) \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
41 ((p)[0] = (u_char) ((s) >> 16), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
42 (p)[1] = (u_char) ((s) >> 8), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
43 (p)[2] = (u_char) (s), \ |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
44 (p) + 3) |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
45 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 #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
|
47 (*(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
|
48 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
49 #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
|
50 (*(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
|
51 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
52 #define ngx_quic_varint_len(value) \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
53 ((value) <= 63 ? 1 \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
54 : ((uint32_t) value) <= 16383 ? 2 \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
55 : ((uint64_t) value) <= 1073741823 ? 4 \ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
56 : 8) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
57 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
58 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
59 static u_char *ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 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
|
61 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
62 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:
8237
diff
changeset
|
63 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:
8237
diff
changeset
|
64 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:
8237
diff
changeset
|
65 u_char **out); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
66 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:
8237
diff
changeset
|
67 u_char *dst); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
68 |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
69 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:
8361
diff
changeset
|
70 ngx_uint_t frame_type); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 static size_t ngx_quic_create_crypto(u_char *p, |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 ngx_quic_crypto_frame_t *crypto); |
8273
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
74 static size_t ngx_quic_create_hs_done(u_char *p); |
8384
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
75 static size_t ngx_quic_create_new_token(u_char *p, |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
76 ngx_quic_new_token_frame_t *token); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf); |
8245
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
78 static size_t ngx_quic_create_max_streams(u_char *p, |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
79 ngx_quic_max_streams_frame_t *ms); |
8266
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
80 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:
8264
diff
changeset
|
81 ngx_quic_max_stream_data_frame_t *ms); |
8338
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
82 static size_t ngx_quic_create_max_data(u_char *p, |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
83 ngx_quic_max_data_frame_t *md); |
8235
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
84 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
85 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
86 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:
8257
diff
changeset
|
87 uint16_t id, ngx_quic_tp_t *dst); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
88 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
89 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
90 /* literal errors indexed by corresponding value */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
91 static char *ngx_quic_errors[] = { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
92 "NO_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
93 "INTERNAL_ERROR", |
8440
f9592e804834
QUIC error SERVER_BUSY renamed to CONNECTION_REFUSED in draft-29.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8426
diff
changeset
|
94 "CONNECTION_REFUSED", |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 "FLOW_CONTROL_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 "STREAM_LIMIT_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
97 "STREAM_STATE_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
98 "FINAL_SIZE_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
99 "FRAME_ENCODING_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
100 "TRANSPORT_PARAMETER_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
101 "CONNECTION_ID_LIMIT_ERROR", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
102 "PROTOCOL_VIOLATION", |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
103 "INVALID_TOKEN", |
8426
6ea2f1daedb5
Introduced connection error APPLICATION_ERROR from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8425
diff
changeset
|
104 "APPLICATION_ERROR", |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
105 "CRYPTO_BUFFER_EXCEEDED", |
8444
769d8bdeffb0
Define KEY_UPDATE_ERROR from quic-tls-24.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8440
diff
changeset
|
106 "KEY_UPDATE_ERROR", |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
107 }; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
108 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
109 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
110 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
111 ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out) |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
112 { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
113 u_char *p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
114 uint64_t value; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
115 ngx_uint_t len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
116 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
117 if (pos >= end) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
118 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
119 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
120 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
121 p = pos; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
122 len = 1 << ((*p & 0xc0) >> 6); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
123 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 value = *p++ & 0x3f; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
126 if ((size_t)(end - p) < (len - 1)) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
127 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
128 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
129 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 while (--len) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
131 value = (value << 8) + *p++; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
132 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
133 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
134 *out = value; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
135 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
136 return p; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
137 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
138 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
139 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
140 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
141 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:
8237
diff
changeset
|
142 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
143 if ((size_t)(end - pos) < 1) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
144 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
145 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
146 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
147 *value = *pos; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
148 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
149 return pos + 1; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
150 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
151 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
152 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
153 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
154 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:
8237
diff
changeset
|
155 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
156 if ((size_t)(end - pos) < sizeof(uint32_t)) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
157 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
158 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
159 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
160 *value = ngx_quic_parse_uint32(pos); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
161 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
162 return pos + sizeof(uint32_t); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
163 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
164 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
165 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
166 static ngx_inline u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
167 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:
8237
diff
changeset
|
168 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
169 if ((size_t)(end - pos) < len) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
170 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
171 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
172 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
173 *out = pos; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
174 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
175 return pos + len; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
176 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
177 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
178 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
179 static u_char * |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
180 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:
8237
diff
changeset
|
181 { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
182 if ((size_t)(end - pos) < len) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
183 return NULL; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
184 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
185 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
186 ngx_memcpy(dst, pos, len); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
187 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
188 return pos + len; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
189 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
190 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
191 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
192 static void |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
193 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
|
194 { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 u_char *p; |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
196 ngx_uint_t bits, len; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
198 p = *pos; |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
199 bits = 0; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
200 |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
201 while (value >> ((8 << bits) - 2)) { |
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
202 bits++; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
203 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
204 |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
205 len = (1 << bits); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
207 while (len--) { |
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
208 *p++ = value >> (len * 8); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
210 |
8351
dd84c9cef75b
Improved ngx_quic_build_int() code and readability.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8344
diff
changeset
|
211 **pos |= bits << 6; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
212 *pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
213 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
215 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
216 u_char * |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
217 ngx_quic_error_text(uint64_t error_code) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
218 { |
8447
97adb87f149b
Get rid of hardcoded numbers used for quic handshake errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8444
diff
changeset
|
219 if (error_code >= NGX_QUIC_ERR_CRYPTO_ERROR) { |
97adb87f149b
Get rid of hardcoded numbers used for quic handshake errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8444
diff
changeset
|
220 return (u_char *) "handshake error"; |
97adb87f149b
Get rid of hardcoded numbers used for quic handshake errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8444
diff
changeset
|
221 } |
8342 | 222 |
223 if (error_code >= NGX_QUIC_ERR_LAST) { | |
224 return (u_char *) "unknown error"; | |
225 } | |
226 | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
227 return (u_char *) ngx_quic_errors[error_code]; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
228 } |
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 ngx_int_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
232 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
|
233 { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
234 u_char *p, *end; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
235 uint8_t idlen; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 p = pkt->data; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
238 end = pkt->data + pkt->len; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
239 |
8359 | 240 #ifdef NGX_QUIC_DEBUG_PACKETS |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
241 ngx_quic_hexdump(pkt->log, "quic long packet in", pkt->data, pkt->len); |
8359 | 242 #endif |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
243 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
244 p = ngx_quic_read_uint8(p, end, &pkt->flags); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
245 if (p == NULL) { |
8275 | 246 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 247 "quic packet is too small to read flags"); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
248 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
249 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
251 if (!ngx_quic_long_pkt(pkt->flags)) { |
8361 | 252 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic not a long packet"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
253 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
254 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
255 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
256 p = ngx_quic_read_uint32(p, end, &pkt->version); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
257 if (p == NULL) { |
8275 | 258 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 259 "quic packet is too small to read version"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
260 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
261 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
262 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
263 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 264 "quic long packet flags:%xi version:%xD", |
265 pkt->flags, pkt->version); | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
266 |
8386
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
267 if (!(pkt->flags & NGX_QUIC_PKT_FIXED_BIT)) { |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
268 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic fixed bit is not set"); |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
269 return NGX_DECLINED; |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
270 } |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
271 |
8269
c9c3a73df6e8
Support for HTTP/3 ALPN.
Roman Arutyunyan <arut@nginx.com>
parents:
8268
diff
changeset
|
272 if (pkt->version != NGX_QUIC_VERSION) { |
8275 | 273 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 274 "quic unsupported version: 0x%xi", pkt->version); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
275 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
276 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
277 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
278 p = ngx_quic_read_uint8(p, end, &idlen); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
279 if (p == NULL) { |
8275 | 280 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 281 "quic packet is too small to read dcid len"); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
282 return NGX_ERROR; |
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 |
8387
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
285 if (idlen > NGX_QUIC_CID_LEN_MAX) { |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
286 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:
8386
diff
changeset
|
287 "quic packet dcid is too long"); |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
288 return NGX_ERROR; |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
289 } |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
290 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
291 pkt->dcid.len = idlen; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
292 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
293 p = ngx_quic_read_bytes(p, end, idlen, &pkt->dcid.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
294 if (p == NULL) { |
8275 | 295 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 296 "quic packet is too small to read dcid"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
297 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
298 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
299 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
300 p = ngx_quic_read_uint8(p, end, &idlen); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
301 if (p == NULL) { |
8275 | 302 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 303 "quic packet is too small to read scid len"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
304 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
305 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
306 |
8387
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
307 if (idlen > NGX_QUIC_CID_LEN_MAX) { |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
308 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:
8386
diff
changeset
|
309 "quic packet scid is too long"); |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
310 return NGX_ERROR; |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
311 } |
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
8386
diff
changeset
|
312 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
313 pkt->scid.len = idlen; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
314 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
315 p = ngx_quic_read_bytes(p, end, idlen, &pkt->scid.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
316 if (p == NULL) { |
8275 | 317 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 318 "quic packet is too small to read scid"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
319 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
320 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
321 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
322 pkt->raw->pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
323 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
324 return NGX_OK; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
325 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
328 size_t |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
329 ngx_quic_create_long_header(ngx_quic_header_t *pkt, u_char *out, |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
330 size_t pkt_len, u_char **pnp) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
331 { |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
332 u_char *p, *start; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
333 |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
334 p = start = out; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
335 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 *p++ = pkt->flags; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 |
8269
c9c3a73df6e8
Support for HTTP/3 ALPN.
Roman Arutyunyan <arut@nginx.com>
parents:
8268
diff
changeset
|
338 p = ngx_quic_write_uint32(p, NGX_QUIC_VERSION); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 |
8344
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
8342
diff
changeset
|
340 *p++ = pkt->dcid.len; |
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
8342
diff
changeset
|
341 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:
8342
diff
changeset
|
342 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 *p++ = pkt->scid.len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 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
|
345 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 if (pkt->level == ssl_encryption_initial) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
347 ngx_quic_build_int(&p, pkt->token.len); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
348 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 |
8315
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
350 ngx_quic_build_int(&p, pkt_len + pkt->num_len); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 *pnp = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 |
8315
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
354 switch (pkt->num_len) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
355 case 1: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
356 *p++ = pkt->trunc; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
357 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
358 case 2: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
359 p = ngx_quic_write_uint16(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
360 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
361 case 3: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
362 p = ngx_quic_write_uint24(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
363 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
364 case 4: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
365 p = ngx_quic_write_uint32(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
366 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
367 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
368 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
373 size_t |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
374 ngx_quic_create_short_header(ngx_quic_header_t *pkt, u_char *out, |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
375 size_t pkt_len, u_char **pnp) |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
376 { |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
377 u_char *p, *start; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
378 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
379 p = start = out; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
380 |
8315
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
381 *p++ = pkt->flags; |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
382 |
8344
e0abe17a2878
Removed source/destination swap from the function creating header.
Vladimir Homutov <vl@nginx.com>
parents:
8342
diff
changeset
|
383 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
384 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
385 *pnp = p; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
386 |
8315
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
387 switch (pkt->num_len) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
388 case 1: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
389 *p++ = pkt->trunc; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
390 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
391 case 2: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
392 p = ngx_quic_write_uint16(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
393 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
394 case 3: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
395 p = ngx_quic_write_uint24(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
396 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
397 case 4: |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
398 p = ngx_quic_write_uint32(p, pkt->trunc); |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
399 break; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
8308
diff
changeset
|
400 } |
8285
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
401 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
402 return p - start; |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
403 } |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
404 |
f85749b60e58
Removed memory allocations from encryption code.
Vladimir Homutov <vl@nginx.com>
parents:
8277
diff
changeset
|
405 |
8383
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
406 size_t |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
407 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:
8370
diff
changeset
|
408 u_char **start) |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
409 { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
410 u_char *p; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
411 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
412 p = out; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
413 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
414 *p++ = pkt->odcid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
415 p = ngx_cpymem(p, pkt->odcid.data, pkt->odcid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
416 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
417 *start = p; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
418 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
419 *p++ = 0xff; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
420 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
421 p = ngx_quic_write_uint32(p, NGX_QUIC_VERSION); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
422 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
423 *p++ = pkt->dcid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
424 p = ngx_cpymem(p, pkt->dcid.data, pkt->dcid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
425 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
426 *p++ = pkt->scid.len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
427 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
428 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
429 p = ngx_cpymem(p, pkt->token.data, pkt->token.len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
430 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
431 return p - out; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
432 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
433 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
434 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
435 ngx_int_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
436 ngx_quic_parse_short_header(ngx_quic_header_t *pkt, ngx_str_t *dcid) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
438 u_char *p, *end; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
439 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
440 p = pkt->data; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
441 end = pkt->data + pkt->len; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
442 |
8359 | 443 #ifdef NGX_QUIC_DEBUG_PACKETS |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
444 ngx_quic_hexdump(pkt->log, "quic short packet in", pkt->data, pkt->len); |
8359 | 445 #endif |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
446 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
447 p = ngx_quic_read_uint8(p, end, &pkt->flags); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
448 if (p == NULL) { |
8275 | 449 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 450 "quic packet is too small to read flags"); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
451 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
452 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
453 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
454 if (!ngx_quic_short_pkt(pkt->flags)) { |
8361 | 455 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic not a short packet"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
456 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
457 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
458 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
459 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 460 "quic short packet flags:%xi", pkt->flags); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
461 |
8386
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
462 if (!(pkt->flags & NGX_QUIC_PKT_FIXED_BIT)) { |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
463 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic fixed bit is not set"); |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
464 return NGX_DECLINED; |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
465 } |
81f85c479d7e
Discard packets without fixed bit or reserved bits set.
Vladimir Homutov <vl@nginx.com>
parents:
8385
diff
changeset
|
466 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
467 if (ngx_memcmp(p, dcid->data, dcid->len) != 0) { |
8275 | 468 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "unexpected quic dcid"); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
469 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
470 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
471 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
472 pkt->dcid.len = dcid->len; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
473 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
474 p = ngx_quic_read_bytes(p, end, dcid->len, &pkt->dcid.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
475 if (p == NULL) { |
8275 | 476 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 477 "quic packet is too small to read dcid"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
478 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
479 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
480 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
481 pkt->raw->pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
482 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
483 return NGX_OK; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
484 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
485 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
486 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
487 ngx_int_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
488 ngx_quic_parse_initial_header(ngx_quic_header_t *pkt) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
489 { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
490 u_char *p, *end; |
8242 | 491 uint64_t varint; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
492 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
493 p = pkt->raw->pos; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
494 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
495 end = pkt->raw->last; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
496 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
497 pkt->log->action = "parsing quic initial header"; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
498 |
8242 | 499 p = ngx_quic_parse_int(p, end, &varint); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
500 if (p == NULL) { |
8275 | 501 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 502 "quic failed to parse token length"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
503 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
504 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
505 |
8242 | 506 pkt->token.len = varint; |
507 | |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
508 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
509 if (p == NULL) { |
8275 | 510 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 511 "quic packet too small to read token data"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
512 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
513 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
514 |
8242 | 515 p = ngx_quic_parse_int(p, end, &varint); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
516 if (p == NULL) { |
8361 | 517 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic bad packet length"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
518 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
519 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
520 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
521 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 522 "quic initial packet length: %uL", varint); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
523 |
8242 | 524 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) { |
8361 | 525 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
526 "quic truncated initial packet"); | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
527 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
528 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
529 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
530 pkt->raw->pos = p; |
8242 | 531 pkt->len = varint; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
532 |
8359 | 533 #ifdef NGX_QUIC_DEBUG_PACKETS |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
534 ngx_quic_hexdump(pkt->log, "quic DCID", pkt->dcid.data, pkt->dcid.len); |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
535 ngx_quic_hexdump(pkt->log, "quic SCID", pkt->scid.data, pkt->scid.len); |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
536 ngx_quic_hexdump(pkt->log, "quic token", pkt->token.data, pkt->token.len); |
8359 | 537 #endif |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
538 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
539 return NGX_OK; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
540 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
541 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
542 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
543 ngx_int_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
544 ngx_quic_parse_handshake_header(ngx_quic_header_t *pkt) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
545 { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
546 u_char *p, *end; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
547 uint64_t plen; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
548 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
549 p = pkt->raw->pos; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
550 end = pkt->raw->last; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
551 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
552 pkt->log->action = "parsing quic handshake header"; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
553 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
554 p = ngx_quic_parse_int(p, end, &plen); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
555 if (p == NULL) { |
8361 | 556 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic bad packet length"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
557 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
558 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
559 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
560 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 561 "quic handshake packet length: %uL", plen); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
562 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
563 if (plen > (uint64_t)((pkt->data + pkt->len) - p)) { |
8361 | 564 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
565 "quic truncated handshake packet"); | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
566 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
567 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
568 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
569 pkt->raw->pos = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
570 pkt->len = plen; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
571 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
572 return NGX_OK; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
573 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
574 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
575 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
576 #define ngx_quic_stream_bit_off(val) (((val) & 0x04) ? 1 : 0) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
577 #define ngx_quic_stream_bit_len(val) (((val) & 0x02) ? 1 : 0) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
578 #define ngx_quic_stream_bit_fin(val) (((val) & 0x01) ? 1 : 0) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
579 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
580 ssize_t |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
581 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:
8237
diff
changeset
|
582 ngx_quic_frame_t *f) |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
583 { |
8326 | 584 u_char *p; |
585 uint64_t varint; | |
586 ngx_uint_t i; | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
587 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
588 p = start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
589 |
8242 | 590 p = ngx_quic_parse_int(p, end, &varint); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
591 if (p == NULL) { |
8385
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
8384
diff
changeset
|
592 pkt->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
8275 | 593 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 594 "quic failed to obtain quic frame type"); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
595 return NGX_ERROR; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
596 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
597 |
8242 | 598 f->type = varint; |
599 | |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
600 if (ngx_quic_frame_allowed(pkt, f->type) != NGX_OK) { |
8385
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
8384
diff
changeset
|
601 pkt->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION; |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
8384
diff
changeset
|
602 return NGX_ERROR; |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
603 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
604 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
605 switch (f->type) { |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
606 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
607 case NGX_QUIC_FT_CRYPTO: |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
608 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
609 p = ngx_quic_parse_int(p, end, &f->u.crypto.offset); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
610 if (p == NULL) { |
8361 | 611 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
612 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
613 |
8333
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
614 p = ngx_quic_parse_int(p, end, &f->u.crypto.length); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
615 if (p == NULL) { |
8361 | 616 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
617 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
618 |
8333
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
619 p = ngx_quic_read_bytes(p, end, f->u.crypto.length, &f->u.crypto.data); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
620 if (p == NULL) { |
8361 | 621 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
622 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
623 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
624 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 625 "quic frame in: CRYPTO length: %uL off:%uL pp:%p", |
8333
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
626 f->u.crypto.length, f->u.crypto.offset, |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
627 f->u.crypto.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
628 |
8359 | 629 #ifdef NGX_QUIC_DEBUG_FRAMES |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
630 ngx_quic_hexdump(pkt->log, "quic CRYPTO frame", |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
631 f->u.crypto.data, f->u.crypto.length); |
8359 | 632 #endif |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
633 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
635 case NGX_QUIC_FT_PADDING: |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
636 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
637 while (p < end && *p == NGX_QUIC_FT_PADDING) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
638 p++; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
639 } |
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 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
642 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 case NGX_QUIC_FT_ACK: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
644 case NGX_QUIC_FT_ACK_ECN: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
645 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
646 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:
8356
diff
changeset
|
647 && (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:
8356
diff
changeset
|
648 && (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:
8356
diff
changeset
|
649 && (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:
8356
diff
changeset
|
650 { |
8361 | 651 goto error; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 |
8326 | 654 f->u.ack.ranges_start = p; |
655 | |
656 /* process all ranges to get bounds, values are ignored */ | |
657 for (i = 0; i < f->u.ack.range_count; i++) { | |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
658 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
659 p = ngx_quic_parse_int(p, end, &varint); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
660 if (p) { |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
661 p = ngx_quic_parse_int(p, end, &varint); |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
662 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
663 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
664 if (p == NULL) { |
8361 | 665 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
666 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
667 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
668 |
8326 | 669 f->u.ack.ranges_end = p; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
670 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
671 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 672 "quic frame in ACK largest:%ui delay:%ui" |
673 " count:%ui first:%ui", f->u.ack.largest, | |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
674 f->u.ack.delay, |
8264
c58bbe31e87d
Fixed received ACK fields order in debug logging.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8262
diff
changeset
|
675 f->u.ack.range_count, |
c58bbe31e87d
Fixed received ACK fields order in debug logging.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8262
diff
changeset
|
676 f->u.ack.first_range); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
677 |
8326 | 678 if (f->type == NGX_QUIC_FT_ACK_ECN) { |
679 | |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
680 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:
8356
diff
changeset
|
681 && (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:
8356
diff
changeset
|
682 && (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:
8356
diff
changeset
|
683 { |
8361 | 684 goto error; |
8326 | 685 } |
686 | |
687 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | |
8359 | 688 "quic ACK ECN counters: %ui %ui %ui", |
8326 | 689 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); |
690 } | |
691 | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
693 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
694 case NGX_QUIC_FT_PING: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
696 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
697 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
|
698 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
699 p = ngx_quic_parse_int(p, end, &f->u.ncid.seqnum); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
700 if (p == NULL) { |
8361 | 701 goto error; |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
702 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
703 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
704 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:
8356
diff
changeset
|
705 if (p == NULL) { |
8361 | 706 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
707 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
708 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
709 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
710 if (p == NULL) { |
8361 | 711 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
712 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
713 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
714 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:
8237
diff
changeset
|
715 if (p == NULL) { |
8361 | 716 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
717 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
718 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
719 p = ngx_quic_copy_bytes(p, end, 16, f->u.ncid.srt); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
720 if (p == NULL) { |
8361 | 721 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
722 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
723 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
724 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 725 "quic frame in: NCID seq:%ui retire:%ui len:%ui", |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
726 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
727 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
728 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
729 case NGX_QUIC_FT_CONNECTION_CLOSE2: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
730 /* fall through */ |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
731 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
732 case NGX_QUIC_FT_CONNECTION_CLOSE: |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
733 |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
734 p = ngx_quic_parse_int(p, end, &f->u.close.error_code); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
735 if (p == NULL) { |
8361 | 736 goto error; |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
737 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
738 |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
739 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
740 p = ngx_quic_parse_int(p, end, &f->u.close.frame_type); |
8256
0a18893299fe
Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8255
diff
changeset
|
741 if (p == NULL) { |
8361 | 742 goto error; |
8256
0a18893299fe
Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8255
diff
changeset
|
743 } |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
744 } |
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
745 |
8254
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8251
diff
changeset
|
746 p = ngx_quic_parse_int(p, end, &varint); |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
747 if (p == NULL) { |
8361 | 748 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
749 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 |
8254
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8251
diff
changeset
|
751 f->u.close.reason.len = varint; |
856d5a2de258
Fixed build with macOS's long long abomination.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8251
diff
changeset
|
752 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
753 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:
8237
diff
changeset
|
754 &f->u.close.reason.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
755 if (p == NULL) { |
8361 | 756 goto error; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 } |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
758 |
8249
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
759 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
760 |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
761 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 762 "quic frame in CONNECTION_CLOSE" |
763 " err:%s code:0x%xi type:0x%xi reason:'%V'", | |
8249
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
764 ngx_quic_error_text(f->u.close.error_code), |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
765 f->u.close.error_code, f->u.close.frame_type, |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
766 &f->u.close.reason); |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
767 } else { |
3f4b407fa0b8
Added parsing of CONNECTION_CLOSE2 frame (0x1D).
Vladimir Homutov <vl@nginx.com>
parents:
8247
diff
changeset
|
768 |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
769 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 770 "quic frame in: CONNECTION_CLOSE2:" |
771 " code:0x%xi reason:'%V'", | |
8250
8f9cb6d66662
Fixed parsing of CONNECTION CLOSE2 frames.
Vladimir Homutov <vl@nginx.com>
parents:
8249
diff
changeset
|
772 f->u.close.error_code, &f->u.close.reason); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
773 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
774 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
775 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
776 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
777 case NGX_QUIC_FT_STREAM0: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
778 case NGX_QUIC_FT_STREAM1: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 case NGX_QUIC_FT_STREAM2: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
780 case NGX_QUIC_FT_STREAM3: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
781 case NGX_QUIC_FT_STREAM4: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
782 case NGX_QUIC_FT_STREAM5: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 case NGX_QUIC_FT_STREAM6: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
784 case NGX_QUIC_FT_STREAM7: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
785 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
786 f->u.stream.type = f->type; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
787 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
788 f->u.stream.off = ngx_quic_stream_bit_off(f->type); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
789 f->u.stream.len = ngx_quic_stream_bit_len(f->type); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
790 f->u.stream.fin = ngx_quic_stream_bit_fin(f->type); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
791 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
792 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:
8237
diff
changeset
|
793 if (p == NULL) { |
8361 | 794 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
795 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
796 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
797 if (f->type & 0x04) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
798 p = ngx_quic_parse_int(p, end, &f->u.stream.offset); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
799 if (p == NULL) { |
8361 | 800 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
801 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
802 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 } else { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
804 f->u.stream.offset = 0; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
806 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
807 if (f->type & 0x02) { |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
808 p = ngx_quic_parse_int(p, end, &f->u.stream.length); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
809 if (p == NULL) { |
8361 | 810 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
811 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
812 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 } else { |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
814 f->u.stream.length = end - p; /* up to packet end */ |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
815 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
817 p = ngx_quic_read_bytes(p, end, f->u.stream.length, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
818 &f->u.stream.data); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
819 if (p == NULL) { |
8361 | 820 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
821 } |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
823 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 824 "quic frame in: STREAM type:0x%xi id:0x%xi offset:0x%xi " |
825 "len:0x%xi bits off:%d len:%d fin:%d", | |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
826 f->type, f->u.stream.stream_id, f->u.stream.offset, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
827 f->u.stream.length, f->u.stream.off, f->u.stream.len, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
828 f->u.stream.fin); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
829 |
8359 | 830 #ifdef NGX_QUIC_DEBUG_FRAMES |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
831 ngx_quic_hexdump(pkt->log, "quic STREAM frame", |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
832 f->u.stream.data, f->u.stream.length); |
8359 | 833 #endif |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
834 break; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 |
8237
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8236
diff
changeset
|
836 case NGX_QUIC_FT_MAX_DATA: |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
837 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
838 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:
8237
diff
changeset
|
839 if (p == NULL) { |
8361 | 840 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
841 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
842 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
843 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 844 "quic frame in: MAX_DATA max_data:%ui", |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
845 f->u.max_data.max_data); |
8237
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8236
diff
changeset
|
846 break; |
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8236
diff
changeset
|
847 |
8231
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
848 case NGX_QUIC_FT_RESET_STREAM: |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
849 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
850 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:
8356
diff
changeset
|
851 && (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:
8356
diff
changeset
|
852 && (p = ngx_quic_parse_int(p, end, |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
853 &f->u.reset_stream.final_size)))) |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
854 { |
8361 | 855 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
856 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
857 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
858 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 859 "quic frame in: RESET_STREAM" |
860 " id:0x%xi error_code:0x%xi final_size:0x%xi", | |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
861 f->u.reset_stream.id, f->u.reset_stream.error_code, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
862 f->u.reset_stream.final_size); |
8231
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
863 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
864 |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
865 case NGX_QUIC_FT_STOP_SENDING: |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
866 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
867 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.id); |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
868 if (p == NULL) { |
8361 | 869 goto error; |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
870 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
871 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
872 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:
8356
diff
changeset
|
873 if (p == NULL) { |
8361 | 874 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
875 } |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
876 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
877 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 878 "quic frame in: STOP_SENDING id:0x%xi error_code:0x%xi", |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
879 f->u.stop_sending.id, f->u.stop_sending.error_code); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
880 |
8231
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
881 break; |
78540e2160d0
Added parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov <vl@nginx.com>
parents:
8224
diff
changeset
|
882 |
8236
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
8235
diff
changeset
|
883 case NGX_QUIC_FT_STREAMS_BLOCKED: |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
884 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
885 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
886 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:
8237
diff
changeset
|
887 if (p == NULL) { |
8361 | 888 goto error; |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
889 } |
8236
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
8235
diff
changeset
|
890 |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
891 f->u.streams_blocked.bidi = |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
892 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0; |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
893 |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
894 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 895 "quic frame in: STREAMS_BLOCKED limit:%ui bidi:%d", |
8240
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
896 f->u.streams_blocked.limit, |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
897 f->u.streams_blocked.bidi); |
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
8237
diff
changeset
|
898 |
8236
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
8235
diff
changeset
|
899 break; |
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
8235
diff
changeset
|
900 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
901 case NGX_QUIC_FT_NEW_TOKEN: |
8273
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
902 /* TODO: implement */ |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
903 |
8275 | 904 ngx_log_error(NGX_LOG_ALERT, pkt->log, 0, |
8361 | 905 "quic unimplemented frame type 0x%xi in packet", f->type); |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
906 |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
907 break; |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
908 |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
909 case NGX_QUIC_FT_MAX_STREAMS: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
910 case NGX_QUIC_FT_MAX_STREAMS2: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
911 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
912 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:
8256
diff
changeset
|
913 if (p == NULL) { |
8361 | 914 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
915 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
916 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
917 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:
8256
diff
changeset
|
918 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
919 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 920 "quic frame in: MAX_STREAMS limit:%ui bidi:%d", |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
921 f->u.max_streams.limit, |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
922 f->u.max_streams.bidi); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
923 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
924 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
925 case NGX_QUIC_FT_MAX_STREAM_DATA: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
926 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
927 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.id); |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
928 if (p == NULL) { |
8361 | 929 goto error; |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
930 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
931 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
932 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:
8356
diff
changeset
|
933 if (p == NULL) { |
8361 | 934 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
935 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
936 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
937 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 938 "quic frame in: MAX_STREAM_DATA id:%ui limit:%ui", |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
939 f->u.max_stream_data.id, |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
940 f->u.max_stream_data.limit); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
941 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
942 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
943 case NGX_QUIC_FT_DATA_BLOCKED: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
944 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
945 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:
8256
diff
changeset
|
946 if (p == NULL) { |
8361 | 947 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
948 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
949 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
950 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 951 "quic frame in: DATA_BLOCKED limit:%ui", |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
952 f->u.data_blocked.limit); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
953 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
954 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
955 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
956 |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
957 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.id); |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
958 if (p == NULL) { |
8361 | 959 goto error; |
8357
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
960 } |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
961 |
05b8dd5d9f7e
Retired the ngx_quic_parse_int_multi() function.
Vladimir Homutov <vl@nginx.com>
parents:
8356
diff
changeset
|
962 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:
8356
diff
changeset
|
963 if (p == NULL) { |
8361 | 964 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
965 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
966 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
967 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 968 "quic frame in: STREAM_DATA_BLOCKED" |
969 " id:%ui limit:%ui", | |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
970 f->u.stream_data_blocked.id, |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
971 f->u.stream_data_blocked.limit); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
972 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
973 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
974 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
975 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
976 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
977 if (p == NULL) { |
8361 | 978 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
979 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
980 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
981 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 982 "quic frame in: RETIRE_CONNECTION_ID" |
983 " sequence_number:%ui", | |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
984 f->u.retire_cid.sequence_number); |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
985 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
986 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
987 case NGX_QUIC_FT_PATH_CHALLENGE: |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
988 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
989 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:
8256
diff
changeset
|
990 if (p == NULL) { |
8361 | 991 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
992 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
993 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
994 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 995 "quic frame in: PATH_CHALLENGE"); |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
996 |
8359 | 997 #ifdef NGX_QUIC_DEBUG_FRAMES |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
998 ngx_quic_hexdump(pkt->log, "quic PATH_CHALLENGE frame data", |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
999 f->u.path_challenge.data, 8); |
8359 | 1000 #endif |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1001 break; |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1002 |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
1003 case NGX_QUIC_FT_PATH_RESPONSE: |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
1004 |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1005 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:
8256
diff
changeset
|
1006 if (p == NULL) { |
8361 | 1007 goto error; |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1008 } |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1009 |
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1010 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
8359 | 1011 "quic frame in: PATH_RESPONSE"); |
8257
085fd6e68367
Implemented parsing of remaining frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8256
diff
changeset
|
1012 |
8359 | 1013 #ifdef NGX_QUIC_DEBUG_FRAMES |
8360
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
1014 ngx_quic_hexdump(pkt->log, "quic PATH_RESPONSE frame data", |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
8359
diff
changeset
|
1015 f->u.path_response.data, 8); |
8359 | 1016 #endif |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
1017 break; |
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
1018 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1019 default: |
8275 | 1020 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
8361 | 1021 "quic unknown frame type 0x%xi", f->type); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1022 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1023 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1024 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1025 return p - start; |
8251
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
8250
diff
changeset
|
1026 |
8361 | 1027 error: |
1028 | |
8385
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
8384
diff
changeset
|
1029 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:
8384
diff
changeset
|
1030 |
8361 | 1031 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
1032 "quic failed to parse frame type 0x%xi", f->type); | |
1033 | |
1034 return NGX_ERROR; | |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1035 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1036 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1038 static ngx_int_t |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1039 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:
8361
diff
changeset
|
1040 { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1041 uint8_t ptype; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1042 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1043 /* frame permissions per packet: 4 bits: IH01: 12.4, Table 3 */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1044 static uint8_t ngx_quic_frame_masks[] = { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1045 /* PADDING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1046 /* PING */ 0xF, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1047 /* ACK */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1048 /* ACK_ECN */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1049 /* RESET_STREAM */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1050 /* STOP_SENDING */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1051 /* CRYPTO */ 0xD, |
8424
c70446e3d771
Treat receipt of NEW_TOKEN as connection error PROTOCOL_VIOLATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8422
diff
changeset
|
1052 /* NEW_TOKEN */ 0x0, /* only sent by server */ |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1053 /* STREAM0 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1054 /* STREAM1 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1055 /* STREAM2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1056 /* STREAM3 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1057 /* STREAM4 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1058 /* STREAM5 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1059 /* STREAM6 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1060 /* STREAM7 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1061 /* MAX_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1062 /* MAX_STREAM_DATA */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1063 /* MAX_STREAMS */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1064 /* MAX_STREAMS2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1065 /* DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1066 /* STREAM_DATA_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1067 /* STREAMS_BLOCKED */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1068 /* STREAMS_BLOCKED2 */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1069 /* NEW_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1070 /* RETIRE_CONNECTION_ID */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1071 /* PATH_CHALLENGE */ 0x3, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1072 /* PATH_RESPONSE */ 0x3, |
8425
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8424
diff
changeset
|
1073 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8424
diff
changeset
|
1074 /* CONNECTION_CLOSE */ 0xF, |
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8424
diff
changeset
|
1075 /* CONNECTION_CLOSE2 */ 0x3, |
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8424
diff
changeset
|
1076 #else |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1077 /* CONNECTION_CLOSE */ 0xD, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1078 /* CONNECTION_CLOSE2 */ 0x1, |
8425
3e38dad3a163
Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8424
diff
changeset
|
1079 #endif |
8370
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1080 /* HANDSHAKE_DONE */ 0x0, /* only sent by server */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1081 }; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1082 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1083 if (ngx_quic_long_pkt(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1084 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1085 if (ngx_quic_pkt_in(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1086 ptype = 8; /* initial */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1087 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1088 } else if (ngx_quic_pkt_hs(pkt->flags)) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1089 ptype = 4; /* handshake */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1090 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1091 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1092 ptype = 2; /* zero-rtt */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1093 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1094 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1095 } else { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1096 ptype = 1; /* application data */ |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1097 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1098 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1099 if (ptype & ngx_quic_frame_masks[frame_type]) { |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1100 return NGX_OK; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1101 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1102 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1103 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1104 "quic frame type 0x%xi is not " |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1105 "allowed in packet with flags 0x%xi", |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1106 frame_type, pkt->flags); |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1107 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1108 return NGX_DECLINED; |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1109 } |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1110 |
262396242352
Reworked macros for parsing/assembling packet types.
Vladimir Homutov <vl@nginx.com>
parents:
8361
diff
changeset
|
1111 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1112 ssize_t |
8326 | 1113 ngx_quic_parse_ack_range(ngx_quic_header_t *pkt, u_char *start, u_char *end, |
1114 uint64_t *gap, uint64_t *range) | |
1115 { | |
1116 u_char *p; | |
1117 | |
1118 p = start; | |
1119 | |
1120 p = ngx_quic_parse_int(p, end, gap); | |
1121 if (p == NULL) { | |
1122 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
8361 | 1123 "quic failed to parse ack frame gap"); |
8326 | 1124 return NGX_ERROR; |
1125 } | |
1126 | |
1127 p = ngx_quic_parse_int(p, end, range); | |
1128 if (p == NULL) { | |
1129 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
8361 | 1130 "quic failed to parse ack frame range"); |
8326 | 1131 return NGX_ERROR; |
1132 } | |
1133 | |
1134 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | |
8359 | 1135 "quic ACK range: gap %ui range %ui", *gap, *range); |
8326 | 1136 |
1137 return p - start; | |
1138 } | |
1139 | |
1140 | |
1141 ssize_t | |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1142 ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f) |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1143 { |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1144 /* |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1145 * QUIC-recovery, section 2: |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1146 * |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1147 * Ack-eliciting Frames: All frames other than ACK, PADDING, and |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1148 * CONNECTION_CLOSE are considered ack-eliciting. |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1149 */ |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1150 f->need_ack = 1; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1151 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1152 switch (f->type) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1153 case NGX_QUIC_FT_ACK: |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1154 f->need_ack = 0; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1155 return ngx_quic_create_ack(p, &f->u.ack); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1156 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1157 case NGX_QUIC_FT_CRYPTO: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1158 return ngx_quic_create_crypto(p, &f->u.crypto); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1159 |
8273
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1160 case NGX_QUIC_FT_HANDSHAKE_DONE: |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1161 return ngx_quic_create_hs_done(p); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1162 |
8384
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1163 case NGX_QUIC_FT_NEW_TOKEN: |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1164 return ngx_quic_create_new_token(p, &f->u.token); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1165 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1166 case NGX_QUIC_FT_STREAM0: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1167 case NGX_QUIC_FT_STREAM1: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1168 case NGX_QUIC_FT_STREAM2: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1169 case NGX_QUIC_FT_STREAM3: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1170 case NGX_QUIC_FT_STREAM4: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1171 case NGX_QUIC_FT_STREAM5: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1172 case NGX_QUIC_FT_STREAM6: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1173 case NGX_QUIC_FT_STREAM7: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1174 return ngx_quic_create_stream(p, &f->u.stream); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1175 |
8235
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1176 case NGX_QUIC_FT_CONNECTION_CLOSE: |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1177 f->need_ack = 0; |
8235
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1178 return ngx_quic_create_close(p, &f->u.close); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1179 |
8245
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1180 case NGX_QUIC_FT_MAX_STREAMS: |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1181 return ngx_quic_create_max_streams(p, &f->u.max_streams); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1182 |
8266
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1183 case NGX_QUIC_FT_MAX_STREAM_DATA: |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1184 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:
8264
diff
changeset
|
1185 |
8338
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1186 case NGX_QUIC_FT_MAX_DATA: |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1187 return ngx_quic_create_max_data(p, &f->u.max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1188 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1189 default: |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1190 /* BUG: unsupported frame type generated */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1191 return NGX_ERROR; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1192 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1193 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1194 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1195 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1196 static size_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1197 ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1198 { |
8244
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
1199 size_t len; |
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
1200 u_char *start; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1201 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1202 /* minimal ACK packet */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1203 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1204 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1205 len = ngx_quic_varint_len(NGX_QUIC_FT_ACK); |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1206 len += ngx_quic_varint_len(ack->largest); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1207 len += ngx_quic_varint_len(0); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1208 len += ngx_quic_varint_len(0); |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1209 len += ngx_quic_varint_len(ack->first_range); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1210 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1211 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1212 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1213 |
8244
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
1214 start = p; |
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
1215 |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1216 ngx_quic_build_int(&p, NGX_QUIC_FT_ACK); |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1217 ngx_quic_build_int(&p, ack->largest); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1218 ngx_quic_build_int(&p, 0); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1219 ngx_quic_build_int(&p, 0); |
8308
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
8307
diff
changeset
|
1220 ngx_quic_build_int(&p, ack->first_range); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1221 |
8244
d60205f37f5a
Fixed ACKs to packet numbers greater than 63.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
1222 return p - start; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1223 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1224 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1225 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1226 static size_t |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1227 ngx_quic_create_crypto(u_char *p, ngx_quic_crypto_frame_t *crypto) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1228 { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1229 size_t len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1230 u_char *start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1231 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1232 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1233 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
|
1234 len += ngx_quic_varint_len(crypto->offset); |
8333
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
1235 len += ngx_quic_varint_len(crypto->length); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
1236 len += crypto->length; |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1237 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1238 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1239 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1240 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1241 start = p; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1242 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1243 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
|
1244 ngx_quic_build_int(&p, crypto->offset); |
8333
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
1245 ngx_quic_build_int(&p, crypto->length); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
8326
diff
changeset
|
1246 p = ngx_cpymem(p, crypto->data, crypto->length); |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1247 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1248 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1249 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1250 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1251 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1252 static size_t |
8273
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1253 ngx_quic_create_hs_done(u_char *p) |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1254 { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1255 u_char *start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1256 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1257 if (p == NULL) { |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1258 return ngx_quic_varint_len(NGX_QUIC_FT_HANDSHAKE_DONE); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1259 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1260 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1261 start = p; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1262 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1263 ngx_quic_build_int(&p, NGX_QUIC_FT_HANDSHAKE_DONE); |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1264 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1265 return p - start; |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1266 } |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1267 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1268 |
cb75f194f1f0
Implemented sending HANDSHAKE_DONE frame after handshake.
Vladimir Homutov <vl@nginx.com>
parents:
8269
diff
changeset
|
1269 static size_t |
8384
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1270 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:
8383
diff
changeset
|
1271 { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1272 size_t len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1273 u_char *start; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1274 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1275 if (p == NULL) { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1276 len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1277 len += ngx_quic_varint_len(token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1278 len += token->length; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1279 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1280 return len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1281 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1282 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1283 start = p; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1284 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1285 ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_TOKEN); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1286 ngx_quic_build_int(&p, token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1287 p = ngx_cpymem(p, token->data, token->length); |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1288 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1289 return p - start; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1290 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1291 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1292 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8383
diff
changeset
|
1293 static size_t |
8224
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1294 ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf) |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1295 { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1296 size_t len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1297 u_char *start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1298 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1299 if (p == NULL) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1300 len = ngx_quic_varint_len(sf->type); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1301 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1302 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1303 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
|
1304 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1305 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1306 len += ngx_quic_varint_len(sf->stream_id); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1307 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1308 /* length is always present in generated frames */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1309 len += ngx_quic_varint_len(sf->length); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1310 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1311 len += sf->length; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1312 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1313 return len; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1314 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1315 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1316 start = p; |
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 ngx_quic_build_int(&p, sf->type); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1319 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
|
1320 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1321 if (sf->off) { |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1322 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
|
1323 } |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1324 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1325 /* length is always present in generated frames */ |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1326 ngx_quic_build_int(&p, sf->length); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1327 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1328 p = ngx_cpymem(p, sf->data, sf->length); |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1329 |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1330 return p - start; |
ae35ccba7aa6
Extracted transport part of the code into separate file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1331 } |
8235
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1332 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1333 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1334 static size_t |
8245
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1335 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:
8244
diff
changeset
|
1336 { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1337 size_t len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1338 u_char *start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1339 ngx_uint_t type; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1340 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1341 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:
8244
diff
changeset
|
1342 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1343 if (p == NULL) { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1344 len = ngx_quic_varint_len(type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1345 len += ngx_quic_varint_len(ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1346 return len; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1347 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1348 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1349 start = p; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1350 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1351 ngx_quic_build_int(&p, type); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1352 ngx_quic_build_int(&p, ms->limit); |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1353 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1354 return p - start; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1355 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1356 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1357 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1358 static ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1359 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:
8257
diff
changeset
|
1360 ngx_quic_tp_t *dst) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1361 { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1362 uint64_t varint; |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1363 ngx_str_t str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1364 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1365 varint = 0; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1366 ngx_str_null(&str); |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1367 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1368 switch (id) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1369 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1370 case NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1371 /* zero-length option */ |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1372 if (end - p != 0) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1373 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1374 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1375 dst->disable_active_migration = 1; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1376 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1377 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1378 case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: |
8415
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8414
diff
changeset
|
1379 case NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE: |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1380 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1381 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1382 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1383 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1384 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1385 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1386 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1387 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1388 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1389 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1390 p = ngx_quic_parse_int(p, end, &varint); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1391 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1392 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1393 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1394 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1395 |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1396 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1397 |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1398 str.len = end - p; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1399 p = ngx_quic_read_bytes(p, end, str.len, &str.data); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1400 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1401 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1402 default: |
8262
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1403 return NGX_DECLINED; |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1404 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1405 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1406 switch (id) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1407 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1408 case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1409 dst->max_idle_timeout = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1410 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1411 |
8415
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8414
diff
changeset
|
1412 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:
8414
diff
changeset
|
1413 dst->max_udp_payload_size = varint; |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1414 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1415 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1416 case NGX_QUIC_TP_INITIAL_MAX_DATA: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1417 dst->initial_max_data = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1418 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1419 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1420 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1421 dst->initial_max_stream_data_bidi_local = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1422 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1423 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1424 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1425 dst->initial_max_stream_data_bidi_remote = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1426 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1427 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1428 case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1429 dst->initial_max_stream_data_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1430 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1431 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1432 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1433 dst->initial_max_streams_bidi = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1434 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1435 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1436 case NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1437 dst->initial_max_streams_uni = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1438 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1439 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1440 case NGX_QUIC_TP_ACK_DELAY_EXPONENT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1441 dst->ack_delay_exponent = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1442 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1443 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1444 case NGX_QUIC_TP_MAX_ACK_DELAY: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1445 dst->max_ack_delay = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1446 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1447 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1448 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1449 dst->active_connection_id_limit = varint; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1450 break; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1451 |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1452 case NGX_QUIC_TP_INITIAL_SCID: |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1453 dst->initial_scid = str; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1454 break; |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1455 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1456 default: |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1457 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1458 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1459 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1460 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1461 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1462 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1463 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1464 ngx_int_t |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1465 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:
8257
diff
changeset
|
1466 ngx_log_t *log) |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1467 { |
8356
42198f77ac85
Removed support of drafts older than currently latest 27.
Vladimir Homutov <vl@nginx.com>
parents:
8351
diff
changeset
|
1468 uint64_t id, len; |
8262
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1469 ngx_int_t rc; |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1470 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1471 while (p < end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1472 p = ngx_quic_parse_int(p, end, &id); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1473 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1474 ngx_log_error(NGX_LOG_INFO, log, 0, |
8361 | 1475 "quic failed to parse transport param id"); |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1476 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1477 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1478 |
8414
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1479 switch (id) { |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1480 case NGX_QUIC_TP_ORIGINAL_DCID: |
8414
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1481 case NGX_QUIC_TP_PREFERRED_ADDRESS: |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1482 case NGX_QUIC_TP_RETRY_SCID: |
8414
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1483 case NGX_QUIC_TP_STATELESS_RESET_TOKEN: |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1484 ngx_log_error(NGX_LOG_INFO, log, 0, |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1485 "quic client sent forbidden transport param" |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1486 " id 0x%xi", id); |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1487 return NGX_ERROR; |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1488 } |
49a98760afd2
Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8391
diff
changeset
|
1489 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1490 p = ngx_quic_parse_int(p, end, &len); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1491 if (p == NULL) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1492 ngx_log_error(NGX_LOG_INFO, log, 0, |
8361 | 1493 "quic failed to parse" |
1494 " transport param id 0x%xi length", id); | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1495 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1496 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1497 |
8262
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1498 rc = ngx_quic_parse_transport_param(p, p + len, id, tp); |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1499 |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1500 if (rc == NGX_ERROR) { |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1501 ngx_log_error(NGX_LOG_INFO, log, 0, |
8361 | 1502 "quic failed to parse" |
1503 " transport param id 0x%xi data", id); | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1504 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1505 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1506 |
8262
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1507 if (rc == NGX_DECLINED) { |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1508 ngx_log_error(NGX_LOG_INFO, log, 0, |
8361 | 1509 "quic unknown transport param id 0x%xi,skipped", id); |
8262
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1510 } |
66f59c67adf4
Skip unknown transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8261
diff
changeset
|
1511 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1512 p += len; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1513 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1514 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1515 if (p != end) { |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1516 ngx_log_error(NGX_LOG_INFO, log, 0, |
8361 | 1517 "quic trailing garbage in" |
1518 " transport parameters: %ui bytes", | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1519 end - p); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1520 return NGX_ERROR; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1521 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1522 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1523 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1524 "quic transport parameters parsed ok"); |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1525 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1526 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1527 "quic tp disable active migration: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1528 tp->disable_active_migration); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1529 |
8359 | 1530 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp idle_timeout: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1531 tp->max_idle_timeout); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1532 |
8415
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8414
diff
changeset
|
1533 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8414
diff
changeset
|
1534 "quic tp max_udp_payload_size: %ui", |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8414
diff
changeset
|
1535 tp->max_udp_payload_size); |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1536 |
8359 | 1537 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_data: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1538 tp->initial_max_data); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1539 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1540 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1541 "quic tp max_stream_data_bidi_local: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1542 tp->initial_max_stream_data_bidi_local); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1543 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1544 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1545 "quic tp max_stream_data_bidi_remote: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1546 tp->initial_max_stream_data_bidi_remote); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1547 |
8359 | 1548 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
1549 "quic tp max_stream_data_uni: %ui", | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1550 tp->initial_max_stream_data_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1551 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1552 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1553 "quic tp initial_max_streams_bidi: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1554 tp->initial_max_streams_bidi); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1555 |
8359 | 1556 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
1557 "quic tp initial_max_streams_uni: %ui", | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1558 tp->initial_max_streams_uni); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1559 |
8359 | 1560 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
1561 "quic tp ack_delay_exponent: %ui", | |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1562 tp->ack_delay_exponent); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1563 |
8359 | 1564 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_ack_delay: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1565 tp->max_ack_delay); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1566 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1567 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
8359 | 1568 "quic tp active_connection_id_limit: %ui", |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1569 tp->active_connection_id_limit); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1570 |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1571 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1572 ngx_quic_hexdump(log, "quic tp initial_source_connection_id:", |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1573 tp->initial_scid.data, tp->initial_scid.len); |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1574 #endif |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1575 |
8260
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1576 return NGX_OK; |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1577 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1578 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8257
diff
changeset
|
1579 |
8266
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1580 static size_t |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1581 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:
8264
diff
changeset
|
1582 { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1583 size_t len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1584 u_char *start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1585 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1586 if (p == NULL) { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1587 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:
8264
diff
changeset
|
1588 len += ngx_quic_varint_len(ms->id); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1589 len += ngx_quic_varint_len(ms->limit); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1590 return len; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1591 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1592 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1593 start = p; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1594 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1595 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:
8264
diff
changeset
|
1596 ngx_quic_build_int(&p, ms->id); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1597 ngx_quic_build_int(&p, ms->limit); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1598 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1599 return p - start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1600 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1601 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8264
diff
changeset
|
1602 |
8338
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1603 static size_t |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1604 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:
8333
diff
changeset
|
1605 { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1606 size_t len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1607 u_char *start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1608 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1609 if (p == NULL) { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1610 len = ngx_quic_varint_len(NGX_QUIC_FT_MAX_DATA); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1611 len += ngx_quic_varint_len(md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1612 return len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1613 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1614 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1615 start = p; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1616 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1617 ngx_quic_build_int(&p, NGX_QUIC_FT_MAX_DATA); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1618 ngx_quic_build_int(&p, md->max_data); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1619 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1620 return p - start; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1621 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1622 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
8333
diff
changeset
|
1623 |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1624 ssize_t |
8422
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1625 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:
8421
diff
changeset
|
1626 size_t *clen) |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1627 { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1628 u_char *p; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1629 size_t len; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1630 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1631 #define ngx_quic_tp_len(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1632 ngx_quic_varint_len(id) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1633 + ngx_quic_varint_len(value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1634 + ngx_quic_varint_len(ngx_quic_varint_len(value)) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1635 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1636 #define ngx_quic_tp_vint(id, value) \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1637 do { \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1638 ngx_quic_build_int(&p, id); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1639 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1640 ngx_quic_build_int(&p, value); \ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1641 } while (0) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1642 |
8416
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1643 #define ngx_quic_tp_strlen(id, value) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1644 ngx_quic_varint_len(id) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1645 + ngx_quic_varint_len(value.len) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1646 + value.len |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1647 |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1648 #define ngx_quic_tp_str(id, value) \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1649 do { \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1650 ngx_quic_build_int(&p, id); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1651 ngx_quic_build_int(&p, value.len); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1652 p = ngx_cpymem(p, value.data, value.len); \ |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1653 } while (0) |
78e362f0b081
Introduced macros for building length-value transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8415
diff
changeset
|
1654 |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1655 p = pos; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1656 |
8422
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1657 len = ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_DATA, tp->initial_max_data); |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1658 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1659 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1660 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1661 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1662 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1663 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1664 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1665 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1666 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1667 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1668 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1669 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1670 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1671 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1672 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1673 |
8277
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8275
diff
changeset
|
1674 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:
8275
diff
changeset
|
1675 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8275
diff
changeset
|
1676 |
8422
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1677 if (clen) { |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1678 *clen = len; |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1679 } |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1680 |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1681 len += ngx_quic_tp_len(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1682 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1683 |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1684 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1685 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:
8416
diff
changeset
|
1686 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:
8416
diff
changeset
|
1687 |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1688 if (tp->retry_scid.len) { |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1689 len += ngx_quic_tp_strlen(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1690 } |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1691 #else |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1692 if (tp->original_dcid.len) { |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1693 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1694 } |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1695 #endif |
8383
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
1696 |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1697 if (pos == NULL) { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1698 return len; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1699 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1700 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1701 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_DATA, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1702 tp->initial_max_data); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1703 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1704 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1705 tp->initial_max_streams_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1706 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1707 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1708 tp->initial_max_streams_bidi); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1709 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1710 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1711 tp->initial_max_stream_data_bidi_local); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1712 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1713 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1714 tp->initial_max_stream_data_bidi_remote); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1715 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1716 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1717 tp->initial_max_stream_data_uni); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1718 |
8277
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8275
diff
changeset
|
1719 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:
8275
diff
changeset
|
1720 tp->max_idle_timeout); |
50db7ce374b7
Advertise our max_idle_timeout in transport parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8275
diff
changeset
|
1721 |
8422
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1722 ngx_quic_tp_vint(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1723 tp->active_connection_id_limit); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8421
diff
changeset
|
1724 |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1725 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1726 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:
8416
diff
changeset
|
1727 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:
8416
diff
changeset
|
1728 |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1729 if (tp->retry_scid.len) { |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1730 ngx_quic_tp_str(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1731 } |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1732 #else |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1733 if (tp->original_dcid.len) { |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1734 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); |
8421
c206233d9c29
Fixed transport parameters on a new connection with a valid token.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8417
diff
changeset
|
1735 } |
8417
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8416
diff
changeset
|
1736 #endif |
8383
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8370
diff
changeset
|
1737 |
8247
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1738 return p - pos; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1739 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1740 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8245
diff
changeset
|
1741 |
8245
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
1742 static size_t |
8235
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1743 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1744 { |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1745 size_t len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1746 u_char *start; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1747 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1748 if (p == NULL) { |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1749 len = ngx_quic_varint_len(NGX_QUIC_FT_CONNECTION_CLOSE); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1750 len += ngx_quic_varint_len(cl->error_code); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1751 len += ngx_quic_varint_len(cl->frame_type); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1752 len += ngx_quic_varint_len(cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1753 len += cl->reason.len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1754 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1755 return len; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1756 } |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1757 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1758 start = p; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1759 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1760 ngx_quic_build_int(&p, NGX_QUIC_FT_CONNECTION_CLOSE); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1761 ngx_quic_build_int(&p, cl->error_code); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1762 ngx_quic_build_int(&p, cl->frame_type); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1763 ngx_quic_build_int(&p, cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1764 p = ngx_cpymem(p, cl->reason.data, cl->reason.len); |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1765 |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1766 return p - start; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8231
diff
changeset
|
1767 } |