lsquic_engine_public.h revision b62ec17f
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_engine_public.h -- Engine's "public interface"
4 *
5 * This structure is used to bundle things in engine that connections
6 * need.  This way, the space per mini connection is one pointer instead
7 * of several.
8 */
9
10#ifndef LSQUIC_ENGINE_PUBLIC_H
11#define LSQUIC_ENGINE_PUBLIC_H 1
12
13struct lsquic_cid;
14struct lsquic_conn;
15struct lsquic_engine;
16struct stack_st_X509;
17struct lsquic_hash;
18struct lsquic_stream_if;
19struct ssl_ctx_st;
20struct crand;
21struct evp_aead_ctx_st;
22
23enum warning_type
24{
25    WT_ACKPARSE_MINI,
26    WT_ACKPARSE_FULL,
27    WT_NO_POISON,
28    N_WARNING_TYPES,
29};
30
31#define WARNING_INTERVAL (24ULL * 3600ULL * 1000000ULL)
32
33struct lsquic_engine_public {
34    struct lsquic_mm                enp_mm;
35    struct lsquic_engine_settings   enp_settings;
36    struct token_generator         *enp_tokgen;
37    lsquic_lookup_cert_f            enp_lookup_cert;
38    void                           *enp_cert_lu_ctx;
39    struct ssl_ctx_st *           (*enp_get_ssl_ctx)(void *peer_ctx);
40    const struct lsquic_shared_hash_if
41                                   *enp_shi;
42    void                           *enp_shi_ctx;
43    lsquic_time_t                   enp_last_warning[N_WARNING_TYPES];
44    const struct lsquic_stream_if  *enp_stream_if;
45    void                           *enp_stream_if_ctx;
46    const struct lsquic_hset_if    *enp_hsi_if;
47    void                           *enp_hsi_ctx;
48    void                          (*enp_generate_scid)(struct lsquic_conn *,
49                                            struct lsquic_cid *, unsigned);
50    int                           (*enp_verify_cert)(void *verify_ctx,
51                                            struct stack_st_X509 *chain);
52    void                           *enp_verify_ctx;
53    const struct lsquic_packout_mem_if
54                                   *enp_pmi;
55    void                           *enp_pmi_ctx;
56    const struct lsquic_keylog_if  *enp_kli;
57    void                           *enp_kli_ctx;
58    struct lsquic_engine           *enp_engine;
59    struct lsquic_hash             *enp_srst_hash;
60    enum {
61        ENPUB_PROC  = (1 << 0), /* Being processed by one of the user-facing
62                                 * functions.
63                                 */
64        ENPUB_CAN_SEND = (1 << 1),
65        ENPUB_HTTP  = (1 << 2), /* Engine in HTTP mode */
66    }                               enp_flags;
67    unsigned char                   enp_ver_tags_buf[ sizeof(lsquic_ver_tag_t) * N_LSQVER ];
68    unsigned                        enp_ver_tags_len;
69    struct crand                   *enp_crand;
70    struct evp_aead_ctx_st         *enp_retry_aead_ctx;
71    unsigned char                  *enp_alpn;   /* May be set if not HTTP */
72    /* es_noprogress_timeout converted to microseconds for speed */
73    lsquic_time_t                   enp_noprog_timeout;
74    lsquic_time_t                   enp_mtu_probe_timer;
75};
76
77/* Put connection onto the Tickable Queue if it is not already on it.  If
78 * connection is being destroyed, this is a no-op.
79 */
80void
81lsquic_engine_add_conn_to_tickable (struct lsquic_engine_public *,
82                                                        lsquic_conn_t *);
83
84/* Put connection onto Advisory Tick Time  Queue if it is not already on it.
85 */
86void
87lsquic_engine_add_conn_to_attq (struct lsquic_engine_public *enpub,
88                                lsquic_conn_t *, lsquic_time_t, unsigned why);
89
90void
91lsquic_engine_retire_cid (struct lsquic_engine_public *,
92              struct lsquic_conn *, unsigned cce_idx, lsquic_time_t now);
93
94int
95lsquic_engine_add_cid (struct lsquic_engine_public *,
96                              struct lsquic_conn *, unsigned cce_idx);
97
98struct lsquic_conn *
99lsquic_engine_find_conn (const struct lsquic_engine_public *pub,
100                         const lsquic_cid_t *cid);
101
102#endif
103