Skip to content

Commit

Permalink
QUIC CHANNEL: Introduce concept of (non-)addressed mode
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>
(Merged from #21715)
  • Loading branch information
hlandau committed Sep 1, 2023
1 parent 51e671e commit 617b459
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion include/internal/quic_txp.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ int ossl_quic_tx_packetiser_set_cur_dcid(OSSL_QUIC_TX_PACKETISER *txp,
int ossl_quic_tx_packetiser_set_cur_scid(OSSL_QUIC_TX_PACKETISER *txp,
const QUIC_CONN_ID *scid);

/* Change the destination L4 address the TXP uses to send datagrams. */
/*
* Change the destination L4 address the TXP uses to send datagrams. Specify
* NULL (or AF_UNSPEC) to disable use of addressed mode.
*/
int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp,
const BIO_ADDR *peer);

Expand Down
15 changes: 14 additions & 1 deletion ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,13 +584,26 @@ int ossl_quic_channel_set_mutator(QUIC_CHANNEL *ch,

int ossl_quic_channel_get_peer_addr(QUIC_CHANNEL *ch, BIO_ADDR *peer_addr)
{
if (!ch->addressed_mode)
return 0;

*peer_addr = ch->cur_peer_addr;
return 1;
}

int ossl_quic_channel_set_peer_addr(QUIC_CHANNEL *ch, const BIO_ADDR *peer_addr)
{
ch->cur_peer_addr = *peer_addr;
if (ch->state != QUIC_CHANNEL_STATE_IDLE)
return 0;

if (peer_addr == NULL || BIO_ADDR_family(peer_addr) == AF_UNSPEC) {
BIO_ADDR_clear(&ch->cur_peer_addr);
ch->addressed_mode = 0;
return 1;
}

ch->cur_peer_addr = *peer_addr;
ch->addressed_mode = 1;
return 1;
}

Expand Down
3 changes: 3 additions & 0 deletions ssl/quic/quic_channel_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ struct quic_channel_st {
/* Inhibit tick for testing purposes? */
unsigned int inhibit_tick : 1;

/* Are we using addressed mode? */
unsigned int addressed_mode : 1;

/* Saved error stack in case permanent error was encountered */
ERR_STATE *err_state;
};
Expand Down
4 changes: 2 additions & 2 deletions ssl/quic/quic_txp.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp,
const BIO_ADDR *peer)
{
if (peer == NULL) {
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_NULL_PARAMETER);
return 0;
BIO_ADDR_clear(&txp->args.peer);
return 1;
}

txp->args.peer = *peer;
Expand Down

0 comments on commit 617b459

Please sign in to comment.