1 /* 2 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #ifndef OSSL_QUIC_PORT_LOCAL_H 11 # define OSSL_QUIC_PORT_LOCAL_H 12 13 # include "internal/quic_port.h" 14 # include "internal/quic_reactor.h" 15 # include "internal/list.h" 16 17 # ifndef OPENSSL_NO_QUIC 18 19 /* 20 * QUIC Port Structure 21 * =================== 22 * 23 * QUIC port internals. It is intended that only the QUIC_PORT and QUIC_CHANNEL 24 * implementation be allowed to access this structure directly. 25 * 26 * Other components should not include this header. 27 */ 28 DECLARE_LIST_OF(ch, QUIC_CHANNEL); 29 30 /* A port is always in one of the following states: */ 31 enum { 32 /* Initial and steady state. */ 33 QUIC_PORT_STATE_RUNNING, 34 35 /* 36 * Terminal state indicating port is no longer functioning. There are no 37 * transitions out of this state. May be triggered by e.g. a permanent 38 * network BIO error. 39 */ 40 QUIC_PORT_STATE_FAILED 41 }; 42 43 struct quic_port_st { 44 /* The engine which this port is a child of. */ 45 QUIC_ENGINE *engine; 46 47 /* 48 * QUIC_ENGINE keeps the ports which belong to it on a list for bookkeeping 49 * purposes. 50 */ 51 OSSL_LIST_MEMBER(port, QUIC_PORT); 52 53 /* Used to create handshake layer objects inside newly created channels. */ 54 SSL_CTX *channel_ctx; 55 56 /* Network-side read and write BIOs. */ 57 BIO *net_rbio, *net_wbio; 58 59 /* RX demuxer. We register incoming DCIDs with this. */ 60 QUIC_DEMUX *demux; 61 62 /* List of all child channels. */ 63 OSSL_LIST(ch) channel_list; 64 65 /* Special TSERVER channel. To be removed in the future. */ 66 QUIC_CHANNEL *tserver_ch; 67 68 /* LCIDM used for incoming packet routing by DCID. */ 69 QUIC_LCIDM *lcidm; 70 71 /* SRTM used for incoming packet routing by SRT. */ 72 QUIC_SRTM *srtm; 73 74 /* Port-level permanent errors (causing failure state) are stored here. */ 75 ERR_STATE *err_state; 76 77 /* DCID length used for incoming short header packets. */ 78 unsigned char rx_short_dcid_len; 79 /* For clients, CID length used for outgoing Initial packets. */ 80 unsigned char tx_init_dcid_len; 81 82 /* Port state (QUIC_PORT_STATE_*). */ 83 unsigned int state : 1; 84 85 /* Is this port created to support multiple connections? */ 86 unsigned int is_multi_conn : 1; 87 88 /* Has this port sent any packet of any kind yet? */ 89 unsigned int have_sent_any_pkt : 1; 90 91 /* Does this port allow incoming connections? */ 92 unsigned int is_server : 1; 93 94 /* Are we on the QUIC_ENGINE linked list of ports? */ 95 unsigned int on_engine_list : 1; 96 }; 97 98 # endif 99 100 #endif 101