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