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