2 * Copyright (C) 1996-2021 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/ErrorDetail.h"
14 #include "security/forward.h"
18 /// a summary a TLS I/O operation outcome
19 class IoResult
: public RefCountable
{
21 typedef RefCount
<IoResult
> Pointer
;
23 /// all possible outcome cases
24 typedef enum { ioSuccess
, ioWantRead
, ioWantWrite
, ioError
} Category
;
26 explicit IoResult(const Category aCategory
): category(aCategory
) {}
27 explicit IoResult(const ErrorDetailPointer
&anErrorDetail
): errorDetail(anErrorDetail
) {}
28 IoResult(const IoResult
&aRes
) = default;
30 /// convenience wrapper to detect successful I/O outcome; implies !wantsIo()
31 bool successful() const { return category
== ioSuccess
; }
33 /// convenience wrapper to detect whether more I/O is needed
34 bool wantsIo() const { return category
== ioWantRead
|| category
== ioWantWrite
; }
36 void print(std::ostream
&os
) const;
38 ErrorDetailPointer errorDetail
; ///< ioError case details (or nil)
40 Category category
= ioError
; ///< primary outcome classification
42 /* the data members below facilitate human-friendly debugging */
43 const char *errorDescription
= nullptr; ///< a brief description of an error
44 bool important
= false; ///< whether the error was serious/unusual
48 operator <<(std::ostream
&os
, const IoResult
&result
)
54 /// accept a TLS connection over the specified to-Squid transport connection
55 IoResult
Accept(Comm::Connection
&transport
);
57 /// establish a TLS connection over the specified from-Squid transport connection
58 IoResult
Connect(Comm::Connection
&transport
);
60 /// clear any errors that a TLS library has accumulated in its global storage
63 } // namespace Security
65 #endif /* SQUID_SRC_SECURITY_IO_H */