Skip to content

Commit

Permalink
QUIC TXP: Allow callbacks on ACK transmission
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #21029)
  • Loading branch information
hlandau authored and paulidale committed Jun 15, 2023
1 parent 007f9e9 commit 8f9c921
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/internal/quic_txp.h
Expand Up @@ -184,6 +184,17 @@ void ossl_quic_tx_packetiser_set_msg_callback_arg(OSSL_QUIC_TX_PACKETISER *txp,
*/
QUIC_PN ossl_quic_tx_packetiser_get_next_pn(OSSL_QUIC_TX_PACKETISER *txp,
uint32_t pn_space);

/*
* Sets a callback which is called whenever TXP sends an ACK frame. The callee
* must not modify the ACK frame data. Can be used to snoop on PNs being ACKed.
*/
void ossl_quic_tx_packetiser_set_ack_tx_cb(OSSL_QUIC_TX_PACKETISER *txp,
void (*cb)(const OSSL_QUIC_FRAME_ACK *ack,
uint32_t pn_space,
void *arg),
void *cb_arg);

# endif

#endif
18 changes: 18 additions & 0 deletions ssl/quic/quic_txp.c
Expand Up @@ -75,6 +75,11 @@ struct ossl_quic_tx_packetiser_st {
void *msg_callback_arg;
SSL *msg_callback_ssl;

/* Callbacks. */
void (*ack_tx_cb)(const OSSL_QUIC_FRAME_ACK *ack,
uint32_t pn_space,
void *arg);
void *ack_tx_cb_arg;
};

/*
Expand Down Expand Up @@ -474,6 +479,16 @@ int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp,
return 1;
}

void ossl_quic_tx_packetiser_set_ack_tx_cb(OSSL_QUIC_TX_PACKETISER *txp,
void (*cb)(const OSSL_QUIC_FRAME_ACK *ack,
uint32_t pn_space,
void *arg),
void *cb_arg)
{
txp->ack_tx_cb = cb;
txp->ack_tx_cb_arg = cb_arg;
}

int ossl_quic_tx_packetiser_discard_enc_level(OSSL_QUIC_TX_PACKETISER *txp,
uint32_t enc_level)
{
Expand Down Expand Up @@ -1247,6 +1262,9 @@ static int txp_generate_pre_token(OSSL_QUIC_TX_PACKETISER *txp,

if (ack->num_ack_ranges > 0)
tpkt->ackm_pkt.largest_acked = ack->ack_ranges[0].end;

if (txp->ack_tx_cb != NULL)
txp->ack_tx_cb(&ack2, pn_space, txp->ack_tx_cb_arg);
} else {
tx_helper_rollback(h);
}
Expand Down

0 comments on commit 8f9c921

Please sign in to comment.