Home | History | Annotate | Download | only in test
      1 /* Copyright (c) 2014, Google Inc.
      2  *
      3  * Permission to use, copy, modify, and/or distribute this software for any
      4  * purpose with or without fee is hereby granted, provided that the above
      5  * copyright notice and this permission notice appear in all copies.
      6  *
      7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
     12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
     13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
     14 
     15 #ifndef HEADER_PACKETED_BIO
     16 #define HEADER_PACKETED_BIO
     17 
     18 #include <openssl/base.h>
     19 #include <openssl/bio.h>
     20 
     21 #include "../../crypto/test/scoped_types.h"
     22 
     23 #if defined(OPENSSL_WINDOWS)
     24 #pragma warning(push, 3)
     25 #include <winsock2.h>
     26 #pragma warning(pop)
     27 #else
     28 #include <sys/types.h>
     29 #endif
     30 
     31 
     32 // PacketedBioCreate creates a filter BIO which implements a reliable in-order
     33 // blocking datagram socket. The resulting BIO, on |BIO_read|, may simulate a
     34 // timeout which sets |*out_timeout| to the timeout and fails the read.
     35 // |*out_timeout| must be zero on entry to |BIO_read|; it is an error to not
     36 // apply the timeout before the next |BIO_read|.
     37 //
     38 // Note: The read timeout simulation is intended to be used with the async BIO
     39 // wrapper. It doesn't simulate BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, used in DTLS's
     40 // blocking mode.
     41 ScopedBIO PacketedBioCreate(timeval *out_timeout);
     42 
     43 
     44 #endif  // HEADER_PACKETED_BIO
     45