diff options
author | Matt Caswell <matt@openssl.org> | 2023-06-08 12:18:38 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-06-28 09:53:22 +1000 |
commit | 37f27b91deda5b6537883c06e845f0d2c28c5d5c (patch) | |
tree | 9b750371e7748f085e5a12d111191562b43e1d44 /ssl | |
parent | 956b4c75dc3f8710bf7b4e1cf01b4ef6d5ca2b45 (diff) |
Add a test quicserver utility
This QUIC server utility is intended for test purposes only and is expected
to be replaced in a future version of OpenSSL by s_server. At that point
it will be removed.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21204)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_tserver.c | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/ssl/quic/quic_tserver.c b/ssl/quic/quic_tserver.c index 6fc341f3c4..0bfebbdb3f 100644 --- a/ssl/quic/quic_tserver.c +++ b/ssl/quic/quic_tserver.c @@ -11,6 +11,7 @@ #include "internal/quic_channel.h" #include "internal/quic_statm.h" #include "internal/common.h" +#include "internal/time.h" /* * QUIC Test Server Module @@ -44,9 +45,22 @@ static int alpn_select_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg) { - static const unsigned char alpn[] = { 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' }; + QUIC_TSERVER *srv = arg; + static const unsigned char alpndeflt[] = { + 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' + }; + static const unsigned char *alpn; + size_t alpnlen; + + if (srv->args.alpn == NULL) { + alpn = alpndeflt; + alpnlen = sizeof(alpn); + } else { + alpn = srv->args.alpn; + alpnlen = srv->args.alpnlen; + } - if (SSL_select_next_proto((unsigned char **)out, outlen, alpn, sizeof(alpn), + if (SSL_select_next_proto((unsigned char **)out, outlen, alpn, alpnlen, in, inlen) != OPENSSL_NPN_NEGOTIATED) return SSL_TLSEXT_ERR_ALERT_FATAL; @@ -423,3 +437,48 @@ uint64_t ossl_quic_tserver_pop_incoming_stream(QUIC_TSERVER *srv) return qs->id; } + +int ossl_quic_tserver_is_stream_totally_acked(QUIC_TSERVER *srv, + uint64_t stream_id) +{ + QUIC_STREAM *qs; + + qs = ossl_quic_stream_map_get_by_id(ossl_quic_channel_get_qsm(srv->ch), + stream_id); + if (qs == NULL) + return 1; + + return ossl_quic_sstream_is_totally_acked(qs->sstream); +} + +int ossl_quic_tserver_get_net_read_desired(QUIC_TSERVER *srv) +{ + return ossl_quic_reactor_net_read_desired( + ossl_quic_channel_get_reactor(srv->ch)); +} + +int ossl_quic_tserver_get_net_write_desired(QUIC_TSERVER *srv) +{ + return ossl_quic_reactor_net_write_desired( + ossl_quic_channel_get_reactor(srv->ch)); +} + +OSSL_TIME ossl_quic_tserver_get_deadline(QUIC_TSERVER *srv) +{ + return ossl_quic_reactor_get_tick_deadline( + ossl_quic_channel_get_reactor(srv->ch)); +} + +int ossl_quic_tserver_shutdown(QUIC_TSERVER *srv) +{ + ossl_quic_channel_local_close(srv->ch, 0); + + /* TODO(QUIC): !SSL_SHUTDOWN_FLAG_NO_STREAM_FLUSH */ + + if (ossl_quic_channel_is_terminated(srv->ch)) + return 1; + + ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(srv->ch), 0); + + return ossl_quic_channel_is_terminated(srv->ch); +} |