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