comparison src/event/ngx_event_quic_transport.h @ 8251:c217a907ce42 quic

Added checks for permitted frame types. + cleanup in macros for packet types + some style fixes in quic_transport.h (case, indentation)
author Vladimir Homutov <vl@nginx.com>
date Fri, 20 Mar 2020 20:03:44 +0300
parents 3f4b407fa0b8
children 085fd6e68367
comparison
equal deleted inserted replaced
8250:8f9cb6d66662 8251:c217a907ce42
9 9
10 10
11 #include <ngx_event_openssl.h> 11 #include <ngx_event_openssl.h>
12 12
13 13
14 /* 17.2. Long Header Packets */ 14 #define ngx_quic_long_pkt(flags) ((flags) & 0x80) /* 17.2 */
15 #define NGX_QUIC_PKT_LONG 0x80 15 #define ngx_quic_short_pkt(flags) (((flags) & 0x80) == 0) /* 17.3 */
16 16
17 #define NGX_QUIC_PKT_INITIAL 0xC0 17 /* Long packet types */
18 #define NGX_QUIC_PKT_HANDSHAKE 0xE0 18 #define NGX_QUIC_PKT_INITIAL 0xC0 /* 17.2.2 */
19 #define NGX_QUIC_PKT_ZRTT 0xD0 /* 17.2.3 */
20 #define NGX_QUIC_PKT_HANDSHAKE 0xE0 /* 17.2.4 */
21 #define NGX_QUIC_PKT_RETRY 0xF0 /* 17.2.5 */
22
23 #define ngx_quic_pkt_in(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_INITIAL)
24 #define ngx_quic_pkt_zrtt(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_ZRTT)
25 #define ngx_quic_pkt_hs(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_HANDSHAKE)
26 #define ngx_quic_pkt_retry(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_RETRY)
19 27
20 /* 12.4. Frames and Frame Types */ 28 /* 12.4. Frames and Frame Types */
21 #define NGX_QUIC_FT_PADDING 0x00 29 #define NGX_QUIC_FT_PADDING 0x00
22 #define NGX_QUIC_FT_PING 0x01 30 #define NGX_QUIC_FT_PING 0x01
23 #define NGX_QUIC_FT_ACK 0x02 31 #define NGX_QUIC_FT_ACK 0x02
24 #define NGX_QUIC_FT_ACK_ECN 0x03 32 #define NGX_QUIC_FT_ACK_ECN 0x03
25 #define NGX_QUIC_FT_RESET_STREAM 0x04 33 #define NGX_QUIC_FT_RESET_STREAM 0x04
26 #define NGX_QUIC_FT_STOP_SENDING 0x05 34 #define NGX_QUIC_FT_STOP_SENDING 0x05
27 #define NGX_QUIC_FT_CRYPTO 0x06 35 #define NGX_QUIC_FT_CRYPTO 0x06
28 #define NGX_QUIC_FT_NEW_TOKEN 0x07 36 #define NGX_QUIC_FT_NEW_TOKEN 0x07
29 #define NGX_QUIC_FT_STREAM0 0x08 37 #define NGX_QUIC_FT_STREAM0 0x08
30 #define NGX_QUIC_FT_STREAM1 0x09 38 #define NGX_QUIC_FT_STREAM1 0x09
31 #define NGX_QUIC_FT_STREAM2 0x0A 39 #define NGX_QUIC_FT_STREAM2 0x0A
32 #define NGX_QUIC_FT_STREAM3 0x0B 40 #define NGX_QUIC_FT_STREAM3 0x0B
33 #define NGX_QUIC_FT_STREAM4 0x0C 41 #define NGX_QUIC_FT_STREAM4 0x0C
34 #define NGX_QUIC_FT_STREAM5 0x0D 42 #define NGX_QUIC_FT_STREAM5 0x0D
35 #define NGX_QUIC_FT_STREAM6 0x0E 43 #define NGX_QUIC_FT_STREAM6 0x0E
36 #define NGX_QUIC_FT_STREAM7 0x0F 44 #define NGX_QUIC_FT_STREAM7 0x0F
37 #define NGX_QUIC_FT_MAX_DATA 0x10 45 #define NGX_QUIC_FT_MAX_DATA 0x10
38 #define NGX_QUIC_FT_MAX_STREAM_DATA 0x11 46 #define NGX_QUIC_FT_MAX_STREAM_DATA 0x11
39 #define NGX_QUIC_FT_MAX_STREAMS 0x12 47 #define NGX_QUIC_FT_MAX_STREAMS 0x12
40 #define NGX_QUIC_FT_MAX_STREAMS2 0x13 // XXX 48 #define NGX_QUIC_FT_MAX_STREAMS2 0x13
41 #define NGX_QUIC_FT_DATA_BLOCKED 0x14 49 #define NGX_QUIC_FT_DATA_BLOCKED 0x14
42 #define NGX_QUIC_FT_STREAM_DATA_BLOCKED 0x15 50 #define NGX_QUIC_FT_STREAM_DATA_BLOCKED 0x15
43 #define NGX_QUIC_FT_STREAMS_BLOCKED 0x16 51 #define NGX_QUIC_FT_STREAMS_BLOCKED 0x16
44 #define NGX_QUIC_FT_STREAMS_BLOCKED2 0x17 // XXX 52 #define NGX_QUIC_FT_STREAMS_BLOCKED2 0x17
45 #define NGX_QUIC_FT_NEW_CONNECTION_ID 0x18 53 #define NGX_QUIC_FT_NEW_CONNECTION_ID 0x18
46 #define NGX_QUIC_FT_RETIRE_CONNECTION_ID 0x19 54 #define NGX_QUIC_FT_RETIRE_CONNECTION_ID 0x19
47 #define NGX_QUIC_FT_PATH_CHALLENGE 0x1A 55 #define NGX_QUIC_FT_PATH_CHALLENGE 0x1A
48 #define NGX_QUIC_FT_PATH_RESPONSE 0x1B 56 #define NGX_QUIC_FT_PATH_RESPONSE 0x1B
49 #define NGX_QUIC_FT_CONNECTION_CLOSE 0x1C 57 #define NGX_QUIC_FT_CONNECTION_CLOSE 0x1C
50 #define NGX_QUIC_FT_CONNECTION_CLOSE2 0x1D 58 #define NGX_QUIC_FT_CONNECTION_CLOSE2 0x1D
51 #define NGX_QUIC_FT_HANDSHAKE_DONE 0x1E 59 #define NGX_QUIC_FT_HANDSHAKE_DONE 0x1E
52 60
53 /* 22.4. QUIC Transport Error Codes Registry */ 61 /* 22.4. QUIC Transport Error Codes Registry */
54 #define NGX_QUIC_ERR_NO_ERROR 0x00 62 #define NGX_QUIC_ERR_NO_ERROR 0x00
55 #define NGX_QUIC_ERR_INTERNAL_ERROR 0x01 63 #define NGX_QUIC_ERR_INTERNAL_ERROR 0x01
56 #define NGX_QUIC_ERR_SERVER_BUSY 0x02 64 #define NGX_QUIC_ERR_SERVER_BUSY 0x02
57 #define NGX_QUIC_ERR_FLOW_CONTROL_ERROR 0x03 65 #define NGX_QUIC_ERR_FLOW_CONTROL_ERROR 0x03
58 #define NGX_QUIC_ERR_STREAM_LIMIT_ERROR 0x04 66 #define NGX_QUIC_ERR_STREAM_LIMIT_ERROR 0x04
59 #define NGX_QUIC_ERR_STREAM_STATE_ERROR 0x05 67 #define NGX_QUIC_ERR_STREAM_STATE_ERROR 0x05
60 #define NGX_QUIC_ERR_FINAL_SIZE_ERROR 0x06 68 #define NGX_QUIC_ERR_FINAL_SIZE_ERROR 0x06
61 #define NGX_QUIC_ERR_FRAME_ENCODING_ERROR 0x07 69 #define NGX_QUIC_ERR_FRAME_ENCODING_ERROR 0x07
62 #define NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR 0x08 70 #define NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR 0x08
63 #define NGX_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR 0x09 71 #define NGX_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR 0x09
64 #define NGX_QUIC_ERR_PROTOCOL_VIOLATION 0x0A 72 #define NGX_QUIC_ERR_PROTOCOL_VIOLATION 0x0A
65 #define NGX_QUIC_ERR_INVALID_TOKEN 0x0B 73 #define NGX_QUIC_ERR_INVALID_TOKEN 0x0B
66 /* 0xC is not defined */ 74 /* 0xC is not defined */
67 #define NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED 0x0D 75 #define NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED 0x0D
68 /* 0xE is not defined */ 76 /* 0xE is not defined */
69 #define NGX_QUIC_ERR_CRYPTO_ERROR 0x10 77 #define NGX_QUIC_ERR_CRYPTO_ERROR 0x10
70 78
71 #define NGX_QUIC_ERR_LAST NGX_QUIC_ERR_CRYPTO_ERROR 79 #define NGX_QUIC_ERR_LAST NGX_QUIC_ERR_CRYPTO_ERROR
72 80
73 /* Transport parameters */ 81 /* Transport parameters */
74 #define NGX_QUIC_TP_ORIGINAL_CONNECTION_ID 0x00 82 #define NGX_QUIC_TP_ORIGINAL_CONNECTION_ID 0x00
79 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL 0x05 87 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL 0x05
80 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE 0x06 88 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE 0x06
81 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI 0x07 89 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI 0x07
82 #define NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI 0x08 90 #define NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI 0x08
83 #define NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI 0x09 91 #define NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI 0x09
84 #define NGX_QUIC_TP_ACK_DELAY_EXPONENT 0x0a 92 #define NGX_QUIC_TP_ACK_DELAY_EXPONENT 0x0A
85 #define NGX_QUIC_TP_MAX_ACK_DELAY 0x0b 93 #define NGX_QUIC_TP_MAX_ACK_DELAY 0x0B
86 #define NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION 0x0c 94 #define NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION 0x0C
87 #define NGX_QUIC_TP_PREFERRED_ADDRESS 0x0d 95 #define NGX_QUIC_TP_PREFERRED_ADDRESS 0x0D
88 #define NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT 0x0e 96 #define NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT 0x0E
89 97
90 98
91 typedef struct { 99 typedef struct {
92 ngx_uint_t pn; 100 ngx_uint_t pn;
93 uint64_t largest; 101 uint64_t largest;