lsquic_engine_public.h revision b62ec17f
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_engine_public.h -- Engine's "public interface"
450aadb33SDmitri Tikhonov *
55392f7a3SLiteSpeed Tech * This structure is used to bundle things in engine that connections
65392f7a3SLiteSpeed Tech * need.  This way, the space per mini connection is one pointer instead
75392f7a3SLiteSpeed Tech * of several.
850aadb33SDmitri Tikhonov */
950aadb33SDmitri Tikhonov
1050aadb33SDmitri Tikhonov#ifndef LSQUIC_ENGINE_PUBLIC_H
1150aadb33SDmitri Tikhonov#define LSQUIC_ENGINE_PUBLIC_H 1
1250aadb33SDmitri Tikhonov
13b62ec17fSDmitri Tikhonovstruct lsquic_cid;
1450aadb33SDmitri Tikhonovstruct lsquic_conn;
1550aadb33SDmitri Tikhonovstruct lsquic_engine;
167f2bd84cSDmitri Tikhonovstruct stack_st_X509;
175392f7a3SLiteSpeed Techstruct lsquic_hash;
185392f7a3SLiteSpeed Techstruct lsquic_stream_if;
195392f7a3SLiteSpeed Techstruct ssl_ctx_st;
2010c41073SDmitri Tikhonovstruct crand;
219fc12041SDmitri Tikhonovstruct evp_aead_ctx_st;
225392f7a3SLiteSpeed Tech
235392f7a3SLiteSpeed Techenum warning_type
245392f7a3SLiteSpeed Tech{
255392f7a3SLiteSpeed Tech    WT_ACKPARSE_MINI,
265392f7a3SLiteSpeed Tech    WT_ACKPARSE_FULL,
27de46bf2fSDmitri Tikhonov    WT_NO_POISON,
285392f7a3SLiteSpeed Tech    N_WARNING_TYPES,
295392f7a3SLiteSpeed Tech};
305392f7a3SLiteSpeed Tech
315392f7a3SLiteSpeed Tech#define WARNING_INTERVAL (24ULL * 3600ULL * 1000000ULL)
3250aadb33SDmitri Tikhonov
3350aadb33SDmitri Tikhonovstruct lsquic_engine_public {
3450aadb33SDmitri Tikhonov    struct lsquic_mm                enp_mm;
3550aadb33SDmitri Tikhonov    struct lsquic_engine_settings   enp_settings;
365392f7a3SLiteSpeed Tech    struct token_generator         *enp_tokgen;
375392f7a3SLiteSpeed Tech    lsquic_lookup_cert_f            enp_lookup_cert;
385392f7a3SLiteSpeed Tech    void                           *enp_cert_lu_ctx;
395392f7a3SLiteSpeed Tech    struct ssl_ctx_st *           (*enp_get_ssl_ctx)(void *peer_ctx);
405392f7a3SLiteSpeed Tech    const struct lsquic_shared_hash_if
415392f7a3SLiteSpeed Tech                                   *enp_shi;
425392f7a3SLiteSpeed Tech    void                           *enp_shi_ctx;
435392f7a3SLiteSpeed Tech    lsquic_time_t                   enp_last_warning[N_WARNING_TYPES];
445392f7a3SLiteSpeed Tech    const struct lsquic_stream_if  *enp_stream_if;
455392f7a3SLiteSpeed Tech    void                           *enp_stream_if_ctx;
463b55e6aeSDmitri Tikhonov    const struct lsquic_hset_if    *enp_hsi_if;
473b55e6aeSDmitri Tikhonov    void                           *enp_hsi_ctx;
48b62ec17fSDmitri Tikhonov    void                          (*enp_generate_scid)(struct lsquic_conn *,
49b62ec17fSDmitri Tikhonov                                            struct lsquic_cid *, unsigned);
507f2bd84cSDmitri Tikhonov    int                           (*enp_verify_cert)(void *verify_ctx,
517f2bd84cSDmitri Tikhonov                                            struct stack_st_X509 *chain);
527f2bd84cSDmitri Tikhonov    void                           *enp_verify_ctx;
5350aadb33SDmitri Tikhonov    const struct lsquic_packout_mem_if
5450aadb33SDmitri Tikhonov                                   *enp_pmi;
5550aadb33SDmitri Tikhonov    void                           *enp_pmi_ctx;
565392f7a3SLiteSpeed Tech    const struct lsquic_keylog_if  *enp_kli;
575392f7a3SLiteSpeed Tech    void                           *enp_kli_ctx;
5850aadb33SDmitri Tikhonov    struct lsquic_engine           *enp_engine;
595392f7a3SLiteSpeed Tech    struct lsquic_hash             *enp_srst_hash;
6050aadb33SDmitri Tikhonov    enum {
6150aadb33SDmitri Tikhonov        ENPUB_PROC  = (1 << 0), /* Being processed by one of the user-facing
6250aadb33SDmitri Tikhonov                                 * functions.
6350aadb33SDmitri Tikhonov                                 */
64c44946ecSDmitri Tikhonov        ENPUB_CAN_SEND = (1 << 1),
65fa4561dcSDmitri Tikhonov        ENPUB_HTTP  = (1 << 2), /* Engine in HTTP mode */
6650aadb33SDmitri Tikhonov    }                               enp_flags;
675392f7a3SLiteSpeed Tech    unsigned char                   enp_ver_tags_buf[ sizeof(lsquic_ver_tag_t) * N_LSQVER ];
685392f7a3SLiteSpeed Tech    unsigned                        enp_ver_tags_len;
6910c41073SDmitri Tikhonov    struct crand                   *enp_crand;
709fc12041SDmitri Tikhonov    struct evp_aead_ctx_st         *enp_retry_aead_ctx;
71fa4561dcSDmitri Tikhonov    unsigned char                  *enp_alpn;   /* May be set if not HTTP */
728ae5ecb4SDmitri Tikhonov    /* es_noprogress_timeout converted to microseconds for speed */
738ae5ecb4SDmitri Tikhonov    lsquic_time_t                   enp_noprog_timeout;
74b8fa6195SDmitri Tikhonov    lsquic_time_t                   enp_mtu_probe_timer;
7550aadb33SDmitri Tikhonov};
7650aadb33SDmitri Tikhonov
77e8bd737dSDmitri Tikhonov/* Put connection onto the Tickable Queue if it is not already on it.  If
7850aadb33SDmitri Tikhonov * connection is being destroyed, this is a no-op.
7950aadb33SDmitri Tikhonov */
8050aadb33SDmitri Tikhonovvoid
81e8bd737dSDmitri Tikhonovlsquic_engine_add_conn_to_tickable (struct lsquic_engine_public *,
82e8bd737dSDmitri Tikhonov                                                        lsquic_conn_t *);
8350aadb33SDmitri Tikhonov
8450aadb33SDmitri Tikhonov/* Put connection onto Advisory Tick Time  Queue if it is not already on it.
8550aadb33SDmitri Tikhonov */
8650aadb33SDmitri Tikhonovvoid
8750aadb33SDmitri Tikhonovlsquic_engine_add_conn_to_attq (struct lsquic_engine_public *enpub,
880adf085aSDmitri Tikhonov                                lsquic_conn_t *, lsquic_time_t, unsigned why);
8950aadb33SDmitri Tikhonov
905392f7a3SLiteSpeed Techvoid
915392f7a3SLiteSpeed Techlsquic_engine_retire_cid (struct lsquic_engine_public *,
925392f7a3SLiteSpeed Tech              struct lsquic_conn *, unsigned cce_idx, lsquic_time_t now);
935392f7a3SLiteSpeed Tech
945392f7a3SLiteSpeed Techint
955392f7a3SLiteSpeed Techlsquic_engine_add_cid (struct lsquic_engine_public *,
965392f7a3SLiteSpeed Tech                              struct lsquic_conn *, unsigned cce_idx);
975392f7a3SLiteSpeed Tech
985392f7a3SLiteSpeed Techstruct lsquic_conn *
995392f7a3SLiteSpeed Techlsquic_engine_find_conn (const struct lsquic_engine_public *pub,
1005392f7a3SLiteSpeed Tech                         const lsquic_cid_t *cid);
1015392f7a3SLiteSpeed Tech
10250aadb33SDmitri Tikhonov#endif
103