if (!ossl_quic_rxfc_init(&ch->conn_rxfc, NULL,
2 * 1024 * 1024,
10 * 1024 * 1024,
- get_time, NULL))
+ get_time, ch))
goto err;
if (!ossl_statm_init(&ch->statm))
if ((ch->cc_data = ch->cc_method->new(NULL, NULL, NULL)) == NULL)
goto err;
- if ((ch->ackm = ossl_ackm_new(get_time, NULL, &ch->statm,
+ if ((ch->ackm = ossl_ackm_new(get_time, ch, &ch->statm,
ch->cc_method, ch->cc_data)) == NULL)
goto err;
txp_args.cc_method = ch->cc_method;
txp_args.cc_data = ch->cc_data;
txp_args.now = get_time;
+ txp_args.now_arg = ch;
for (pn_space = QUIC_PN_SPACE_INITIAL; pn_space < QUIC_PN_SPACE_NUM; ++pn_space) {
ch->crypto_send[pn_space] = ossl_quic_sstream_new(INIT_CRYPTO_BUF_LEN);
if (ch->crypto_send[pn_space] == NULL)
if ((ch->demux = ossl_quic_demux_new(/*BIO=*/NULL,
/*Short CID Len=*/rx_short_cid_len,
- get_time, NULL)) == NULL)
+ get_time, ch)) == NULL)
goto err;
/*
if (!ossl_quic_rxfc_init(&ch->stream0->rxfc, &ch->conn_rxfc,
1 * 1024 * 1024,
5 * 1024 * 1024,
- get_time, NULL))
+ get_time, ch))
goto err;
/* Plug in the TLS handshake layer. */
ch->is_server = args->is_server;
ch->tls = args->tls;
ch->mutex = args->mutex;
+ ch->now_cb = args->now_cb;
+ ch->now_cb_arg = args->now_cb_arg;
if (!ch_init(ch)) {
OPENSSL_free(ch);
/* Used by various components. */
static OSSL_TIME get_time(void *arg)
{
- return ossl_time_now();
+ QUIC_CHANNEL *ch = arg;
+
+ if (ch->now_cb == NULL)
+ return ossl_time_now();
+
+ return ch->now_cb(ch->now_cb_arg);
}
/* Used by QSM. */
* expired.
*/
if (ossl_quic_channel_is_terminating(ch)) {
- now = ossl_time_now();
+ now = get_time(ch);
if (ossl_time_compare(now, ch->terminate_deadline) >= 0) {
ch_on_terminating_timeout(ch);
* ACKM ACK generation deadline is polled by TXP, so we don't need to handle
* it here.
*/
- now = ossl_time_now();
+ now = get_time(ch);
if (ossl_time_compare(now, ch->idle_deadline) >= 0) {
/*
* Idle timeout differs from normal protocol violation because we do not
ch->state = tcause->remote ? QUIC_CHANNEL_STATE_TERMINATING_DRAINING
: QUIC_CHANNEL_STATE_TERMINATING_CLOSING;
ch->terminate_deadline
- = ossl_time_add(ossl_time_now(),
+ = ossl_time_add(get_time(ch),
ossl_time_multiply(ossl_ackm_get_pto_duration(ch->ackm),
3));
if (ch->max_idle_timeout == 0)
ch->idle_deadline = ossl_time_infinite();
else
- ch->idle_deadline = ossl_time_add(ossl_time_now(),
+ ch->idle_deadline = ossl_time_add(get_time(ch),
ossl_ms2time(ch->max_idle_timeout));
}
return 1;
}
+void ossl_quic_conn_set_override_now_cb(SSL *s,
+ OSSL_TIME (*now_cb)(void *arg),
+ void *now_cb_arg)
+{
+ QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
+
+ qc->override_now_cb = now_cb;
+ qc->override_now_cb_arg = now_cb_arg;
+}
+
/*
* QUIC Front-End I/O API: Network BIO Configuration
* =================================================
args.is_server = 0;
args.tls = qc->tls;
args.mutex = qc->mutex;
+ args.now_cb = qc->override_now_cb;
+ args.now_cb_arg = qc->override_now_cb_arg;
qc->ch = ossl_quic_channel_new(&args);
if (qc->ch == NULL)