Lines Matching refs:port

25 static int port_init(QUIC_PORT *port);
26 static void port_cleanup(QUIC_PORT *port);
30 static void port_rx_pre(QUIC_PORT *port);
33 DEFINE_LIST_OF_IMPL(port, QUIC_PORT);
37 QUIC_PORT *port; in ossl_quic_port_new() local
39 if ((port = OPENSSL_zalloc(sizeof(QUIC_PORT))) == NULL) in ossl_quic_port_new()
42 port->engine = args->engine; in ossl_quic_port_new()
43 port->channel_ctx = args->channel_ctx; in ossl_quic_port_new()
44 port->is_multi_conn = args->is_multi_conn; in ossl_quic_port_new()
46 if (!port_init(port)) { in ossl_quic_port_new()
47 OPENSSL_free(port); in ossl_quic_port_new()
51 return port; in ossl_quic_port_new()
54 void ossl_quic_port_free(QUIC_PORT *port) in ossl_quic_port_free() argument
56 if (port == NULL) in ossl_quic_port_free()
59 port_cleanup(port); in ossl_quic_port_free()
60 OPENSSL_free(port); in ossl_quic_port_free()
63 static int port_init(QUIC_PORT *port) in port_init() argument
65 size_t rx_short_dcid_len = (port->is_multi_conn ? INIT_DCID_LEN : 0); in port_init()
67 if (port->engine == NULL || port->channel_ctx == NULL) in port_init()
70 if ((port->err_state = OSSL_ERR_STATE_new()) == NULL) in port_init()
73 if ((port->demux = ossl_quic_demux_new(/*BIO=*/NULL, in port_init()
75 get_time, port)) == NULL) in port_init()
78 ossl_quic_demux_set_default_handler(port->demux, in port_init()
80 port); in port_init()
82 if ((port->srtm = ossl_quic_srtm_new(port->engine->libctx, in port_init()
83 port->engine->propq)) == NULL) in port_init()
86 if ((port->lcidm = ossl_quic_lcidm_new(port->engine->libctx, in port_init()
90 port->rx_short_dcid_len = (unsigned char)rx_short_dcid_len; in port_init()
91 port->tx_init_dcid_len = INIT_DCID_LEN; in port_init()
92 port->state = QUIC_PORT_STATE_RUNNING; in port_init()
94 ossl_list_port_insert_tail(&port->engine->port_list, port); in port_init()
95 port->on_engine_list = 1; in port_init()
99 port_cleanup(port); in port_init()
103 static void port_cleanup(QUIC_PORT *port) in port_cleanup() argument
105 assert(ossl_list_ch_num(&port->channel_list) == 0); in port_cleanup()
107 ossl_quic_demux_free(port->demux); in port_cleanup()
108 port->demux = NULL; in port_cleanup()
110 ossl_quic_srtm_free(port->srtm); in port_cleanup()
111 port->srtm = NULL; in port_cleanup()
113 ossl_quic_lcidm_free(port->lcidm); in port_cleanup()
114 port->lcidm = NULL; in port_cleanup()
116 OSSL_ERR_STATE_free(port->err_state); in port_cleanup()
117 port->err_state = NULL; in port_cleanup()
119 if (port->on_engine_list) { in port_cleanup()
120 ossl_list_port_remove(&port->engine->port_list, port); in port_cleanup()
121 port->on_engine_list = 0; in port_cleanup()
125 static void port_transition_failed(QUIC_PORT *port) in port_transition_failed() argument
127 if (port->state == QUIC_PORT_STATE_FAILED) in port_transition_failed()
130 port->state = QUIC_PORT_STATE_FAILED; in port_transition_failed()
133 int ossl_quic_port_is_running(const QUIC_PORT *port) in ossl_quic_port_is_running() argument
135 return port->state == QUIC_PORT_STATE_RUNNING; in ossl_quic_port_is_running()
138 QUIC_ENGINE *ossl_quic_port_get0_engine(QUIC_PORT *port) in ossl_quic_port_get0_engine() argument
140 return port->engine; in ossl_quic_port_get0_engine()
143 QUIC_REACTOR *ossl_quic_port_get0_reactor(QUIC_PORT *port) in ossl_quic_port_get0_reactor() argument
145 return ossl_quic_engine_get0_reactor(port->engine); in ossl_quic_port_get0_reactor()
148 QUIC_DEMUX *ossl_quic_port_get0_demux(QUIC_PORT *port) in ossl_quic_port_get0_demux() argument
150 return port->demux; in ossl_quic_port_get0_demux()
153 CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port) in ossl_quic_port_get0_mutex() argument
155 return ossl_quic_engine_get0_mutex(port->engine); in ossl_quic_port_get0_mutex()
158 OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port) in ossl_quic_port_get_time() argument
160 return ossl_quic_engine_get_time(port->engine); in ossl_quic_port_get_time()
163 static OSSL_TIME get_time(void *port) in get_time() argument
165 return ossl_quic_port_get_time((QUIC_PORT *)port); in get_time()
168 int ossl_quic_port_get_rx_short_dcid_len(const QUIC_PORT *port) in ossl_quic_port_get_rx_short_dcid_len() argument
170 return port->rx_short_dcid_len; in ossl_quic_port_get_rx_short_dcid_len()
173 int ossl_quic_port_get_tx_init_dcid_len(const QUIC_PORT *port) in ossl_quic_port_get_tx_init_dcid_len() argument
175 return port->tx_init_dcid_len; in ossl_quic_port_get_tx_init_dcid_len()
194 BIO *ossl_quic_port_get_net_rbio(QUIC_PORT *port) in ossl_quic_port_get_net_rbio() argument
196 return port->net_rbio; in ossl_quic_port_get_net_rbio()
199 BIO *ossl_quic_port_get_net_wbio(QUIC_PORT *port) in ossl_quic_port_get_net_wbio() argument
201 return port->net_wbio; in ossl_quic_port_get_net_wbio()
204 static int port_update_poll_desc(QUIC_PORT *port, BIO *net_bio, int for_write) in port_update_poll_desc() argument
227 ossl_quic_reactor_set_poll_w(&port->engine->rtor, &d); in port_update_poll_desc()
229 ossl_quic_reactor_set_poll_r(&port->engine->rtor, &d); in port_update_poll_desc()
234 int ossl_quic_port_update_poll_descriptors(QUIC_PORT *port) in ossl_quic_port_update_poll_descriptors() argument
238 if (!port_update_poll_desc(port, port->net_rbio, /*for_write=*/0)) in ossl_quic_port_update_poll_descriptors()
241 if (!port_update_poll_desc(port, port->net_wbio, /*for_write=*/1)) in ossl_quic_port_update_poll_descriptors()
253 int ossl_quic_port_set_net_rbio(QUIC_PORT *port, BIO *net_rbio) in ossl_quic_port_set_net_rbio() argument
255 if (port->net_rbio == net_rbio) in ossl_quic_port_set_net_rbio()
258 if (!port_update_poll_desc(port, net_rbio, /*for_write=*/0)) in ossl_quic_port_set_net_rbio()
261 ossl_quic_demux_set_bio(port->demux, net_rbio); in ossl_quic_port_set_net_rbio()
262 port->net_rbio = net_rbio; in ossl_quic_port_set_net_rbio()
266 int ossl_quic_port_set_net_wbio(QUIC_PORT *port, BIO *net_wbio) in ossl_quic_port_set_net_wbio() argument
270 if (port->net_wbio == net_wbio) in ossl_quic_port_set_net_wbio()
273 if (!port_update_poll_desc(port, net_wbio, /*for_write=*/1)) in ossl_quic_port_set_net_wbio()
276 OSSL_LIST_FOREACH(ch, ch, &port->channel_list) in ossl_quic_port_set_net_wbio()
279 port->net_wbio = net_wbio; in ossl_quic_port_set_net_wbio()
288 static SSL *port_new_handshake_layer(QUIC_PORT *port) in port_new_handshake_layer() argument
293 tls = ossl_ssl_connection_new_int(port->channel_ctx, NULL, TLS_method()); in port_new_handshake_layer()
306 static QUIC_CHANNEL *port_make_channel(QUIC_PORT *port, SSL *tls, int is_server) in port_make_channel() argument
311 args.port = port; in port_make_channel()
313 args.tls = (tls != NULL ? tls : port_new_handshake_layer(port)); in port_make_channel()
314 args.lcidm = port->lcidm; in port_make_channel()
315 args.srtm = port->srtm; in port_make_channel()
335 QUIC_CHANNEL *ossl_quic_port_create_outgoing(QUIC_PORT *port, SSL *tls) in ossl_quic_port_create_outgoing() argument
337 return port_make_channel(port, tls, /*is_server=*/0); in ossl_quic_port_create_outgoing()
340 QUIC_CHANNEL *ossl_quic_port_create_incoming(QUIC_PORT *port, SSL *tls) in ossl_quic_port_create_incoming() argument
344 assert(port->tserver_ch == NULL); in ossl_quic_port_create_incoming()
346 ch = port_make_channel(port, tls, /*is_server=*/1); in ossl_quic_port_create_incoming()
347 port->tserver_ch = ch; in ossl_quic_port_create_incoming()
348 port->is_server = 1; in ossl_quic_port_create_incoming()
361 void ossl_quic_port_subtick(QUIC_PORT *port, QUIC_TICK_RESULT *res, in ossl_quic_port_subtick() argument
370 if (!port->engine->inhibit_tick) { in ossl_quic_port_subtick()
372 if (ossl_quic_port_is_running(port)) in ossl_quic_port_subtick()
373 port_rx_pre(port); in ossl_quic_port_subtick()
376 OSSL_LIST_FOREACH(ch, ch, &port->channel_list) { in ossl_quic_port_subtick()
386 static void port_rx_pre(QUIC_PORT *port) in port_rx_pre() argument
406 if (!port->is_server && !port->have_sent_any_pkt) in port_rx_pre()
413 ret = ossl_quic_demux_pump(port->demux); in port_rx_pre()
421 ossl_quic_port_raise_net_error(port, NULL); in port_rx_pre()
429 static void port_on_new_conn(QUIC_PORT *port, const BIO_ADDR *peer, in port_on_new_conn() argument
434 if (port->tserver_ch != NULL) { in port_on_new_conn()
436 if (!ossl_quic_channel_on_new_conn(port->tserver_ch, peer, scid, dcid)) in port_on_new_conn()
439 *new_ch = port->tserver_ch; in port_on_new_conn()
440 port->tserver_ch = NULL; in port_on_new_conn()
445 static int port_try_handle_stateless_reset(QUIC_PORT *port, const QUIC_URXE *e) in port_try_handle_stateless_reset() argument
478 if (!ossl_quic_srtm_lookup(port->srtm, in port_try_handle_stateless_reset()
498 QUIC_PORT *port = arg; in port_default_packet_handler() local
504 if (!ossl_quic_port_is_running(port)) in port_default_packet_handler()
507 if (port_try_handle_stateless_reset(port, e)) in port_default_packet_handler()
511 && ossl_quic_lcidm_lookup(port->lcidm, dcid, NULL, in port_default_packet_handler()
527 if (port->tserver_ch == NULL) in port_default_packet_handler()
573 port_on_new_conn(port, &e->peer, &hdr.src_conn_id, &hdr.dst_conn_id, in port_default_packet_handler()
581 ossl_quic_demux_release_urxe(port->demux, e); in port_default_packet_handler()
584 void ossl_quic_port_raise_net_error(QUIC_PORT *port, in ossl_quic_port_raise_net_error() argument
589 if (!ossl_quic_port_is_running(port)) in ossl_quic_port_raise_net_error()
598 OSSL_ERR_STATE_save(port->err_state); in ossl_quic_port_raise_net_error()
600 port_transition_failed(port); in ossl_quic_port_raise_net_error()
606 OSSL_LIST_FOREACH(ch, ch, &port->channel_list) in ossl_quic_port_raise_net_error()
611 void ossl_quic_port_restore_err_state(const QUIC_PORT *port) in ossl_quic_port_restore_err_state() argument
614 OSSL_ERR_STATE_restore(port->err_state); in ossl_quic_port_restore_err_state()