/* Gets/sets the underlying network read and write BIOs. */
BIO *ossl_quic_channel_get_net_rbio(QUIC_CHANNEL *ch);
BIO *ossl_quic_channel_get_net_wbio(QUIC_CHANNEL *ch);
-int ossl_quic_channel_set0_net_rbio(QUIC_CHANNEL *ch, BIO *net_rbio);
-int ossl_quic_channel_set0_net_wbio(QUIC_CHANNEL *ch, BIO *net_wbio);
+int ossl_quic_channel_set_net_rbio(QUIC_CHANNEL *ch, BIO *net_rbio);
+int ossl_quic_channel_set_net_wbio(QUIC_CHANNEL *ch, BIO *net_wbio);
/*
* Returns an existing stream by stream ID. Returns NULL if the stream does not
ossl_qrx_free(ch->qrx);
ossl_quic_demux_free(ch->demux);
OPENSSL_free(ch->local_transport_params);
- BIO_free(ch->net_rbio);
- BIO_free(ch->net_wbio);
}
QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args)
return ch->net_wbio;
}
-int ossl_quic_channel_set0_net_rbio(QUIC_CHANNEL *ch, BIO *net_rbio)
+/*
+ * QUIC_CHANNEL does not ref any BIO it is provided with, nor is any ref
+ * transferred to it. The caller (i.e., QUIC_CONNECTION) is responsible for
+ * ensuring the BIO lasts until the channel is freed or the BIO is switched out
+ * for another BIO by a subsequent successful call to this function.
+ */
+int ossl_quic_channel_set_net_rbio(QUIC_CHANNEL *ch, BIO *net_rbio)
{
BIO_POLL_DESCRIPTOR d = {0};
}
ossl_quic_reactor_set_poll_r(&ch->rtor, &d);
- BIO_free(ch->net_rbio);
ossl_quic_demux_set_bio(ch->demux, net_rbio);
ch->net_rbio = net_rbio;
return 1;
}
-int ossl_quic_channel_set0_net_wbio(QUIC_CHANNEL *ch, BIO *net_wbio)
+int ossl_quic_channel_set_net_wbio(QUIC_CHANNEL *ch, BIO *net_wbio)
{
BIO_POLL_DESCRIPTOR d = {0};
}
ossl_quic_reactor_set_poll_w(&ch->rtor, &d);
- BIO_free(ch->net_wbio);
ossl_qtx_set_bio(ch->qtx, net_wbio);
ch->net_wbio = net_wbio;
return 1;
ossl_quic_channel_free(qc->ch);
+ BIO_free(qc->net_rbio);
+ BIO_free(qc->net_wbio);
+
/* Note: SSL_free calls OPENSSL_free(qc) for us */
}
if (qc->net_rbio == net_rbio)
return;
- if (qc->ch != NULL && !ossl_quic_channel_set0_net_rbio(qc->ch, net_rbio))
+ if (qc->ch != NULL && !ossl_quic_channel_set_net_rbio(qc->ch, net_rbio))
return;
+ BIO_free(qc->net_rbio);
qc->net_rbio = net_rbio;
/*
if (qc->net_wbio == net_wbio)
return;
- if (qc->ch != NULL && !ossl_quic_channel_set0_net_wbio(qc->ch, net_wbio))
+ if (qc->ch != NULL && !ossl_quic_channel_set_net_wbio(qc->ch, net_wbio))
return;
+ BIO_free(qc->net_wbio);
qc->net_wbio = net_wbio;
if (net_wbio != NULL) {
{
assert(qc->ch != NULL);
- if (!ossl_quic_channel_set0_net_rbio(qc->ch, qc->net_rbio)
- || !ossl_quic_channel_set0_net_wbio(qc->ch, qc->net_wbio)
+ if (!ossl_quic_channel_set_net_rbio(qc->ch, qc->net_rbio)
+ || !ossl_quic_channel_set_net_wbio(qc->ch, qc->net_wbio)
|| !ossl_quic_channel_set_peer_addr(qc->ch, &qc->init_peer_addr))
return 0;
{
int ret;
- fprintf(stderr, "# handshake begin\n");
-
if (qc->ch != NULL && ossl_quic_channel_is_term_any(qc->ch))
return QUIC_RAISE_NON_NORMAL_ERROR(qc, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL);