2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef OSSL_QUIC_TSERVER_H
11 # define OSSL_QUIC_TSERVER_H
13 # include <openssl/ssl.h>
14 # include "internal/quic_stream.h"
16 # ifndef OPENSSL_NO_QUIC
19 * QUIC Test Server Module
20 * =======================
22 * This implements a QUIC test server. Since full QUIC server support is not yet
23 * implemented this server is limited in features and scope. It exists to
24 * provide a target for our QUIC client to talk to for testing purposes.
26 * A given QUIC test server instance supports only one client at a time.
28 * Note that this test server is not suitable for production use because it does
29 * not implement address verification, anti-amplification or retry logic.
31 typedef struct quic_tserver_st QUIC_TSERVER;
33 typedef struct quic_tserver_args_st {
36 BIO *net_rbio, *net_wbio;
39 QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args,
40 const char *certfile, const char *keyfile);
42 void ossl_quic_tserver_free(QUIC_TSERVER *srv);
44 /* Advances the state machine. */
45 int ossl_quic_tserver_tick(QUIC_TSERVER *srv);
47 /* Returns 1 if we have a (non-terminated) client. */
48 int ossl_quic_tserver_is_connected(QUIC_TSERVER *srv);
51 * Attempts to read from stream 0. Writes the number of bytes read to
52 * *bytes_read and returns 1 on success. If no bytes are available, 0 is written
53 * to *bytes_read and 1 is returned (this is considered a success case).
55 * Returns 0 if connection is not currently active. If the receive part of
56 * the stream has reached the end of stream condition, returns 0; call
57 * ossl_quic_tserver_has_read_ended() to identify this condition.
59 int ossl_quic_tserver_read(QUIC_TSERVER *srv,
65 * Returns 1 if the read part of the stream has ended normally.
67 int ossl_quic_tserver_has_read_ended(QUIC_TSERVER *srv);
70 * Attempts to write to stream 0. Writes the number of bytes consumed to
71 * *bytes_written and returns 1 on success. If there is no space currently
72 * available to write any bytes, 0 is written to *consumed and 1 is returned
73 * (this is considered a success case).
75 * Note that unlike libssl public APIs, this API always works in a 'partial
78 * Returns 0 if connection is not currently active.
80 int ossl_quic_tserver_write(QUIC_TSERVER *srv,
81 const unsigned char *buf,
83 size_t *bytes_written);
86 * Signals normal end of the stream.
88 int ossl_quic_tserver_conclude(QUIC_TSERVER *srv);