lsquic_engine_public.h revision 7d09751d
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_conn;
14struct lsquic_engine;
15struct stack_st_X509;
16struct lsquic_hash;
17struct lsquic_stream_if;
18struct ssl_ctx_st;
19
20enum warning_type
21{
22    WT_ACKPARSE_MINI,
23    WT_ACKPARSE_FULL,
24    WT_NO_POISON,
25    N_WARNING_TYPES,
26};
27
28#define WARNING_INTERVAL (24ULL * 3600ULL * 1000000ULL)
29
30struct lsquic_engine_public {
31    struct lsquic_mm                enp_mm;
32    struct lsquic_engine_settings   enp_settings;
33    struct token_generator         *enp_tokgen;
34    lsquic_lookup_cert_f            enp_lookup_cert;
35    void                           *enp_cert_lu_ctx;
36    struct ssl_ctx_st *           (*enp_get_ssl_ctx)(void *peer_ctx);
37    const struct lsquic_shared_hash_if
38                                   *enp_shi;
39    void                           *enp_shi_ctx;
40    lsquic_time_t                   enp_last_warning[N_WARNING_TYPES];
41    const struct lsquic_stream_if  *enp_stream_if;
42    void                           *enp_stream_if_ctx;
43    const struct lsquic_hset_if    *enp_hsi_if;
44    void                           *enp_hsi_ctx;
45    int                           (*enp_verify_cert)(void *verify_ctx,
46                                            struct stack_st_X509 *chain);
47    void                           *enp_verify_ctx;
48    const struct lsquic_packout_mem_if
49                                   *enp_pmi;
50    void                           *enp_pmi_ctx;
51    const struct lsquic_keylog_if  *enp_kli;
52    void                           *enp_kli_ctx;
53    struct lsquic_engine           *enp_engine;
54    struct lsquic_hash             *enp_srst_hash;
55    enum {
56        ENPUB_PROC  = (1 << 0), /* Being processed by one of the user-facing
57                                 * functions.
58                                 */
59        ENPUB_CAN_SEND = (1 << 1),
60    }                               enp_flags;
61    unsigned char                   enp_ver_tags_buf[ sizeof(lsquic_ver_tag_t) * N_LSQVER ];
62    unsigned                        enp_ver_tags_len;
63};
64
65/* Put connection onto the Tickable Queue if it is not already on it.  If
66 * connection is being destroyed, this is a no-op.
67 */
68void
69lsquic_engine_add_conn_to_tickable (struct lsquic_engine_public *,
70                                                        lsquic_conn_t *);
71
72/* Put connection onto Advisory Tick Time  Queue if it is not already on it.
73 */
74void
75lsquic_engine_add_conn_to_attq (struct lsquic_engine_public *enpub,
76                                lsquic_conn_t *, lsquic_time_t, unsigned why);
77
78void
79lsquic_engine_retire_cid (struct lsquic_engine_public *,
80              struct lsquic_conn *, unsigned cce_idx, lsquic_time_t now);
81
82int
83lsquic_engine_add_cid (struct lsquic_engine_public *,
84                              struct lsquic_conn *, unsigned cce_idx);
85
86struct lsquic_conn *
87lsquic_engine_find_conn (const struct lsquic_engine_public *pub,
88                         const lsquic_cid_t *cid);
89
90#endif
91