]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/ossl_shim/packeted_bio.h
afdba1300a7db7994abff984a561c156be7f6465
[thirdparty/openssl.git] / test / ossl_shim / packeted_bio.h
1 /*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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
8 */
9
10 #ifndef HEADER_PACKETED_BIO
11 #define HEADER_PACKETED_BIO
12
13 #include <openssl/base.h>
14 #include <openssl/bio.h>
15
16 #if defined(OPENSSL_SYS_WINDOWS)
17 OPENSSL_MSVC_PRAGMA(warning(push, 3))
18 #include <winsock2.h>
19 OPENSSL_MSVC_PRAGMA(warning(pop))
20 #else
21 #include <sys/time.h>
22 #endif
23
24
25 // PacketedBioCreate creates a filter BIO which implements a reliable in-order
26 // blocking datagram socket. It internally maintains a clock and honors
27 // |BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT| based on it.
28 //
29 // During a |BIO_read|, the peer may signal the filter BIO to simulate a
30 // timeout. If |advance_clock| is true, it automatically advances the clock and
31 // continues reading, subject to the read deadline. Otherwise, it fails
32 // immediately. The caller must then call |PacketedBioAdvanceClock| before
33 // retrying |BIO_read|.
34 bssl::UniquePtr<BIO> PacketedBioCreate(bool advance_clock);
35
36 // PacketedBioGetClock returns the current time for |bio|.
37 timeval PacketedBioGetClock(const BIO *bio);
38
39 // PacketedBioAdvanceClock advances |bio|'s internal clock and returns true if
40 // there is a pending timeout. Otherwise, it returns false.
41 bool PacketedBioAdvanceClock(BIO *bio);
42
43
44 #endif // HEADER_PACKETED_BIO