Io.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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/ErrorDetail.h"
14 #include "security/forward.h"
15 
16 namespace Security {
17 
19 class IoResult: public RefCountable {
20 public:
22 
25 
26  explicit IoResult(const Category aCategory): category(aCategory) {}
27  explicit IoResult(const ErrorDetailPointer &anErrorDetail): errorDetail(anErrorDetail) {}
28  IoResult(const IoResult &aRes) = default;
29 
31  bool successful() const { return category == ioSuccess; }
32 
34  bool wantsIo() const { return category == ioWantRead || category == ioWantWrite; }
35 
37  void printGist(std::ostream &) const;
38 
41  void printWithExtras(std::ostream &) const;
42 
44 
46 
47  /* the data members below facilitate human-friendly debugging */
48  const char *errorDescription = nullptr;
49  bool important = false;
50 
51 private:
52  void printDescription(std::ostream &) const;
53 };
54 
55 inline std::ostream &
56 operator <<(std::ostream &os, const IoResult &result)
57 {
58  result.printGist(os);
59  return os;
60 }
61 
63 IoResult Accept(Comm::Connection &transport);
64 
67 
69 void ForgetErrors();
70 
71 } // namespace Security
72 
73 #endif /* SQUID_SRC_SECURITY_IO_H */
74 
void printDescription(std::ostream &) const
common part of printGist() and printWithExtras()
Definition: Io.cc:29
void printWithExtras(std::ostream &) const
Definition: Io.cc:59
ErrorDetailPointer errorDetail
ioError case details (or nil)
Definition: Io.h:43
a summary a TLS I/O operation outcome
Definition: Io.h:19
IoResult(const ErrorDetailPointer &anErrorDetail)
Definition: Io.h:27
void printGist(std::ostream &) const
reports brief summary (on one line) suitable for low-level debugging
Definition: Io.cc:50
bool successful() const
convenience wrapper to detect successful I/O outcome; implies !wantsIo()
Definition: Io.h:31
RefCount< IoResult > Pointer
Definition: Io.h:21
Category category
primary outcome classification
Definition: Io.h:45
std::ostream & operator<<(std::ostream &, const EncryptorAnswer &)
void ForgetErrors()
clear any errors that a TLS library has accumulated in its global storage
Definition: Io.cc:71
bool wantsIo() const
convenience wrapper to detect whether more I/O is needed
Definition: Io.h:34
Category
all possible outcome cases
Definition: Io.h:24
const char * errorDescription
a brief description of an error
Definition: Io.h:48
IoResult Connect(Comm::Connection &transport)
establish a TLS connection over the specified from-Squid transport connection
Definition: Io.cc:226
IoResult Accept(Comm::Connection &transport)
accept a TLS connection over the specified to-Squid transport connection
Definition: Io.cc:211
bool important
whether the error was serious/unusual
Definition: Io.h:49
Network/connection security abstraction layer.
Definition: Connection.h:33
IoResult(const Category aCategory)
Definition: Io.h:26

 

Introduction

Documentation

Support

Miscellaneous