2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_SRC_SECURITY_IO_H
10 #define SQUID_SRC_SECURITY_IO_H
12 #include "comm/forward.h"
13 #include "security/forward.h"
14 #include "security/ErrorDetail.h"
18 /// a summary a TLS I/O operation outcome
21 /// all possible outcome cases
22 typedef enum { ioSuccess
, ioWantRead
, ioWantWrite
, ioError
} Category
;
24 explicit IoResult(const Category aCategory
): category(aCategory
) {}
25 explicit IoResult(const ErrorDetailPointer
&anErrorDetail
): errorDetail(anErrorDetail
) {}
27 /// convenience wrapper to detect successful I/O outcome; implies !wantsIo()
28 bool successful() const { return category
== ioSuccess
; }
30 /// convenience wrapper to detect whether more I/O is needed
31 bool wantsIo() const { return category
== ioWantRead
|| category
== ioWantWrite
; }
33 ErrorDetailPointer errorDetail
; ///< ioError case details (or nil)
35 Category category
= ioError
; ///< primary outcome classification
37 /* the data members below facilitate human-friendly debugging */
38 const char *errorDescription
= nullptr; ///< a brief description of an error
39 bool important
= false; ///< whether the error was serious/unusual
42 /// accept a TLS connection over the specified to-Squid transport connection
43 IoResult
Accept(Comm::Connection
&transport
);
45 /// establish a TLS connection over the specified from-Squid transport connection
46 IoResult
Connect(Comm::Connection
&transport
);
48 /// clear any errors that a TLS library has accumulated in its global storage
51 } // namespace Security
53 #endif /* SQUID_SRC_SECURITY_IO_H */