diff src/event/ngx_event_quic.h @ 8224:ae35ccba7aa6 quic

Extracted transport part of the code into separate file. All code dealing with serializing/deserializing is moved int srv/event/ngx_event_quic_transport.c/h file. All macros for dealing with data are internal to source file. The header file exposes frame types and error codes. The exported functions are currently packet header parsers and writers and frames parser/writer. The ngx_quic_header_t structure is updated with 'log' member. This avoids passing extra argument to parsing functions that need to report errors.
author Vladimir Homutov <vl@nginx.com>
date Wed, 18 Mar 2020 12:58:27 +0300
parents 61f9b873e2e7
children e9891e8ee975
line wrap: on
line diff
--- a/src/event/ngx_event_quic.h
+++ b/src/event/ngx_event_quic.h
@@ -11,57 +11,8 @@
 #include <ngx_event_openssl.h>
 
 
-#define quic_version                       0xff000018  /* draft-24 (ngtcp2) */
-//#define quic_version                       0xff00001b  /* draft-27 (FFN 76) */
-
-/* 17.2.  Long Header Packets */
-
-#define NGX_QUIC_PKT_LONG                  0x80
-
-#define NGX_QUIC_PKT_INITIAL               0xc0
-#define NGX_QUIC_PKT_HANDSHAKE             0xe0
-
-
-#if (NGX_HAVE_NONALIGNED)
-
-#define ngx_quic_parse_uint16(p)  ntohs(*(uint16_t *) (p))
-#define ngx_quic_parse_uint32(p)  ntohl(*(uint32_t *) (p))
-
-#define ngx_quic_write_uint16  ngx_quic_write_uint16_aligned
-#define ngx_quic_write_uint32  ngx_quic_write_uint32_aligned
-
-#else
-
-#define ngx_quic_parse_uint16(p)  ((p)[0] << 8 | (p)[1])
-#define ngx_quic_parse_uint32(p)                                              \
-    ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])
-
-#define ngx_quic_write_uint16(p, s)                                           \
-    ((p)[0] = (u_char) ((s) >> 8),                                            \
-     (p)[1] = (u_char)  (s),                                                  \
-     (p) + sizeof(uint16_t))
-
-#define ngx_quic_write_uint32(p, s)                                           \
-    ((p)[0] = (u_char) ((s) >> 24),                                           \
-     (p)[1] = (u_char) ((s) >> 16),                                           \
-     (p)[2] = (u_char) ((s) >> 8),                                            \
-     (p)[3] = (u_char)  (s),                                                  \
-     (p) + sizeof(uint32_t))
-
-#endif
-
-
-#define ngx_quic_write_uint16_aligned(p, s)                                   \
-    (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t))
-
-#define ngx_quic_write_uint32_aligned(p, s)                                   \
-    (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t))
-
-#define ngx_quic_varint_len(value)                                            \
-     ((value) <= 63 ? 1                                                       \
-     : ((uint32_t) value) <= 16383 ? 2                                        \
-     : ((uint64_t) value) <= 1073741823 ?  4                                  \
-     : 8)
+#define quic_version        0xff000018  /* draft-24 (ngtcp2) */
+//#define quic_version      0xff00001b  /* draft-27 (FFN 76) */
 
 
 struct ngx_quic_stream_s {
@@ -71,35 +22,6 @@ struct ngx_quic_stream_s {
     void               *data;
 };
 
-typedef struct ngx_quic_secret_s ngx_quic_secret_t;
-typedef enum ssl_encryption_level_t  ngx_quic_level_t;
-
-typedef struct {
-    ngx_quic_secret_t  *secret;
-    ngx_uint_t          type;
-    ngx_uint_t          *number;
-    ngx_uint_t          flags;
-    uint32_t            version;
-    ngx_str_t           token;
-    ngx_quic_level_t    level;
-
-    /* filled in by parser */
-    ngx_buf_t          *raw;        /* udp datagram from wire */
-
-    u_char             *data;       /* quic packet */
-    size_t              len;
-
-    /* cleartext fields */
-    ngx_str_t           dcid;
-    ngx_str_t           scid;
-
-    uint64_t            pn;
-
-    ngx_str_t           payload;  /* decrypted payload */
-
-} ngx_quic_header_t;
-
-void ngx_quic_build_int(u_char **pos, uint64_t value);
 
 void ngx_quic_init_ssl_methods(SSL_CTX* ctx);