]> git.ipfire.org Git - thirdparty/squid.git/blob - src/security/Io.h
Detail client closures of CONNECT tunnels during TLS handshake (#691)
[thirdparty/squid.git] / src / security / Io.h
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 #ifndef SQUID_SRC_SECURITY_IO_H
10 #define SQUID_SRC_SECURITY_IO_H
11
12 #include "comm/forward.h"
13 #include "security/forward.h"
14 #include "security/ErrorDetail.h"
15
16 namespace Security {
17
18 /// a summary a TLS I/O operation outcome
19 class IoResult {
20 public:
21 /// all possible outcome cases
22 typedef enum { ioSuccess, ioWantRead, ioWantWrite, ioError } Category;
23
24 explicit IoResult(const Category aCategory): category(aCategory) {}
25 explicit IoResult(const ErrorDetailPointer &anErrorDetail): errorDetail(anErrorDetail) {}
26
27 /// convenience wrapper to detect successful I/O outcome; implies !wantsIo()
28 bool successful() const { return category == ioSuccess; }
29
30 /// convenience wrapper to detect whether more I/O is needed
31 bool wantsIo() const { return category == ioWantRead || category == ioWantWrite; }
32
33 ErrorDetailPointer errorDetail; ///< ioError case details (or nil)
34
35 Category category = ioError; ///< primary outcome classification
36
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
40 };
41
42 /// accept a TLS connection over the specified to-Squid transport connection
43 IoResult Accept(Comm::Connection &transport);
44
45 /// establish a TLS connection over the specified from-Squid transport connection
46 IoResult Connect(Comm::Connection &transport);
47
48 /// clear any errors that a TLS library has accumulated in its global storage
49 void ForgetErrors();
50
51 } // namespace Security
52
53 #endif /* SQUID_SRC_SECURITY_IO_H */
54