/* For testing use. While enabled, ticking is not performed. */
void ossl_quic_port_set_inhibit_tick(QUIC_PORT *port, int inhibit);
+/* Returns 1 if the port is running/healthy, 0 if it has failed. */
+int ossl_quic_port_is_running(const QUIC_PORT *port);
+
/*
* Events
* ======
ossl_quic_reactor_init(&port->rtor, port_tick, port, ossl_time_zero());
port->rx_short_dcid_len = (unsigned char)rx_short_dcid_len;
port->tx_init_dcid_len = INIT_DCID_LEN;
+ port->state = QUIC_PORT_STATE_RUNNING;
return 1;
err:
port->lcidm = NULL;
}
+static void port_transition_failed(QUIC_PORT *port)
+{
+ if (port->state == QUIC_PORT_STATE_FAILED)
+ return;
+
+ port->state = QUIC_PORT_STATE_FAILED;
+}
+
+int ossl_quic_port_is_running(const QUIC_PORT *port)
+{
+ return port->state == QUIC_PORT_STATE_RUNNING;
+}
+
QUIC_REACTOR *ossl_quic_port_get0_reactor(QUIC_PORT *port)
{
return &port->rtor;
QUIC_PKT_HDR hdr;
QUIC_CHANNEL *ch = NULL, *new_ch = NULL;
+ /* Don't handle anything if we are no longer running. */
+ if (!ossl_quic_port_is_running(port))
+ goto undesirable;
+
if (dcid != NULL
&& ossl_quic_lcidm_lookup(port->lcidm, dcid, NULL,
(void **)&ch)) {
if (port->tserver_ch == NULL)
goto undesirable;
- // TODO fsm
-
/*
* We have got a packet for an unknown DCID. This might be an attempt to
* open a new connection.
{
QUIC_CHANNEL *ch;
- // TODO fsm
+ port_transition_failed(port);
LIST_FOREACH(ch, ch, &port->channel_list)
ossl_quic_channel_raise_net_error(ch);
*/
DECLARE_LIST_OF(ch, QUIC_CHANNEL);
+/* A port is always in one of the following states: */
+enum {
+ /* Initial and steady state. */
+ QUIC_PORT_STATE_RUNNING,
+
+ /*
+ * Terminal state indicating port is no longer functioning. There are no
+ * transitions out of this state. May be triggered by e.g. a permanent
+ * network BIO error.
+ */
+ QUIC_PORT_STATE_FAILED
+};
+
struct quic_port_st {
OSSL_LIB_CTX *libctx;
const char *propq;
/* For clients, CID length used for outgoing Initial packets. */
unsigned char tx_init_dcid_len;
+ /* Port state (QUIC_PORT_STATE_*). */
+ unsigned int state : 1;
+
/* Is this port created to support multiple connections? */
unsigned int is_multi_conn : 1;