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