lsquic_engine_public.h revision 2f4629f2
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; 22struct lsquic_server_config; 23 24enum warning_type 25{ 26 WT_ACKPARSE_MINI, 27 WT_ACKPARSE_FULL, 28 WT_NO_POISON, 29 N_WARNING_TYPES, 30}; 31 32#define WARNING_INTERVAL (24ULL * 3600ULL * 1000000ULL) 33 34struct lsquic_engine_public { 35 struct lsquic_mm enp_mm; 36 struct lsquic_engine_settings enp_settings; 37 struct token_generator *enp_tokgen; 38 lsquic_lookup_cert_f enp_lookup_cert; 39 void *enp_cert_lu_ctx; 40 struct ssl_ctx_st * (*enp_get_ssl_ctx)(void *peer_ctx); 41 const struct lsquic_shared_hash_if 42 *enp_shi; 43 void *enp_shi_ctx; 44 lsquic_time_t enp_last_warning[N_WARNING_TYPES]; 45 const struct lsquic_stream_if *enp_stream_if; 46 void *enp_stream_if_ctx; 47 const struct lsquic_hset_if *enp_hsi_if; 48 void *enp_hsi_ctx; 49 void (*enp_generate_scid)(struct lsquic_conn *, 50 struct lsquic_cid *, unsigned); 51 int (*enp_verify_cert)(void *verify_ctx, 52 struct stack_st_X509 *chain); 53 void *enp_verify_ctx; 54 const struct lsquic_packout_mem_if 55 *enp_pmi; 56 void *enp_pmi_ctx; 57 const struct lsquic_keylog_if *enp_kli; 58 void *enp_kli_ctx; 59 struct lsquic_engine *enp_engine; 60 struct lsquic_hash *enp_srst_hash; 61 enum { 62 ENPUB_PROC = (1 << 0), /* Being processed by one of the user-facing 63 * functions. 64 */ 65 ENPUB_CAN_SEND = (1 << 1), 66 ENPUB_HTTP = (1 << 2), /* Engine in HTTP mode */ 67 } enp_flags; 68 unsigned char enp_ver_tags_buf[ sizeof(lsquic_ver_tag_t) * N_LSQVER ]; 69 unsigned enp_ver_tags_len; 70 struct crand *enp_crand; 71 struct evp_aead_ctx_st *enp_retry_aead_ctx; 72 unsigned char *enp_alpn; /* May be set if not HTTP */ 73 /* es_noprogress_timeout converted to microseconds for speed */ 74 lsquic_time_t enp_noprog_timeout; 75 lsquic_time_t enp_mtu_probe_timer; 76 /* Certs used by gQUIC server: */ 77 struct lsquic_hash *enp_compressed_server_certs; 78 struct lsquic_hash *enp_server_certs; 79 /* gQUIC server configuration: */ 80 struct lsquic_server_config *enp_server_config; 81}; 82 83/* Put connection onto the Tickable Queue if it is not already on it. If 84 * connection is being destroyed, this is a no-op. 85 */ 86void 87lsquic_engine_add_conn_to_tickable (struct lsquic_engine_public *, 88 lsquic_conn_t *); 89 90/* Put connection onto Advisory Tick Time Queue if it is not already on it. 91 */ 92void 93lsquic_engine_add_conn_to_attq (struct lsquic_engine_public *enpub, 94 lsquic_conn_t *, lsquic_time_t, unsigned why); 95 96void 97lsquic_engine_retire_cid (struct lsquic_engine_public *, 98 struct lsquic_conn *, unsigned cce_idx, lsquic_time_t now); 99 100int 101lsquic_engine_add_cid (struct lsquic_engine_public *, 102 struct lsquic_conn *, unsigned cce_idx); 103 104struct lsquic_conn * 105lsquic_engine_find_conn (const struct lsquic_engine_public *pub, 106 const lsquic_cid_t *cid); 107 108#endif 109