comparison src/event/ngx_event_quic_transport.h @ 8370:262396242352 quic

Reworked macros for parsing/assembling packet types. Previously, macros checking a packet type with the long header also checked whether this is a long header. Now it requires a separate preceding check.
author Vladimir Homutov <vl@nginx.com>
date Thu, 30 Apr 2020 12:38:38 +0300
parents a5141e6b3214
children 9d9531431c8c
comparison
equal deleted inserted replaced
8369:bddf704d62c1 8370:262396242352
10 10
11 #include <ngx_config.h> 11 #include <ngx_config.h>
12 #include <ngx_core.h> 12 #include <ngx_core.h>
13 13
14 14
15 #define ngx_quic_long_pkt(flags) ((flags) & 0x80) /* 17.2 */ 15 /* QUIC flags in first byte, see quic-transport 17.2 and 17.3 */
16 #define ngx_quic_short_pkt(flags) (((flags) & 0x80) == 0) /* 17.3 */ 16
17 #define NGX_QUIC_PKT_LONG 0x80 /* header form */
18 #define NGX_QUIC_PKT_FIXED_BIT 0x40
19 #define NGX_QUIC_PKT_TYPE 0x30 /* in long packet */
20 #define NGX_QUIC_PKT_KPHASE 0x04 /* in short packet */
21
22 #define ngx_quic_long_pkt(flags) ((flags) & NGX_QUIC_PKT_LONG)
23 #define ngx_quic_short_pkt(flags) (((flags) & NGX_QUIC_PKT_LONG) == 0)
17 24
18 /* Long packet types */ 25 /* Long packet types */
19 #define NGX_QUIC_PKT_INITIAL 0xC0 /* 17.2.2 */ 26 #define NGX_QUIC_PKT_INITIAL 0x00
20 #define NGX_QUIC_PKT_ZRTT 0xD0 /* 17.2.3 */ 27 #define NGX_QUIC_PKT_ZRTT 0x10
21 #define NGX_QUIC_PKT_HANDSHAKE 0xE0 /* 17.2.4 */ 28 #define NGX_QUIC_PKT_HANDSHAKE 0x20
22 #define NGX_QUIC_PKT_RETRY 0xF0 /* 17.2.5 */ 29 #define NGX_QUIC_PKT_RETRY 0x30
23 #define NGX_QUIC_PKT_KPHASE 0x04 /* 17.3 */ 30
24 31 #define ngx_quic_pkt_in(flags) \
25 #define ngx_quic_pkt_in(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_INITIAL) 32 (((flags) & NGX_QUIC_PKT_TYPE) == NGX_QUIC_PKT_INITIAL)
26 #define ngx_quic_pkt_zrtt(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_ZRTT) 33 #define ngx_quic_pkt_zrtt(flags) \
27 #define ngx_quic_pkt_hs(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_HANDSHAKE) 34 (((flags) & NGX_QUIC_PKT_TYPE) == NGX_QUIC_PKT_ZRTT)
28 #define ngx_quic_pkt_retry(flags) (((flags) & 0xF0) == NGX_QUIC_PKT_RETRY) 35 #define ngx_quic_pkt_hs(flags) \
36 (((flags) & NGX_QUIC_PKT_TYPE) == NGX_QUIC_PKT_HANDSHAKE)
37 #define ngx_quic_pkt_retry(flags) \
38 (((flags) & NGX_QUIC_PKT_TYPE) == NGX_QUIC_PKT_RETRY)
39
29 40
30 /* 12.4. Frames and Frame Types */ 41 /* 12.4. Frames and Frame Types */
31 #define NGX_QUIC_FT_PADDING 0x00 42 #define NGX_QUIC_FT_PADDING 0x00
32 #define NGX_QUIC_FT_PING 0x01 43 #define NGX_QUIC_FT_PING 0x01
33 #define NGX_QUIC_FT_ACK 0x02 44 #define NGX_QUIC_FT_ACK 0x02