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