Skip to content

Commit

Permalink
QUIC APL: Implement base listener API, move addressing mode handling …
Browse files Browse the repository at this point in the history
…into PORT

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from #23334)
  • Loading branch information
hlandau committed Apr 19, 2024
1 parent f0c14fd commit 6301dba
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 125 deletions.
3 changes: 3 additions & 0 deletions include/internal/quic_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ QUIC_STREAM_MAP *ossl_quic_channel_get_qsm(QUIC_CHANNEL *ch);
/* Gets the statistics manager used with the channel. */
OSSL_STATM *ossl_quic_channel_get_statm(QUIC_CHANNEL *ch);

/* Gets the TLS handshake layer used with the channel. */
SSL *ossl_quic_channel_get0_tls(QUIC_CHANNEL *ch);

/*
* Gets/sets the current peer address. Generally this should be used before
* starting a channel in client mode.
Expand Down
27 changes: 27 additions & 0 deletions include/internal/quic_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ QUIC_CHANNEL *ossl_quic_port_create_outgoing(QUIC_PORT *port, SSL *tls);
*/
QUIC_CHANNEL *ossl_quic_port_create_incoming(QUIC_PORT *port, SSL *tls);

/*
* Pop an incoming channel from the incoming channel queue. Returns NULL if
* there are no pending incoming channels.
*/
QUIC_CHANNEL *ossl_quic_port_pop_incoming(QUIC_PORT *port);

/*
* Queries and Accessors
* =====================
Expand Down Expand Up @@ -124,6 +130,27 @@ void ossl_quic_port_restore_err_state(const QUIC_PORT *port);
void ossl_quic_port_subtick(QUIC_PORT *port, QUIC_TICK_RESULT *r,
uint32_t flags);

/* Returns the number of queued incoming channels. */
size_t ossl_quic_port_get_num_incoming_channels(const QUIC_PORT *port);

/* Returns 1 if incoming connections should currently be allowed. */
void ossl_quic_port_set_allow_incoming(QUIC_PORT *port, int allow_incoming);

/* Returns 1 if we are using addressed mode on the read side. */
int ossl_quic_port_is_addressed_r(const QUIC_PORT *port);

/* Returns 1 if we are using addressed mode on the write side. */
int ossl_quic_port_is_addressed_w(const QUIC_PORT *port);

/* Returns 1 if we are using addressed mode. */
int ossl_quic_port_is_addressed(const QUIC_PORT *port);

/*
* Returns the current network BIO epoch. This increments whenever the network
* BIO configuration changes.
*/
uint64_t ossl_quic_port_get_net_bio_epoch(const QUIC_PORT *port);

/*
* Events
* ======
Expand Down
3 changes: 2 additions & 1 deletion include/internal/ssl_unwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct ssl_connection_st *ossl_quic_obj_get0_handshake_layer(QUIC_OBJ *obj);

# define IS_QUIC_METHOD(m) \
((m) == OSSL_QUIC_client_method() || \
(m) == OSSL_QUIC_client_thread_method())
(m) == OSSL_QUIC_client_thread_method() || \
(m) == OSSL_QUIC_server_method())

# define IS_QUIC_CTX(ctx) IS_QUIC_METHOD((ctx)->method)

Expand Down
5 changes: 5 additions & 0 deletions include/openssl/quic.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ __owur const SSL_METHOD *OSSL_QUIC_client_thread_method(void);
# define OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT \
((uint64_t)0xFFFFFFFFFFFFFFFFULL)

/*
* Method used for QUIC server operation.
*/
__owur const SSL_METHOD *OSSL_QUIC_server_method(void);

# ifdef __cplusplus
}
# endif
Expand Down
5 changes: 5 additions & 0 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ OSSL_STATM *ossl_quic_channel_get_statm(QUIC_CHANNEL *ch)
return &ch->statm;
}

SSL *ossl_quic_channel_get0_tls(QUIC_CHANNEL *ch)
{
return ch->tls;
}

QUIC_STREAM *ossl_quic_channel_get_stream_by_id(QUIC_CHANNEL *ch,
uint64_t stream_id)
{
Expand Down
3 changes: 2 additions & 1 deletion ssl/quic/quic_channel_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct quic_channel_st {
* QUIC_PORT keeps the channels which belong to it on a list for bookkeeping
* purposes.
*/
OSSL_LIST_MEMBER(ch, struct quic_channel_st);
OSSL_LIST_MEMBER(ch, QUIC_CHANNEL);
OSSL_LIST_MEMBER(incoming_ch, QUIC_CHANNEL);

/*
* The associated TLS 1.3 connection data. Used to provide the handshake
Expand Down
2 changes: 1 addition & 1 deletion ssl/quic/quic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ QUIC_PORT *ossl_quic_engine_create_port(QUIC_ENGINE *qeng,

/*
* QUIC Engine: Ticker-Mutator
* ==========================
* ===========================
*/

/*
Expand Down

0 comments on commit 6301dba

Please sign in to comment.