1 // Copyright 2014 The BoringSSL Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef HEADER_ASYNC_BIO
16 #define HEADER_ASYNC_BIO
17 
18 #include <openssl/bio.h>
19 
20 
21 // AsyncBioCreate creates a filter BIO for testing asynchronous state
22 // machines which consume a stream socket. Reads and writes will fail
23 // and return EAGAIN unless explicitly allowed. Each async BIO has a
24 // read quota and a write quota. Initially both are zero. As each is
25 // incremented, bytes are allowed to flow through the BIO.
26 bssl::UniquePtr<BIO> AsyncBioCreate();
27 
28 // AsyncBioCreateDatagram creates a filter BIO for testing for
29 // asynchronous state machines which consume datagram sockets. The read
30 // and write quota count in packets rather than bytes.
31 bssl::UniquePtr<BIO> AsyncBioCreateDatagram();
32 
33 // AsyncBioAllowRead increments |bio|'s read quota by |count|.
34 void AsyncBioAllowRead(BIO *bio, size_t count);
35 
36 // AsyncBioAllowWrite increments |bio|'s write quota by |count|.
37 void AsyncBioAllowWrite(BIO *bio, size_t count);
38 
39 
40 #endif  // HEADER_ASYNC_BIO
41