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 OSSL_TEST_SHIM_ASYNC_BIO_H 11 #define OSSL_TEST_SHIM_ASYNC_BIO_H 12 13 #include <openssl/base.h> 14 #include <openssl/bio.h> 15 16 17 // AsyncBioCreate creates a filter BIO for testing asynchronous state 18 // machines which consume a stream socket. Reads and writes will fail 19 // and return EAGAIN unless explicitly allowed. Each async BIO has a 20 // read quota and a write quota. Initially both are zero. As each is 21 // incremented, bytes are allowed to flow through the BIO. 22 bssl::UniquePtr<BIO> AsyncBioCreate(); 23 24 // AsyncBioCreateDatagram creates a filter BIO for testing for 25 // asynchronous state machines which consume datagram sockets. The read 26 // and write quota count in packets rather than bytes. 27 bssl::UniquePtr<BIO> AsyncBioCreateDatagram(); 28 29 // AsyncBioAllowRead increments |bio|'s read quota by |count|. 30 void AsyncBioAllowRead(BIO *bio, size_t count); 31 32 // AsyncBioAllowWrite increments |bio|'s write quota by |count|. 33 void AsyncBioAllowWrite(BIO *bio, size_t count); 34 35 // AsyncBioEnforceWriteQuota configures where |bio| enforces its write quota. 36 void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce); 37 38 39 #endif // OSSL_TEST_SHIM_ASYNC_BIO_H 40