comparison src/event/ngx_event_quic.h @ 7647:3cb4f16426a5 quic

Introduced quic_version macro, uint16/uint32 routines ported.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 28 Feb 2020 13:09:52 +0300
parents 01dc595de244
children b28ea685a56e
comparison
equal deleted inserted replaced
7646:01dc595de244 7647:3cb4f16426a5
7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_ 7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_
8 #define _NGX_EVENT_QUIC_H_INCLUDED_ 8 #define _NGX_EVENT_QUIC_H_INCLUDED_
9 9
10 10
11 #include <ngx_event_openssl.h> 11 #include <ngx_event_openssl.h>
12
13 #define quic_version 0xff000018
12 14
13 15
14 typedef struct { 16 typedef struct {
15 ngx_str_t secret; 17 ngx_str_t secret;
16 ngx_str_t key; 18 ngx_str_t key;
56 58
57 ngx_int_t 59 ngx_int_t
58 ngx_quic_tls_hp(ngx_connection_t *c, const EVP_CIPHER *cipher, 60 ngx_quic_tls_hp(ngx_connection_t *c, const EVP_CIPHER *cipher,
59 ngx_quic_secret_t *s, u_char *out, u_char *in); 61 ngx_quic_secret_t *s, u_char *out, u_char *in);
60 62
63
64 #if (NGX_HAVE_NONALIGNED)
65
66 #define ngx_quic_parse_uint16(p) ntohs(*(uint16_t *) (p))
67 #define ngx_quic_parse_uint32(p) ntohl(*(uint32_t *) (p))
68
69 #else
70
71 #define ngx_quic_parse_uint16(p) ((p)[0] << 8 | (p)[1])
72 #define ngx_quic_parse_uint32(p) \
73 ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])
74
75 #endif
76
77
78 #define ngx_quic_write_uint16_aligned(p, s) \
79 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t))
80 #define ngx_quic_write_uint32_aligned(p, s) \
81 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t))
82
83 #if (NGX_HAVE_NONALIGNED)
84
85 #define ngx_quic_write_uint16 ngx_quic_write_uint16_aligned
86 #define ngx_quic_write_uint32 ngx_quic_write_uint32_aligned
87
88 #else
89
90 #define ngx_quic_write_uint16(p, s) \
91 ((p)[0] = (u_char) ((s) >> 8), \
92 (p)[1] = (u_char) (s), \
93 (p) + sizeof(uint16_t))
94
95 #define ngx_quic_write_uint32(p, s) \
96 ((p)[0] = (u_char) ((s) >> 24), \
97 (p)[1] = (u_char) ((s) >> 16), \
98 (p)[2] = (u_char) ((s) >> 8), \
99 (p)[3] = (u_char) (s), \
100 (p) + sizeof(uint32_t))
101
102 #endif
103
61 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */ 104 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */